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

# Dynamic Workflow Trigger

> API to dynamically create and trigger a single step workflow.



## OpenAPI

````yaml POST /{workspace_key}/trigger/
openapi: 3.1.1
info:
  title: SuprSend API
  description: APIs supported on suprsend platform
  version: 1.2.2
servers:
  - url: https://hub.suprsend.com
security:
  - sec0: []
  - BearerAuth: []
paths:
  /{workspace_key}/trigger/:
    post:
      summary: Dynamic Workflow Trigger
      description: API to dynamically create and trigger a single step workflow.
      operationId: dynamic-workflow-trigger
      parameters:
        - name: workspace_key
          in: path
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - template
                - notification_category
                - users
              properties:
                name:
                  type: string
                  description: >-
                    Unique name of the workflow. The workflow name should be
                    easily identifiable for your reference at a later stage. You
                    can see workflow-related analytics on the workflow page (how
                    many notifications were sent, delivered, clicked or
                    interacted).
                  default: _workflow_name_
                template:
                  type: string
                  description: >-
                    Unique slug of the template created on SuprSend dashboard.
                    You can get this by clicking on the clipboard icon next to
                    the Template name on SuprSend templates page.
                  default: _template_slug_
                notification_category:
                  type: string
                  description: >-
                    Used to apply user category level
                    [preferences]("/docs/user-preferences") on notification
                    trigger.
                  default: transactional
                users:
                  type: array
                  description: Array object of target users.
                  items:
                    properties:
                      distinct_id:
                        type: string
                        description: unique identifier of the user
                        default: _distinct_id_
                      $channels:
                        type: array
                        description: >-
                          send notification on selected channels in user
                          profile. Following channel keys can be used - email,
                          sms, whatsapp, androidpush, iospush, slack, webpush
                        default: []
                        items:
                          type: string
                      $email:
                        type: array
                        description: To trigger notification on a particular email
                        default: []
                        items:
                          type: string
                      $sms:
                        type: array
                        description: Send SMS on a particular number.
                        default: []
                        items:
                          type: string
                      $whatsapp:
                        type: array
                        description: Send Whatsapp on a particular number.
                        default: []
                        items:
                          type: string
                      $androidpush:
                        type: array
                        description: Send androidpush on the given push token
                        items:
                          type: string
                      $iospush:
                        type: array
                        description: Send iOSpush on the given push token
                        items:
                          type: string
                      $slack:
                        type: array
                        description: Slack channel configuration
                        items:
                          oneOf:
                            - type: object
                              title: user email_id
                              required:
                                - email
                                - access_token
                              properties:
                                email:
                                  type: string
                                  format: email
                                  description: User email address
                                  example: user@example.com
                                access_token:
                                  type: string
                                  description: Slack bot access token
                                  example: xoxb-XXXXXXXX
                            - type: object
                              title: user member_id
                              required:
                                - user_id
                                - access_token
                              properties:
                                user_id:
                                  type: string
                                  description: Slack user ID (U/WXXXXXXXX format)
                                  example: U/WXXXXXXXX
                                access_token:
                                  type: string
                                  description: Slack bot access token
                                  example: xoxb-XXXXXXXX
                            - type: object
                              title: Slack channel
                              required:
                                - channel
                                - access_token
                              properties:
                                channel:
                                  type: string
                                  description: Slack channel ID (CXXXXXXXX format)
                                  example: CXXXXXXXX
                                access_token:
                                  type: string
                                  description: Slack bot access token
                                  example: xoxb-XXXXXX
                            - type: object
                              title: Using incoming webhook
                              required:
                                - incoming_webhook
                              properties:
                                incoming_webhook: null
                                type: object
                                required:
                                  - url
                                properties:
                                  url:
                                    type: string
                                    format: uri
                                    description: Slack incoming webhook URL
                                    example: >-
                                      https://hooks.slack.com/services/TXXXX/BXXXX/XXXXXXX
                      $ms_teams:
                        type: array
                        description: Microsoft Teams channel configuration
                        items:
                          oneOf:
                            - type: object
                              title: MS Teams using conversation ID
                              required:
                                - tenant_id
                                - service_url
                                - conversation_id
                              properties:
                                tenant_id:
                                  type: string
                                  description: Microsoft Teams tenant ID
                                  example: c1981ab2-9aaf-xxxx-xxxx
                                service_url:
                                  type: string
                                  format: uri
                                  description: Microsoft Teams service URL
                                  example: https://smba.trafficmanager.net/amer
                                conversation_id:
                                  type: string
                                  description: Microsoft Teams conversation ID
                                  example: 19:c1524d7c-a06f-456f-8abe-xxxx
                            - type: object
                              title: MS Teams using user ID
                              required:
                                - tenant_id
                                - service_url
                                - user_id
                              properties:
                                tenant_id:
                                  type: string
                                  description: Microsoft Teams tenant ID
                                  example: c1981ab2-9aaf-xxxx-xxxx
                                service_url:
                                  type: string
                                  format: uri
                                  description: Microsoft Teams service URL
                                  example: https://smba.trafficmanager.net/amer
                                user_id:
                                  type: string
                                  description: Microsoft Teams user ID
                                  example: 29:1nsLcmJ2RKtYH6Cxxxx-xxxx
                            - type: object
                              title: MS Teams using incoming webhook
                              required:
                                - incoming_webhook
                              properties:
                                incoming_webhook:
                                  type: object
                                  required:
                                    - url
                                  properties:
                                    url:
                                      type: string
                                      format: uri
                                      description: Microsoft Teams incoming webhook URL
                                      example: >-
                                        https://wnk1z.webhook.office.com/webhookb2/XXXXXXXXX
                    required:
                      - distinct_id
                    type: object
                data:
                  type: object
                  description: >-
                    variable data required to render dynamic template content or
                    workflow properties like dynamic delay or channel override
                    in send node.
                  properties:
                    $attachments:
                      type: array
                      description: >-
                        Use this key to pass email attachment in the trigger.
                        You can either pass attachment as a public URL or as a
                        base64-encoded file (limit < 50KB).
                      items:
                        oneOf:
                          - type: object
                            title: publicly accessible URL
                            description: >-
                              Pass file as **publicly accessible URL** (No limit
                              on file size)
                            required:
                              - url
                            properties:
                              url:
                                type: string
                                format: uri
                                description: Publicly accessible URL of the file
                                example: https://bitcoincore.org/bitcoin.pdf
                              filename:
                                type: string
                                description: Filename to be shown in email
                                example: billing.pdf
                              ignore_if_error:
                                type: boolean
                                description: Ignore the attachment if it fails to load
                          - type: object
                            title: base64-encoded file
                            description: >-
                              Pass file as a **base-64 file** (supported limit <
                              50KB)
                            required:
                              - data
                            properties:
                              data:
                                type: string
                                description: Base64-encoded content of the file
                              filename:
                                type: string
                                description: Filename to be shown in email
                              contentType:
                                type: string
                                example: application/pdf
                  additionalProperties:
                    type: string
                delivery:
                  type: object
                  description: >-
                    delivery instructions for the workflow. You can set [Smart
                    Delivery](https://docs.suprsend.com/docs/smart-delivery)
                    preference by setting "smart":true
                  properties:
                    smart:
                      type: boolean
                      description: You can enable smart delivery by setting it true
                      default: false
                    success:
                      type: string
                      description: >-
                        Success event for stopping further notification in case
                        smart is set to true. You can set notification status
                        like delivery, interaction or custom success event
                      default: seen
                    time_to_live:
                      type: string
                      description: >
                        Time window to define delay between subsequent channel
                        trigger in case of smart delivery.

                        Delay = `time_to_live / (number_of_channels - 1)`.
                        Format - `XXdXXhXXmXXs` or if its number (n) then delay
                        is in seconds (n)
                    mandatory_channels:
                      type: array
                      description: >-
                        Channels on which notification has to be sent
                        immediately in case of smart delivery. Following channel
                        keys can be used - email, sms, whatsapp, androidpush,
                        iospush, slack, webpush
                      items:
                        type: string
                delay:
                  type: string
                  description: >-
                    Workflow will be halted for the time mentioned in delay, and
                    become active once the delay period is over. Format -
                    `XXdXXhXXmXXs` or if its number (n) then delay is in seconds
                    (n)
                trigger_at:
                  type: string
                  description: >-
                    Trigger workflow on a specific date-time. Format - date
                    string in ISO 8601 e.g. "2022-08-27T20:14:51.643Z"
                  format: date
                tenant_id:
                  type: string
                  description: >-
                    string identifier of the tenant this workflow is associated
                    with
                $idempotency_key:
                  type: string
                  description: >-
                    Unique identifier of the request (deduplicates request for
                    24hrs)
      responses:
        '202':
          description: '202'
          content:
            application/json:
              examples:
                Result:
                  value: Accepted - OK
              schema:
                type: string
                example: Accepted - OK
        '400':
          description: '400'
          content:
            application/json:
              examples:
                Result:
                  value:
                    status: fail
                    message: BAD REQUEST
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: fail
                    description: Indicates the failure status of the request.
                  message:
                    type: string
                    example: BAD REQUEST
                    description: Describes the reason for the failure.
      deprecated: false
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: cURL
          label: Dynamic Workflow Trigger
          source: >
            curl -X POST
            "https://hub.suprsend.com/{workspace_key}/dynamic-workflow/" \
              --header 'Authorization: Bearer __YOUR_API_KEY__' \
              --header 'Content-Type: application/json' \
              --data '{
                "name": "Welcome Email Workflow",
                "template": "welcome-email-template",
                "notification_category": "transactional",
                "users": [
                  {
                    "distinct_id": "user123",
                    "$email": ["user@example.com"],
                    "$channels": ["email"]
                  }
                ],
                "data": {
                  "user_name": "John Doe",
                  "welcome_message": "Welcome to our platform!"
                }
              }'
components:
  securitySchemes:
    sec0:
      type: apiKey
      in: header
      name: Authorization
      x-bearer-format: bearer
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where <token>
        is your auth token.
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API_Key
      description: >-
        Pass as `Bearer <API_KEY>`. Get API Key from SuprSend dashboard
        Developers -> API Keys section.

````