Duplicate a step
Copies one step, including its options, and stores the copy directly after the original on the main line.
- Method
- POST
- Path
https://api.returning.ai / v1/ workflow-builder/ data-workflows/ {workflowId}/ nodes/ {nodeId}/ duplicate - Permission
- workflowBuilder
- Retries
- Not idempotent: two accepted calls create two copies.
Authentication#
- Header
Authorization: Bearer <API_KEY>- Permission
- workflowBuilder
Authorization: Bearer <API_KEY> with workflowBuilder, on a workflow of the key's community. If-Match is optional. Send the revision you read to avoid overwriting a concurrent change (a stale value is refused with 409 VERSION_CONFLICT); omit it and your write wins as the last one. A deployed workflow is edited with the same call: the change applies immediately.
| Failure | Meaning | Recovery |
|---|---|---|
404 NODE_NOT_FOUND | The step is not part of this workflow | Read the workflow for its step ids. |
Behaviour#
A router is copied with its branches and the steps inside them. Every reference between the copies is rewired, including a {{<stepId>.path}} template.
The copy is a new step with a new id, so the original is untouched and both can be edited independently.
Request#
Path parameters#
Headers#
Bearer <API_KEY>.EgBearer <API_KEY>
revision the change is based on, bare or quoted, to avoid overwriting a concurrent change: a stale value is refused with 409 VERSION_CONFLICT. Omit it for last-write-wins.Eg162af81f5de4ff2b557a4087de9a9a73a0ed4e621f737787e35a93614cb50d1c
Watch for
- The copy is inserted after the original on the main line, never inside a branch. To place a copy inside a branch, delete it and create it again with a branch position.
- Credentials are copied as stored and are already redacted in the response. Nothing is re-supplied and nothing is revealed.
- A Code step is copied like any other step, with its source, including when it sits inside a copied router.
- Duplicating a router duplicates its branch structure, so the copy's branches and their members are independent of the original's.
More examples and details
curl --request POST \
--url "https://api.returning.ai/v1/workflow-builder/data-workflows/65f1a2b3c4d5e6f708192a3b/nodes/65f1a2b3c4d5e6f708192a3c/duplicate" \
--header "Authorization: Bearer <API_KEY>" \
--header "If-Match: 162af81f5de4ff2b557a4087de9a9a73a0ed4e621f737787e35a93614cb50d1c"
{
"data": {
"node": {
"_id": "65f1a2b3c4d5e6f708192a44",
"name": "Read member XP (Copy)",
"type": "platform-action",
"order": 2,
"continueOnFailure": false,
"retryOnFailure": false,
"options": {
"action": "get-user-fields",
"selectUser": { "type": "email", "value": ["{{65f1a2b3c4d5e6f708192a41.email}}"] },
"fields": [{ "label": "Total XP", "field": "total_xp" }]
}
},
"revision": "68f78253046393414dec404e5442c140bb5db0393a7d1c389ff57bba71585501",
"redactedPaths": []
}
}
curl --request POST \
--url 'https://api.returning.ai/v1/workflow-builder/data-workflows/<workflowId>/nodes/<nodeId>/duplicate' \
--header 'Authorization: Bearer <API_KEY>'
Response#
HTTP 201 with the copy in { node, revision, redactedPaths }, and the revision in the ETag header. The copy carries a (Copy) suffix on its name and a new _id.
Read back with GET /{workflowId}: the copy must sit after the original, and any router copy must own copies of the branch steps, not the originals.
Eg{ ... }
Eg{ ... }
Eg"65f1a2b3c4d5e6f708192a44"
Eg"Read member XP (Copy)"
Eg"platform-action"
Eg2
Egfalse
Egfalse
["__REDACTED__"].RuleNullable
Eg{ ... }
Eg"success"
workflowNodeIds and nestedNodes.Eg"68f78253046393414dec404e5442c140bb5db0393a7d1c389ff57bba71585501"
Eg[]
{
"data": {
"node": {
"_id": "65f1a2b3c4d5e6f708192a44",
"name": "Read member XP (Copy)",
"type": "platform-action",
"order": 2,
"continueOnFailure": false,
"retryOnFailure": false,
"options": {
"action": "get-user-fields",
"selectUser": {
"type": "email",
"value": ["{{65f1a2b3c4d5e6f708192a41.email}}"]
},
"fields": [
{
"label": "Total XP",
"field": "total_xp"
}
]
}
},
"revision": "68f78253046393414dec404e5442c140bb5db0393a7d1c389ff57bba71585501",
"redactedPaths": []
}
}
Errors#
Fix the request04
VALIDATION_FAILEDFix the requestAUTHENTICATION_REQUIREDFix the requestAPI_KEY_REQUIREDFix the requestAPI_KEY_PERMISSION_DENIEDFix the requestworkflowBuilder. Grant the permission.Fix the data03
NODE_NOT_FOUNDFix the dataVERSION_CONFLICTFix the dataIf-Match that is not the current revision. meta.currentRevision carries the live value. Re-read and resend.WORKFLOW_LOCKEDFix the dataRetry with backoff03
RATE_LIMITEDRetry with backoffINTERNAL_ERRORRetry with backoffLOCK_UNAVAILABLERetry with backoffRetries
Not idempotent: two accepted calls create two copies. A retry after a timeout can leave a duplicate, so read the workflow before resending.
{
"meta": {
"status": "error",
"statusCode": 400,
"code": "VALIDATION_FAILED",
"errors": [
{
"path": "params.workflowId",
"message": "Id must be a 24 character hex string"
}
],
"requestId": "3f4d0e8b-7a6c-4f1e-9b2d-5a7c8e1f0a3b"
},
"message": "API request rejected error.",
"detail": "The request body is not valid.",
"solution": "Read error detail and try again."
}