REST APIMessages

Messages

Send a message, with files, to one of your contacts or chats with a developer key.

POST /v1/messages/send sends one message (a text, files, or both) as the key's holder, from their own linked account, to one of their own contacts or chats (a direct chat or a group). It is the same send, with the same rules and refusals, as the MCP tool send_message, which takes no files. Pantheon shows the message as sent by an agent. To send email, use POST /v1/email/send.

Access. The key needs its sending switch on: the send scope ("Send messages & email" in Settings, Developer), which is off on a new key until its holder turns it on. A key without it is refused with 403 sending_off. It needs no other scope. A key sends only as its holder and only to the holder's own chats, whatever the key's record scope.

Who it goes to. contact_id is an id the API already gave you:

  • contact_id from GET /v1/chats or a search hit, or a contact record's id, when that chat is on one channel. A person you reach on several channels is refused with 404 contact_not_accessible rather than guessing a channel.
  • A channel's id from a contact record's channels, to choose the channel yourself.

The message goes out on the channel that chat is on. An id that is not one of your chats, a teammate's or another workspace's, is the same 404 contact_not_accessible.

Body. text is 1 to 4096 UTF-16 code units, sent as written. That is what text.length counts in JavaScript and Java, and len(text.encode('utf-16-le')) // 2 in Python: most characters count 1, and an emoji counts 2 or more (👍 is 2, 👨‍👩‍👧 is 8). It is not a count of bytes or of visible characters. Over the limit is 400 invalid_input with details.field text, and nothing is cut. text is required unless you send files, when it is their caption. There are no mentions here. Any other field is refused with 400 unknown_field, so a misspelled dry_run never sends for real.

Files. attachments is 1 to 8 files as objects, [{ "id": "90210" }], each once. id is the file id POST /v1/uploads/{id}/finish answered. You can send only a file you uploaded with a developer key in this workspace. Nothing else is accepted: not a file you received or uploaded in the app, a teammate's, one uploaded in another workspace, or one that others can read because it is in a workspace document or on a group's message. Each of those, an id that does not exist and a file the antivirus refuses get the same 422 invalid_attachments.

Every file is checked before anything goes out, so a file that cannot be sent stops the whole send. One message with files is one automated send, however many files it carries.

  • Which channels. Telegram, WhatsApp and iMessage carry files; X carries one per message, an image, a GIF or a video (any other type is 400 validation when it is sent: a dry run does not check it). A channel that carries no files (SMS, Instagram), or fewer than you sent (X, more than one), is 422 channel_limit_exceeded with details.limit files_per_message, details.max the files it takes (0 for none) and details.actual how many you sent, a dry run included (see Refusals below). iMessage sends at most 6 messages a minute, a caption counting as one, so more than that at once is 422 imessage_send_cap_exceeded. On Telegram each file is a message, and so is a text sent with several: there must be room for all of them in the minute before the first goes, else it is 429 rate_limited with nothing sent (details.retry_after_ms). More than the minute can ever hold is 400 validation with details.reason_detail too_many_files, and details.limit is how many files fit. WhatsApp and iMessage files need a phone or Mac that can send files.
  • How a file goes out. As what its type is: a photo, a video, an audio file or a document. Never as a voice note or a sticker.
  • HEIC photos. iMessage sends them as they are. Every other channel sends a JPEG made from it when you send. A photo that cannot be converted is 422 heic_convert_failed; one not ready in time is 422 rendition_pending (details.retryable: true). Send it again in a moment.
  • Where a caption goes. On WhatsApp it is the first file's caption. On iMessage it is its own message after the last file. On Telegram and X it is the caption of a single file, and a message before several. A channel can have a shorter caption limit of its own (Telegram's is 1,024 characters on most accounts): send a longer text as its own message. Over Telegram's limit the send is 400 validation with details.reason_detail caption_too_long and nothing is sent; only Telegram knows your account's limit, so a dry run does not check it.
Request
{
  "contact_id": "3b2c1a90-5d7e-4a10-8c55-0a4f6f0b7d21",
  "text": "The report you asked for",
  "attachments": [{ "id": "90210" }]
}

Answer. to is { id, name, type }: the contact_id you sent, and the chat's name and type (null when unknown). channel is the channel it goes out on. attachments is the files it carries, in order, each { id, name, size, mime_type }; it is absent on a message without files. send is { id, status }:

send.statusHTTPMeaning
sent200The channel accepted it. This is final: there is no later status to read
sending202Your phone or Mac is sending it (WhatsApp, iMessage). Read how it ended with GET /v1/messages/sends/{id}
202 Accepted
{
  "send": { "id": "8f14e45f-ceea-4f7a-9a3b-2b6f0f2f9c11", "status": "sending" },
  "to": { "id": "3b2c1a90-5d7e-4a10-8c55-0a4f6f0b7d21", "name": "Ana Lee", "type": "private" },
  "channel": "whatsapp_personal"
}

A send that stopped partway. Files can go out as several messages, so a send can stop after some of it left: 422 partial_dispatch. Nothing can be taken back, so it is final, and it is charged as one automated send. details says what went:

422 partial_dispatch
{
  "error": {
    "code": "partial_dispatch",
    "message": "The send stopped partway: some of it went out and the rest did not",
    "details": {
      "send": { "id": "8f14e45f-ceea-4f7a-9a3b-2b6f0f2f9c11" },
      "dispatched_count": 1,
      "total_count": 3,
      "text_sent": true,
      "unsent_attachments": [{ "id": "90211" }, { "id": "90212" }],
      "failure_code": "bridge_offline",
      "user_message": "Only 1 of 3 attachments went out. The rest were not sent. …",
      "retryable": false
    }
  }
}

dispatched_count and total_count count files. text_sent says whether the text went out (absent when there was none). unsent_attachments is the files that did not go out, or whose going out could not be confirmed; failure_code says why. Check the chat, then send those alone: sending everything again repeats what already went. The same idempotency_key replays this answer.

Status. GET /v1/messages/sends/{id} answers { send: { id, status, failure_reason, updated_at }, channel, device } for one of your own sends in this workspace. status is sending, sent, failed (with failure_reason, one of these) or unconfirmed (the device could not say). A send of several files has one status, its weakest file's: one that failed makes it failed. Only WhatsApp and iMessage sends made through your phone or Mac have a status. The id of a send on any other channel answers 404 send_not_found, and so does an id that is not one of your sends.

Dry run. dry_run: true checks who it goes to, on which channel, whether you may send, and its files, and sends nothing: { would_send, to, channel }, with attachments when it carries files. A file that cannot be sent is refused as it is in a real send. When would_send is false, refusal is { code, message, details }, the error a real send would answer. It does not check that your phone or Mac will deliver the message, except that it reports a Mac where Pantheon is locked.

Retries. Send idempotency_key in the body (or the Idempotency-Key header; both must match when you send both, and a retry may move it from one to the other). For 24 hours from the first call, a retry with the same API key, the same idempotency_key and the same message never runs a send that may have gone a second time:

  • The first call finished. The retry gets the same answer with Idempotent-Replayed: true, an error included, and nothing is sent.
  • The answer was a 429, or an error with details.retryable: true (other than the 409 below). Nothing went out and the key is free, so the retry is a new attempt.
  • The answer was 504 outcome_unknown or 502 worker_unavailable. The message may have gone, and the key cannot tell you: the retry replays that answer. Check the chat before you send it under a new key.
  • The first call is still running, or its result could not be saved. The retry is 409 idempotency_in_flight. If it does not clear, the message may have gone: check the chat. A 503 idempotency_unavailable means the key could not be checked or the result could not be saved; retry with the same key, never a new one.
  • The key was used for a different message. 422 idempotency_key_reuse, and nothing is sent.

A call with no key, or from another API key, is always a new send. So can be one whose key is more than 24 hours old.

Refusals.

  • contact_not_accessible (404): not one of your chats, or it is on several channels. no_channel_owner (400): the contact has no channel to send on.
  • bridge_offline (422, details.retryable: true): no phone or Mac with Pantheon is connected.
  • bridge_not_ready (422, details.retryable: true): one is connected and cannot send yet; details.reason_detail says why (vault_locked: Pantheon is locked on the Mac).
  • no_consent (403): iMessage sending is not turned on for this account. no_channel_address (422): the contact has no address on the channel.
  • invalid_attachments (422): a file that cannot be sent. media_resolve_failed (422, details.retryable: true): the files could not be checked just now. duplicate_attachment and too_many_attachments (400): see Files above.
  • channel_limit_exceeded (422): the message is over its channel's own limits, and nothing is sent. details.limit says which (text_length, caption_length, files_per_message or file_bytes), details.max and details.actual give the numbers (characters, files or bytes), details.channel names the chat's channel as channel does in an answer, and details.kind the file's kind for a file over its size. For example, an SMS takes 1,600 characters, a caption on WhatsApp Business 1,024, an X DM one file, and a WhatsApp Business photo 5 MB.
  • partial_dispatch (422): some of it went out. See above.
  • rate_limited (429): too many sends at once; details.retry_after_ms.
  • automated_send_rate_limited (429, retryable): automated sends from your account are past their own share of the channel's per-minute limit, which keeps room for the messages the person types; nothing was sent, and details.retry_after_ms says when to try again.
  • automated_send_credits_needed (429): the month's included sends are used and the workspace's credits cannot cover this send; the workspace owner buys credits in Settings → Billing, and details.resets_at says when the included sends reset.
  • automated_send_cap_reached (429): the workspace's monthly ceiling of automated sends is reached, even with credits left; details.limit and details.left give the numbers and details.resets_at says when it resets.
  • automated_send_daily_cap (429, retryable): your account has sent as many automated messages on this channel as it may for the day or the hour, counted together with its MCP sends and routines; details.retry_after_ms says when to try again and details.limit is the day's cap. With details.reason cold it is the lower daily cap on messages to people who have never written to your account on this channel (50 a day on WhatsApp and Telegram, 25 on iMessage, SMS and X DMs, 10 on Instagram and Messenger): details.limit is that cap, and a message to someone who has written back still goes. A message to a group never counts toward it.
  • telegram_not_ready and sending_unavailable (503, details.retryable: true): nothing was sent; try again.

Price. Each real send is an automated send: 10¢, from the workspace usage pool while the plan's included sends for the month last, then from the workspace's bought credits only, counted in one month shared across the API, MCP and routines. A message with files is one, however many, and so is one that stopped partway. A dry run and a status each cost one data call. A send refused before anything went out and a replay cost nothing.

POST
/v1/messages/send

Authorization

apiKeyAuth
AuthorizationBearer <token>

Developer API key — Authorization: Bearer pk_live_...

In: header

Header Parameters

Idempotency-Key?string

Optional. Any unique string (a UUID v4 is a good choice). A retry with the same key and the same request replays the first answer (Idempotent-Replayed: true) for 24 hours; one key belongs to one API key.

Length1 <= length <= 255

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.pantheon.run/v1/messages/send" \  -H "Content-Type: application/json" \  -d '{}'
{
  "attachments": [
    {
      "id": "string",
      "mime_type": "string",
      "name": "string",
      "size": 0
    }
  ],
  "channel": "string",
  "refusal": {
    "code": "string",
    "details": {},
    "message": "string"
  },
  "send": {
    "id": "string",
    "status": "sent"
  },
  "to": {
    "id": "string",
    "name": "string",
    "type": "private"
  },
  "would_send": true
}
{
  "attachments": [
    {
      "id": "string",
      "mime_type": "string",
      "name": "string",
      "size": 0
    }
  ],
  "channel": "string",
  "refusal": {
    "code": "string",
    "details": {},
    "message": "string"
  },
  "send": {
    "id": "string",
    "status": "sent"
  },
  "to": {
    "id": "string",
    "name": "string",
    "type": "private"
  },
  "would_send": true
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "code": "string",
  "error": "string",
  "message": "string",
  "statusCode": 0
}
{
  "code": "string",
  "error": "string",
  "message": "string",
  "statusCode": 0
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
GET
/v1/messages/sends/{id}

Authorization

apiKeyAuth
AuthorizationBearer <token>

Developer API key — Authorization: Bearer pk_live_...

In: header

Path Parameters

id*string

send.id from POST /v1/messages/send.

Lengthlength <= 64

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://api.pantheon.run/v1/messages/sends/string"
{
  "channel": "string",
  "device": "string",
  "send": {
    "failure_reason": "string",
    "id": "string",
    "status": "sending",
    "updated_at": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}
{
  "error": {
    "code": "string",
    "details": {},
    "message": "string"
  }
}