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

# Trigger a workflow

> Executes a workflow using its associated trigger. Supports two execution modes:

- **Asynchronous** (default): Set `x-api-wait: false` or omit the header. Returns immediately with an empty (`null`) response body. The workflow run ID is returned in the `X-Pf-Run-Id` response header — use it to [poll for results](/api-reference/async-polling).

- **Synchronous**: Set `x-api-wait: true`. Waits up to 60 seconds for the workflow to complete. If it finishes in time, the response body contains the full results. If it times out, returns a timeout message with the run ID.



## OpenAPI

````yaml post /ext/triggers/{triggerId}
openapi: 3.0.1
info:
  title: AI Workflow API
  description: API for triggering and managing AI-powered workflows
  version: 1.0.0
servers:
  - url: https://triggers.app.pinkfish.ai
security:
  - apiKeyAuth: []
paths:
  /ext/triggers/{triggerId}:
    post:
      summary: Trigger a workflow
      description: >-
        Executes a workflow using its associated trigger. Supports two execution
        modes:


        - **Asynchronous** (default): Set `x-api-wait: false` or omit the
        header. Returns immediately with an empty (`null`) response body. The
        workflow run ID is returned in the `X-Pf-Run-Id` response header — use
        it to [poll for results](/api-reference/async-polling).


        - **Synchronous**: Set `x-api-wait: true`. Waits up to 60 seconds for
        the workflow to complete. If it finishes in time, the response body
        contains the full results. If it times out, returns a timeout message
        with the run ID.
      parameters:
        - name: triggerId
          in: path
          required: true
          schema:
            type: string
          description: The unique identifier of the trigger
        - name: myvar
          in: query
          schema:
            type: string
          description: Optional query parameter for the trigger
        - name: x-api-wait
          in: header
          required: false
          schema:
            type: string
            enum:
              - 'true'
              - 'false'
            default: 'false'
          description: >-
            Set to `true` for synchronous execution (waits up to 60 seconds for
            results). Set to `false` or omit for asynchronous (fire-and-forget)
            execution.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              additionalProperties: true
            example:
              user_request: what is the capital of France
          application/x-www-form-urlencoded:
            schema:
              type: object
              additionalProperties:
                type: string
            example:
              TESTKEY: TESTVAR
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
              additionalProperties: true
      responses:
        '200':
          description: >-
            Workflow triggered successfully.


            **Async mode** (`x-api-wait: false`): Response body is `null`. Use
            the `X-Pf-Run-Id` and `X-Pf-Automation-Id` headers to [poll for
            results](/api-reference/async-polling).


            **Sync mode** (`x-api-wait: true`): Response body contains the full
            workflow results if completed within 60 seconds, or a timeout
            message with the run ID.
          headers:
            X-Pf-Run-Id:
              schema:
                type: string
              description: >-
                The unique identifier for this workflow run. Use this to poll
                for status and results.
            X-Pf-Automation-Id:
              schema:
                type: string
              description: >-
                The automation/workflow ID. Use this together with `X-Pf-Run-Id`
                to poll for status and results.
          content:
            application/json:
              schema:
                type: object
                nullable: true
                description: >-
                  Sync mode: full workflow results. Async mode: null (check
                  X-Pf-Run-Id and X-Pf-Automation-Id response headers).
                properties:
                  automationId:
                    type: string
                  automationVersion:
                    type: integer
                  automationName:
                    type: string
                  id:
                    type: string
                    description: The run ID
                  type:
                    type: string
                  results:
                    type: array
                    items:
                      type: object
                      properties:
                        stepIndex:
                          type: integer
                        stepVersion:
                          type: integer
                        result:
                          type: object
                        resultUrls:
                          type: object
                        exitCode:
                          type: integer
                        duration:
                          type: integer
                  started:
                    type: string
                    format: date-time
                  status:
                    type: string
              examples:
                async:
                  summary: 'Async response (x-api-wait: false)'
                  description: >-
                    Body is null. The run ID and automation ID are in the
                    response headers.
                  value: null
                sync:
                  summary: 'Sync response (x-api-wait: true)'
                  description: Full workflow results returned in the body.
                  value:
                    automationId: d831ue4rccbc73knbi80
                    automationVersion: 3
                    automationName: Hello World
                    id: '1778786188583648270'
                    type: TRIGGER
                    results:
                      - stepIndex: 1
                        stepVersion: 3
                        resultUrls:
                          output.txt:
                            url: https://run-files.app.pinkfish.ai/...
                            mimeType: text/plain
                            size: 13
                          stdout.txt:
                            url: https://run-files.app.pinkfish.ai/...
                            mimeType: text/plain
                            size: 419
                        exitCode: 0
                        duration: 2593
                    started: '2026-05-14T19:16:28Z'
                    status: COMPLETE
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
      required:
        - error
        - message
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````