Messenger Handover Protocol
Share one Facebook Page between two Meta apps and hand conversations between them
Two independent Meta apps can be connected to the same Facebook Page and both send and receive
Messenger messages in the same conversations — but only through Meta's handover protocol. At any
moment exactly one app owns a given thread. Only that app receives the conversation on its
normal messages webhook, and only that app may reply.
This tutorial is for the engineering team of any app that shares a Page with another app. It is symmetric: nothing here is specific to either side, except the default-application role, which has to be agreed once per Page.
Throughout, App A is the default application and App B is the other app.
Links marked ↗ go to Meta's official Messenger Platform documentation and open in a new tab. Where this guide and Meta's docs disagree, Meta's docs win — except where noted, which is flagged explicitly.
What you have to build
- Two webhook intake paths. Handle Meta's
messageswebhook (you own the thread) and Meta'sstandbywebhook (the other app owns it). Both arrive at the same webhook URL. - Ownership state. Know, per conversation, whether you currently own the thread, and never call the Send API when you do not.
- Handover calls and handover events. Call
pass_thread_control/take_thread_control/request_thread_controlwhen you want to release or claim a conversation, and react to the matching webhook events when the other side does.
If either app skips step 1 or 2, the symptom is the same: messages silently stop arriving for one app, or the Send API starts rejecting sends. That is a handover state problem, not a permissions problem.
Conversation Routing replaced the Handover Protocol
Meta no longer supports the Handover Protocol for Messenger and has migrated every business to Conversation Routing. Conversation Routing is backwards compatible with most of the Handover Protocol API, so the endpoints below are unchanged, but two things differ and both bite in practice:
- "Primary receiver" is now the default application. It is set in Facebook Page settings by an
admin (or someone with the
MANAGEtask). Conversation Routing is effectively off until a default application is chosen. take_thread_controlis blocked unless a default application is set. This is the most common reason a correct-looking integration cannot recover a thread. The Graph error is(#27 / 2018464) Take thread control is not supported when Conversation Routing is not enabled. The per-app "Take control of conversations" toggle is necessary but not sufficient — an admin must also set the default application on the Page.
Meta's older Handover Protocol reference is still published and is still the clearest description of the roles and events. The overview page it used to link to has been retired.
Agree which app is the default application before writing any code. Everything else follows from that choice.
Roles
The Page admin assigns roles once, in Page settings. Roles are per Page, not per conversation, and they do not change during a conversation.
The default application is the default owner: every new conversation starts owned by it, and control returns to it whenever another app releases the thread. The other app is a secondary receiver.
| Capability | App A (default) | App B (secondary) |
|---|---|---|
| Owns new threads by default | Yes | No |
pass_thread_control to another app | Yes | Yes, but only while it owns the thread |
take_thread_control (seize the thread) | Yes | No |
request_thread_control (ask for the thread) | No | Yes |
Receives messages while it owns the thread | Yes | Yes |
Receives standby while it does not own the thread | Yes | Yes |
The practical consequence: the default application can always recover a stuck conversation unilaterally, and the secondary cannot. Whichever side runs the human agent desk is usually the better candidate for default application.
A Page also has an implicit third participant: the Page Inbox (app id 263902037430900). Staff
replying from Meta Business Suite take thread control as that app, so both apps can lose ownership
without either of them calling anything.
Page setup
Subscribe both apps to the Page
Each app subscribes itself with its own Page access token, using the
subscribed_apps edge:
curl -X POST "https://graph.facebook.com/v25.0/{PAGE_ID}/subscribed_apps" \
-d "subscribed_fields=messages,message_echoes,message_reads,messaging_postbacks,messaging_referrals,messaging_optins,messaging_handovers,standby" \
-d "access_token={PAGE_ACCESS_TOKEN}"Neither app can subscribe the other. Each side does this from its own app, with its own token.
Webhook fields both apps must subscribe to
| Field | Why it is mandatory here |
|---|---|
messages | Inbound messages while you own the thread. Without ownership this channel is silent. |
standby | The same inbound messages while the other app owns the thread. Skip this and conversations look dead rather than blocked. |
messaging_handovers | pass_thread_control, take_thread_control, request_thread_control. Without it you learn you lost the thread only when a send fails. |
message_echoes | Messages the other app sent as the Page, so both inboxes show the same transcript. |
messaging_postbacks | Button taps. Also delivered on standby, but without the payload. |
message_reads, message_reactions, messaging_referrals, messaging_optins | Normal Messenger events; all except reactions also appear on standby. |
Instagram uses the singular spellings messaging_handover and messaging_referral. If a connected
Instagram account is in scope, subscribe both spellings on their respective channels.
Permissions and tokens
Both apps need pages_messaging and pages_manage_metadata, granted by the same Page admin, and
each must hold its own Page access token for the shared Page. Every handover call below is
Page-scoped and authenticated with that token. If you are new to Meta webhooks generally, start with
Graph API Webhooks — Getting Started.
The two delivery channels
Both channels arrive as POSTs to the same webhook URL, on the same entry array, with identical
event payloads. Only the key differs.
You own the thread:
{
"object": "page",
"entry": [
{
"id": "<PAGE_ID>",
"time": 1458692752478,
"messaging": [
{ "sender": { "id": "<PSID>" }, "recipient": { "id": "<PAGE_ID>" }, "message": {} }
]
}
]
}The other app owns the thread — same message, different key:
{
"object": "page",
"entry": [
{
"id": "<PAGE_ID>",
"time": 1458692752478,
"standby": [
{ "sender": { "id": "<PSID>" }, "recipient": { "id": "<PAGE_ID>" }, "message": {} }
]
}
]
}A webhook handler that only reads
entry.messagingwill lose every conversation the moment the other app takes control. This is the single most common bug on a two-app Page. Read both keys.
messaging | standby | |
|---|---|---|
| Meaning | You own this thread | Another app owns this thread |
| May you send? | Yes | No — the Send API will reject |
| Event types delivered | All subscribed events | messages, message_reads, message_deliveries, messaging_postbacks |
Postback payload included | Yes | No — only the app that sent the button receives it |
What to do with a standby event
Ingest it, do not act on it:
- Store the message so your transcript stays complete. When control comes back, your side must not look like it missed half the conversation.
- Feed it to your bot's conversation memory, but suppress the reply. A bot that skips standby messages resumes, after handover, as if the customer never spoke to the other app.
- Do not call the Send API. You are not the owner.
- Flag it in your data model, so downstream code and support staff can tell a blocked conversation from an unanswered one.
Knowing who owns a thread
There are three signals, and a working integration uses all three.
1. The channel the event arrived on. An event on messaging means you own the thread at that
moment; an event on standby means you do not. This is the cheapest ownership signal available and
it costs no API call.
2. Handover webhook events. messaging_handovers tells you the moment control moves, and names
the app involved.
3. The thread_owner endpoint, for the truth on demand:
curl -G "https://graph.facebook.com/v25.0/{PAGE_ID}/thread_owner" \
-d "recipient={PSID}" \
-d "access_token={PAGE_ACCESS_TOKEN}"{ "data": [ { "thread_owner": { "app_id": "263902037430900" } } ] }Treat this as a diagnostic, not a pre-flight check. Calling it before every send adds a round trip and still races with the other app. Send, and recover on the specific failure instead.
The state machine
pass_thread_control (to the other app)
take_thread_control (by the default app)
+----------------------------------------------------->+
| |
[ You own it ] [ Other app owns it ]
^ |
| the other app passes or releases back to you |
| you take_thread_control (default application only) |
| 24h of inactivity -> returns to the default app |
+<-----------------------------------------------------+
request_thread_control does not move anything. It only asks.Persisting it
Store the owner per conversation, alongside the time it last changed. Two rules matter:
- Never model "we own it" as null or unknown. On
take_thread_controlMeta names only the previous owner, so the new owner is genuinely unattributable. Write an explicitunknownsentinel, not null. If null means "ours", a thread someone took from you silently reads as yours and every send fails. - Compare app ids as strings. Meta types them as strings but has been observed sending bare
numbers. A
123 !== "123"mismatch makes every handover look like it involved a third party, and the "we lost control" branch never fires.
The handover APIs
All calls are POST https://graph.facebook.com/v25.0/{PAGE_ID}/{endpoint} with the Page access
token, except thread_owner, which is a GET. All return {"success": true}. Check for
success: false in the body as well as a non-2xx status — Meta returns both.
| Endpoint | Who may call it | Effect |
|---|---|---|
pass_thread_control | Current thread owner | Give the thread to target_app_id |
release_thread_control | Current thread owner | Give the thread back to the default application |
take_thread_control | Default application only | Seize the thread from whoever holds it |
request_thread_control | Any non-owner app | Ask the owner to hand over; transfers nothing |
extend_thread_control | Current thread owner | Hold the thread past the 24-hour inactivity expiry |
thread_owner (GET) | Any subscribed app | Read the current owner's app id |
release_thread_control, extend_thread_control and thread_owner are documented on the
Conversation Routing
page rather than in the older handover reference.
pass_thread_control
The call both sides will use most.
curl -X POST "https://graph.facebook.com/v25.0/{PAGE_ID}/pass_thread_control" \
-H "Content-Type: application/json" \
-d '{
"recipient": { "id": "<PSID>" },
"target_app_id": "<THE OTHER APP ID>",
"metadata": "Escalated: customer asked for a human",
"access_token": "<PAGE_ACCESS_TOKEN>"
}'target_app_idmust already be connected to the Page. Nothing in the API can grant that; the call is rejected otherwise.metadatais free text, delivered verbatim to the receiving app in its webhook. Keep it under 1000 characters — longer strings are rejected. Use it to carry the handover reason, a ticket id or a conversation summary. It is the only in-band channel between the two apps, so it is worth agreeing a small JSON shape for it.- Meta also allows a bundled form —
thread_controlas a field onPOST /me/messages— which sends a farewell message and passes the thread in one call. Avoid it if your outbound messages go through a pipeline that persists, deduplicates and logs them: the bundled message bypasses that pipeline, so the farewell is never recorded and may be double-counted against Meta's echo. Send the farewell first, then pass control.
take_thread_control
curl -X POST "https://graph.facebook.com/v25.0/{PAGE_ID}/take_thread_control" \
-H "Content-Type: application/json" \
-d '{
"recipient": { "id": "<PSID>" },
"metadata": "Agent replying from the unified inbox",
"access_token": "<PAGE_ACCESS_TOKEN>"
}'Only the default application may call this, and only when Conversation Routing has a default
application set on the Page. Otherwise it fails with (#27 / 2018464).
request_thread_control
Same body as take_thread_control, without the seize. It fires a request_thread_control webhook at
the current owner and nothing else happens — the owner must respond by calling
pass_thread_control. If the owner ignores it, the requester waits forever. Agree a timeout and a
fallback between the two teams.
release_thread_control
curl -X POST "https://graph.facebook.com/v25.0/{PAGE_ID}/release_thread_control" \
-H "Content-Type: application/json" \
-d '{ "recipient": { "id": "<PSID>" }, "access_token": "<PAGE_ACCESS_TOKEN>" }'Returns the thread to the default application. Prefer this over pass_thread_control when handing
back: it needs no knowledge of the other app's id, so it cannot be aimed at the wrong app.
extend_thread_control and the 24-hour expiry
Thread control expires after 24 hours of inactivity and the thread returns to idle. For a long-running human case, the owner extends it:
curl -X POST "https://graph.facebook.com/v25.0/{PAGE_ID}/extend_thread_control" \
-H "Content-Type: application/json" \
-d '{ "recipient": { "id": "<PSID>" }, "duration": 86400, "access_token": "<PAGE_ACCESS_TOKEN>" }'duration is in seconds, and control can be extended up to a maximum of 7 days.
Handover webhook events
These arrive on the messaging array (not standby), each carrying one of three keys. They contain
no message, so parse them before any message-shaped handling — a handler that branches on
message first will drop them, and the integration then works fine until the first handover and
mysteriously stops. See Meta's
messaging_handovers reference.
{
"sender": { "id": "<PSID>" },
"recipient": { "id": "<PAGE_ID>" },
"timestamp": 1458692752478,
"pass_thread_control": {
"new_owner_app_id": "123456789",
"metadata": "Escalated: customer asked for a human"
}
}| Event key | Delivered to | Names | Did you lose control? |
|---|---|---|---|
pass_thread_control | Both apps | new_owner_app_id | Yes, unless the new owner is you |
take_thread_control | The app that lost the thread | previous_owner_app_id | Yes, if the previous owner is you |
request_thread_control | The current owner | requested_owner_app_id | No — nothing moved yet |
Note the asymmetry on take_thread_control: it names only the previous owner, so the app that
seized the thread is not identified. You know you lost it; you cannot tell to whom. This is why the
persisted owner needs an unknown sentinel.
How to react
pass_thread_controlnaming you as new owner — you now own the thread. Resume normal handling;messagingevents will start arriving. Readmetadatafor the context the other side sent.pass_thread_controlnaming someone else — stop sending. Switch that conversation to standby handling.take_thread_control— you lost it. Do not automatically take it back: that yanks the thread away from whichever human is mid-reply, and two apps that both auto-reclaim will fight in a loop. Reclaim at the moment a human on your side actually decides to answer, not on the event.request_thread_control— the other app is asking. Decide (your bot may be mid-flow), then either callpass_thread_controlor do not. Either way, respond in-band: silence is indistinguishable from an outage to the requester.
Walkthroughs
1. Clean escalation
The normal path. App A decides the conversation needs the other side, sends its farewell through its own send pipeline, then passes control.
1. Customer sends "I need a human"
Meta -> App A entry.messaging (App A owns the thread)
Meta -> App B entry.standby
2. App A sends its farewell
App A -> POST /{PAGE_ID}/messages
3. App A hands the thread over
App A -> POST /{PAGE_ID}/pass_thread_control target_app_id = App B
4. Meta notifies BOTH apps
Meta -> App A messaging_handovers: pass_thread_control
Meta -> App B messaging_handovers: pass_thread_control
5. Customer sends "thanks" - the channels have now swapped
Meta -> App B entry.messaging (App B owns the thread)
Meta -> App A entry.standbyApp A keeps ingesting on standby. It just stops replying.
2. Returning control
When App B is finished it calls release_thread_control, or pass_thread_control with App A's id.
Both apps receive the event and the channels swap back.
3. App B wants a thread it does not own
App B cannot seize the thread; only the default application can. It has to ask.
1. App B asks for the thread
App B -> POST /{PAGE_ID}/request_thread_control
metadata = "agent picked up ticket 4471"
2. Meta forwards the request to the owner
Meta -> App A messaging_handovers: request_thread_control
3. App A decides. NOTHING here is automatic.
4. App A hands over (or does not)
App A -> POST /{PAGE_ID}/pass_thread_control target_app_id = App B
Meta -> App B messaging_handovers: pass_thread_controlIf App A never responds, App B waits forever. Agree a timeout and what App B does when it fires — typically surface a warning to the human agent rather than retry silently.
4. A human answers from Meta Business Suite
Neither app is involved, and in practice this happens constantly. The Page Inbox app
(263902037430900) becomes the thread owner, both apps start receiving standby, and both apps'
sends begin failing. Only the default application can recover the thread, with
take_thread_control.
Worth stating plainly to the Page owner: when their staff reply from Business Suite or the Facebook Page inbox, they take the conversation away from both apps.
Sending, and what failure looks like
Only the thread owner may send. A non-owner's Send API call fails with:
(#10) Message failed to send because another app is controlling this thread nowThe error subcodes observed for this in production are 2018278 and 2018300. Meta has shipped it
under more than one subcode and the set is not documented as stable, so match on the subcode and
fall back to matching code === 10 against the message text. Missing a subcode should only cost you
the automatic recovery, never correctness — the send must still fail loudly.
Recovery pattern
Do not check ownership before every send. Send, and recover on that specific error:
- Send the message.
- Not a "another app is controlling this thread" error? Done, or it is a real error — surface it.
- If it is that error, call
take_thread_control. - On success, retry the send exactly once. An unbounded retry loop against a thread the other app keeps reclaiming will hammer the Graph API.
- If the reclaim fails with subcode
2018464, Conversation Routing is not configured — no code change can fix it, a Page admin must set the default application. - If the reclaim fails for any other reason, return the original send error, not the reclaim error. The first one describes what the operator actually hit, and the two causes need different fixes.
This pattern only works for the default application. A secondary app, which cannot take control,
must surface the failure to its agent and call request_thread_control instead.
The 24-hour messaging window still applies
Handover does not change Messenger's standard messaging window. Whichever app owns the thread may
only send freely within 24 hours of the customer's last message; outside it, it needs a valid
message tag
such as HUMAN_AGENT or CONFIRMED_EVENT_UPDATE. A handover at hour 23 gives the receiving app one
hour, not a fresh 24.
Both apps should track the window from the customer's last inbound message — including ones
received on standby, which is another reason to ingest them. See the
Messenger Platform policy overview
for what the window permits.
Edge cases
Echoes and duplicate transcripts. With message_echoes subscribed, every message either app
sends as the Page comes back to both apps as an echo. Deduplicate against your own outbound records
by mid, or the other app's messages appear twice in your inbox and your own sends look like they
reached the customer twice.
Handover events carry no message. Parse the three *_thread_control keys before any message
handling.
App ids arrive as numbers. Meta types new_owner_app_id and its siblings as strings but has been
observed sending bare integers. Stringify both sides before comparing.
Postback payloads are stripped on standby. You get the postback event but not its payload —
only the app that sent the button receives that. Do not build cross-app flows that depend on reading
the other app's postback payloads.
Race conditions. Two apps can act in the same instant: App A passes control while App B requests
it; a customer message arrives mid-handover. Treat the webhook as the source of truth, not your own
optimistic write, and make handover handling idempotent — the same pass_thread_control event
delivered twice must not toggle anything.
Never auto-reclaim on losing control. If both apps reclaim automatically on
take_thread_control, they ping-pong the thread indefinitely and the customer sees nothing.
Typing indicators and read receipts. sender_action calls obey the same ownership rule. A
non-owner showing a typing indicator fails exactly as a send does.
Control expires. After 24 hours of inactivity the thread goes idle and returns to the default
application. A human case parked over a weekend will have quietly moved unless the owner called
extend_thread_control.
Instagram. The same protocol applies, with the singular field names messaging_handover and
messaging_referral, and a different inbox app id: 1217981644879628.
Checklist
Agree before writing code
- Which app is the default application, and confirm a Page admin has set it in Page settings
- Exchange app ids — each side needs the other's to call
pass_thread_control - Agree the
metadataformat (plain text, or a small JSON envelope with reason, ticket id, agent name) - Agree what triggers a handover in each direction, and the timeout for an unanswered
request_thread_control - Confirm the Page owner understands that replying from Business Suite takes control from both apps
Each side implements
- Webhook reads both
entry.messagingandentry.standby - Handover events parsed before message handling
- Thread owner persisted per conversation, with an explicit
unknownsentinel - App ids compared as strings
- Standby messages stored and fed to bot memory, with replies suppressed
- Send path detects the not-thread-owner error by subcode and message text
- Default application only: reclaim-and-retry-once on that error
- Echo deduplication by
mid - Subscribed to all required fields via
POST /{PAGE_ID}/subscribed_apps
Joint test plan
Run these together against the real Page, with both teams watching their logs.
| # | Test | Expected |
|---|---|---|
| 1 | Customer messages a fresh thread | App A gets messaging; App B gets standby |
| 2 | App A passes control to App B | Both apps receive pass_thread_control; channels swap |
| 3 | Customer sends another message | Owner gets messaging, non-owner gets standby, same content |
| 4 | Non-owner attempts a send | Fails with (#10) / subcode 2018278 — confirm it is detected, not swallowed |
| 5 | Owner sends a message | Delivered; non-owner receives it as an echo, not duplicated in its inbox |
| 6 | App B calls release_thread_control | Thread returns to App A; both see the event |
| 7 | App B calls request_thread_control | App A receives the request and can pass |
| 8 | Human replies from Business Suite | Both apps go to standby; thread_owner returns 263902037430900 |
| 9 | App A calls take_thread_control after test 8 | Succeeds. If it returns 2018464, Conversation Routing is not configured — stop and fix the Page settings |
| 10 | Leave a thread idle past 24h | Control reverts to App A |
Run test 9 first, on a staging Page. It is a Page-settings problem that no amount of code can work around, and finding it late invalidates the rest of the plan.
Reference
Known app ids
| App | Id |
|---|---|
| Meta Page Inbox (Business Suite) | 263902037430900 |
| Meta Instagram Inbox | 1217981644879628 |
| App A | exchange with the other team |
| App B | exchange with the other team |
Error codes
| Code | Meaning | Fix |
|---|---|---|
(#10) subcode 2018278 or 2018300 | "Message failed to send because another app is controlling this thread now" | Take or request control, then retry once |
(#27) subcode 2018464 | "Take thread control is not supported when Conversation Routing is not enabled" | A Page admin must set the default application in Page settings |
Endpoints
Base: https://graph.facebook.com/v25.0
| Call | Method | Path | Body |
|---|---|---|---|
| Pass | POST | /{PAGE_ID}/pass_thread_control | recipient, target_app_id, metadata? |
| Release | POST | /{PAGE_ID}/release_thread_control | recipient, metadata? |
| Take | POST | /{PAGE_ID}/take_thread_control | recipient, metadata? |
| Request | POST | /{PAGE_ID}/request_thread_control | recipient, metadata? |
| Extend | POST | /{PAGE_ID}/extend_thread_control | recipient, duration |
| Who owns it | GET | /{PAGE_ID}/thread_owner | recipient (query param) |
| Subscribe | POST | /{PAGE_ID}/subscribed_apps | subscribed_fields |
Official Meta documentation
- Conversation Routing — the current model, and the source for
release_thread_control,extend_thread_controlandthread_owner - Handover Protocol API reference — roles and the original endpoint reference
- Pass Thread Control
- Take Thread Control
- Request Thread Control
- Secondary Receivers
standbywebhook eventmessaging_handoverswebhook eventmessageswebhook eventmessaging_postbackswebhook event- Send API reference
- Sending messages and message tags
- Page
subscribed_appsedge - Graph API Webhooks — Getting Started
- Messenger Platform changelog
Error subcodes, the multi-subcode behaviour and the app-id stringification issue are from production experience with this integration, not from Meta's documentation.