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

# Clone a flow

> Create a copy of an existing flow, including its actions and settings. The optional body can override the new flow's `name` and target `deviceIds`. Returns 404 if the source flow does not exist.



## OpenAPI

````yaml /api-reference/workflows.yaml post /flows/{flowId}/clone
openapi: 3.1.0
info:
  title: Workflows
  version: v1
servers:
  - url: https://api.mobilerun.ai
    description: Droidrun Cloud API
security:
  - bearerAuth: []
paths:
  /flows/{flowId}/clone:
    post:
      tags:
        - Flows
      summary: Clone a flow
      description: >-
        Create a copy of an existing flow, including its actions and settings.
        The optional body can override the new flow's `name` and target
        `deviceIds`. Returns 404 if the source flow does not exist.
      operationId: cloneFlow
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: flowId
          in: path
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CloneFlowBody'
      responses:
        '201':
          description: Flow cloned
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Flow'
                required:
                  - data
        '404':
          description: Not Found
          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.flows.clone('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');


            console.log(response.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
            )
            response = client.workflows.flows.clone(
                flow_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
            )
            print(response.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\tresponse, err := client.Workflows.Flows.Clone(\n\t\tcontext.TODO(),\n\t\t\"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e\",\n\t\tmobileruncloud.WorkflowFlowCloneParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: CLI
          source: |-
            mobilerun-cloud workflows:flows clone \
              --api-key 'My API Key' \
              --flow-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e
components:
  schemas:
    CloneFlowBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 256
        deviceIds:
          type: array
          items:
            type: string
            format: uuid
          maxItems: 256
      additionalProperties: false
    Flow:
      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'
        triggerId:
          type: string
          format: uuid
        enabled:
          type: boolean
        deviceIds:
          type: array
          items:
            type: string
            format: uuid
        cooldownSeconds:
          type:
            - integer
            - 'null'
        cooldownScope:
          type: string
          enum:
            - flow
            - device
        notifyWebhookId:
          type:
            - string
            - 'null'
          format: uuid
        notifyOnSuccess:
          type: boolean
        notifyOnFailure:
          type: boolean
        lastTriggeredAt:
          type:
            - string
            - 'null'
        status:
          $ref: '#/components/schemas/FlowStatus'
        consecutiveFailures:
          type: integer
          minimum: 0
        lastFailureCode:
          $ref: '#/components/schemas/FlowFailureCode'
        lastFailureAt:
          type:
            - string
            - 'null'
        blockedAt:
          type:
            - string
            - 'null'
        createdAt:
          type:
            - string
            - 'null'
        updatedAt:
          type:
            - string
            - 'null'
      required:
        - id
        - userId
        - ownerId
        - createdBy
        - name
        - description
        - triggerId
        - enabled
        - deviceIds
        - cooldownSeconds
        - cooldownScope
        - notifyWebhookId
        - notifyOnSuccess
        - notifyOnFailure
        - lastTriggeredAt
        - status
        - consecutiveFailures
        - lastFailureCode
        - lastFailureAt
        - blockedAt
        - createdAt
        - updatedAt
    FlowStatus:
      type: string
      enum:
        - healthy
        - failing
        - blocked
    FlowFailureCode:
      type:
        - string
        - 'null'
      enum:
        - device_not_found
        - permission_denied
        - client_error
        - transient
        - logic
        - invalid_config
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Opaque
      description: Bearer token via Authorization header

````