Endpoints
Create a procedure
Create a procedure from its name, trigger and steps through a review; it stays unpublished until you publish it
create_procedure saves a new procedure the way the Procedures editor does: its name, its trigger and its steps together. You write steps as plain text; QwryAI builds the editor's document from them and links each Action a step runs to its published version. The call returns a review; nothing is saved until you apply it. The new procedure isn't live until it's published.
https://api.qwryai.com/public/v1/tools/create_procedureAuthentication
Send your API key as Authorization: Bearer YOUR_API_KEY; it needs the Change actions and procedures permission. See Authentication.
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
chatbotId | string | Yes | The agent's id, from list_agents. |
name | string | Yes | The procedure's name, 1 to 100 characters. |
description | string | No | A short description, up to 500 characters. |
trigger | object | Yes | When the procedure starts, below. |
steps | array | Yes | 1 to 15 steps, counting those inside branches, below. |
trigger
| Field | Type | Required | Description |
|---|---|---|---|
whenToUse | string | Yes | The customer request that starts it, up to 500 characters. It can be empty only when a chip starts the procedure. |
channels | array | No | Where it runs: conversation, widget, email, sms, whatsapp, instagram, facebook, messenger, telegram, tiktok, zendesk-messaging, zendesk, slack, api, phone, android_sdk, ios_sdk. Each channel once. Left out, every channel. |
noReply | object | No | No reply chip: { "afterMinutes" }, 1 to 1,440. Starts after the customer has been silent this long. |
repeat | object | No | Repeat chip: { "everyMinutes", "times" }. Starts again at this interval, 2 to 10 times in all, until the customer replies. |
schedules | array | No | Schedule chips, up to 10. get_authoring_schema with kind: "playbook" describes a schedule. |
api | object | No | API chip: {}. The procedure can be started for one contact with start_procedure_for_contact. |
ticketOpened, ticketClosed | object | No | Helpdesk chips: {}. Starts in the conversation when its ticket opens or closes. |
steps
| Step | Shape | Description |
|---|---|---|
| Instruction | { "kind": "instruction", "text" } | One thing the agent does: ask, confirm, tell, or run one Action. Up to 1,000 characters. |
| Message | { "kind": "message", "text", "subject"? } | Sent to the customer as written, with variables filled in. Up to 4,000 characters; subject (up to 200) is for email. |
| Branch | { "kind": "branch", "branches": [{ "condition", "steps" }], "otherwise"? } | If, Else if and Otherwise. 1 to 4 conditions of up to 500 characters; each branch holds instruction and message steps, never another branch. |
In step text, [[actionId]] runs an Action, using the actionId from List actions of an Action that is published. [[actionId#field.path]] uses a field of its result in a later step, and {{contact.email}} or {{contact.first_name|there}} inserts a variable, with an optional fallback after |.
Request example
curl -X POST 'https://api.qwryai.com/public/v1/tools/create_procedure' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"chatbotId": "YOUR_AGENT_ID",
"name": "Lost loyalty card",
"trigger": {
"whenToUse": "The customer says they lost their loyalty card.",
"channels": ["widget", "conversation", "email", "whatsapp"]
},
"steps": [
{ "kind": "instruction", "text": "Ask the customer for their loyalty card number and their email address." },
{ "kind": "instruction", "text": "Create a ticket for the lost card with [[ACTION_ID]]." },
{ "kind": "instruction", "text": "Tell the customer their ticket number is [[ACTION_ID#ticketId]]." }
]
}'const response = await fetch(
"https://api.qwryai.com/public/v1/tools/create_procedure",
{
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
chatbotId: "YOUR_AGENT_ID",
name: "Quiet chat check-in",
trigger: { whenToUse: "", channels: ["widget"], noReply: { afterMinutes: 10 } },
steps: [
{ kind: "message", text: "Still there, {{contact.first_name|there}}? I'm happy to help with anything else." },
],
}),
}
);
const { data: review } = await response.json();import requests
review = requests.post(
"https://api.qwryai.com/public/v1/tools/create_procedure",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"chatbotId": "YOUR_AGENT_ID",
"name": "Delivery feedback",
"trigger": {"whenToUse": "The customer wants to rate their delivery."},
"steps": [
{"kind": "instruction", "text": "Ask the customer to rate their delivery from 1 to 5."},
{
"kind": "branch",
"branches": [{"condition": "The rating is 1 or 2", "steps": [
{"kind": "instruction", "text": "Ask what went wrong and apologise."}]}],
"otherwise": [{"kind": "instruction", "text": "Thank the customer for the rating."}],
},
],
},
).json()["data"]Response
The review
{
"success": true,
"data": {
"status": "review_required",
"reviewId": "3b7e1c90-4f2a-4d68-a5b3-9e0c8d7f6a12",
"tool": "create_procedure",
"changes": [
{
"title": "Create unpublished Procedure draft: Lost loyalty card",
"before": null,
"after": {
"trigger": {
"whenToUse": "The customer says they lost their loyalty card.",
"channels": ["widget", "conversation", "email", "whatsapp"]
},
"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 card with @Create ticket.",
"3. Tell the customer their ticket number is @Create ticket → ticketId."
]
}
}
],
"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:
{
"success": true,
"data": {
"status": "succeeded",
"reviewId": "3b7e1c90-4f2a-4d68-a5b3-9e0c8d7f6a12",
"tool": "create_procedure",
"data": {
"applied": true,
"effect": "saved_draft",
"draftId": "playbook-draft:5a8d2c71-e94b-4f06-b3a2-7c1e0d9f4b68",
"url": "/<workspace>/<agentId>/ai-actions/playbooks/playbook-draft%3A5a8d2c71-e94b-4f06-b3a2-7c1e0d9f4b68",
"revision": 1,
"receiptId": "<receiptId>",
"triggerRevision": 1,
"publicationChanged": false
},
"receipt": { "applied": true }
}
}draftId is the new procedure's id. publicationChanged is false: the procedure is saved but not live. Publish it from the Procedures page, or with publish_draft after show_pending_changes (both need Change agent settings). The receipt is shortened here.
Errors
| HTTP status | code | when |
|---|---|---|
| 400 | INVALID_ARGUMENTS | An argument failed the schema or the procedure's rules: a missing trigger, more than 15 steps, a step over its length, a nested branch, an unknown or unpublished [[actionId]], an unknown {{variable}}, or an empty whenToUse with no chip. 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 review no longer matches what the server would save. 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.