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

# Create messaging ad

> Starts a draft click-to-message ad campaign (campaign/ad set/ad) for the given audience and creative. Use `ads.publishCampaign` to publish it once ready.



## OpenAPI

````yaml /api-reference/platform-api.json post /v1/ads/campaigns
openapi: 3.1.1
info:
  title: ChatbotX
  version: 0.0.1
servers:
  - url: https://app.chatbotx.io/api
security:
  - bearerAuth: []
  - developerAccessToken: []
  - tokenInSearchParams: []
paths:
  /v1/ads/campaigns:
    post:
      tags:
        - Ads
      summary: Create messaging ad
      description: >-
        Starts a draft click-to-message ad campaign (campaign/ad set/ad) for the
        given audience and creative. Use `ads.publishCampaign` to publish it
        once ready.
      operationId: ads.createCampaign
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                channel:
                  enum:
                    - messenger
                    - instagram
                    - whatsapp
                  type: string
                  description: Channel to run the messaging ad on.
                integrationId:
                  type: string
                  pattern: ^\d+$
                  description: Channel integration id (numeric string).
                whatsappPageIntegrationId:
                  type: string
                  pattern: ^\d+$
                  description: >-
                    Messenger page integration id, required when channel is
                    whatsapp.
                adAccountId:
                  type: string
                  pattern: ^act_\d+$
                  description: >-
                    Meta ad account id (act_<id>). Get it from
                    `ads.listCampaignAdAccounts`.
                name:
                  type: string
                  minLength: 1
                  maxLength: 120
                  description: Campaign name.
                campaign:
                  type: object
                  properties:
                    specialAdCategories:
                      type: array
                      minItems: 1
                      items:
                        enum:
                          - NONE
                          - HOUSING
                          - EMPLOYMENT
                          - CREDIT
                          - FINANCIAL_PRODUCTS_SERVICES
                          - ISSUES_ELECTIONS_POLITICS
                          - ONLINE_GAMBLING_AND_GAMING
                        type: string
                      description: >-
                        Meta special ad category classifications this campaign
                        falls under.
                    specialAdCategoryCountry:
                      type: array
                      items:
                        type: string
                        minLength: 2
                        maxLength: 2
                      description: >-
                        ISO 3166-1 alpha-2 country codes required for some
                        special ad categories.
                  required:
                    - specialAdCategories
                  description: Campaign-level settings.
                adSet:
                  type: object
                  properties:
                    dailyBudgetMinorUnits:
                      type: integer
                      minimum: -9007199254740991
                      maximum: 9007199254740991
                      exclusiveMinimum: 0
                      description: >-
                        Daily budget in the ad account's currency minor units
                        (e.g. cents).
                    targeting:
                      type: object
                      properties:
                        countries:
                          type: array
                          minItems: 1
                          items:
                            type: string
                            minLength: 2
                            maxLength: 2
                        ageMin:
                          type: integer
                          minimum: 13
                          maximum: 65
                        ageMax:
                          type: integer
                          minimum: 13
                          maximum: 65
                        genders:
                          type: array
                          items:
                            anyOf:
                              - const: 1
                              - const: 2
                        locales:
                          type: array
                          items:
                            type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                      required:
                        - countries
                      description: Audience targeting for the ad set.
                    startTime:
                      type: string
                      description: ISO 8601 ad set start time.
                    endTime:
                      type: string
                      description: ISO 8601 ad set end time.
                  required:
                    - dailyBudgetMinorUnits
                    - targeting
                  description: Ad set-level settings.
                creative:
                  type: object
                  properties:
                    media:
                      anyOf:
                        - type: object
                          properties:
                            kind:
                              const: image
                            imageKey:
                              type: string
                              minLength: 1
                              maxLength: 1024
                            fileId:
                              type: string
                              minLength: 1
                            imageMimeType:
                              type: string
                              maxLength: 255
                            imageFileName:
                              type: string
                              maxLength: 255
                            link:
                              type: string
                              format: uri
                            message:
                              type: string
                              maxLength: 500
                            headline:
                              type: string
                              maxLength: 40
                            description:
                              type: string
                              maxLength: 200
                            caption:
                              type: string
                              maxLength: 30
                          required:
                            - kind
                            - imageKey
                            - fileId
                            - link
                        - type: object
                          properties:
                            kind:
                              const: video
                            videoId:
                              type: string
                              minLength: 1
                            thumbnailImageHash:
                              type: string
                              minLength: 1
                            title:
                              type: string
                              maxLength: 40
                            message:
                              type: string
                              maxLength: 500
                            linkDescription:
                              type: string
                              maxLength: 200
                          required:
                            - kind
                            - videoId
                      description: Ad creative media (image or video).
                    welcomeMessage:
                      anyOf:
                        - type: object
                          properties:
                            type:
                              const: default
                          required:
                            - type
                        - type: object
                          properties:
                            type:
                              const: single
                            message:
                              type: string
                              minLength: 1
                              maxLength: 2000
                            quickReplies:
                              type: array
                              maxItems: 3
                              items:
                                type: object
                                properties:
                                  title:
                                    type: string
                                    minLength: 1
                                    maxLength: 20
                                required:
                                  - title
                          required:
                            - type
                            - message
                        - type: object
                          properties:
                            type:
                              const: templates
                            templates:
                              type: array
                              minItems: 1
                              maxItems: 5
                              items:
                                type: object
                                properties:
                                  heading:
                                    type: string
                                    maxLength: 80
                                  message:
                                    type: string
                                    minLength: 1
                                    maxLength: 2000
                                  quickReplies:
                                    type: array
                                    maxItems: 3
                                    items:
                                      type: object
                                      properties:
                                        title:
                                          type: string
                                          minLength: 1
                                          maxLength: 20
                                      required:
                                        - title
                                required:
                                  - message
                          required:
                            - type
                            - templates
                      description: Click-to-message welcome message shown to the contact.
                  required:
                    - media
                    - welcomeMessage
                  description: Ad creative settings.
              required:
                - channel
                - integrationId
                - adAccountId
                - name
                - campaign
                - adSet
                - creative
      responses:
        '201':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  channel:
                    type: string
                  adAccountId:
                    type: string
                  name:
                    type: string
                  createState:
                    type: string
                  publishState:
                    type: string
                  metaCampaignId:
                    anyOf:
                      - type: string
                      - type: 'null'
                  metaAdSetId:
                    anyOf:
                      - type: string
                      - type: 'null'
                  metaAdCreativeId:
                    anyOf:
                      - type: string
                      - type: 'null'
                  metaAdId:
                    anyOf:
                      - type: string
                      - type: 'null'
                  lastError:
                    anyOf:
                      - type: string
                      - type: 'null'
                  cleanupError:
                    anyOf:
                      - type: string
                      - type: 'null'
                  effectiveStatus:
                    anyOf:
                      - type: string
                      - type: 'null'
                  createdAt:
                    type: string
                    format: date-time
                    x-native-type: date
                required:
                  - id
                  - channel
                  - adAccountId
                  - name
                  - createState
                  - publishState
                  - metaCampaignId
                  - metaAdSetId
                  - metaAdCreativeId
                  - metaAdId
                  - lastError
                  - cleanupError
                  - effectiveStatus
                  - createdAt
        '400':
          description: '400'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: businessError
                      status:
                        const: 400
                      message:
                        type: string
                        default: An error occurred while processing your request
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - $ref: '#/components/schemas/UndefinedError'
        '401':
          description: '401'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: UNAUTHORIZED
                      status:
                        const: 401
                      message:
                        type: string
                        default: Authentication required
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: INVALID_CHATBOT_TOKEN
                      status:
                        const: 401
                      message:
                        type: string
                        default: Invalid or missing workspace API token
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - $ref: '#/components/schemas/UndefinedError'
        '403':
          description: '403'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: FORBIDDEN
                      status:
                        const: 403
                      message:
                        type: string
                        default: You do not have permission to perform this action
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: trialExpired
                      status:
                        const: 403
                      message:
                        type: string
                        default: Trial expired
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: macLimitReached
                      status:
                        const: 403
                      message:
                        type: string
                        default: Monthly active contact limit reached
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - $ref: '#/components/schemas/UndefinedError'
        '422':
          description: '422'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: invalidRequestData
                      status:
                        const: 422
                      message:
                        type: string
                        default: Input validation failed
                      data:
                        type: object
                        properties:
                          issues:
                            type: array
                            items:
                              type: object
                              properties:
                                message:
                                  type: string
                                path:
                                  type: array
                                  items:
                                    anyOf:
                                      - type: string
                                      - type: number
                                      - type: object
                                        properties:
                                          key:
                                            anyOf:
                                              - type: string
                                              - type: number
                                        required:
                                          - key
                                        additionalProperties: {}
                              required:
                                - message
                              additionalProperties: {}
                        required:
                          - issues
                        additionalProperties: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                      - data
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: validation
                      status:
                        const: 422
                      message:
                        type: string
                        default: Validation error
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - $ref: '#/components/schemas/UndefinedError'
        '429':
          description: '429'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: tooManyRequests
                      status:
                        const: 429
                      message:
                        type: string
                        default: Too many requests
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - $ref: '#/components/schemas/UndefinedError'
        '500':
          description: '500'
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      defined:
                        const: true
                      code:
                        const: INTERNAL_SERVER_ERROR
                      status:
                        const: 500
                      message:
                        type: string
                        default: An unexpected error occurred
                      data: {}
                    required:
                      - defined
                      - code
                      - status
                      - message
                  - $ref: '#/components/schemas/UndefinedError'
components:
  schemas:
    UndefinedError:
      type: object
      properties:
        defined:
          const: false
        code:
          type: string
        status:
          type: number
        message:
          type: string
        data: {}
      required:
        - defined
        - code
        - status
        - message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    developerAccessToken:
      type: http
      scheme: bearer
    tokenInSearchParams:
      type: apiKey
      in: query
      name: token

````