# Delete a procedure > Delete a procedure and its trigger through a review, after pausing it `delete_procedure` deletes a procedure from the agent's **Procedures** page, together with the trigger that starts it. The call returns a review; nothing is deleted until you apply it. Published versions, releases and the history of past runs are kept. ```http POST https://api.qwryai.com/public/v1/tools/delete_procedure ``` > [!WARNING] > > A live procedure can't be deleted. Pause it first with `toggle_procedure` (see [Update a procedure](/docs/api-reference/v2/procedures/update-a-procedure)); otherwise the tool returns `400 INVALID_ARGUMENTS` with `Pause every active deployment of this resource before deleting its draft`. ## Authentication Send your API key as `Authorization: Bearer YOUR_API_KEY`; it needs the **Change actions and procedures** permission. See [Authentication](/docs/api-reference/v2/authentication). ## Body parameters | Name | Type | Required | Description | | - | - | - | - | | `chatbotId` | `string` | Yes | The agent's id, from `list_agents`. | | `draftId` | `string` | Yes | The procedure's `id`, from [List procedures](/docs/api-reference/v2/procedures/list-procedures). | | `expectedRevision` | `integer` | Yes | The procedure's current `revision`. | ## Request example > [tab] cURL > > ```bash > curl -X POST 'https://api.qwryai.com/public/v1/tools/delete_procedure' \ > -H 'Authorization: Bearer YOUR_API_KEY' \ > -H 'Content-Type: application/json' \ > -d '{"chatbotId": "YOUR_AGENT_ID", "draftId": "PROCEDURE_ID", "expectedRevision": 3}' > ``` > [tab] JavaScript > > ```javascript > const headers = { > Authorization: "Bearer YOUR_API_KEY", > "Content-Type": "application/json", > }; > const { data: review } = await fetch( > "https://api.qwryai.com/public/v1/tools/delete_procedure", > { > method: "POST", > headers, > body: JSON.stringify({ chatbotId: "YOUR_AGENT_ID", draftId: "PROCEDURE_ID", expectedRevision: 3 }), > } > ).then((response) => response.json()); > > // After a person approves review.changes: > await fetch(`https://api.qwryai.com/public/v1/reviews/${review.reviewId}/apply`, { > method: "POST", > headers, > }); > ``` > [tab] Python > > ```python > import requests > > review = requests.post( > "https://api.qwryai.com/public/v1/tools/delete_procedure", > headers={"Authorization": "Bearer YOUR_API_KEY"}, > json={"chatbotId": "YOUR_AGENT_ID", "draftId": "PROCEDURE_ID", "expectedRevision": 3}, > ).json()["data"] > ``` ## Response ### The review ```json { "success": true, "data": { "status": "review_required", "reviewId": "6c9a2f13-0e8b-4d47-b1a5-8f3e2d0c7b96", "tool": "delete_procedure", "changes": [ { "title": "Delete Procedure draft: Speak to a manager", "before": { "name": "Speak to a manager" }, "after": { "deleted": true, "retained": "Immutable compiled versions, releases and execution history" } } ], "unchanged": [], "expiresAt": "2026-12-01T10:15:00.000Z", "next": "Show these changes to the user. Call apply_change with this reviewId only after they approve; the review expires in 15 minutes." } } ``` ### After you apply it Apply with `POST https://api.qwryai.com/public/v1/reviews/{reviewId}/apply`: ```json { "success": true, "data": { "status": "succeeded", "reviewId": "6c9a2f13-0e8b-4d47-b1a5-8f3e2d0c7b96", "tool": "delete_procedure", "data": { "applied": true, "effect": "deleted_draft", "draftId": "playbook-draft:c0f7e3a5-21d8-4b9c-8e46-3a5b7d9f1c02", "deletedSkillDraftIds": ["skill-draft:c0f7e3a5-21d8-4b9c-8e46-3a5b7d9f1c02"], "retained": "Immutable compiled versions, releases and execution history", "receiptId": "" }, "receipt": { "applied": true } } } ``` `deletedSkillDraftIds` is the trigger removed with the procedure. The `receipt` is shortened here. ## Errors | HTTP status | code | when | | - | - | - | | 400 | `INVALID_ARGUMENTS` | An argument failed the schema, or the delete can't be prepared: no procedure has that id, `expectedRevision` isn't current, or the procedure is still live. `message` says which. | | 400 | `CHATBOT_ID_REQUIRED` | `chatbotId` is missing or isn't a valid agent id. | | 403 | `INSUFFICIENT_PERMISSION` | The key doesn't hold **Change actions and procedures**. | | 404 | `CHATBOT_NOT_FOUND` | No agent with that `chatbotId` in your workspace. | | 409 | `STALE_REVIEW` | On apply: the procedure changed after the review. Read it again and call the tool again. | | 409 | `REVIEW_ALREADY_USED` / `REVIEW_EXPIRED` | On apply: the review was used already, or more than 15 minutes passed. | | 429 | `INTEGRATION_RATE_LIMIT_EXCEEDED` | More than 2,000 requests in 15 minutes for this key. | | 500 | `TOOL_FAILED` | The tool failed on our side. Try again. | Authentication and plan errors are listed in [Error Handling](/docs/api-reference/v2/error-handling).