Skip to content

Send a Messenger message

POST
/v1/Accounts/{auth_id}/Integrations/Meta/Messenger/Messages
curl --request POST \
--url https://api.siprtc.io/v1/Accounts/example/Integrations/Meta/Messenger/Messages \
--header 'Authorization: Basic <credentials>' \
--header 'Content-Type: application/json' \
--data '{ "message": "Hello from Acme support", "pageAccessToken": "", "pageId": "100000000000001", "recipientId": "7000000000000001" }'

Sends a text message from a connected Facebook page to a person through the Messenger Send API. The page’s stored token is used: the page is looked up in this account’s integration, then in its parent account’s. pageAccessToken, when sent, is used instead of any stored token. If Facebook reports the token expired, the login’s token is refreshed once and the send retried. Facebook’s answer is returned as is: on success its recipient_id and message_id; on a Facebook error, Facebook’s HTTP status and error body. Messenger’s own rules apply (for example the 24-hour standard messaging window). Authentication: HTTP Basic with the account’s Auth ID and Auth Secret. The operation always applies to the authenticated account; {auth_id} should be its Auth ID (with a parent account’s credentials on a sub-account’s path, the parent’s own integration is used, not the sub-account’s).

auth_id
required
string

Auth ID of the authenticated account

Page, recipient and text

Media type application/json
object
message
required

Message is the text to send. Required.

string

Example

Hello from Acme support
pageAccessToken

PageAccessToken is a page access token to send with instead of a stored one; it takes precedence over pageId. Optional.

string

Example

pageId

PageID is the connected Facebook page to send from; its stored page token is used. Required unless pageAccessToken is sent.

string

Example

100000000000001
recipientId
required

RecipientID is the person’s page-scoped id (PSID) on that page. Required.

string

Example

7000000000000001

OK

Media type application/json
object
message_id

MessageID is Facebook’s id of the sent message.

string
recipient_id

RecipientID is the recipient’s page-scoped id.

string

Example

{
"message_id": "m_fake-message-id",
"recipient_id": "7000000000000001"
}

Invalid body, recipientId or message missing (message only, no status), neither pageId nor pageAccessToken, no stored token for the page, or a network error reaching Facebook

Media type application/json
object
message

Message says what went wrong.

string
status

Status is always “failed” on an error (some validation errors omit it).

string

Example

{
"message": "error message",
"status": "failed"
}

Missing or invalid credentials; the body is the JSON string Authentication failed

Media type application/json
string

Example generated

example

Facebook refused the send: Facebook’s status and error body, passed through

Media type application/json
object
error

Error is Facebook’s error object.

object
code

Code is Facebook’s error code.

integer
error_subcode

ErrorSubcode is Facebook’s error subcode, when given.

integer
fbtrace_id

FbtraceID is Facebook’s trace id for support.

string
message

Message is Facebook’s description of the error.

string
type

Type is Facebook’s error type.

string

Example

{
"error": {
"code": 100,
"error_subcode": 2018001,
"fbtrace_id": "AAAAAAAAAAA",
"message": "(#100) No matching user found",
"type": "OAuthException"
}
}