AI Agent Control API
Switch the AI agent off and on for a conversation from your own system, and get notified when it changes
Let your own system — a helpdesk, a CRM, your backend — take a conversation over from the AI agent, and hand it back when your team is done. Every endpoint lives under:
https://<your-domain>/app/api/v1/conversation/botAll request and response bodies are JSON.
When you need this
It depends on how Conversation Routing is set up for your Facebook Page, in Meta Business Suite → Settings → Integrations → Conversation Routing.
- No default app. Every app connected to the Page receives every message and can reply to it, so Meta has no conversation "thread" to hand from one app to another. The only way to hand a customer to your own team is to switch our AI agent off for that conversation: your tool answers, and ours stays quiet until you switch it back on.
- Our app is the default app. Switching the AI off still stops it replying. You can also
pass the Meta thread to another app (
humanHandover, below), and when you switch the AI back on it takes the thread back automatically.
1. Create an API key
- In the dashboard, open Settings → API Keys and click New API key. Organization owners and admins can do this.
- Name the key after the system that will use it, so you know which one to revoke later.
- Tick Switch the AI agent off and on (
conversations:bot). A key only gets the permissions you tick, and a key without this one gets403. - Copy the key. It starts with
org_sk_and is shown only once — only a fingerprint of it is stored.
Treat it like a password:
- Keep it on your server. Never put it in a website, browser extension or mobile app.
- Anyone with the key can switch the AI off for any conversation in your organization.
- Revoke it from the same page if it may have leaked. It stops working immediately.
Send it on every request:
Authorization: Bearer org_sk_…
Content-Type: application/jsonEach key may make 300 requests per minute. Past that you get 429 with a Retry-After
header, in seconds.
2. Identify the conversation
Every call names one conversation, in one of two ways. Sending both, or neither, is a
400.
Our conversation ID — conversationId. It is in every AI agent webhook
(data.conversationId, see Webhooks).
The IDs your system already has — all three of:
| Field | Messenger | |
|---|---|---|
platform | MESSENGER | WHATSAPP |
channelId | Your Facebook Page ID | Your WhatsApp phone number ID |
platformUserId | The customer's Page-scoped ID (PSID) | The customer's WhatsApp number |
For other platforms (INSTAGRAM, WEB, MOBILE), use the channelId and platformUserId
from our webhook payloads — they are exactly the values this lookup expects.
If a lookup by these IDs returns 404 for a conversation you can see in your inbox, use its
conversationId instead.
3. Check whether the AI is on
curl -sS "https://<your-domain>/app/api/v1/conversation/bot?platform=MESSENGER&channelId=104857362918273&platformUserId=7430219856123047" \
-H "Authorization: Bearer $API_KEY"or ?conversationId=conv_abc123.
{
"success": true,
"conversationId": "conv_abc123",
"botEnabled": false,
"disableReason": "handled_in_zendesk",
"threadOwnerAppId": null,
"apiKeyId": "3f6c1a2e-…"
}apiKeyId is the ID of the key you called with. Keep it — it is how you recognise your own
changes in webhooks.
4. Switch the AI off
curl -sS -X POST "https://<your-domain>/app/api/v1/conversation/bot" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"platform": "MESSENGER",
"channelId": "104857362918273",
"platformUserId": "7430219856123047",
"enabled": false,
"reason": "handled_in_zendesk",
"actorLabel": "agent@acme.com"
}'{
"success": true,
"conversationId": "conv_abc123",
"botEnabled": false,
"changed": true,
"disableReason": "handled_in_zendesk",
"handover": { "requested": false, "passed": false, "takenBack": null },
"apiKeyId": "3f6c1a2e-…"
}changed is false when the AI was already in the state you asked for. Repeating a call is
safe: it changes nothing and sends no second webhook.
Request fields
| Field | Type | Required | What it does |
|---|---|---|---|
conversationId | string | One of the two forms | See Identify the conversation. |
platform, channelId, platformUserId | strings | One of the two forms | All three together. |
enabled | boolean | Yes | false stops the AI, true resumes it. A missing or null value is a 400 — it is never read as "leave it as it is". |
reason | string, ≤ 255 | No | Why the AI was stopped. Shown in the conversation's history and in reports. Defaults to org_api. Ignored when enabled is true. |
actorLabel | string, ≤ 128 | No | Who, on your side, made the change. Shown next to the key's name in the conversation's history. |
humanHandover | boolean | No, default false | Also pass the Meta thread to another app. Only allowed with enabled: false. See below. |
handoverAppId | string | No | The app to pass the thread to. Only read when humanHandover is true. |
reclaimThread | boolean | No, default true | When switching the AI back on, take the Messenger thread back. |
A field sent as null is treated as not sent.
5. Switch the AI back on
curl -sS -X POST "https://<your-domain>/app/api/v1/conversation/bot" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "conversationId": "conv_abc123", "enabled": true }'On Messenger, if another app holds the thread, the AI takes it back so it can reply
(handover.takenBack: true). If your own tool should keep the thread for now, send
"reclaimThread": false. On a Page with no default app there is no thread to take, and the
response says so in handover.code (ROUTING_NOT_ENABLED) — the AI is switched on either way.
6. Hand the Meta thread to another app (optional)
Only useful when our app is the Page's default app in Conversation Routing.
curl -sS -X POST "https://<your-domain>/app/api/v1/conversation/bot" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"conversationId": "conv_abc123",
"enabled": false,
"humanHandover": true,
"handoverAppId": "<the other app's Meta app ID>"
}'Without handoverAppId, the thread goes to the handover target saved for that Page or
Instagram account in our dashboard, and on Messenger falls back to Meta Business Suite / Page
Inbox.
The response is always 200 once the AI's state is saved, even if Meta refused to move the
thread. Check handover:
handover | Meaning |
|---|---|
passed: true | The thread was passed to targetAppId. |
code: "NOT_THREAD_OWNER" | Another app already holds the thread — often a person replying in Business Suite. currentOwnerAppId says which. |
code: "ROUTING_NOT_ENABLED" | Conversation Routing has no default app on this Page, so there is no thread to move. |
code: "NO_TARGET_CONFIGURED" | Instagram, with no handover target saved and no handoverAppId sent. |
code: "TARGET_IS_SELF" | The target app is our own app. |
code: "UNSUPPORTED_CHANNEL" | This conversation is not on Messenger or Instagram. |
code: "UNSUPPORTED" | Switching back on: Instagram threads are not taken back automatically. |
code: "PLATFORM_ERROR" | Meta refused. error has its message. |
Errors
Errors share one shape:
{ "success": false, "code": "INVALID_REQUEST", "error": "enabled: enabled (boolean) is required" }| Status | code | When |
|---|---|---|
400 | INVALID_REQUEST | Invalid JSON; enabled missing; both or neither ways of identifying the conversation; humanHandover: true with enabled: true. |
401 | UNAUTHENTICATED | Missing, unknown or revoked key. |
403 | FORBIDDEN | The key is not allowed to control the AI agent. |
404 | NOT_FOUND | No such conversation in your organization. |
429 | RATE_LIMITED | Too many requests. Wait for Retry-After seconds. |
500 | INTERNAL | Something went wrong on our side. Safe to retry. |
7. Webhooks: know when the AI stops or starts
The AI can be switched off and on by more than your system: a team member in the inbox, an automated workflow when a customer asks for a person, or a ticket being closed. To hear about all of them, open Settings → Webhooks and subscribe to:
| Event | Sent when |
|---|---|
conversation.bot_disabled | The AI agent is switched off for a conversation. |
conversation.bot_enabled | The AI agent is switched back on — from this moment it is answering the customer again. |
Each is sent once per change. Switching the AI off when it is already off sends nothing.
Full field-by-field reference for each event: AI Agent Stopped and AI Agent Resumed.
{
"event": "conversation.bot_disabled",
"timestamp": "2026-09-10T09:14:03.250Z",
"data": {
"eventId": "6f1c2a9e-4b7d-4f0e-9a51-2d8c3e7b1a44",
"conversationId": "conv_abc123",
"platform": "MESSENGER",
"channelId": "104857362918273",
"platformUserId": "7430219856123047",
"customerName": "John Doe",
"botEnabled": false,
"reason": "customer_asked_for_human",
"actor": {
"source": "workflow",
"memberId": null,
"apiKeyId": null,
"orgApiKeyId": null,
"label": "Zapier: human handover"
},
"ticketId": "ticket_xyz789",
"threadOwnerAppId": null,
"inboxUrl": "https://<your-domain>/app/inbox/all/conv_abc123",
"at": "2026-09-10T09:14:03.118Z"
}
}- Skip duplicates with
data.eventId. It stays the same if a delivery is resent. - Several Pages? Route on
data.channelId(your Page ID on Messenger) anddata.platformUserId. data.atis when the change happened;timestampis when this delivery was sent.data.reasonis alwaysnullonconversation.bot_enabled.
Ignore your own changes
You also receive events for changes your own API calls made. They carry
actor.source: "org_api" and actor.orgApiKeyId equal to the apiKeyId returned by your
calls — skip those, or your system may react to itself.
actor.source is one of manual (a team member in the inbox), workflow (an automated
workflow), org_api (an API key), agent_api (the Mobile Chat API), ticket_close or
auto_close (switched back on when a ticket was closed).
Verify the signature
Every delivery carries X-Webhook-Signature: the hex HMAC-SHA256 of the raw request body,
using the secret shown for that webhook in Settings → Webhooks.
const crypto = require('crypto');
const express = require('express');
app.post('/webhooks/fastcom', express.raw({ type: 'application/json' }), (req, res) => {
const expected = crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(req.body) // the raw bytes, before JSON parsing
.digest('hex');
const received = req.get('X-Webhook-Signature') || '';
if (
received.length !== expected.length ||
!crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected))
) {
return res.status(401).end();
}
res.status(200).end(); // answer within 30 seconds
handle(JSON.parse(req.body.toString('utf8')));
});Deliveries are not retried automatically. A failed delivery can be resent from the webhook's logs in Settings → Webhooks.
Putting it together
- A customer asks for a person. Our workflow switches the AI off, and you receive
conversation.bot_disabledwithactor.source: "workflow". - Your helpdesk opens a ticket for
data.channelId+data.platformUserId, and your team replies from your tool. - When the ticket is solved, your system calls
POST … { "enabled": true }. - You receive
conversation.bot_enabledwithactor.orgApiKeyIdequal to your key's ID — your own change, so you skip it.