> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trysela.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Replay Recent Chat Webhooks

> Queues webhook and configured integration-action deliveries using each requested lead's most recent chat. Only leads owned by the authenticated API user are processed; inaccessible lead IDs are skipped and counted in the response. Work is split into background-task chunks, so a 202 response means the replay was queued.



## OpenAPI

````yaml /Sela_API.yaml post /api/agents/webhooks/replay-recent-chat/
openapi: 3.0.3
info:
  title: Sela API
  version: 1.0.2
  description: >-
    Create and manage leads, configure outbound webhook subscriptions, and use
    customer-specific lead ingestion workflows. Unless an endpoint says
    otherwise, authenticate with `Authorization: Token <api-key>`.
servers:
  - url: https://api.trysela.com/
    description: Production API
security: []
tags:
  - name: Leads
    description: Create, retrieve, update, and schedule customer leads.
  - name: Call Control
    description: Pause or resume outbound calling for an API user.
  - name: Lead Types
    description: >-
      Discover lead categories and the public metadata fields accepted for each
      one.
  - name: Webhooks
    description: >-
      Manage subscriptions that deliver lead and call events to customer
      systems.
  - name: Lead Ingestion
    description: >-
      Submit provider-specific lead payloads through ingestion URLs configured
      by Sela.
  - name: File Ingestion
    description: Request temporary upload URLs for configured CSV ingestion sources.
paths:
  /api/agents/webhooks/replay-recent-chat/:
    post:
      tags:
        - Webhooks
      summary: Replay Recent Chat Webhooks
      description: >-
        Queues webhook and configured integration-action deliveries using each
        requested lead's most recent chat. Only leads owned by the authenticated
        API user are processed; inaccessible lead IDs are skipped and counted in
        the response. Work is split into background-task chunks, so a 202
        response means the replay was queued.
      operationId: agents_webhooks_replay_recent_chat_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReplayRecentChatWebhooksRequestRequest'
            examples:
              ReplayCompleted-callWebhooks:
                value:
                  lead_ids:
                    - 123
                    - 456
                  triggers:
                    - CALL_COMPLETE
                    - LEAD_UPDATED
                summary: Replay completed-call webhooks
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/ReplayRecentChatWebhooksRequestRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ReplayRecentChatWebhooksRequestRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReplayRecentChatWebhooksResponse'
              examples:
                ReplayQueued:
                  value:
                    task_ids:
                      - c449ad2a-1d86-48f7-9a1e-d571f1c9ed30
                    task_count: 1
                    lead_count: 2
                    skipped_lead_count: 0
                    chunk_size: 100
                    triggers:
                      - CALL_COMPLETE
                      - LEAD_UPDATED
                  summary: Replay queued
          description: Webhook replay tasks queued successfully.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookReplayValidationErrorResponse'
          description: Lead IDs or trigger values are invalid.
        '401':
          description: API token is missing or invalid.
        '429':
          description: Webhook replay rate limit exceeded.
      security:
        - tokenAuth: []
      x-codeSamples:
        - lang: curl
          label: ReplayCompleted-callWebhooks
          source: |-
            curl --request POST \
              --url https://api.trysela.com/api/agents/webhooks/replay-recent-chat/ \
              --header 'Authorization: Token <api-key>' \
              --header 'Content-Type: application/json' \
              --data '{
                "lead_ids": [
                  123,
                  456
                ],
                "triggers": [
                  "CALL_COMPLETE",
                  "LEAD_UPDATED"
                ]
              }'
components:
  schemas:
    ReplayRecentChatWebhooksRequestRequest:
      type: object
      description: Validate manual webhook replay requests for recent chats.
      properties:
        lead_ids:
          type: array
          items:
            type: integer
            minimum: 1
          description: >-
            Lead IDs whose most recent chats should be replayed. Only leads
            owned by the authenticated API user are processed.
          maxItems: 5000
        triggers:
          type: array
          items:
            $ref: '#/components/schemas/TriggersEnum'
          description: Webhook trigger values to replay for each authorized lead.
          maxItems: 22
      required:
        - lead_ids
        - triggers
    ReplayRecentChatWebhooksResponse:
      type: object
      description: Describe an accepted webhook replay request.
      properties:
        task_ids:
          type: array
          items:
            type: string
          description: Celery task IDs for the queued replay chunks.
        task_count:
          type: integer
          minimum: 0
          description: Number of replay tasks queued.
        lead_count:
          type: integer
          minimum: 0
          description: Number of authorized leads queued for replay.
        skipped_lead_count:
          type: integer
          minimum: 0
          description: >-
            Number of requested lead IDs skipped because they are not owned by
            the caller.
        chunk_size:
          type: integer
          minimum: 1
          description: Maximum number of leads processed by each replay task.
        triggers:
          type: array
          items:
            $ref: '#/components/schemas/TriggersEnum'
          description: Webhook trigger values queued for replay.
      required:
        - chunk_size
        - lead_count
        - skipped_lead_count
        - task_count
        - task_ids
        - triggers
    WebhookReplayValidationErrorResponse:
      type: object
      properties:
        lead_ids:
          type: array
          items:
            type: string
        triggers:
          type: array
          items:
            type: string
    TriggersEnum:
      enum:
        - LEAD_CREATED
        - LEAD_UPDATED
        - LEAD_CLOSED
        - LEAD_CLOSED_INCOMPLETE
        - LEAD_LOST
        - LEAD_SCHEDULE_COMPLETED
        - LEAD_LATE_CALLBACK
        - LEAD_OUT_OF_TERRITORY
        - LEAD_BAD_NUMBER
        - LEAD_CANCELLED
        - LEAD_CALLBACK_TO_TRANSFER
        - LEAD_BEFORE_REENGAGEMENT
        - LEAD_REENGAGEMENT
        - LEAD_FIRST_INBOUND
        - CALL_COMPLETE
        - BEFORE_CALLING
        - CALL_FAILED
        - CALL_ENDED
        - CALL_TRANSFER_INITIATED
        - SMS_COMPLETE
        - SMS_DNC
        - CALL_DNC
      type: string
      description: |-
        * `LEAD_CREATED` - Lead Created
        * `LEAD_UPDATED` - Lead Updated
        * `LEAD_CLOSED` - Lead Closed
        * `LEAD_CLOSED_INCOMPLETE` - Lead Closed Incomplete
        * `LEAD_LOST` - Lead Lost
        * `LEAD_SCHEDULE_COMPLETED` - Lead Schedule Completed
        * `LEAD_LATE_CALLBACK` - Lead Late Callback
        * `LEAD_OUT_OF_TERRITORY` - Lead Out of Territory
        * `LEAD_BAD_NUMBER` - Lead Bad Number
        * `LEAD_CANCELLED` - Lead Cancelled
        * `LEAD_CALLBACK_TO_TRANSFER` - Lead Callback to Transfer
        * `LEAD_BEFORE_REENGAGEMENT` - Lead Before Reengagement
        * `LEAD_REENGAGEMENT` - Lead Reengagement
        * `LEAD_FIRST_INBOUND` - Lead First Inbound
        * `CALL_COMPLETE` - Call Complete
        * `BEFORE_CALLING` - Before Calling
        * `CALL_FAILED` - Call Failed
        * `CALL_ENDED` - Call Ended
        * `CALL_TRANSFER_INITIATED` - Call Transfer Initiated
        * `SMS_COMPLETE` - SMS Complete
        * `SMS_DNC` - SMS DNC
        * `CALL_DNC` - CALL DNC
  securitySchemes:
    tokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Token-based authentication with required prefix "Token"

````