> ## 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.

# Create a trigger

> Create a trigger with an activation type of `event`, `schedule`, or `custom`. Each type requires its own fields (e.g. `eventType` and optional `conditions` for events, `scheduleRule` and `timezone` for schedules, `customPayloadSchema` for custom triggers); mismatched fields are rejected.



## OpenAPI

````yaml /api-reference/workflows.yaml post /triggers
openapi: 3.1.0
info:
  title: Workflows
  version: v1
servers:
  - url: https://api.mobilerun.ai
    description: Droidrun Cloud API
security:
  - bearerAuth: []
paths:
  /triggers:
    post:
      tags:
        - Triggers
      summary: Create a trigger
      description: >-
        Create a trigger with an activation type of `event`, `schedule`, or
        `custom`. Each type requires its own fields (e.g. `eventType` and
        optional `conditions` for events, `scheduleRule` and `timezone` for
        schedules, `customPayloadSchema` for custom triggers); mismatched fields
        are rejected.
      operationId: createTrigger
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTriggerBody'
      responses:
        '201':
          description: Trigger created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Trigger'
                required:
                  - data
      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 trigger = await client.workflows.triggers.create({ activation:
            'event', name: 'x' });


            console.log(trigger.data);
        - 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
            )
            trigger = client.workflows.triggers.create(
                activation="event",
                name="x",
            )
            print(trigger.data)
        - 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\ttrigger, err := client.Workflows.Triggers.New(context.TODO(), mobileruncloud.WorkflowTriggerNewParams{\n\t\tActivation: mobileruncloud.WorkflowTriggerNewParamsActivationEvent,\n\t\tName:       \"x\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", trigger.Data)\n}\n"
        - lang: CLI
          source: |-
            mobilerun-cloud workflows:triggers create \
              --api-key 'My API Key' \
              --activation event \
              --name x
components:
  schemas:
    CreateTriggerBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 256
        description:
          type: string
          maxLength: 2048
        activation:
          type: string
          enum:
            - event
            - schedule
            - custom
        eventType:
          type: string
          maxLength: 256
        conditions:
          type: object
          properties:
            all:
              type: array
              items:
                type: object
            any:
              type: array
              items:
                type: object
        scheduleRule:
          type: object
          properties:
            type:
              type: string
              enum:
                - once
                - cron
                - recurring
            dateTime:
              type: string
              description: ISO 8601 datetime (for type=once)
            expression:
              type: string
              description: Cron expression (for type=cron)
            rrule:
              type: string
              description: RRULE string (for type=recurring)
          required:
            - type
        timezone:
          type: string
        customPayloadSchema:
          $ref: '#/components/schemas/CustomPayloadSchema'
      required:
        - name
        - activation
    Trigger:
      type: object
      properties:
        id:
          type: string
          format: uuid
        userId:
          type: string
          format: uuid
          description: 'Deprecated: use ownerId (tenancy) / createdBy (actor).'
          deprecated: true
        ownerId:
          type: string
          format: uuid
        createdBy:
          type:
            - string
            - 'null'
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - 'null'
        activation:
          type: string
          enum:
            - event
            - schedule
            - custom
        scheduleRule:
          $ref: '#/components/schemas/ScheduleRule'
        timezone:
          type:
            - string
            - 'null'
        nextFireTime:
          type:
            - string
            - 'null'
        eventType:
          type:
            - string
            - 'null'
        conditions: {}
        customPayloadSchema:
          type:
            - object
            - 'null'
          additionalProperties: {}
        createdAt:
          type:
            - string
            - 'null'
        updatedAt:
          type:
            - string
            - 'null'
      required:
        - id
        - userId
        - ownerId
        - createdBy
        - name
        - description
        - activation
        - scheduleRule
        - timezone
        - eventType
        - customPayloadSchema
        - createdAt
        - updatedAt
    CustomPayloadSchema:
      type: object
      description: Optional JSON Schema for validating payloads sent to this custom trigger
      additionalProperties: true
    ScheduleRule:
      type: object
      properties:
        type:
          type: string
          enum:
            - once
            - cron
            - recurring
        dateTime:
          type: string
          description: ISO 8601 datetime (for type=once)
        expression:
          type: string
          description: Cron expression (for type=cron)
        rrule:
          type: string
          description: RRULE string (for type=recurring)
      required:
        - type
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Opaque
      description: Bearer token via Authorization header

````