Endpoints
Update a procedure
Change a procedure's name, description, trigger or steps, or pause and resume it
update_procedure saves a change to an existing procedure: send only what you want to change. New steps replace all of its steps, and a new trigger replaces the whole trigger. The call returns a review; nothing changes until you apply it. To pause or resume a published procedure, use toggle_procedure.
https://api.qwryai.com/public/v1/tools/update_procedureAuthentication
Send your API key as Authorization: Bearer YOUR_API_KEY; it needs the Change actions and procedures permission. See Authentication.
Body parameters
Send at least one of name, description, trigger or steps.
| Name | Type | Required | Description |
|---|---|---|---|
chatbotId | string | Yes | The agent's id, from list_agents. |
procedure_id | string | Yes | The procedure's id, from List procedures. |
name | string | No | A new name, 1 to 100 characters. |
description | string | No | A new description, up to 500 characters. |
trigger | object | No | The whole new trigger: whenToUse, channels and every chip to keep. A chip you leave out is removed. Same shape as in Create a procedure. |
steps | array | No | All the procedure's steps after the change, in the same format as Create a procedure. Read them with Get a procedure and change only what you need. |
Read get_automation_publication with kind: "playbook" first, and copy the draft's revision and the deployment's id and transitionSequence.
| Name | Type | Required | Description |
|---|---|---|---|
chatbotId | string | Yes | The agent's id. |
draftId | string | Yes | The procedure's id. |
expectedRevision | integer | Yes | The draft's draftRevision. |
deploymentId | string | Yes | The deployment's id. |
expectedSequence | integer | Yes | The deployment's transitionSequence. |
enabled | boolean | Yes | false pauses an active procedure; true resumes a paused one. |
Request example
curl -X POST 'https://api.qwryai.com/public/v1/tools/update_procedure' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"chatbotId": "YOUR_AGENT_ID",
"procedure_id": "PROCEDURE_ID",
"name": "Replace a lost loyalty card"
}'const headers = {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
};
const call = (tool, body) =>
fetch(`https://api.qwryai.com/public/v1/tools/${tool}`, {
method: "POST",
headers,
body: JSON.stringify({ chatbotId: "YOUR_AGENT_ID", ...body }),
}).then((response) => response.json());
// Pause a live procedure
const { data: publication } = await call("get_automation_publication", {
kind: "playbook",
draftId: "PROCEDURE_ID",
});
const deployment = publication.deployments.find((item) => item.state === "active");
const { data: review } = await call("toggle_procedure", {
draftId: "PROCEDURE_ID",
expectedRevision: publication.draftRevision,
deploymentId: deployment.id,
expectedSequence: deployment.transitionSequence,
enabled: false,
});import requests
headers = {"Authorization": "Bearer YOUR_API_KEY"}
procedure = requests.post(
"https://api.qwryai.com/public/v1/tools/get_automation_detail",
headers=headers,
json={"chatbotId": "YOUR_AGENT_ID", "kind": "playbook", "draftId": "PROCEDURE_ID", "offset": 0},
).json()["data"]
steps = procedure["steps"]
steps[-1] = {"kind": "instruction", "text": "Tell the customer the new card will be ready in 3 working days."}
review = requests.post(
"https://api.qwryai.com/public/v1/tools/update_procedure",
headers=headers,
json={"chatbotId": "YOUR_AGENT_ID", "procedure_id": "PROCEDURE_ID", "steps": steps},
).json()["data"]Response
The review
A change to the name, description or steps shows the procedure before and after:
{
"success": true,
"data": {
"status": "review_required",
"reviewId": "d2e5f8a1-3b6c-4e90-87d4-1a0b9c8e7f65",
"tool": "update_procedure",
"changes": [
{
"title": "Save Procedure draft: Replace a lost loyalty card",
"before": {
"name": "Lost loyalty card",
"steps": [
"1. Ask the customer for their loyalty card number and their email address.",
"2. Create a ticket for the lost loyalty card with @Create ticket."
]
},
"after": {
"name": "Replace a lost loyalty card",
"steps": [
"1. Ask the customer for their loyalty card number and their email address.",
"2. Create a ticket for the lost loyalty card with @Create ticket."
],
"url": "/<workspace>/<agentId>/ai-actions/playbooks/playbook-draft%3A5a8d2c71-e94b-4f06-b3a2-7c1e0d9f4b68"
}
}
],
"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."
}
}A trigger change shows the trigger before and after. A toggle_procedure review is titled Pause Playbook: <name> or Resume Playbook: <name> and shows the deployment's state before and after.
After you apply it
Apply with POST https://api.qwryai.com/public/v1/reviews/{reviewId}/apply:
{
"success": true,
"data": {
"status": "succeeded",
"reviewId": "d2e5f8a1-3b6c-4e90-87d4-1a0b9c8e7f65",
"tool": "update_procedure",
"data": {
"applied": true,
"effect": "saved_draft",
"draftId": "playbook-draft:5a8d2c71-e94b-4f06-b3a2-7c1e0d9f4b68",
"revision": 2,
"receiptId": "<receiptId>",
"publicationChanged": false
},
"receipt": { "applied": true }
}
}update_procedure saves the draft: customers keep the published version until you publish the change from the Procedures page or with publish_draft (which needs Change agent settings). A toggle_procedure change applies at once and returns the deployment's new state. The receipt is shortened here.
Errors
| HTTP status | code | when |
|---|---|---|
| 400 | INVALID_ARGUMENTS | An argument failed the schema or the procedure's rules, nothing to change was given, the procedure already has these steps and this name, no procedure has that id, or resuming it would pass the plan's limit of enabled procedures. 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. |
| 404 | AUTOMATION_NOT_FOUND | toggle_procedure: no draft or deployment with those ids. |
| 409 | AUTOMATION_CONFLICT | toggle_procedure: the revision or sequence changed since you read them, or the procedure is already in the state you asked for. Read get_automation_publication again. |
| 409 | STALE_REVIEW | On apply: the procedure changed after the review. Read it again and call the tool again. |
| 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.