Delete a workflow
Deletes one workflow together with its trigger, its steps and its run history.
- Method
- DELETE
- Path
https://api.returning.ai / v1/ workflow-builder/ data-workflows/ {workflowId} - Permission
- workflowBuilder
- Retries
- A retry after an ambiguous failure is safe in the sense that a second delete of a missing workflow answers
404rather than deleting something else.
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 and a stale value is refused with 409 VERSION_CONFLICT instead of deleting a workflow someone else has changed since; omit it and the delete applies as the last write. Deleting a deployed workflow needs no extra header: the delete applies immediately.
Deleting is a client-visible, irreversible change. Take an export first if the workflow should be recoverable.
| Failure | Meaning | Recovery |
|---|---|---|
409 VERSION_CONFLICT | Someone changed or already deleted it since your read | Re-read; if it is gone, the delete is effectively done. |
Behaviour#
It is irreversible: there is no restore route and no recycle bin.
A deployed workflow can be deleted like any other, in one call, with its trigger, steps and run history. Because that takes a live workflow out of service and leaves nothing to read back, POST /{workflowId}/undeploy first when the intent is to stop it rather than remove it.
Request#
Path parameters#
_id.Rule^[0-9a-fA-F]{24}$
Eg65f1a2b3c4d5e6f708192a3b
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
- Deleting a step, a branch or a whole workflow cannot be undone. Export first.
- A delete does not need an undeploy first, and it does not need a confirmation header. A deployed workflow is removed in one call, so the export and the second read in this page are the only protection there is.
- Run history goes with the workflow. Export anything you need to keep from
GET /{workflowId}/runsbefore deleting. - Deleting does not revoke a webhook key that was stored elsewhere. The key becomes useless once the trigger is gone, but stop senders as well.
- A delete is logged as one audit line with the workflow id, the operation and the revision before it. The body is never logged.
More examples and details
Export first when the definition matters:
curl --request GET \
--url "https://api.returning.ai/v1/workflow-builder/data-workflows/65f1a2b3c4d5e6f708192a3b/export" \
--header "Authorization: Bearer <API_KEY>" \
--output vip-bonus.workflow.json
Then delete:
curl --request DELETE \
--url "https://api.returning.ai/v1/workflow-builder/data-workflows/65f1a2b3c4d5e6f708192a3b" \
--header "Authorization: Bearer <API_KEY>" \
--header "If-Match: 162af81f5de4ff2b557a4087de9a9a73a0ed4e621f737787e35a93614cb50d1c"
{
"data": {
"id": "65f1a2b3c4d5e6f708192a3b",
"deleted": true
}
}
curl --request DELETE \
--url 'https://api.returning.ai/v1/workflow-builder/data-workflows/<workflowId>' \
--header 'Authorization: Bearer <API_KEY>'
Response#
HTTP 200 with data.deleted: true. There is nothing left to read back on the workflow itself, so prove the delete with the list: GET / must no longer contain that _id, and GET /{workflowId} must answer 404 WORKFLOW_NOT_FOUND. Runs of the workflow are removed with it, so GET /{workflowId}/runs also answers 404.
The response carries no revision: a deleted workflow has none.
{
"data": {
"id": "65f1a2b3c4d5e6f708192a3b",
"deleted": true
}
}
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
WORKFLOW_NOT_FOUNDFix the dataVERSION_CONFLICTFix the dataIf-Match that is not the current revision. Re-read; retry only if the workflow still exists.WORKFLOW_LOCKEDFix the dataRetry with backoff03
RATE_LIMITEDRetry with backoffINTERNAL_ERRORRetry with backoffLOCK_UNAVAILABLERetry with backoffRetries
A retry after an ambiguous failure is safe in the sense that a second delete of a missing workflow answers 404 rather than deleting something else. Do not switch to a new id to "make the delete work": confirm with GET / which id still exists. The cascade is not transactional. A failure part way through can leave the workflow row removed while a run record briefly remains; the records are scoped to the deleted id and are not reachable through any 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."
}