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

> Create a flow that binds a trigger (`triggerId`) to an ordered list of actions, with at least one action required. Optional settings include target `deviceIds`, a cooldown (`cooldownSeconds`/`cooldownScope`), and webhook notifications on success or failure.



## OpenAPI

````yaml /api-reference/workflows.yaml post /flows
openapi: 3.1.0
info:
  title: Workflows
  version: v1
servers:
  - description: Droidrun Cloud API
    url: https://api.mobilerun.ai/v1
security:
  - bearerAuth: []
paths:
  /flows:
    post:
      tags:
        - Flows
      summary: Create a flow
      description: >-
        Create a flow that binds a trigger (`triggerId`) to an ordered list of
        actions, with at least one action required. Optional settings include
        target `deviceIds`, a cooldown (`cooldownSeconds`/`cooldownScope`), and
        webhook notifications on success or failure.
      operationId: createFlow
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFlowBody'
      responses:
        '201':
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/Flow'
                required:
                  - data
                type: object
          description: Flow created
        '402':
          content:
            application/json:
              schema:
                properties:
                  error:
                    enum:
                      - agent_slots_not_entitled
                    type: string
                  message:
                    type: string
                required:
                  - error
                  - message
                type: object
          description: The owner has no workflow agent slots
        '409':
          content:
            application/json:
              schema:
                properties:
                  error:
                    enum:
                      - agent_slot_limit_reached
                    type: string
                  limit:
                    minimum: 0
                    type: integer
                  message:
                    type: string
                  used:
                    minimum: 0
                    type: integer
                required:
                  - error
                  - message
                  - limit
                  - used
                type: object
          description: The owner has reached the workflow agent limit
        '503':
          content:
            application/json:
              schema:
                properties:
                  error:
                    enum:
                      - billing_temporarily_unavailable
                    type: string
                  message:
                    type: string
                required:
                  - error
                  - message
                type: object
          description: Workflow agent capacity could not be verified
      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 flow = await client.workflows.flows.create({
              actions: [{ actionId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', position: 0 }],
              name: 'x',
              triggerId: '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
            });

            console.log(flow.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
            )
            flow = client.workflows.flows.create(
                actions=[{
                    "action_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
                    "position": 0,
                }],
                name="x",
                trigger_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )
            print(flow.data)
components:
  schemas:
    CreateFlowBody:
      additionalProperties: false
      properties:
        actions:
          items:
            $ref: '#/components/schemas/FlowActionInput'
          minItems: 1
          type: array
        cooldownScope:
          $ref: '#/components/schemas/CooldownScope'
        cooldownSeconds:
          minimum: 0
          type:
            - integer
            - 'null'
        description:
          maxLength: 2048
          type: string
        deviceIds:
          default: []
          items:
            format: uuid
            type: string
          maxItems: 256
          type: array
        enabled:
          default: true
          type: boolean
        healthMonitoringEnabled:
          default: true
          type: boolean
        name:
          maxLength: 256
          minLength: 1
          type: string
        notifyOnFailure:
          default: false
          type: boolean
        notifyOnSuccess:
          default: false
          type: boolean
        notifyWebhookId:
          format: uuid
          type:
            - string
            - 'null'
        recordingEnabled:
          default: false
          deprecated: true
          description: >-
            Deprecated compatibility field. true maps to
            recordingPolicy.mode="flow"; false maps to "off".
          type: boolean
        recordingPolicy:
          additionalProperties: false
          properties:
            mode:
              $ref: '#/components/schemas/RecordingPolicyMode'
          required:
            - mode
          type: object
        selfHealingEnabled:
          default: true
          type: boolean
        selfHealingMaxAttempts:
          default: 2
          maximum: 5
          minimum: 1
          type: integer
        triggerId:
          format: uuid
          type: string
      required:
        - name
        - triggerId
        - actions
      type: object
    Flow:
      properties:
        archivedAt:
          type:
            - string
            - 'null'
        blockedAt:
          type:
            - string
            - 'null'
        consecutiveFailures:
          minimum: 0
          type: integer
        cooldownScope:
          enum:
            - flow
            - device
          type: string
        cooldownSeconds:
          type:
            - integer
            - 'null'
        createdAt:
          type:
            - string
            - 'null'
        createdBy:
          format: uuid
          type:
            - string
            - 'null'
        description:
          type:
            - string
            - 'null'
        deviceIds:
          items:
            format: uuid
            type: string
          type: array
        enabled:
          description: >-
            Compatibility projection of lifecycleStatus; true only when
            lifecycleStatus is enabled.
          type: boolean
        healthMonitoringEnabled:
          type: boolean
        id:
          format: uuid
          type: string
        lastFailureAt:
          type:
            - string
            - 'null'
        lastFailureCode:
          $ref: '#/components/schemas/FlowFailureCode'
        lastTriggeredAt:
          type:
            - string
            - 'null'
        lifecycleStatus:
          $ref: '#/components/schemas/AgentLifecycleStatus'
        name:
          type: string
        notifyOnFailure:
          type: boolean
        notifyOnSuccess:
          type: boolean
        notifyWebhookId:
          format: uuid
          type:
            - string
            - 'null'
        ownerId:
          format: uuid
          type: string
        recordingEnabled:
          deprecated: true
          description: >-
            Deprecated: use recordingPolicy.mode ("flow" =
            recordingEnabled=true, "off" = recordingEnabled=false).
          type: boolean
        recordingPolicy:
          $ref: '#/components/schemas/RecordingPolicy'
        selfHealingEnabled:
          type: boolean
        selfHealingMaxAttempts:
          maximum: 5
          minimum: 1
          type: integer
        status:
          $ref: '#/components/schemas/FlowStatus'
        templateResolutionVersion:
          description: >-
            Template-resolver semantics this flow runs under (MVA-23). 1 =
            legacy (missing/forbidden/null all resolve to ''). 2 = typed
            (missing/forbidden throw, a whole-token null stays JSON null).
            Existing flows stay 1; new flows default to 2.
          maximum: 2
          minimum: 1
          type: integer
        triggerId:
          format: uuid
          type: string
        updatedAt:
          type:
            - string
            - 'null'
        userId:
          deprecated: true
          description: 'Deprecated: use ownerId (tenancy) / createdBy (actor).'
          format: uuid
          type: string
      required:
        - id
        - userId
        - ownerId
        - createdBy
        - name
        - description
        - triggerId
        - enabled
        - lifecycleStatus
        - archivedAt
        - deviceIds
        - cooldownSeconds
        - cooldownScope
        - notifyWebhookId
        - notifyOnSuccess
        - notifyOnFailure
        - lastTriggeredAt
        - status
        - templateResolutionVersion
        - consecutiveFailures
        - lastFailureCode
        - lastFailureAt
        - blockedAt
        - healthMonitoringEnabled
        - selfHealingEnabled
        - selfHealingMaxAttempts
        - recordingEnabled
        - recordingPolicy
        - createdAt
        - updatedAt
      type: object
    FlowActionInput:
      additionalProperties: false
      properties:
        actionId:
          format: uuid
          type: string
        children:
          items:
            $ref: '#/components/schemas/FlowChildActionInput'
          type: array
        continueOnError:
          default: false
          type: boolean
        nameOverride:
          maxLength: 256
          minLength: 1
          type: string
        overrides:
          $ref: '#/components/schemas/FlowActionOverrides'
        position:
          minimum: 0
          type: integer
        recordingEnabled:
          default: false
          type: boolean
      required:
        - actionId
        - position
      type: object
    CooldownScope:
      default: flow
      enum:
        - flow
        - device
      type: string
    RecordingPolicyMode:
      enum:
        - 'off'
        - flow
        - selected_steps
      type: string
    FlowFailureCode:
      enum:
        - device_not_found
        - permission_denied
        - client_error
        - transient
        - logic
        - invalid_config
      type:
        - string
        - 'null'
    AgentLifecycleStatus:
      enum:
        - enabled
        - disabled
        - archived
      type: string
    RecordingPolicy:
      properties:
        mode:
          $ref: '#/components/schemas/RecordingPolicyMode'
      required:
        - mode
      type: object
    FlowStatus:
      enum:
        - healthy
        - failing
        - blocked
      type: string
    FlowChildActionInput:
      additionalProperties: false
      properties:
        actionId:
          format: uuid
          type: string
        continueOnError:
          default: false
          type: boolean
        nameOverride:
          maxLength: 256
          minLength: 1
          type: string
        overrides:
          $ref: '#/components/schemas/FlowActionOverrides'
        position:
          minimum: 0
          type: integer
        recordingEnabled:
          default: false
          type: boolean
      required:
        - actionId
        - position
      type: object
    FlowActionOverrides:
      additionalProperties: false
      properties:
        params:
          additionalProperties: {}
          type: object
      type:
        - object
        - 'null'
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.