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

# Import Subscription (Subscribe to an Event)

> Create an event subscription by importing one of the pre-defined scenario templates. Pick the template for the event you want from the request examples, then change only:

**Required token scopes:** `Create scenarios`, `Manage scenarios on behalf of user` (both are required)

* **`url`** *(required)* - located under `data.actions[0].params.url`. Replace `{{yourWebhookURL}}` with the destination URL that should receive the events.
* **`asStatus`** - keep `"active"` to enable the subscription immediately, `"inactive"` to save it as an inactive revision, or `"draft"` to save it as a draft.
* Template-specific placeholders such as `{{word1}}`/`{{word2}}` (Messages with Specific Text) or `{{targetLabelId}}` (Specific Label Added).

Optionally, you can include an `authorUid` body field (a Texter user UID) to attribute the action to a specific user; when omitted, it is attributed automatically.

Every event also has its own page under **Webhooks** in the sidebar (e.g. [All Messages](/he/api-reference/webhooks/message-events/all-messages)) with the ready-to-send template, exactly what to change in it, and the payload your URL receives.

If the provided templates don't satisfy your needs, contact [Texter Support](https://wa.me/972586640430) and we'll gladly help modify any triggers, conditions, or actions for your webhook.


## OpenAPI

````yaml he/api-reference/openapi.json POST /scenarios/manage/import
openapi: 3.1.0
info:
  title: Texter API V2
  version: 2.0.0
  description: >-
    The **Texter API** lets your developers control the Texter platform
    programmatically:


    - Manage and send your WhatsApp template messages

    - Retrieve chats by ID or by various filters

    - Assign and resolve conversations

    - Send session messages into active chats

    - Manage labels

    - Monitor and resolve channel health issues

    - Subscribe to real-time webhook events

    - Manage quick replies (coming soon)


    For any questions please contact [Texter
    Support](https://wa.me/972586640430).
  contact:
    name: Texter Support
    url: https://wa.me/972586640430
servers:
  - url: https://{projectID}.texterchat.com/server/api/v2
    description: Your Texter environment. Replace projectID with your project subdomain
    variables:
      projectID:
        default: demo
        description: >-
          Your unique project subdomain. If your environment URL is
          https://demo.texterchat.com, your projectID is "demo"
security:
  - bearerAuth: []
tags:
  - name: Manage Templates
    description: >-
      Create, localize, submit, update, delete and send WhatsApp template
      messages, and retrieve approved templates for your connected WhatsApp
      accounts.


      **Suggested token for this group** - create one API token with the scopes:
      *Send template messages*, *View template messages*, *Manage WhatsApp
      templates*, *Manage all chats*, *List all chats* (the last two also cover
      the Templates Subscriptions group). Each endpoint below also lists the
      exact scopes it needs.
  - name: Templates Subscriptions
    description: >-
      Manage recipient subscriptions for WhatsApp template messages -
      unsubscribe or resubscribe recipients, and list unsubscribed users across
      all channels or for a specific account.


      **Suggested token for this group** - scopes: *Manage all chats*, *List all
      chats*. Each endpoint below also lists the exact scopes it needs.
  - name: Messages
    description: >-
      Retrieve message history from a chat, or send new session messages - text,
      media, buttons, lists, contact cards and locations - within the active
      WhatsApp 24-hour session window.


      **Suggested token for this group** - scopes: *Send session message*, *View
      all chats*. Each endpoint below also lists the exact scopes it needs.
  - name: Chats
    description: >-
      Fetch chat details, search conversations, update chat properties, assign
      or resolve chats, and manage their CRM metadata.


      **Suggested token for this group** - scopes: *Manage all chats*, *List all
      chats*, *Send session message*. Each endpoint below also lists the exact
      scopes it needs.
  - name: Labels
    description: >-
      Create and edit labels, assign or remove them from chats, retrieve label
      data, or delete labels from your inbox.


      **Suggested token for this group** - scopes: *Manage labels*, *Manage all
      chats* (needed for managing labels on chats). Each endpoint below also
      lists the exact scopes it needs.
  - name: Channels
    description: >-
      Monitor and maintain the health of connected messaging channels - retrieve
      active channel health problems, filter them by severity or account, and
      mark issues as resolved.


      **Suggested token for this group** - scopes: *Manage channels*. Each
      endpoint below also lists the exact scopes it needs.
  - name: Quick Replies
    description: >-
      Manage quick replies - prepared messages agents can send into matching
      chats with one click. Quick replies marked with `aiQuickReply` client
      metadata appear as **AI suggestions** in the Texter inbox (see Create
      Quick Reply for the full flow).


      **Suggested token for this group** - scopes: *View quick replies*, *Manage
      quick replies*. Each endpoint below also lists the exact scopes it needs.
  - name: Files
    description: >-
      Generate public access links to media files stored in Texter.


      **Suggested token for this group** - scopes: *View all files*, *View all
      chats* (both required). Each endpoint below also lists the exact scopes it
      needs.
  - name: Subscribe to Events
    description: >-
      Register webhooks for events occurring in your Texter environment. Under
      the hood this uses **Scenarios** - a workflow automation feature within
      Texter. To make integration easy, pre-defined templates are provided:
      import a scenario JSON, plug in your webhook URL and user UID, and the
      subscription is active.


      See the **Webhook Events** pages for the payload your URL receives for
      each event.


      **Suggested token for this group** - scopes: *View scenarios*, *Create
      scenarios*, *Delete scenarios*, *Activate/inactivate scenarios*, *Manage
      scenarios on behalf of user*. Each endpoint below also lists the exact
      scopes it needs.


      If the provided templates don't satisfy your needs, contact [Texter
      Support](https://wa.me/972586640430) and we'll gladly help modify any
      triggers, conditions or actions for your webhook.
  - name: Scenarios (Advanced)
    description: >-
      Full programmatic control over scenarios for advanced automations: create
      scenarios from scratch, copy them, edit drafts, publish revisions, inspect
      execution runs, and discover the available building blocks (events,
      conditions, loaders, actions). For plain webhook subscriptions, the
      **Subscribe to Events** group with its ready-made templates is the simpler
      path.


      **Suggested token for this group** - scopes: *View scenarios*, *Create
      scenarios*, *Edit scenarios*, *Delete scenarios*, *Activate/inactivate
      scenarios*, *Manage scenarios on behalf of user*, *View scenarios runs*.
      Each endpoint below also lists the exact scopes it needs.
paths:
  /scenarios/manage/import:
    post:
      tags:
        - Subscribe to Events
      summary: Import Subscription (Subscribe to an Event)
      description: >-
        Create an event subscription by importing one of the pre-defined
        scenario templates. Pick the template for the event you want from the
        request examples, then change only:


        **Required token scopes:** `Create scenarios`, `Manage scenarios on
        behalf of user` (both are required)



        - **`url`** *(required)* - located under `data.actions[0].params.url`.
        Replace `{{yourWebhookURL}}` with the destination URL that should
        receive the events.

        - **`asStatus`** - keep `"active"` to enable the subscription
        immediately, `"inactive"` to save it as an inactive revision, or
        `"draft"` to save it as a draft.

        - Template-specific placeholders such as `{{word1}}`/`{{word2}}`
        (Messages with Specific Text) or `{{targetLabelId}}` (Specific Label
        Added).


        Optionally, you can include an `authorUid` body field (a Texter user
        UID) to attribute the action to a specific user; when omitted, it is
        attributed automatically.


        Every event also has its own page under **Webhooks** in the sidebar
        (e.g. [All
        Messages](/he/api-reference/webhooks/message-events/all-messages)) with
        the ready-to-send template, exactly what to change in it, and the
        payload your URL receives.


        If the provided templates don't satisfy your needs, contact [Texter
        Support](https://wa.me/972586640430) and we'll gladly help modify any
        triggers, conditions, or actions for your webhook.
      operationId: import-subscription
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                authorUid:
                  type: string
                  description: >-
                    Optional - Texter user ID (UID) to attribute the
                    subscription to. When omitted, it is attributed
                    automatically
                data:
                  type: object
                  description: The scenario definition (use one of the provided templates)
                  properties:
                    version:
                      type: string
                      enum:
                        - v1
                        - v1.1
                    name:
                      type: string
                    description:
                      type: string
                    triggerEvents:
                      type: array
                      items:
                        type: string
                    loaders:
                      type: object
                      additionalProperties: true
                    conditions:
                      type: array
                      items: {}
                    actions:
                      type: array
                      items:
                        type: object
                        additionalProperties: true
                    options:
                      type: object
                      properties:
                        unorderedActions:
                          type: boolean
                  required:
                    - version
                    - name
                    - triggerEvents
                    - loaders
                    - conditions
                    - actions
                asStatus:
                  type: string
                  enum:
                    - active
                    - inactive
                    - draft
              required:
                - data
                - asStatus
            examples:
              All Messages:
                value:
                  data:
                    version: v1
                    name: (SUB) All Messages
                    description: Sends a webhook for each new message (incoming & outgoing)
                    triggerEvents:
                      - domain.message.created
                    loaders:
                      beforeConditions:
                        - name: chat
                          alias: chat
                          params:
                            id:
                              '##provide':
                                provider: message
                                key: parent_chat
                          confidentialData: false
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: newMessage
                            eventData:
                              message:
                                '##provide':
                                  provider: message
                                  key: message
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              New Incoming Messages:
                value:
                  data:
                    version: v1
                    name: (SUB) New Incoming Messages
                    description: Sends a webhook for each new incoming message
                    triggerEvents:
                      - domain.message.created
                    loaders:
                      beforeConditions: []
                      afterConditions:
                        - name: chat
                          alias: chat
                          params:
                            id:
                              '##provide':
                                provider: message
                                key: parent_chat
                          confidentialData: false
                    conditions:
                      - - name: filtrex
                          params:
                            expression: direction == "incoming"
                            value:
                              '##provide':
                                provider: message
                                key: message
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: newIncomingMessage
                            eventData:
                              message:
                                '##provide':
                                  provider: message
                                  key: message
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Messages with Specific Text:
                value:
                  data:
                    version: v1
                    name: (SUB) Messages with Specific Text
                    description: >-
                      Sends a webhook when a new incoming message includes a
                      specific word(s).
                    triggerEvents:
                      - domain.message.created
                    loaders:
                      beforeConditions: []
                      afterConditions:
                        - name: chat
                          alias: chat
                          params:
                            id:
                              '##provide':
                                provider: message
                                key: parent_chat
                          confidentialData: false
                    conditions:
                      - - name: filtrex
                          params:
                            expression: direction == "incoming"
                            value:
                              '##provide':
                                provider: message
                                key: message
                          confidentialData: false
                        - name: filtrex
                          params:
                            expression: 'text == "{{word1}}" or text == "{{word2}}" '
                            value:
                              '##provide':
                                provider: message
                                key: message
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: newMatchedMessage
                            eventData:
                              message:
                                '##provide':
                                  provider: message
                                  key: message
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Messages with Attachments:
                value:
                  data:
                    version: v1
                    name: (SUB) Messages with Attachments
                    description: >-
                      Sends a webhook when a new incoming message includes a
                      media item (image / video / document / audio / sticker)
                    triggerEvents:
                      - domain.message.created
                    loaders:
                      beforeConditions: []
                      afterConditions:
                        - name: chat
                          alias: chat
                          params:
                            id:
                              '##provide':
                                provider: message
                                key: parent_chat
                          confidentialData: false
                    conditions:
                      - - name: filtrex
                          params:
                            expression: direction == "incoming"
                            value:
                              '##provide':
                                provider: message
                                key: message
                          confidentialData: false
                        - name: filtrex
                          params:
                            expression: type == "media"
                            value:
                              '##provide':
                                provider: message
                                key: message
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: newMediaMessage
                            eventData:
                              message:
                                '##provide':
                                  provider: message
                                  key: message
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Messages Failed to Deliver:
                value:
                  data:
                    version: v1
                    name: (SUB) Messages Failed to Deliver
                    description: >-
                      Sends a webhook when an outgoing message fails to deliver
                      (blocked by Meta)
                    triggerEvents:
                      - app.message.statusRequest
                    loaders:
                      afterConditions:
                        - name: chat
                          alias: chat
                          params:
                            name:
                              '##provide':
                                provider: messageStatusRequest
                                key: chat.name
                            accountId:
                              '##provide':
                                provider: messageStatusRequest
                                key: chat.accountId
                            idByChannel:
                              '##provide':
                                provider: messageStatusRequest
                                key: chat.id
                          confidentialData: false
                    conditions:
                      - - name: compare
                          params:
                            comparison: Equal
                            compareTo: 4
                            value:
                              '##provide':
                                provider: messageStatusRequest
                                key: status
                          confidentialData: false
                      - - name: compare
                          params:
                            comparison: Equal
                            compareTo: 5
                            value:
                              '##provide':
                                provider: messageStatusRequest
                                key: status
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: messageFailed
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                              error: '%messageStatusRequest:error%'
                              timestamp: '%messageStatusRequest:timestamp%'
                              externalId: '%messageStatusRequest:ids%'
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Message Status Changed:
                value:
                  data:
                    version: v1
                    name: (SUB) Messages Status Changed
                    description: >-
                      Sends a webhook for all outgoing messages status changes
                      (e.g., from "Delivered" to "Seen")
                    triggerEvents:
                      - app.message.statusRequest
                    loaders:
                      beforeConditions:
                        - name: chat
                          alias: chat
                          params:
                            name:
                              '##provide':
                                provider: messageStatusRequest
                                key: chat.name
                            accountId:
                              '##provide':
                                provider: messageStatusRequest
                                key: chat.accountId
                            idByChannel:
                              '##provide':
                                provider: messageStatusRequest
                                key: chat.id
                          confidentialData: false
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: messageStatusChanged
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                              messageStatus: '%messageStatusRequest:status%'
                              error: '%messageStatusRequest:error%'
                              timestamp: '%messageStatusRequest:timestamp%'
                              externalId: '%messageStatusRequest:ids%'
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Unsubscribed from Template Messages:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Unsubscribed
                    description: >-
                      Sends a webhook when a chat unsubscribed from receiving
                      template messages (e.g., by replying "הסר")
                    triggerEvents:
                      - domain.chat.unsubscribed
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatUnsubscribed
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Subscribed to Template Messages:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Subscribed
                    description: >-
                      Sends a webhook when a chat subscribes or opts back in to
                      receiving template messages.
                    triggerEvents:
                      - domain.chat.subscribed
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatSubscribed
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Taken:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Assigned
                    description: >-
                      Sends a webhook when a chat is assigned, with full chat
                      data and a narrowed agent object.
                    triggerEvents:
                      - domain.chat.assigned
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatAssigned
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                              agent:
                                id:
                                  '##provide':
                                    provider: agent
                                    key: _id
                                crmId:
                                  '##provide':
                                    provider: agent
                                    key: crmId
                                email:
                                  '##provide':
                                    provider: agent
                                    key: email
                                displayName:
                                  '##provide':
                                    provider: agent
                                    key: displayName
                                roles:
                                  '##provide':
                                    provider: agent
                                    key: roles
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Pending:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Pending
                    description: >-
                      Sends a webhook when a chat moves to pending status
                      (waiting for a human agent).
                    triggerEvents:
                      - domain.chat.pending
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatPending
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Resolved:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Resolved
                    description: Sends a webhook when a chat is resolved.
                    triggerEvents:
                      - domain.chat.resolved
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatResolved
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Resolved by Bot:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Resolved by Bot
                    description: >-
                      Sends a webhook when a chat is resolved automatically by
                      the bot (no human agent assigned).
                    triggerEvents:
                      - domain.chat.resolved
                    loaders: {}
                    conditions:
                      - - name: filtrex
                          params:
                            expression: not exists(agent.uid)
                            value: '%chat:chat%'
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatResolvedByBot
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Resolved by Agent:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Resolved by Agent
                    description: Sends a webhook when a chat is resolved by a human agent.
                    triggerEvents:
                      - domain.chat.resolved
                    loaders: {}
                    conditions:
                      - - name: filtrex
                          params:
                            expression: exists(agent.uid)
                            value: '%chat:chat%'
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatResolvedByAgent
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Chat Labels Changed:
                value:
                  data:
                    version: v1
                    name: (SUB) Chat Labels Updated
                    description: >-
                      Sends a webhook when a chat's labels change, with the
                      chat, previous labels, and the added/removed diff.
                    triggerEvents:
                      - domain.chat.labels
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatLabelsUpdated
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                              oldLabels:
                                '##provide':
                                  provider: oldLabels
                                  key: labels
                              addedLabels:
                                '##provide':
                                  provider: addedLabels
                                  key: labels
                              removedLabels:
                                '##provide':
                                  provider: removedLabels
                                  key: labels
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Specific Label Added to Chat:
                value:
                  data:
                    version: v1
                    name: (SUB) Specific Label Added
                    description: Sends a webhook when a specific label is added to a chat.
                    triggerEvents:
                      - domain.chat.labels
                    loaders: {}
                    conditions:
                      - - name: filtrex
                          params:
                            expression: inArray(addedLabels, "{{targetLabelId}}")
                            value:
                              addedLabels:
                                '##provide':
                                  provider: addedLabels
                                  key: labels
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: chatSpecificLabelAdded
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                              oldLabels:
                                '##provide':
                                  provider: oldLabels
                                  key: labels
                              addedLabels:
                                '##provide':
                                  provider: addedLabels
                                  key: labels
                              removedLabels:
                                '##provide':
                                  provider: removedLabels
                                  key: labels
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              External Bot Enabled:
                value:
                  data:
                    version: v1
                    name: (SUB) External Bot Enabled
                    description: Sends a webhook when externalBot is set to true on a chat.
                    triggerEvents:
                      - domain.chat.updated.externalBot
                      - app.bot.chat.setExternal
                    loaders: {}
                    conditions:
                      - - name: filtrex
                          params:
                            expression: exists(externalBot) and externalBot
                            value:
                              '##provide':
                                provider: chat
                                key: chat
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: externalBotEnabled
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              External Bot Disabled:
                value:
                  data:
                    version: v1
                    name: (SUB) External Bot Disabled
                    description: >-
                      Sends a webhook when externalBot is set to false on a
                      chat.
                    triggerEvents:
                      - domain.chat.updated.externalBot
                      - app.bot.chat.setExternal
                    loaders: {}
                    conditions:
                      - - name: compare
                          params:
                            comparison: Equal
                            compareTo: false
                            value:
                              '##provide':
                                provider: chat
                                key: externalBot
                          confidentialData: false
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: externalBotDisabled
                            eventData:
                              chat:
                                '##provide':
                                  provider: chat
                                  key: chat
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Channel Health Problem Created:
                value:
                  data:
                    version: v1
                    name: (SUB) Channel Health Problem Created
                    description: >-
                      Sends a webhook when a channel health problem is detected
                      on a WhatsApp account.
                    triggerEvents:
                      - domain.channel.health.problem.created
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: channelHealthProblemCreated
                            eventData:
                              problem:
                                '##provide':
                                  provider: problem
                                  key: problem
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
              Channel Health Problem Resolved:
                value:
                  data:
                    version: v1
                    name: (SUB) Channel Health Problem Resolved
                    description: >-
                      Sends a webhook when a previously detected channel health
                      problem is resolved.
                    triggerEvents:
                      - domain.channel.health.problem.resolved
                    loaders: {}
                    conditions: []
                    actions:
                      - name: request
                        params:
                          url: '{{yourWebhookURL}}'
                          method: post
                          json: true
                          data:
                            eventName: channelHealthProblemResolved
                            eventData:
                              problem:
                                '##provide':
                                  provider: problem
                                  key: problem
                        confidentialData: false
                    options:
                      unorderedActions: false
                  asStatus: active
      responses:
        '201':
          description: >-
            The created subscription (scenario object). Field-by-field
            reference: [The Scenario object](/he/api-reference/objects/scenario)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Scenario'
        '400':
          description: Validation error, or `authorUid` user not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error: 'authorUid: User with ID abc123 not found'
        '401':
          description: Missing or invalid token, or missing required scopes
components:
  schemas:
    Scenario:
      type: object
      description: An event subscription (scenario) in Texter
      properties:
        _id:
          type: string
          description: Unique identifier of the subscription/scenario
        system:
          type: string
          description: >-
            System scenario identifier. Present only on built-in system
            scenarios (returned when `includeSystem=true`)
        drafts:
          type: array
          description: >-
            Draft revisions of this scenario being edited. Same shape as a
            revision, but with `status: "draft"`, no
            `version`/`revisionComment`, and metadata limited to
            `authorUid`/`created`/`modified`
          items:
            type: object
            additionalProperties: true
        inactiveRevisions:
          type: array
          items:
            $ref: '#/components/schemas/ScenarioRevision'
          description: Inactive revisions
        activeRevision:
          allOf:
            - $ref: '#/components/schemas/ScenarioRevision'
          description: The currently active version of the scenario
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message
      required:
        - error
    ScenarioRevision:
      type: object
      description: A specific snapshot of the scenario logic
      properties:
        _id:
          type: string
          description: Unique identifier of this specific revision
        scenarioId:
          type: string
          description: Reference to the parent scenario ID
        name:
          type: string
          description: Human-readable name of the subscription/scenario
        description:
          type: string
        status:
          type: string
          enum:
            - active
            - inactive
          description: The state of this specific revision
        version:
          type: number
          description: The version number of this revision
        parentVersion:
          type: number
          description: The version number this revision was based on
        revisionComment:
          type: string
        triggerEvents:
          type: array
          items:
            type: string
          description: Internal events that trigger this scenario
        conditions:
          type: array
          description: >-
            Condition **groups**: an array of groups, each group an array of
            conditions. All conditions inside a group must pass (AND); the
            scenario fires if **any** group passes (OR between groups)
          items:
            type: array
            items:
              type: object
              properties:
                name:
                  type: string
                  description: Condition component, e.g. `filtrex`, `compare`
                params:
                  description: Component parameters
                confidentialData:
                  type: boolean
        loaders:
          type: object
          description: Data loaders by position
          properties:
            beforeConditions:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    description: Loader component, e.g. `chat`
                  alias:
                    type: string
                    description: Name under which the loaded data is exposed
                  params:
                    description: Loader parameters
                  confidentialData:
                    type: boolean
            afterConditions:
              type: array
              items:
                type: object
                properties:
                  name:
                    type: string
                    description: Loader component, e.g. `chat`
                  alias:
                    type: string
                    description: Name under which the loaded data is exposed
                  params:
                    description: Loader parameters
                  confidentialData:
                    type: boolean
        actions:
          type: array
          description: Actions to execute, e.g. the `request` webhook action
          items:
            type: object
            properties:
              name:
                type: string
                description: Action component, e.g. `request`
              params:
                description: Action parameters
              confidentialData:
                type: boolean
        loops:
          type: array
          description: Loop definitions, when the scenario iterates over data
          items:
            type: object
            properties:
              loop:
                type: object
                additionalProperties: true
                description: >-
                  Foreach definition: `input`, `as`, `foreachMode` (`sequential`
                  with `itemDelay`/`breakOnError`, or `parallel` with
                  `concurency`)
              position:
                type: string
                enum:
                  - afterEvents
                  - beforeConditions
                  - afterConditions
                  - beforeActions
        tags:
          type: array
          items:
            type: string
        attachedData:
          type: object
          additionalProperties: true
          description: Free-form data attached when the revision was created
        system:
          type: string
          description: >-
            System scenario identifier. Present only on built-in system
            scenarios
        options:
          type: object
          properties:
            unorderedActions:
              type: boolean
              description: If true, actions may run in parallel; if false, sequentially
        metadata:
          type: object
          properties:
            authorUid:
              type: string
              description: User ID of the person who created this revision
            created:
              type: number
              description: Timestamp (ms) of revision creation
            modified:
              type: number
              description: Timestamp (ms) of the last draft modification
            activated:
              type: number
              description: Timestamp (ms) of the most recent activation
            activations:
              type: array
              description: History of activations
              items:
                type: object
                properties:
                  timestamp:
                    type: number
                  userUid:
                    type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token generated in Texter: gear icon → Developers → API Tokens. When
        creating a token, assign it the scopes required by the endpoints you
        plan to call - each endpoint lists its required scopes.

````