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

# Create workflow trigger

> Create a new trigger for a workflow. Triggers define when the workflow should automatically execute.

Trigger types:
- `inbound_message`: Workflow starts when WhatsApp messages arrive at specified phone number (requires phone_number_id)
- `api_call`: Workflow starts only via POST /workflows/{id}/executions (no phone_number_id needed)

After creating a trigger:
- For inbound_message: Messages to the phone_number_id will start workflow executions
- For api_call: Workflow can only be started via API endpoint

Note: A workflow can have multiple triggers (e.g., multiple phone numbers, or both inbound_message and api_call).




## OpenAPI

````yaml /api/platform/v1/openapi-workflows.yaml post /workflows/{workflow_id}/triggers
openapi: 3.1.0
info:
  title: Kapso Platform API – Advanced Resources
  version: 0.1.0
  description: >
    Build WhatsApp automation workflows and serverless functions. Create
    multi-step conversation flows, inspect executions, and deploy custom logic.
servers:
  - url: https://api.kapso.ai/platform/v1
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Workflows
    description: Create and manage conversation workflows and executions
  - name: Workflow Triggers
    description: Configure workflow triggers to automate execution
  - name: Functions
    description: Manage serverless functions, deployments, and secrets
  - name: WhatsApp Conversations
    description: Query WhatsApp conversation data and related resources
paths:
  /workflows/{workflow_id}/triggers:
    parameters:
      - name: workflow_id
        in: path
        required: true
        schema:
          type: string
          format: uuid
        description: Workflow identifier
    post:
      tags:
        - Workflow Triggers
      summary: Create workflow trigger
      description: >
        Create a new trigger for a workflow. Triggers define when the workflow
        should automatically execute.


        Trigger types:

        - `inbound_message`: Workflow starts when WhatsApp messages arrive at
        specified phone number (requires phone_number_id)

        - `api_call`: Workflow starts only via POST /workflows/{id}/executions
        (no phone_number_id needed)


        After creating a trigger:

        - For inbound_message: Messages to the phone_number_id will start
        workflow executions

        - For api_call: Workflow can only be started via API endpoint


        Note: A workflow can have multiple triggers (e.g., multiple phone
        numbers, or both inbound_message and api_call).
      operationId: createWorkflowTrigger
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkflowTriggerCreateRequest'
      responses:
        '201':
          description: Trigger created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkflowTriggerResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  schemas:
    WorkflowTriggerCreateRequest:
      type: object
      required:
        - trigger
      properties:
        trigger:
          type: object
          required:
            - trigger_type
          properties:
            trigger_type:
              type: string
              enum:
                - inbound_message
                - api_call
                - whatsapp_event
              description: >
                Type of trigger to create:

                - `inbound_message`: Workflow starts when messages arrive at a
                WhatsApp number (requires phone_number_id)

                - `api_call`: Workflow starts via API endpoint (no
                phone_number_id needed)

                - `whatsapp_event`: Workflow starts on WhatsApp events (requires
                event, optional phone_number_id)
            active:
              type: boolean
              description: Whether the trigger should be active immediately after creation
              default: true
            phone_number_id:
              type: string
              description: >
                **Required for inbound_message triggers.** For whatsapp_event
                triggers, optional to scope to specific number. WhatsApp
                Business phone number ID that will trigger this workflow.
                Messages to this number will start workflow executions. Not used
                for api_call triggers.
              example: '123456789012345'
            event:
              type: string
              enum:
                - whatsapp.message.received
                - whatsapp.message.sent
                - whatsapp.message.failed
                - whatsapp.conversation.created
                - whatsapp.conversation.ended
              description: >
                **Required for whatsapp_event triggers.** WhatsApp event type
                that will trigger the workflow. Not used for inbound_message or
                api_call triggers.
      description: Request to create a new workflow trigger
    WorkflowTriggerResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/WorkflowTrigger'
      description: Single workflow trigger response
    WorkflowTrigger:
      type: object
      required:
        - id
        - workflow_id
        - trigger_type
        - active
      properties:
        id:
          type: string
          format: uuid
          description: Unique trigger identifier
        workflow_id:
          type: string
          format: uuid
          description: ID of the workflow this trigger belongs to
        trigger_type:
          type: string
          enum:
            - inbound_message
            - api_call
            - whatsapp_event
          description: >
            Trigger activation mechanism:

            - `inbound_message`: Triggered by incoming WhatsApp messages to a
            specific phone number

            - `api_call`: Triggered by POST /workflows/{id}/executions API calls

            - `whatsapp_event`: Triggered by WhatsApp events (message and
            conversation lifecycle)
        active:
          type: boolean
          description: >
            Whether this trigger is enabled. Inactive triggers will not start
            workflow executions even when their conditions are met. Use this to
            temporarily disable a trigger without deleting it.
        display_name:
          type:
            - string
            - 'null'
          description: |
            Human-readable trigger name. Format varies by type:
            - Inbound message: "WhatsApp: [phone number display name]"
            - API call: "API Call Trigger"
        created_at:
          type: string
          format: date-time
          description: Trigger creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Last modification timestamp
        triggerable:
          type: object
          description: >
            Type-specific trigger configuration. Structure varies by
            trigger_type:

            - For `inbound_message`: Contains phone_number_id

            - For `api_call`: Empty object

            - For `whatsapp_event`: Contains event and optional phone_number_id
          oneOf:
            - type: object
              description: Inbound message trigger configuration
              required:
                - phone_number_id
              properties:
                phone_number_id:
                  type: string
                  description: >-
                    WhatsApp Business phone number ID that will trigger the
                    workflow
            - type: object
              description: API call trigger configuration (no additional fields)
              additionalProperties: false
            - type: object
              description: WhatsApp event trigger configuration
              required:
                - event
              properties:
                event:
                  type: string
                  enum:
                    - whatsapp.message.received
                    - whatsapp.message.sent
                    - whatsapp.message.failed
                    - whatsapp.conversation.created
                    - whatsapp.conversation.ended
                  description: WhatsApp event type that will trigger the workflow
                phone_number_id:
                  type: string
                  description: >-
                    Optional WhatsApp Business phone number ID to scope trigger
                    to specific number
      description: Workflow trigger defining when and how a workflow execution should start
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable error message
  responses:
    UnauthorizedError:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFoundError:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    ValidationError:
      description: Request validation failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````