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

# Fire a custom trigger with payload

> Invoke a custom trigger directly with an arbitrary JSON payload.

Fan-out: a trigger may be referenced by multiple flows (workflows). Firing it enqueues one execution per enabled, non-deleted flow attached to this trigger, each receiving the same payload. The `enqueuedCount` in the response reports how many were enqueued (0 if no flows are attached, or if all matching flows are gated by a cooldown).

Payload validation:
- If the trigger has a `customPayloadSchema`, the payload is validated against it (JSON Schema via AJV).
- If no schema is configured, the payload only needs to be a JSON object — any keys and values are accepted.

Only triggers with `activation = "custom"` can be fired through this endpoint; event and schedule triggers return 409.



## OpenAPI

````yaml /api-reference/workflows.yaml post /triggers/{triggerId}/fire
openapi: 3.1.0
info:
  title: Workflows
  version: v1
servers:
  - url: https://api.mobilerun.ai
    description: Droidrun Cloud API
security:
  - bearerAuth: []
paths:
  /triggers/{triggerId}/fire:
    post:
      tags:
        - Triggers
      summary: Fire a custom trigger with payload
      description: >-
        Invoke a custom trigger directly with an arbitrary JSON payload.


        Fan-out: a trigger may be referenced by multiple flows (workflows).
        Firing it enqueues one execution per enabled, non-deleted flow attached
        to this trigger, each receiving the same payload. The `enqueuedCount` in
        the response reports how many were enqueued (0 if no flows are attached,
        or if all matching flows are gated by a cooldown).


        Payload validation:

        - If the trigger has a `customPayloadSchema`, the payload is validated
        against it (JSON Schema via AJV).

        - If no schema is configured, the payload only needs to be a JSON object
        — any keys and values are accepted.


        Only triggers with `activation = "custom"` can be fired through this
        endpoint; event and schedule triggers return 409.
      operationId: fireCustomTrigger
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: triggerId
          in: path
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FireCustomTriggerBody'
      responses:
        '202':
          description: >-
            Custom trigger fired; one execution enqueued per enabled flow
            attached to this trigger
          content:
            application/json:
              schema:
                type: object
                properties:
                  invocationId:
                    type: string
                    format: uuid
                    description: >-
                      Unique ID for this fire invocation. Job IDs in the
                      execution queue are derived from it (one per enqueued
                      flow).
                  enqueuedCount:
                    type: integer
                    minimum: 0
                    description: >-
                      Number of flow executions enqueued. May be 0 if no flows
                      are attached to this trigger, or if all attached flows are
                      currently in cooldown.
                required:
                  - invocationId
                  - enqueuedCount
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
        '409':
          description: Trigger exists but is not of type "custom"
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  details:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                        message:
                          type: string
                      required:
                        - field
                        - message
                required:
                  - error
                  - details
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Mobilerun from '@mobilerun/sdk';


            const client = new Mobilerun({
              apiKey: process.env['MOBILERUN_CLOUD_API_KEY'], // This is the default and can be omitted
            });


            const response = await
            client.workflows.triggers.fire('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
            {
              payload: { foo: 'bar' },
            });


            console.log(response.enqueuedCount);
        - lang: Python
          source: |-
            import os
            from mobilerun_sdk import Mobilerun

            client = Mobilerun(
                api_key=os.environ.get("MOBILERUN_CLOUD_API_KEY"),  # This is the default and can be omitted
            )
            response = client.workflows.triggers.fire(
                trigger_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                payload={
                    "foo": "bar"
                },
            )
            print(response.enqueued_count)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/stainless-sdks/droidrun-cloud-go\"\n\t\"github.com/stainless-sdks/droidrun-cloud-go/option\"\n)\n\nfunc main() {\n\tclient := mobileruncloud.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Workflows.Triggers.Fire(\n\t\tcontext.TODO(),\n\t\t\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n\t\tmobileruncloud.WorkflowTriggerFireParams{\n\t\t\tPayload: map[string]any{\n\t\t\t\t\"foo\": \"bar\",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.EnqueuedCount)\n}\n"
        - lang: CLI
          source: |-
            mobilerun-cloud workflows:triggers fire \
              --api-key 'My API Key' \
              --trigger-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e \
              --payload '{foo: bar}'
components:
  schemas:
    FireCustomTriggerBody:
      type: object
      properties:
        payload:
          type: object
          description: >-
            Arbitrary JSON object forwarded to every flow attached to this
            trigger. Validated against the trigger's customPayloadSchema when
            one is configured; otherwise only "must be a JSON object" is
            enforced.
          additionalProperties: true
      required:
        - payload
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Opaque
      description: Bearer token via Authorization header

````