Delete a router branch
Removes one branch from a router step and deletes the steps that belonged to it.
- Method
- DELETE
- Path
https://api.returning.ai / v1/ workflow-builder/ data-workflows/ {workflowId}/ nodes/ {nodeId}/ branches/ {branchIndex} - Permission
- workflowBuilder
- Retries
- A second delete of the same index deletes a different branch if the list shifted, because the index is positional.
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.
Branch indexes shift after a delete, so read the router before deleting to be sure which branch you are removing.
| Failure | Meaning | Recovery |
|---|---|---|
400 VALIDATION_FAILED | The delete would leave the router with no branches | Add the replacement branch first. |
404 BRANCH_NOT_FOUND | No branch at that index | Read the router and use an existing index. |
Behaviour#
The remaining branches keep their relative order, and the router's branch list is rewritten without the branch you removed.
A router must keep at least one branch, so deleting the last one is refused.
Request#
Path parameters#
_id.Rule^[0-9a-fA-F]{24}$
Eg65f1a2b3c4d5e6f708192a3b
_id.Rule^[0-9a-fA-F]{24}$
Eg65f1a2b3c4d5e6f708192a3c
RuleMin 0
Eg0
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 step ids of the deleted branch are gone. Any reference to them becomes unresolved, and
POST /{workflowId}/validatereports it as a warning. Deploy still proceeds, so fix the references before the next run. - Branch indexes shift after the delete. Never reuse an index from before the call.
- Deleting a branch is irreversible. Export the workflow first if the branch is worth recovering.
- A fallback branch is just another branch here: deleting it leaves only condition branches, which is valid.
More examples and details
curl --request DELETE \
--url "https://api.returning.ai/v1/workflow-builder/data-workflows/65f1a2b3c4d5e6f708192a3b/nodes/65f1a2b3c4d5e6f708192a3e/branches/1" \
--header "Authorization: Bearer <API_KEY>" \
--header "If-Match: 162af81f5de4ff2b557a4087de9a9a73a0ed4e621f737787e35a93614cb50d1c"
{
"data": {
"node": {
"_id": "65f1a2b3c4d5e6f708192a3e",
"name": "XP over 100?",
"type": "router",
"order": 2,
"continueOnFailure": false,
"retryOnFailure": false,
"options": {
"executePaths": "first_matching",
"branches": [
{ "branchName": "XP > 100", "branchType": "CONDITION", "workflowNodeIds": ["65f1a2b3c4d5e6f708192a3d"] }
]
}
},
"revision": "68f78253046393414dec404e5442c140bb5db0393a7d1c389ff57bba71585501",
"redactedPaths": []
}
}
curl --request DELETE \
--url 'https://api.returning.ai/v1/workflow-builder/data-workflows/<workflowId>/nodes/<nodeId>/branches/<branchIndex>' \
--header 'Authorization: Bearer <API_KEY>'
Response#
HTTP 200 with the router step and the workflow's new revision. The response is the readback: options.branches no longer contains the deleted branch, and the surviving branches are in their stored order.
The steps of the deleted branch are gone from the workflow. Read GET /{workflowId} to confirm they are absent from nodes, and run POST /{workflowId}/validate in case another step referenced one of them.
Eg{ ... }
Eg{ ... }
Eg"65f1a2b3c4d5e6f708192a3c"
Eg"XP over 100?"
Eg"router"
Eg1
Egfalse
Egfalse
["__REDACTED__"].RuleNullable
Eg{ ... }
Eg"success"
workflowNodeIds and nestedNodes.Eg"68f78253046393414dec404e5442c140bb5db0393a7d1c389ff57bba71585501"
Eg[]
{
"data": {
"node": {
"_id": "65f1a2b3c4d5e6f708192a3c",
"name": "XP over 100?",
"type": "router",
"order": 1,
"continueOnFailure": false,
"retryOnFailure": false,
"options": {
"executePaths": "first_matching",
"branches": [
{
"branchName": "Otherwise",
"branchType": "FALLBACK",
"workflowNodeIds": []
}
]
}
},
"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 data04
NODE_NOT_FOUNDFix the dataBRANCH_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
A second delete of the same index deletes a different branch if the list shifted, because the index is positional. Read the router before retrying, and send the revision you just read.
{
"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."
}