---
title: "Copy a Flow based on the specified Flow Id"
method: POST
path: "/flows/{flow_id}/copy"
tags: ["flows"]
---

# Copy a Flow based on the specified Flow Id

`POST /flows/{flow_id}/copy`

You need `workspaces.flow.edit` permission and belong to workspace containing source flow to access this resource
Flow can be copied in two modes:
* as new flow
* as a draft of existing flow

Modes are mutually exclusive (see example requests)

In both cases flow is copied into draft of new/existing flow. So to make flow to work draft should be published manually. That is done to avoid disruptions of already running flow (flow is not stopped or changed in any other way except draft), and because most likely flow copy will require additional configuration.
Flow can be copied in any workspace and contract, of course if user has enough privileges to read original flow and has enough privileges to edit flow in destination workspace.
Platform forbids to copy flow if flow components can not be used in destination context (e.g. component visibility is restricted to team, and you are copying flow in another contract)

**Notices:**
 1. The topic (`data.attributes.topic_id`) must be accessible to the flow in the destination workspace, otherwise it will not be copied.
 2. It's forbidden to use the `data.attributes.topic_id` parameter if flow does not contain at least one step with Pub/Sub component.
 3. It's forbidden to use the `data.attributes.topic_id` parameter if your flow uses more than one Pub/Sub topic in different steps. You can copy the flow if your flow has several Pub/Sub steps that uses only one topic.
 4. In case when the `data.attributes.topic_id` parameter is absent from your call, topics ID will be removed from a copy if it's not accessible and left intact if the topic is available in destination context.

Please note the following facts about credentials, secrets, topics and agents used in flow:
 - All these entities are not copied along with the flow if they are not accessible in the destination context.
 - Naturally, if the flow is copied into the same workspace, these entities will be accessible to the flow draft.
 - Topic can be replaced during copy. Read details about `data.attributes.topic_id` parameter.

## Path parameters

- `flow_id` string, required

## Request body

- union
  - object
    - `data` object, required
      - `type` 'flow-copy', required
      - `attributes` object, required
        - `dest_flow_id` string, required — Destination flow identifier
        - `name` string — Makes possible to customize name of the draft (and flow when new flow is created)
        - `topic_id` string — Required only if flow contains Pub-Sub components. Only one topic reference allowed
  - object
    - `data` object, required
      - `type` 'flow-copy', required
      - `attributes` object, required
        - `name` string — Makes possible to customize name of the draft (and flow when new flow is created)
        - `topic_id` string — Required only if flow contains Pub-Sub components. Only one topic reference allowed
      - `relationships` object, required
        - `dest_workspace` object, required
          - `data` object, required
            - `id` string, required — Destination workspace identifier
            - `type` 'workspace', required

## Response `201`

Created

- object
  - `data` object, required
    - `id` string, required
    - `type` 'flow', required
    - `links` object, required
      - `self` string, required
    - `attributes` object, required
      - `default_mapper_type` 'jsonata', required
      - `type` 'ordinary' | 'long_running', required — You need `workspaces.flow.toggleRealtime` permission to set `long_running` value
      - `nodes_config` object
        - `step_id` object — The Id of flow step. Format: step_1, step_2, step_n
          - `log_level` 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal' — Log level of component running in this step
          - `replicas` integer — This parameter configures the maximum container replicas, that can be run simultaneously
          - `passthrough` object
            - `disabled` boolean, required — This parameter toggles passthrough for a step
          - `consume_raw_data` boolean — This parameter configures the parsing behaviour in the webhook step. In case it is true, webhook step receives input message in raw structure.
          - `prefetch` integer — This parameter configures the maximum amount of messages, that the step can process simultaneously
          - `disable_dynamic_flow_control` boolean — This parameter configures disabling publisher confirms in sailor. Supports only for components with sailor-jvm version above 3.3.5 and sailor-nodejs version above 2.6.10
          - `persistent_messages` boolean — This parameter configures messages persistence in sailor. Supports only for components with JVM sailor version above 3.4.0 and NodeJS sailor above 2.7.0
      - `created_at` string, date-time, required
      - `last_modified` string, date-time, required
      - `name` string, required — Name of your Flow
      - `description` string, nullable — Flow description
      - `cron` string, nullable, required
      - `variables` object — Flow Variables
      - `shut_down_timeout` integer — *Flow Shutdown Timeout* The maximum time, in minutes, that a flow will wait after processing the last message before terminating. If new messages are received during this time, the flow will continue processing them.
      - `graph` object, required — Flow graph representing component connections
        - `nodes` union[], required
          - union
            - object
              - …
            - object
              - …
        - `edges` object[], required
          - `id` string, required
          - `target` string, required
          - `source` string, required
          - `config` object, required
            - `mapper_type` string
            - `mapper` object, required
            - `condition` string, nullable, required — condition for Content Based Router component
      - `api_version` string, required
      - `current_status` 'inactive', required
      - `status` 'inactive', required
      - `stats_enabled` boolean — *Flow Stats Toggle* By default each step of a flow generates stats about input/output messages and errors. You can see them on the Executions and Dashboard pages. To disable input/output message stats you can set flow's `attributes.stats_enabled` flag to `false`.
      - `updated_at` string, date-time
    - `relationships` object, required
      - `user` object, required
        - `data` object, required
          - `id` string, required — User ID
          - `type` 'user', required
        - `links` object, required
          - `self` string, required
      - `workspace` object, required
        - `data` object, required
          - `id` string, required — Workspace ID
          - `type` 'workspace', required
        - `links` object, required
          - `self` string, required
      - `versions` object, required
        - `links` object, required
          - `related` string, required
      - `latest_version` object, required
        - `data` object, required
          - `id` string, required — Flow-version ID
          - `type` 'flow-version', required
        - `links` object, required
          - `self` string, required
          - `related` string, required
  - `meta` object, required
  - `included` union[]
    - union
      - object
        - `id` string, required
        - `type` 'flow-container', required
        - `links` object, required
          - `self` string, required
        - `attributes` object, required
          - `step_id` string, required
        - `relationships` object, required
          - `flow` object, required
            - `data` object, required
              - …
            - `links` object, required
              - …
      - object
        - `id` string, required
        - `type` 'descriptor', required
        - `links` object, required
          - `self` string, required
        - `attributes` object, required
          - `repo_name` string, required
          - `team_name` string, required
          - `short_revision` string, required
          - `is_latest` boolean, required
          - `description` string, required
          - `icon` string, required — Component icon as base64 string
          - `language` string, required
          - `sailor_version` string, required
          - `title` string, required
          - `triggers` object
        - `relationships` object, required
          - `version` object, required
            - `data` object, required
              - …
            - `links` object, required
              - …

## Other responses

- `401` — Unauthorized
- `403` — Forbidden

---

[API](https://skmtc.net/elastic/apis/elastic-io-rest-api-documentation-v2.md) · [All operations](https://skmtc.net/elastic/apis/elastic-io-rest-api-documentation-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/elastic/elastic-io-rest-api-documentation-v2/revisions/411f9f98c01e/schema)
