411f9f98c01e
Copy a Flow based on the specified Flow Id
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:
- The topic (data.attributes.topic_id) must be accessible to the flow in the destination workspace, otherwise it will not be copied.
- It's forbidden to use the data.attributes.topic_id parameter if flow does not contain at least one step with Pub/Sub component.
- 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.
- 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 identifier
Request body
Example request
{
"data": {
"attributes": {
"dest_flow_id": "5b4f337bff4304610483ba67",
"name": "My new Flow",
"topic_id": "5b4f337bff4304610483ba67"
}
}
}Response
Created
Example response
{
"data": {
"id": "5b4f337bff4304610483ba67",
"links": {
"self": "/v2/flows/5b4f337bff4304610483ba67"
},
"attributes": {
"created_at": "2020-01-12T14:50:42.215Z",
"last_modified": "2021-12-13T14:24:53.825Z",
"name": "PetStore to Email Flow",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"cron": "*/3 * * * *",
"shut_down_timeout": 5,
"graph": {
"nodes": [
{
"name": "petStore",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"command": "core/petStore:getPetsByStatus@51ff8236dd1d461f67111b145f69441bafdeb710",
"id": "step_1",
"credentials_id": "609e6f5164b6470011d26387",
"selected_data_samples": [
"5b4f337bff4304610483ba67"
]
}
],
"edges": [
{
"id": "mapper:step_1:step_2",
"target": "step_2",
"source": "step_1",
"config": {
"mapper_type": "jsonata"
}
}
]
},
"api_version": "2.0",
"stats_enabled": true,
"updated_at": "2021-12-13T14:24:53.825Z"
},
"relationships": {
"user": {
"data": {
"id": "5b4f337bff4304610483ba67"
},
"links": {
"self": "/v2/users/5b4f337bff4304610483ba67"
}
},
"workspace": {
"data": {
"id": "5b4f337bff4304610483ba67"
},
"links": {
"self": "/v2/workspaces/5b4f337bff4304610483ba67"
}
},
"versions": {
"links": {
"related": "/v2/flows/5b4f337bff4304610483ba67/versions"
}
},
"latest_version": {
"data": {
"id": "e4b690fb0a65c37789e7be0bf523414e0f98a8e6"
},
"links": {
"self": "/v2/flows/5b4f337bff4304610483ba67/versions/e4b690fb0a65c37789e7be0bf523414e0f98a8e6",
"related": "/v2/flows/5b4f337bff4304610483ba67/versions/e4b690fb0a65c37789e7be0bf523414e0f98a8e6"
}
}
}
},
"included": [
{
"id": "5b4f337bff4304610483ba67",
"links": {
"self": "/v2/flows/5b4f337bff4304610483ba67/flow-containers/5b4f337bff4304610483ba67_mapper:step_1:step_2"
},
"attributes": {
"step_id": "mapper:step_1:step_2"
},
"relationships": {
"flow": {
"data": {
"id": "5b4f337bff4304610483ba67"
},
"links": {
"self": "/v2/flows/5b4f337bff4304610483ba67"
}
}
}
}
]
}