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

# Schedule campaign

> Resolves the final recipient audience (filters + manual + imported −
excluded), pre-computes and validates every contact's template
variables, persists one CampaignDispatches document per contact with
campaignDispatchVariables already filled, and enqueues them to SQS in
batch — replacing talqui-core-api's campaignSchedule.js (which neither
resolves nor validates variables, and relies on a 1000-per-5min poller
to enqueue).



## OpenAPI

````yaml /api/services-api.yaml post /v1/tenants/{tenantID}/campaigns/{campaignID}/schedule
openapi: 3.0.3
info:
  description: >-
    Talqui is an omnichannel customer service platform that unifies
    conversations from WhatsApp, Instagram, Telegram, and many other channels
    into a single attendant panel, alongside a broader ecosystem of plugins and
    integrations. This API gives developers programmatic access to Talqui's
    services layer, exposing the operations needed to read and manage tenants,
    conversations, plugins, and related resources that power that platform.


    Authentication is available on behalf of an Operator (the default for this
    API), a Plugin Connection, or a Plugin — see the [Talqui authentication
    guide](https://docs.talqui.chat/guides/introduction/authentication/) for how
    each token is obtained and when to use it.


    Need help or have questions not covered here? Reach out to
    support@talqui.com.
  license:
    name: ISC
    url: https://opensource.org/license/isc-license-txt
  title: Talqui - Services API
  version: 0.69.1
servers:
  - description: Production
    url: https://services-api.talqui.chat
security: []
tags:
  - name: Tenants
  - name: Settings
  - name: Analytics/Reports
  - name: Analytics
  - name: Campaigns
  - name: Campaigns/Models
  - name: Contacts
  - name: Contacts/Imports
  - name: Handoff links
  - name: Inboxes
  - name: Messages
  - name: Notifications
  - name: Sessions
  - name: Operators/Shortcuts
  - name: Operators
  - name: Plugins
  - name: Setup
  - name: Uploads
paths:
  /v1/tenants/{tenantID}/campaigns/{campaignID}/schedule:
    post:
      tags:
        - Campaigns
      summary: Schedule campaign
      description: |-
        Resolves the final recipient audience (filters + manual + imported −
        excluded), pre-computes and validates every contact's template
        variables, persists one CampaignDispatches document per contact with
        campaignDispatchVariables already filled, and enqueues them to SQS in
        batch — replacing talqui-core-api's campaignSchedule.js (which neither
        resolves nor validates variables, and relies on a 1000-per-5min poller
        to enqueue).
      operationId: ScheduleCampaignController
      parameters:
        - in: path
          name: tenantID
          required: true
          schema:
            type: string
        - in: path
          name: campaignID
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                dispatchAt:
                  description: >-
                    When to start dispatching: ISO 8601 datetime with offset or
                    Z. Omit/null for immediate dispatch; a value more than 5
                    minutes in the past is rejected.
                  format: date-time
                  nullable: true
                  pattern: >-
                    ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
                  type: string
                excludedContactIDs:
                  description: Contacts explicitly removed from the final audience.
                  items:
                    type: string
                  type: array
                filters:
                  default: []
                  description: >-
                    Segment rules to resolve into recipients — same wire format
                    as /contacts/segment.
                  items:
                    properties:
                      criterion:
                        description: >-
                          The field/criterion name — see the engine for the
                          recognized set.
                        type: string
                      id:
                        description: >-
                          Client-generated identifier for this rule; echoed
                          back, never used for logic.
                        type: string
                      operator:
                        description: One of the CONTACT_SEGMENT_CONDITIONALS values.
                        enum:
                          - eq
                          - ne
                          - ex
                          - nex
                          - ha
                          - nh
                          - gt
                          - lt
                          - gte
                          - lte
                          - sw
                          - ew
                        type: string
                      query:
                        default: []
                        description: >-
                          Operand values for this rule — usually a
                          single-element array.
                        items: {}
                        type: array
                      schema:
                        description: >-
                          Whether this criterion is native to Contact
                          ("contact") or requires a join ("interaction").
                        enum:
                          - contact
                          - interaction
                        type: string
                    required:
                      - id
                      - schema
                      - criterion
                      - operator
                    type: object
                  type: array
                importedContactIDs:
                  description: Contacts resolved from a CSV import.
                  items:
                    type: string
                  type: array
                manualContactIDs:
                  description: Contacts picked manually by the operator.
                  items:
                    type: string
                  type: array
                variableConfigs:
                  additionalProperties:
                    anyOf:
                      - properties:
                          mode:
                            enum:
                              - fixed
                            type: string
                          useModelDefault:
                            type: boolean
                          value:
                            type: string
                        required:
                          - mode
                          - value
                        type: object
                      - properties:
                          contactField:
                            type: string
                          fallback:
                            type: string
                          mode:
                            enum:
                              - contact
                            type: string
                          useModelDefault:
                            type: boolean
                        required:
                          - mode
                          - contactField
                        type: object
                  default: {}
                  description: >-
                    Value source per template variable key (from the campaign
                    model catalog) — fixed or per-contact.
                  type: object
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                additionalProperties: false
                properties:
                  campaignID:
                    type: string
                  campaignStatus:
                    type: string
                  enqueueFailedCount:
                    description: >-
                      Dispatches left pending for the watchdog poller to pick up
                      (queue publish failed or unconfigured).
                    type: number
                  enqueuedCount:
                    description: Dispatches successfully published to SQS in this request.
                    type: number
                  totalContacts:
                    type: number
                  unresolvedCount:
                    description: >-
                      Recipients recorded as failed because a required template
                      variable had no value for them.
                    type: number
                required:
                  - campaignID
                  - totalContacts
                  - campaignStatus
                  - enqueuedCount
                  - enqueueFailedCount
                  - unresolvedCount
                type: object
          description: Response for status 200.
        '400':
          content:
            application/json:
              schema:
                properties:
                  errors:
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/MissingTenantIDError'
                        - $ref: '#/components/schemas/MissingCampaignIDError'
                        - $ref: '#/components/schemas/MissingOrganizationIDError'
                        - $ref: '#/components/schemas/MissingCampaignModelIDError'
                        - $ref: '#/components/schemas/RequestValidationError'
                    maxItems: 1
                    minItems: 1
                    type: array
                required:
                  - errors
                type: object
          description: >-
            MissingTenantIDError (error_code 1001): tenantID absent from the
            URL. | MissingCampaignIDError (error_code 1741): campaignID absent
            from the URL. | MissingOrganizationIDError (error_code 1743):
            operator token carries no organizationID. |
            MissingCampaignModelIDError (error_code 1059): campaign has no model
            selected. | RequestValidationError (error_code 1002): request body
            fails schema validation.
        '401':
          content:
            application/json:
              schema:
                properties:
                  errors:
                    items:
                      $ref: '#/components/schemas/UnauthorizedError'
                    maxItems: 1
                    minItems: 1
                    type: array
                required:
                  - errors
                type: object
          description: 'UnauthorizedError (error_code 1003): missing/invalid operator token.'
        '403':
          content:
            application/json:
              schema:
                properties:
                  errors:
                    items:
                      $ref: '#/components/schemas/ForbiddenError'
                    maxItems: 1
                    minItems: 1
                    type: array
                required:
                  - errors
                type: object
          description: 'ForbiddenError (error_code 1004): operator token rejected upstream.'
        '404':
          content:
            application/json:
              schema:
                properties:
                  errors:
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/CampaignNotFoundError'
                        - $ref: '#/components/schemas/CampaignModelNotFoundError'
                    maxItems: 1
                    minItems: 1
                    type: array
                required:
                  - errors
                type: object
          description: >-
            CampaignNotFoundError (error_code 1740): no campaign matches for
            this tenant. | CampaignModelNotFoundError (error_code 1058): the
            selected model no longer exists.
        '422':
          content:
            application/json:
              schema:
                properties:
                  errors:
                    items:
                      oneOf:
                        - $ref: '#/components/schemas/CampaignNotAllowScheduleError'
                        - $ref: '#/components/schemas/CampaignEmptyAudienceError'
                        - $ref: '#/components/schemas/CampaignVariablesMissingError'
                    maxItems: 1
                    minItems: 1
                    type: array
                required:
                  - errors
                type: object
          description: >-
            CampaignNotAllowScheduleError (error_code 1760): campaign is not in
            draft status. | CampaignEmptyAudienceError (error_code 1762): the
            resolved audience is empty. | CampaignVariablesMissingError
            (error_code 1761): one or more recipients are missing a required
            variable value — rejects the WHOLE request.
        '500':
          content:
            application/json:
              schema:
                properties:
                  errors:
                    items:
                      $ref: '#/components/schemas/UnknownError'
                    maxItems: 1
                    minItems: 1
                    type: array
                required:
                  - errors
                type: object
          description: >-
            UnknownError (error_code 5999): Unexpected internal error not
            otherwise documented for this endpoint.
      security:
        - operatorAuth: []
components:
  schemas:
    MissingTenantIDError:
      additionalProperties: false
      properties:
        error:
          enum:
            - MissingTenantIDError
          type: string
        error_code:
          enum:
            - 1001
          type: number
        message:
          example: tenantID is required.
          type: string
        statusCode:
          enum:
            - 400
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    MissingCampaignIDError:
      additionalProperties: false
      properties:
        error:
          enum:
            - MissingCampaignIDError
          type: string
        error_code:
          enum:
            - 1741
          type: number
        message:
          example: campaignID is required.
          type: string
        statusCode:
          enum:
            - 400
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    MissingOrganizationIDError:
      additionalProperties: false
      properties:
        error:
          enum:
            - MissingOrganizationIDError
          type: string
        error_code:
          enum:
            - 1743
          type: number
        message:
          example: >-
            organizationID could not be resolved from the authenticated
            operator.
          type: string
        statusCode:
          enum:
            - 400
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    MissingCampaignModelIDError:
      additionalProperties: false
      properties:
        error:
          enum:
            - MissingCampaignModelIDError
          type: string
        error_code:
          enum:
            - 1059
          type: number
        message:
          example: campaignModelID is required.
          type: string
        statusCode:
          enum:
            - 400
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    RequestValidationError:
      additionalProperties: false
      properties:
        error:
          enum:
            - RequestValidationError
          type: string
        error_code:
          enum:
            - 1002
          type: number
        fields:
          items:
            additionalProperties: false
            properties:
              allowed:
                type: string
              field:
                type: string
              received:
                type: string
            required:
              - field
              - received
              - allowed
            type: object
          type: array
        message:
          example: Invalid request data.
          type: string
        statusCode:
          enum:
            - 400
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
        - fields
      type: object
    UnauthorizedError:
      additionalProperties: false
      properties:
        error:
          enum:
            - UnauthorizedError
          type: string
        error_code:
          enum:
            - 1003
          type: number
        message:
          example: You are not authorized to perform this request.
          type: string
        statusCode:
          enum:
            - 401
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    ForbiddenError:
      additionalProperties: false
      properties:
        error:
          enum:
            - ForbiddenError
          type: string
        error_code:
          enum:
            - 1004
          type: number
        message:
          example: You do not have access to this resource.
          type: string
        statusCode:
          enum:
            - 403
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    CampaignNotFoundError:
      additionalProperties: false
      properties:
        error:
          enum:
            - CampaignNotFoundError
          type: string
        error_code:
          enum:
            - 1740
          type: number
        message:
          example: Campaign not found.
          type: string
        statusCode:
          enum:
            - 404
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    CampaignModelNotFoundError:
      additionalProperties: false
      properties:
        error:
          enum:
            - CampaignModelNotFoundError
          type: string
        error_code:
          enum:
            - 1058
          type: number
        message:
          example: Campaign model not found.
          type: string
        statusCode:
          enum:
            - 404
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    CampaignNotAllowScheduleError:
      additionalProperties: false
      properties:
        error:
          enum:
            - CampaignNotAllowScheduleError
          type: string
        error_code:
          enum:
            - 1760
          type: number
        message:
          example: Only draft campaigns can be scheduled.
          type: string
        statusCode:
          enum:
            - 422
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    CampaignEmptyAudienceError:
      additionalProperties: false
      properties:
        error:
          enum:
            - CampaignEmptyAudienceError
          type: string
        error_code:
          enum:
            - 1762
          type: number
        message:
          example: The recipient audience for this campaign is empty.
          type: string
        statusCode:
          enum:
            - 422
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    CampaignVariablesMissingError:
      additionalProperties: false
      properties:
        error:
          enum:
            - CampaignVariablesMissingError
          type: string
        error_code:
          enum:
            - 1761
          type: number
        message:
          example: >-
            One or more recipients are missing a required campaign variable
            value.
          type: string
        statusCode:
          enum:
            - 422
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
    UnknownError:
      additionalProperties: false
      properties:
        error:
          enum:
            - UnknownError
          type: string
        error_code:
          enum:
            - 5999
          type: number
        message:
          example: For some unknown reason your request has not succeeded.
          type: string
        statusCode:
          enum:
            - 500
          type: number
      required:
        - statusCode
        - error
        - error_code
        - message
      type: object
  securitySchemes:
    operatorAuth:
      bearerFormat: JWT
      description: >-
        Behalf of an Operator (default). A JWT issued by Talqui Core when an
        operator signs in, scoped to every tenant that operator belongs to. Send
        as `Authorization: Bearer <jwt-token>`.
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.