# Update an action > Change an Action's name, When to use, channels or settings, switch it on or off, or turn it on or off for one channel `build_action` with an `action_id` changes an existing Action the way its editor saves it. Read the Action with [Get an action](/docs/api-reference/v2/actions/get-an-action), change what you need, and send the whole build back; settings you leave out of `config` keep their current values. The call returns a review; nothing changes until you apply it. ```http POST https://api.qwryai.com/public/v1/tools/build_action ``` Other tools change one thing at a time: | To | Use | | - | - | | Switch an Action on or off on one channel, as each channel's Actions list does | `set_action_channel` | | Pause or resume a published Action everywhere | `toggle_action` | | Edit fields of the stored definition directly, such as the inputs it collects | `patch_action_config` | ## 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 > [tab] build_action > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id, from `list_agents`. | > | `action_id` | `string` | Yes, to change an Action | The Action's `id` from `automation_drafts` or `get_action_build`. Leave it out to build a new Action. | > | `type` | `string` | Yes | The Action's type, as `get_action_build` returns it. It can't change. | > | `name` | `string` | Yes | The Action's name, 1 to 64 characters. | > | `when_to_use` | `string` | No | When the agent uses it, up to 7,500 characters. Not needed when `procedure_only` is `true`. | > | `when_not_to_use` | `string` | No | When the agent shouldn't use it, up to 2,000 characters. | > | `procedure_only` | `boolean` | No | `true` makes it usable only from procedures. | > | `channels` | `array` | No | Where it can run: `web`, `agent_page`, `email`, `whatsapp`, `facebook`, `instagram`, `telegram`, `tiktok`, `sms`, `slack`, `zendesk`, `zendesk-messaging`, `api`, `phone`, `android_sdk`, `ios_sdk`. 1 to 20 values; the list replaces the current one. | > | `config` | `object` | No | The type's settings. `get_action_build_schema` with the `type` lists them. | > | `enable` | `boolean` | No | Lead forms, tickets, live chat and Shopify Actions: switch it on or off. | > [tab] set_action_channel > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id. | > | `action` | `string` | Yes | The Action's name, or its id from `list_channel_actions`. | > | `channel` | `string` | Yes | `widget` (Chat bubble), `conversation` (Help Page), `phone`, `api`, `android_sdk`, `ios_sdk`, `email`, `whatsapp`, `instagram`, `messenger`, `telegram`, `slack`, `zendesk`, `zendesk-messaging`, `sms` or `tiktok`. | > | `enabled` | `boolean` | Yes | `true` to switch it on there, `false` to switch it off. | > [tab] toggle_action > > Read `get_automation_publication` with `kind: "ai_action"` 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 Action'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 Action; `true` resumes a paused one. | > [tab] patch_action_config > > | Name | Type | Required | Description | > | - | - | - | - | > | `chatbotId` | `string` | Yes | The agent's id. | > | `action_id` | `string` | Yes | The Action's `id`. | > | `config` | `object` | Yes | A JSON merge patch on the Action's definition: objects merge, arrays and values replace, `null` removes a field. `get_action_config_schema` lists the fields this Action can hold. | > > Actions built in a dashboard editor refuse `patch_action_config`; change those with `build_action`. ## Request example > [tab] cURL > > ```bash > curl -X POST 'https://api.qwryai.com/public/v1/tools/build_action' \ > -H 'Authorization: Bearer YOUR_API_KEY' \ > -H 'Content-Type: application/json' \ > -d '{ > "chatbotId": "YOUR_AGENT_ID", > "action_id": "ACTION_ID", > "type": "escalation", > "name": "Create ticket", > "when_to_use": "Use this when a customer reports a damaged or faulty item.", > "channels": ["web", "agent_page", "email", "whatsapp"] > }' > ``` > [tab] JavaScript > > ```javascript > const response = await fetch( > "https://api.qwryai.com/public/v1/tools/set_action_channel", > { > method: "POST", > headers: { > Authorization: "Bearer YOUR_API_KEY", > "Content-Type": "application/json", > }, > body: JSON.stringify({ > chatbotId: "YOUR_AGENT_ID", > action: "Create ticket", > channel: "whatsapp", > enabled: false, > }), > } > ); > const { data: review } = await response.json(); > ``` > [tab] Python > > ```python > import requests > > headers = {"Authorization": "Bearer YOUR_API_KEY"} > current = requests.post( > "https://api.qwryai.com/public/v1/tools/get_action_build", > headers=headers, > json={"chatbotId": "YOUR_AGENT_ID", "action_id": "ACTION_ID"}, > ).json()["data"]["build"] > > current["name"] = "Report a damaged item" > review = requests.post( > "https://api.qwryai.com/public/v1/tools/build_action", > headers=headers, > json={"chatbotId": "YOUR_AGENT_ID", "action_id": "ACTION_ID", **current}, > ).json()["data"] > ``` ## Response ### The review ```json { "success": true, "data": { "status": "review_required", "reviewId": "1f6b9d24-8c3e-4a75-b0e2-7d9c5a3f1e86", "tool": "build_action", "changes": [ { "title": "Change Create ticket Action: Create ticket", "before": { "type": "Create ticket", "name": "Create ticket", "when_to_use": "Use this when a customer reports a damaged or faulty item. First ask for their email address and what is wrong with the item, then create the ticket.", "procedure_only": false, "channels": ["api", "web", "agent_page", "email", "facebook", "instagram", "whatsapp"], "enabled": true, "platform": "qwryai", "details_collection": "conversation" }, "after": { "type": "Create ticket", "name": "Create ticket", "when_to_use": "Use this when a customer reports a damaged or faulty item.", "procedure_only": false, "channels": ["web", "agent_page", "email", "whatsapp"], "enabled": true, "platform": "qwryai", "details_collection": "conversation" } } ], "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." } } ``` The review shows the Action's settings before and after, with its type by name; `config` settings appear on both sides even when they don't change (shortened here). ### After you apply it Apply with `POST https://api.qwryai.com/public/v1/reviews/{reviewId}/apply`. `data.data` holds the Action's `action_id` and what to do next: ```json { "success": true, "data": { "status": "succeeded", "reviewId": "1f6b9d24-8c3e-4a75-b0e2-7d9c5a3f1e86", "tool": "build_action", "data": { "applied": true, "action_id": "action-draft:8c1e5b20-4a7d-4f3e-9b2c-6d0a1e7f3c58", "next": "Saved on the live agent." }, "receipt": { "applied": true, "action_id": "action-draft:8c1e5b20-4a7d-4f3e-9b2c-6d0a1e7f3c58" } } } ``` > [!NOTE] > > Lead forms, tickets, live chat and Shopify Actions are live as soon as the review is applied. An Action built in an editor (an API call, a widget, a form, an integration such as Slack or Calendly) saves a draft change and returns its `pending_change_key`, and `next` says `Saved as an editor draft. Publish it with publish_draft keys [...]`. It goes live when you publish that change with `publish_draft`, which needs **Change agent settings**; an API Action needs a passing endpoint test first. ## Errors | HTTP status | code | when | | - | - | - | | 400 | `INVALID_ARGUMENTS` | An argument failed the schema, or the change can't be made: no Action has that id, the `type` doesn't match the Action, the Action already has these settings, or a `patch_action_config` targets an editor-built Action. `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_action`: no draft or deployment with those ids. | | 409 | `AUTOMATION_CONFLICT` | `toggle_action`: the revision or sequence changed since you read them, or the Action is already in the state you asked for. Read `get_automation_publication` again. | | 409 | `STALE_REVIEW` | On apply: the Action 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](/docs/api-reference/v2/error-handling).