# Delete an action > Delete an Action's draft and its routing through a review, after pausing it `delete_action` deletes an Action from the agent's **Actions** page, together with the routing that lets the agent pick 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_action ``` > [!WARNING] > > A live Action can't be deleted. Pause it first with `toggle_action` (see [Update an action](/docs/api-reference/v2/actions/update-an-action)); otherwise the tool returns `400 INVALID_ARGUMENTS` with `Pause every active deployment of this resource before deleting its draft`. Update any procedure step that runs the Action, or it has nothing to run. ## 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 Action's `id`, from [List actions](/docs/api-reference/v2/actions/list-actions). | | `expectedRevision` | `integer` | Yes | The Action's current `revision`. | ## Request example > [tab] cURL > > ```bash > curl -X POST 'https://api.qwryai.com/public/v1/tools/delete_action' \ > -H 'Authorization: Bearer YOUR_API_KEY' \ > -H 'Content-Type: application/json' \ > -d '{"chatbotId": "YOUR_AGENT_ID", "draftId": "ACTION_ID", "expectedRevision": 1}' > ``` > [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_action", > { > method: "POST", > headers, > body: JSON.stringify({ chatbotId: "YOUR_AGENT_ID", draftId: "ACTION_ID", expectedRevision: 1 }), > } > ).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_action", > headers={"Authorization": "Bearer YOUR_API_KEY"}, > json={"chatbotId": "YOUR_AGENT_ID", "draftId": "ACTION_ID", "expectedRevision": 1}, > ).json()["data"] > ``` ## Response ### The review ```json { "success": true, "data": { "status": "review_required", "reviewId": "8a4c2e60-7b1d-4f39-9e05-3c6d1b2a7f48", "tool": "delete_action", "changes": [ { "title": "Delete Action draft: Create ticket", "before": { "name": "Create ticket" }, "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": "8a4c2e60-7b1d-4f39-9e05-3c6d1b2a7f48", "tool": "delete_action", "data": { "applied": true, "effect": "deleted_draft", "draftId": "action-draft:8c1e5b20-4a7d-4f3e-9b2c-6d0a1e7f3c58", "deletedSkillDraftIds": ["skill-draft:create_ticket:2b7d9e41-0c3a-4e65-8f19-a4d2c6b8e017"], "retained": "Immutable compiled versions, releases and execution history", "receiptId": "" }, "receipt": { "applied": true } } } ``` `deletedSkillDraftIds` lists the routing drafts removed with the Action. 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 Action has that id, `expectedRevision` isn't current, or the Action 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 Action 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).