Messages

One endpoint sends everything: text, files and templates. The shape is the same whichever provider is behind the channel.

Text

curl
POST /v1/messages

{
  "channel_id": "ch_01h9",
  "to": "+256700000000",
  "type": "text",
  "body": "Your order has shipped."
}

channel_id and to are the only required fields. type defaults to text. to must be E.164 — a leading + and country code, no spaces or dashes.

Every field

FieldTypeWhat it does
channel_idstringThe number to send from. Required.
tostringRecipient in E.164. Required.
typestringtext by default.
bodystringThe text, or the caption alongside a template.
attachmentobjectA file to send. See below.
template_namestringAn approved template, required outside the 24-hour window.
template_languagestringThe template's language code, e.g. en.
template_variablesobjectValues for the template's placeholders, keyed by position.
quoted_message_idstringMakes this a reply to an earlier message.

There is no project_id field, and that is deliberate: the project comes from the API key. A project id in the body would be a way to act on somebody else's project by typing a different one.

Attachments

Give exactly one source: a url Pigeon fetches, raw base64, or a media_id from a previous upload.

By URL
{
  "channel_id": "ch_01h9",
  "to": "+256700000000",
  "attachment": {
    "url": "https://example.com/invoice.pdf",
    "filename": "invoice.pdf",
    "caption": "Your invoice"
  }
}

Uploading first

Worth doing when the same file goes to many recipients: uploaded once, it travels once rather than once per message.

curl
curl -X POST https://api.pigeon.dev/v1/media \
  -H "Authorization: Bearer pgn_live_your_key" \
  -F "file=@invoice.pdf"

# then
{ "attachment": { "media_id": "med_01h9", "caption": "Your invoice" } }

Templates and the 24-hour window

Meta allows free-form messages only within 24 hours of the person last writing to you. Outside that, the message must be an approved template.

A template send
{
  "channel_id": "ch_01h9",
  "to": "+256700000000",
  "template_name": "order_shipped",
  "template_language": "en",
  "template_variables": { "1": "10482", "2": "Thursday" }
}

Pigeon checks the window itself and answers OUTSIDE_CUSTOMER_SERVICE_WINDOW before the request reaches Meta, so the error names the actual problem instead of arriving as a provider code you have to look up.

Reading a message back

curl
curl https://api.pigeon.dev/v1/messages/01a2120c-38cb-7376-b188-84cef21dc768 \
  -H "Authorization: Bearer pgn_live_your_read_key"

Needs a read or admin key. A send-only key is refused here on purpose: a credential that leaks from a server which only ever sends should not also expose every message the project has exchanged.

Status

queued → sent → delivered → read, and status only ever moves forward. A late receipt for an earlier state is ignored rather than winding the message backwards.

Use webhooks to learn when it changes. Polling this endpoint works and will cost you your rate limit for nothing.