> Mapier API rules for agents: > 1. Send an `Idempotency-Key` and an `x-mapier-version` header on every command. The key is optional, but without one a retry is a second send. > 2. A `202` means queued, not delivered. Read the result on `GET /v1/response_stream`. > 3. Check a feature before you promise it. `GET /v1/capabilities` covers every channel, `lines[].capabilities` on `GET /v1/whoami` covers one line, and `POST /v1/commands/{type}/check` covers one call. If a request is refused, read `error.details` and follow its `remedy` when it has one. > 4. Reply with `target.conversationId`. On a new send, name `target.channel`. > 5. Never fall back to another channel, and never resend a command whose result is `ambiguous`. > Full list: https://docs.mapier.ai/skill.md # Channel support (https://docs.mapier.ai/convo/api/channel-support) > Every feature on every channel, in one table A green check means the feature works today. **Soon** means Mapier is adding it, and refuses requests for it until then. A grey dash means the channel itself does not offer it. | Feature | iMessage | WhatsApp | | --- | :---: | :---: | | [Text](https://docs.mapier.ai/convo/guides/send/text) | Yes | Yes | | [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files) | Yes | Yes | | [Several files with text, as one message](https://docs.mapier.ai/convo/guides/send/images-and-files#send-a-photo-with-text) | Yes | Not supported by WhatsApp | | [Links](https://docs.mapier.ai/convo/guides/send/links) with a preview card | Yes | Yes | | [Stickers](https://docs.mapier.ai/convo/guides/send/stickers) | Yes | Yes | | [Ask for the person's location](https://docs.mapier.ai/convo/guides/send/location#ask-for-a-location) | Yes | Yes | | [Send a place](https://docs.mapier.ai/convo/guides/send/location#send-a-place) | Yes | Yes | | [Share your line's contact card](https://docs.mapier.ai/convo/guides/send/contact-cards#share-your-lines-card) | Yes | Not supported by WhatsApp | | [Send someone's contact card](https://docs.mapier.ai/convo/guides/send/contact-cards#send-someones-contact-card) | Yes | Yes | | [Buttons and lists](https://docs.mapier.ai/convo/guides/send/buttons-and-lists) | Not supported by iMessage | Yes | | [Templates](https://docs.mapier.ai/convo/guides/send/templates) | Not supported by iMessage | Yes | | [Polls](https://docs.mapier.ai/convo/guides/send/polls) | Yes | Not supported by WhatsApp | | [App cards](https://docs.mapier.ai/convo/guides/send/app-cards) | Yes | Not supported by WhatsApp | | [Effects](https://docs.mapier.ai/convo/guides/send/effects) | Yes | Not supported by WhatsApp | | [Reactions](https://docs.mapier.ai/convo/guides/send/reactions) | Yes | Yes | | [Edit and unsend](https://docs.mapier.ai/convo/guides/send/edit-and-unsend) | Yes | Not supported by WhatsApp | | [Typing indicator](https://docs.mapier.ai/convo/guides/send/typing-and-read) | Yes | Yes | | [Mark a conversation read](https://docs.mapier.ai/convo/guides/send/typing-and-read) | Yes | Yes | | [Group conversations](https://docs.mapier.ai/convo/guides/conversations/groups) | Yes | Not supported by WhatsApp | | [Create, rename and leave groups](https://docs.mapier.ai/convo/guides/conversations/groups) | Yes | Not supported by WhatsApp | | [Chat backgrounds](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) | Yes | Not supported by WhatsApp | | [Name and photo](https://docs.mapier.ai/convo/guides/lines/name-and-photo) | Yes | Not supported by WhatsApp | | [Receive images and files](https://docs.mapier.ai/convo/guides/receive/incoming-messages) | Yes | Yes | | [Shared locations from the person](https://docs.mapier.ai/convo/guides/send/location#receive-a-location) | Yes | Not supported by WhatsApp | | [The person's edits and unsends](https://docs.mapier.ai/convo/guides/send/edit-and-unsend#hear-when-a-person-edits-or-unsends) | Yes | Not supported by WhatsApp | | [Poll votes](https://docs.mapier.ai/convo/guides/send/polls#read-the-votes) | Yes | Not supported by WhatsApp | | [Delivered status](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) | Yes | Yes | | [Read status](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) | Yes | Yes | | [Check an address before sending](https://docs.mapier.ai/convo/guides/production/check-before-you-send) | Yes | Not supported by WhatsApp | The same data, as JSON: [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities). # Check a command (https://docs.mapier.ai/convo/api/commands/check) > Ask whether a command would be accepted now, without sending it **POST** `/v1/commands/{type}/check` Would `POST /v1/commands/{type}` with this same body and these same headers be accepted now? The check runs every rule the send runs, in the same order, and sends nothing, writes nothing and never uses up the `Idempotency-Key`. Use it to decide before you send: which line a send would use, whether the person can be reached on it, and what `options.degrade: "adapt"` would change. The answer is always `200`. `accepted: false` carries `refusal`, the exact error body the send would answer with, so one handler reads both. A media link is not fetched, so a link the send cannot fetch is accepted here and refused by the send. A check spends the project's command budget as a send does. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/commands/message.send/check \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-shipped" \ -H "x-mapier-version: 2026-12-01" \ -d '{"target": {"conversationId": "a0000000-0000-4000-8000-000000000001"}, "payload": {"text": "Your order shipped."}}' ``` ## Response [#response] ```json title="200 OK" { "accepted": true, "line": { "id": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "selection": "reused_active_chat" }, "channel": "imessage", "adaptations": [] } ``` A refused check names the refusal the send would answer with: ```json title="200 OK" { "accepted": false, "refusal": { "error": { "code": "recipient_not_allowed", "message": "That person replied STOP. They opt back in by texting START or writing to this project again; until then this project cannot message them.", "details": { "reason": "opted_out", "channel": "imessage" }, "requestId": "0192c4e1-8b3c-7d4e-9f50-6a7b8c9d0e1f", "docUrl": "https://docs.mapier.ai/convo/api/errors#recipient_not_allowed.opted_out", "retryable": false } }, "line": null, "channel": null } ``` Only a refusal of the check itself is an error status: a key that is not valid, a body over the size limit, an unknown version, a key without `messages:send`, or a spent command budget. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:send` scope | | `404` | `not_found` | With a personal access token, an `x-mapier-project` it cannot reach | | `409` | `project_archived` | The project is archived | | `413` | `payload_too_large` | The body is over 65,536 bytes | | `422` | `validation_failed` | An `x-mapier-version` that is not a published version — the body's own refusals come back as `accepted: false` | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | A service behind Mapier did not answer; check again | ## Guide [#guide] - [Check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send) # Get a command (https://docs.mapier.ai/convo/api/commands/get) > What happened to a command, by the id its 202 handed back **GET** `/v1/commands/{commandId}` What happened to a command: `queued` until it ends, then exactly what its `command` event on the [stream](https://docs.mapier.ai/convo/api/events/stream) carried, with `settledAt`. Read it when your integration restarted or lost the stream. A finished command is kept for 90 days. Each read counts against the project's command budget. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/commands/3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71 \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "commandId": "3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71", "logicalActionId": null, "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000001", "type": "message.send", "messageId": "0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a99", "externalId": "8C2E4A61-3B7D-4F90-A1C5-6D8E0F2B4A73", "platformMessageId": "8C2E4A61-3B7D-4F90-A1C5-6D8E0F2B4A73", "namePhoto": null, "group": null, "appCard": null, "projectId": "0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "environment": "live", "failureClass": null, "settledAt": "2026-10-18T18:01:03.000Z" } ``` `commandId` is the one a `202` handed back, or a `parts[].commandId` of a send that went out as several messages. A command another project sent is a `404`, the same answer as an id that never existed. The body is the `command` event's: `platformMessageId` is the channel's own id for the message the command wrote, and `externalId` carries the same value under its older, deprecated name. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | --------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | No command with that id in this project | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` that is not a published version | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | A service behind Mapier did not answer; retry with backoff | ## Guide [#guide] - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # How commands work (https://docs.mapier.ai/convo/api/commands) > One endpoint for every command, with one envelope, one answer and the rules they share **POST** `/v1/commands/{type}` Every action you take on a line is a command. They all share one endpoint, one request envelope and one response shape; the `{type}` path segment names the command. ## Request [#request] ### Headers [#headers] - Authorization: string — Bearer credential. See Authentication. - Content-Type: "application/json" - Idempotency-Key?: string — Up to 200 characters; at least one, no control character and no whitespace at either end. Anything else is 422 validation_failed at Idempotency-Key, and the key is never trimmed — a trimmed key is a different key. Send the same key again and the first command is returned instead of a new one, on every type; a message.send no channel ever took is refused with 409 conflict instead. Omit the header and a key is made for this request alone, so a retry is a new command. - x-mapier-version?: string (2026-09-01 | 2026-10-01 | 2026-10-15 | 2026-12-01) — The dated behavior your integration is written against; omitted means your project's default. This reference describes 2026-12-01. See Versions. ### Body [#body] - target?: object — Who the command acts on: conversation, recipient or new_group — or, for profile.get and profile.set, the line. A recipient or new_group target may also name the line the command goes out on at target.lineId, which then names the channel too. Defaults to {}. A message.send whose target names nobody is 422 validation_failed at target.recipientExternalId. - payload?: object — What to do. Shape depends on the command type. Defaults to {}, for commands that take no arguments. - options?: object ({ ifUnsupported?: refuse | skip, degrade?: strict | adapt }) — How to treat what the line cannot carry. Omit it for the default: refuse, never reshape. ifUnsupported: skip, on typing.start or conversation.mark_read only, answers 200 with skipped: true instead of a refusal and sends nothing; on any other type it is a 422. degrade: adapt lets Mapier drop or split a part the channel cannot carry, such as an effect, and says what it changed in the 202's adaptations. The body is capped at **65,536 bytes**. Both keys default to `{}`, so a command whose whole meaning is its type needs no body at all. A body you do send must be JSON, and one that is not an object, or whose `target` or `payload` is not an object, is `422 validation_failed`. See [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it) for the target shapes. ## Command types [#command-types] The `{type}` values the [OpenAPI document](https://docs.mapier.ai/convo/api#the-openapi-document) publishes, each with its page: | Type | Purpose | Reference | | ------------------------ | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------- | | `message.send` | Send a message | [message.send](https://docs.mapier.ai/convo/api/messages/send) | | `reaction.set` | React to a message with one emoji | [reaction.set](https://docs.mapier.ai/convo/api/reactions/add) | | `reaction.remove` | Take back a reaction the line added | [reaction.remove](https://docs.mapier.ai/convo/api/reactions/remove) | | `profile.share` | Offer the line's name and photo in a one-to-one conversation | [profile.share](https://docs.mapier.ai/convo/api/line-profile/share) | | `typing.start` | Show the typing bubble in a one-to-one conversation the person has written in | [typing.start](https://docs.mapier.ai/convo/api/conversations/show-typing) | | `conversation.mark_read` | Mark the person's messages read in a one-to-one conversation | [conversation.mark_read](https://docs.mapier.ai/convo/api/conversations/mark-read) | | `message.edit` | Change the text of a message the line sent, within 15 minutes | [message.edit](https://docs.mapier.ai/convo/api/messages/edit) | | `message.unsend` | Take back a message the line sent, within 2 minutes | [message.unsend](https://docs.mapier.ai/convo/api/messages/unsend) | | `profile.get` | Read the line's own name and photo | [profile.get](https://docs.mapier.ai/convo/api/line-profile/get) | | `profile.set` | Set the line's own name and photo | [profile.set](https://docs.mapier.ai/convo/api/line-profile/set) | | `poll.vote` | Vote on a poll in a conversation, by the ids its `poll.created` event carried | [poll.vote](https://docs.mapier.ai/convo/api/messages/vote-in-poll) | | `group.create` | Start a group chat | [group.create](https://docs.mapier.ai/convo/api/groups/create) | | `group.update` | Rename a group chat or change its members | [group.update](https://docs.mapier.ai/convo/api/groups/update) | | `group.leave` | Leave a group chat; it cannot be undone | [group.leave](https://docs.mapier.ai/convo/api/groups/leave) | | `chat_background.set` | Set the background of a conversation, to a preset, two colors of your own or a photo | [chat_background.set](https://docs.mapier.ai/convo/api/conversations/set-background) | | `chat_background.remove` | Remove the background of a conversation | [chat_background.remove](https://docs.mapier.ai/convo/api/conversations/remove-background) | | `app_card.update` | Replace an iMessage app card your line sent, in place | [app_card.update](https://docs.mapier.ai/convo/api/messages/update-app-card) | | Type | Purpose | Reference | | ----------------------- | --------------------------------------------------------------- | ------------------------------------------------- | | `whatsapp.group.create` | Make a WhatsApp group and get the invite link people join it by | [whatsapp.group.create](https://docs.mapier.ai/convo/api/groups/create) | `whatsapp.group.create` belongs to WhatsApp. Sent to a line on any other channel, it is `404 unsupported_command` with `reason: not_on_channel`. A few older command names still work. Each is deprecated, and the page of the command that replaces it says so in one line. ### Two refusals, before anything is queued [#two-refusals-before-anything-is-queued] A type outside the vocabulary is a `404` at once, before the body is read: ```json title="POST /v1/commands/message.delete — 404" { "error": { "code": "unsupported_command", "message": "`message.delete` is not a command Mapier knows." } } ``` A type the line cannot carry is a `404` too, raised once the line is resolved and before anything is written. `details.reason` says which case it is: - `not_on_channel`: no line of that channel carries the type. `details` names the `channel` and the `capability` the command needed. - `not_on_line`: the channel carries the type and this line reports that it cannot. On `typing.start` or `conversation.mark_read`, send `options.ifUnsupported: "skip"` to get `200` with `skipped: true` instead. Branch on `details.reason`, never on `message`. [Channel support](https://docs.mapier.ai/convo/api/channel-support) and `GET /v1/whoami`'s [`lines[].capabilities`](https://docs.mapier.ai/convo/api/discovery/get-key-details#feature-detect-on-capabilities) say what each line can do before you send. Older versions answer `not_on_line` differently; see [Versions › Older versions](https://docs.mapier.ai/convo/api/versions#older-versions). ## Response [#response] `202 Accepted`: ```json { "commandId": "3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` `lineId` is the line the command went out on, as [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists it. `lineSelection` says why that line: `named`, `reused_active_chat` or `new_best_line`, explained in [The shape of every response](https://docs.mapier.ai/convo/api#the-shape-of-every-response). `repeated` is `true` when the `Idempotency-Key` matched a command already made: nothing new was queued, and `commandId` is the first command's. `status` is `"queued"` on every `202`, a repeat included. It says the command was accepted, never how it ended. A repeated key with nothing to return is not a `202` at all: a `message.send` whose first attempt is still running, or that no channel ever took, is a `409 conflict` (see [Errors](#errors)). The response tells you the command was queued. It does not tell you the message was delivered. Watch the [response stream](https://docs.mapier.ai/convo/api/events/stream) for the `command` event that ends it. ## Idempotency [#idempotency] Every command honors `Idempotency-Key`: a repeat of a key returns the first command and never runs it twice. A `message.send` is recorded against its key by Mapier before the line is asked, so a retried send is never posted twice. It is returned when a channel took the first attempt, and refused with `409 conflict` when none did. A retry of an attempt that got no answer is `409 conflict` with `reason: idempotency_key_in_flight` while it may still be running, and `idempotency_key_unresolved` after. It is never sent again. The result's `logicalActionId` carries your key. On an iMessage line, `group.create` carries a copy of its `commandId` instead. Correlate by `commandId`. See [Idempotency and retries](https://docs.mapier.ai/convo/guides/production/retries). ## What is checked before anything is queued [#what-is-checked-before-anything-is-queued] The body first: over 65,536 bytes is `413 payload_too_large`, and not JSON is `400 bad_request`. A body, `target` or `payload` that is not an object is `422 validation_failed`. So is a target that names nobody (at `target.recipientExternalId`), and an `Idempotency-Key` that is empty, over 200 characters, holds a control character or has whitespace at either end (at `Idempotency-Key`). A `message.send` payload is checked against the line the send resolves to. A key the line does not carry that carries a value, a `kind` or a misspelled field included, is `422 validation_failed` at `payload.`. So is a send with no text, at `payload.text`. See [What a line carries](https://docs.mapier.ai/convo/api/messages/send#what-a-line-carries). An iMessage line also refuses what the conversation cannot carry, with the same code and nothing written; [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it) lists each case: - an email address sent to someone the line has no conversation with, at the target field you wrote it at; - a group chat the channel has not reported yet, at `target.conversationId`; - a reply the line cannot quote, at `target.replyToMessageId`. On an iMessage line Mapier also checks how other commands are addressed, and refuses each with `422 validation_failed` before anything is sent: - a `profile.share` names, at `target.conversationId`, a conversation the person has written in; - a `group.create` names 2 to 32 other people at `target.participantExternalIds`, each an address the channel reads, counted once. The first is the command's recipient. One the channel cannot read, the first included, is refused at `target.participantExternalIds[i]` (or the key and index you wrote); - a `group.update` or a `group.leave` names, at `target.conversationId`, a group chat. An update's action and its `name` or `participantExternalId` are checked too, and a leave's payload must be empty; - a `chat_background.set` or a `chat_background.remove` names, at `target.conversationId`, a one-to-one conversation the person has written in, or a group chat. A set's `payload.preset`, `payload.colors` and `payload.photoUrl` are checked too, and a remove's payload must be empty; - a `message.edit` or a `message.unsend` names, at `target.messageId`, a message this line sent in that conversation, which has a channel id and is inside its window. An edit's `payload.text` is checked too; - a `profile.get` or a `profile.set` names, at `target.lineId`, one of your project's lines (any other id is `403 line_not_allowed`). A set's payload is checked too, and its photo link fetched; - a `message.send`, or any command addressed to a person, that names a line at `target.lineId` names one of your project's lines (any other id is `403 line_not_allowed`), on the channel `target.channel` names if it names one and, beside a `conversationId`, the line that conversation is on; - a `typing.start` names, at `target.conversationId`, a one-to-one conversation the person has written in; - a `conversation.mark_read` names the same, and an optional `payload.externalId` is checked too; - a `poll.vote` names, at `target.conversationId`, a conversation the person has written in, a group's included, and the poll and the choice at `payload.pollExternalId` and `payload.optionExternalId`. `payload.remove` and any other key are refused; - an `app_card.update` names, at `target.messageId`, a card your line sent, any update of it, or a card the person sent that replaced it. Its `url` and `layout` are checked too, and a card that cannot be updated is refused with `reason: card_not_updatable`. A `message.send` of `kind: "app_card"` names, at `payload.app`, an app your organization holds, by its registered name. Mapier checks no other command's payload. The channel checks `profile.share` before it takes it, and that refusal comes back as a `422 validation_failed` too, or a `400 bad_request`, with the channel's word as the `reason`. A `group.create` payload is otherwise checked only when the line runs it. So in a `profile.share` or `group.create` payload, a misspelled field, an out-of-range value or a bad enum can return `202` and end `failed` on the stream seconds later. When you are developing against a new payload shape, keep the stream open. A [`sticker`](https://docs.mapier.ai/convo/guides/send/stickers) and a [`link`](https://docs.mapier.ai/convo/guides/send/links) are checked by Mapier as a text is: every bound at its own field, `422 validation_failed` before anything is queued. What the line can still refuse is its own capability: the result ends `failed` with `capability_constraint_violation`. ## Errors [#errors] | Status | Code | Cause | | ------ | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | Body is not JSON, or the channel refused the request as malformed (`details.reason` is its word); or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:send` scope | | `403` | `line_not_allowed` | `target.lineId` is not one of your project's lines; `details.reason` is `not_owned` and `details.lineId` the id sent. `GET /v1/whoami` lists the lines the key can use | | `403` | `recipient_not_allowed` | The person cannot be sent to: `details.reason` is `opted_out`, `blocked`, `paused`, `outside_service_window`, `recipient_must_write_first` (no one but your line has written in the conversation, or on a test line on a shared number the person is not connected) `app_card_needs_imessage` (an app card into a conversation whose newest message did not go by iMessage) or `group_member_not_test_contact` (on a test line on a shared number, someone in the group is not one of this project's connected Test contacts) | | `404` | `unsupported_command` | Unknown `{type}`, or one the line cannot carry: `details.reason` is `not_on_channel` (no line of the channel carries it) `not_on_line` (this line does not) or `shared_line` (a test line on a shared number does not) | | `404` | `not_found` | Unknown conversation, or another project's | | `409` | `conflict` | The `Idempotency-Key` is taken and there is nothing to return, and `details.reason` says why: `idempotency_key_in_flight` (the first attempt is still running: wait, and retry with the same key), `idempotency_key_failed` (it was refused and not sent: send again under a new key, only the parts not in `details.sentParts` when it names any), `idempotency_key_unresolved` (its outcome is unknown: check the conversation first) or `idempotency_key_reused` (the key already named a different command). For `app_card.update`, `card_update_in_flight`: the card's last send has not finished; wait for its result and send the update again. Or the channel refused the command for a reason of its own, such as `group_has_no_messages_yet` (a member change in a group with no message yet: send a message into it first); such a reason may add `details.retryAfter`, the seconds to wait. See [Idempotency and retries](https://docs.mapier.ai/convo/guides/production/retries#when-a-key-is-refused) | | `409` | `conversation_closed` | The group is closed: your line can no longer reach it, and nothing was sent. `details.reason` is `removed`, `deleted`, `archived` or `suspended`, and `details.conversationId` names the group. It lifts once the group is active again; see [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) | | `409` | `limit_reached` | A daily cap on this line is reached; today only a test line on a shared number has one | | `409` | `project_archived` | The project is archived | | `413` | `payload_too_large` | Body over 65,536 bytes | | `422` | `validation_failed` | A field is wrong, and `details` names it: a non-object body, an `Idempotency-Key` outside its rule, a `message.send` field the line does not carry, or an address, reply, conversation, message, participant, line or payload a command cannot be addressed by (see [What is checked](#what-is-checked-before-anything-is-queued)) | | `429` | `rate_limited` | 600 requests per minute, per project by default; `GET /v1/whoami` reports your project's own (see [Rate limits](https://docs.mapier.ai/convo/api/rate-limits)). The `Retry-After` header says how long to wait (a channel's own rate limit may give the same seconds in `details.retryAfter` too). On a test line on a shared number, `details.reason` `shared_line` is that line's own budget. For `app_card.update`, `card_update_limit`: the card has had 50 updates in the past hour; wait `details.retryAfter` seconds | | `429` | `sandbox_budget_exhausted` | Not returned today. Handle it like `rate_limited` | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `no_line` | No active line on the channel | | `503` | `capacity_exhausted` | Every line is full | | `503` | `line_unavailable` | The line cannot send right now: `details.reason` is `line_paused`, `line_retired`, `transport_down`, `transport_unconfigured` or `channel_not_available` | | `503` | `upstream_unavailable` | The channel did not take the command: `details.reason` is its word, such as `connector_unavailable` (the line is offline) or `outbound_paused` (sending is paused), or `timeout`, `network` or `status_5xx` when no usable answer came back. A `message.send`'s key is then spent: resend it under a new key | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and send the same request | Older versions use other words for two of these; see [Versions › Older versions](https://docs.mapier.ai/convo/api/versions#older-versions). Full descriptions and retry guidance: [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Key concepts](https://docs.mapier.ai/convo/guides/get-started/key-concepts) - [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Find a conversation (https://docs.mapier.ai/convo/api/conversations/find) > Find the conversation a line has with an address, before that person writes again **POST** `/v1/conversation-lookup` Returns the id of the one-to-one conversation a line has with an address: the id `target.conversationId`, [`GET /v1/conversations/{conversationId}/messages`](https://docs.mapier.ai/convo/api/conversations/list-messages) and the stream's events use. Use it when you need that id before the person writes again, for example when you move your own message history onto this API and have people you last talked to before you started streaming. On an iMessage line Mapier also asks the line itself, which knows conversations from before the line's first message through Mapier. When the line knows a conversation Mapier has no record of yet, Mapier opens it, the way a first send would, and emits `conversation.created`. Nothing is sent, and no contact is created. The person's next message, and your next send to them, land in the conversation the lookup named. Like the [handle check](https://docs.mapier.ai/convo/api/discovery/check-an-address), this is a **synchronous read**: the answer is in the HTTP response, and nothing arrives on the stream. ## Body [#body] - lineId: string (UUID) — The line, as GET /v1/whoami lists it. A line this key cannot see is 404 not_found. - address: string (1 to 320 characters) — The other person's address, in any form the line's channel accepts — on iMessage an E.164 number or an Apple ID email. It is parsed by that channel's own rules, and one the channel cannot read is 422 validation_failed at address. ```bash tab="cURL" curl https://api.mapier.ai/v1/conversation-lookup \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ -H "Content-Type: application/json" \ -d '{ "lineId": "0195f3a2-5c1e-7b4d-9a8e-2f6c1d3b4a50", "address": "+14155550100" }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/conversation-lookup`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", "Content-Type": "application/json", }, body: JSON.stringify({ lineId: "0195f3a2-5c1e-7b4d-9a8e-2f6c1d3b4a50", address: "+14155550100", }), }); // 404 means the line has never had a conversation with this address. // A 503 is not a 404: the question could not be asked, so ask again later. const { id, firstObservedAt } = await res.json(); ``` ## Response [#response] ```json title="200" { "id": "0195f3a2-6d2f-7c5e-8b9f-3a7d2e4c5b61", "isGroup": false, "firstObservedAt": "2026-07-14T09:30:00.000Z" } ``` - id: string (UUID) — The conversation's id: what target.conversationId, GET /v1/conversations/{conversationId}/messages and the stream's events use. - isGroup: boolean — Always false: this finds the one-to-one conversation with an address. - firstObservedAt: string | null (ISO 8601) — When the line's channel first saw this conversation, as it reports it; on iMessage this can be before the line's first message through Mapier. Null when the channel does not say: a channel that keeps no history, or one that could not be asked this time. ## When there is no conversation [#when-there-is-no-conversation] `404 not_found` means the line has no conversation with the address: the line's channel said so, or the line keeps no history to ask (a retired line, or a channel that keeps none) and Mapier has no conversation with the address either. A line this key cannot see is the same `404`, with a message that says so. A `404` is never the answer when the channel could not be asked. ## When the lookup cannot run [#when-the-lookup-cannot-run] When the line's channel could not be asked, the lookup never answers `404`. If Mapier already has the conversation, the answer is still a `200`, with `firstObservedAt: null`. If it does not, you get the channel's refusal, a `503 upstream_unavailable` or `503 line_unavailable` with `details.reason`, and the question is worth asking again later. ## Errors [#errors] | Status | Code | Cause | | ------ | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | The body is not JSON, or the channel refused the request as malformed (`details.reason` is its word); or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | The line has never had a conversation with the address, or the line is not one this key can see | | `404` | `unsupported_command` | `reason: shared_line`: the line is a test line on a shared number, which does not answer this lookup | | `409` | `project_archived` | The project is archived | | `413` | `payload_too_large` | Body over 65,536 bytes | | `422` | `validation_failed` | `lineId` is not a UUID, or `address` is missing or not a form the line's channel accepts | | `429` | `rate_limited` | 30 requests per minute, per key; the `Retry-After` header says how long to wait (a channel's own rate limit may give the same seconds in `details.retryAfter` too) | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `line_unavailable` · `upstream_unavailable` | The line's channel could not be asked (see [When the lookup cannot run](#when-the-lookup-cannot-run)); `details.retryAfter`, when present, says when to ask again | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and ask again | ## Guide [#guide] - [List messages](https://docs.mapier.ai/convo/api/conversations/list-messages) - [Send a message](https://docs.mapier.ai/convo/api/messages/send) # Get a conversation (https://docs.mapier.ai/convo/api/conversations/get) > One conversation as it stands, with a group's name and members or the person it is with **GET** `/v1/conversations/{conversationId}` One conversation as Mapier knows it. For a group: its name, its members, and whether your line can still reach it. For a direct conversation: the person it is with. Read it when `conversation.created` names a group, and whenever you need a group's members, which no event carries in full. ```bash curl "https://api.mapier.ai/v1/conversations/a0000000-0000-4000-8000-000000000001" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```json title="200 OK" { "conversationId": "a0000000-0000-4000-8000-000000000001", "channel": "imessage", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "kind": "group", "title": "Trip to Lisbon", "status": "active", "statusReason": null, "peerAddress": null, "participants": [ { "address": "+14155550100", "contactId": "0192a7c0-4444-7555-8666-777788889999", "displayName": null }, { "address": "sam@icloud.com", "contactId": null, "displayName": null } ], "createdAt": "2026-10-18T17:55:02.000Z", "lastMessageAt": "2026-10-18T18:03:11.000Z" } ``` ## Parameters [#parameters] - conversationId: string (UUID, in the path) — A conversation id this key can read — the conversationId of a message or command event. A `conversationId` comes from `message` events, command results, the `conversation.created` event and [`GET /v1/conversations`](https://docs.mapier.ai/convo/api/conversations/list), which lists a line's conversations. ## Response [#response] - conversationId: string (UUID) — Mapier's id for the conversation, the target.conversationId a send names. - channel: string (imessage | whatsapp) — The channel the conversation is on. - lineId: string | null (UUID, or null) — The line the conversation is on. Null only when that line was released from the project. - kind: string (direct | group) — direct: one person and your line. group: a group conversation your line is in. - title: string | null — The group's name as the channel shows it. Null for a direct conversation, and for a group with no name. - status: string (active | closed) — active, or closed when your line can no longer reach the group. A send into a closed conversation is refused with 409 conversation_closed. - statusReason: string | null (removed | deleted | archived | suspended, or null) — Why the group is closed. Null while the conversation is active. - peerAddress: string | null — The person a direct conversation is with, as the channel names them. Null for a group. - participants: object[] ({ address, contactId, displayName }) — A group's members as Mapier knows them, your line excluded. address is the from address their messages carry; contactId is Mapier's id for them, or null when this project has no contact for them; displayName is the name the channel shows for them, or their contact's name, or null. Empty for a direct conversation. - createdAt: string (ISO 8601) — When Mapier first saw the conversation. - lastMessageAt: string | null (ISO 8601, or null) — When the newest message in it was sent or received. Null when it has none. ## A group's status [#a-groups-status] A group is `active` while your line can reach it, and `closed` once it cannot. `statusReason` says why: | `statusReason` | What happened | | -------------- | ------------------------------------------------------------------------------------------- | | `removed` | Your line is no longer in the group: it was removed, or a send found the group out of reach | | `deleted` | The channel deleted the group | | `archived` | The group was archived | | `suspended` | The channel suspended the group | A group closed as `deleted`, `archived` or `suspended` keeps that reason when your line is then removed or a send finds the group out of reach. A group closed as `removed` changes to `deleted`, `archived` or `suspended` if one of those happens later. The reason can change while the group stays closed, with no new `conversation.status_changed`: `statusReason` here is the current one. A closed group is `active` again once your line is added back, the group is unarchived, the suspension is lifted, or a new message arrives in it. `conversation.status_changed` announces each move, and a send into a closed group is [`409 conversation_closed`](https://docs.mapier.ai/convo/api/errors/conversation_closed). A direct conversation is always `active`. On iMessage a group closes as `removed` when your line's `group.leave` ends `succeeded`. iMessage does not tell your line when someone else removes it, so the group stays `active` and a send into it ends `failed`. See [Groups](https://docs.mapier.ai/convo/guides/conversations/groups#leave-a-group). ## Which members are listed [#which-members-are-listed] `participants` is the group's membership as Mapier knows it, your line excluded. On iMessage that is every member. Where a channel does not report a group's whole membership, it is the people who have joined or written since your line was in the group. `conversation.updated` announces each change to the list and to `title`. See [Conversation events](https://docs.mapier.ai/convo/guides/conversations/groups). ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | A conversation this key cannot read — another project's — the same answer a made-up id gets | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | A `conversationId` that is not a UUID, or an `x-mapier-version` that is not a published version | | `429` | `rate_limited` | Over 120 requests a minute for this key, shared with the list and history reads — see [Rate limits](https://docs.mapier.ai/convo/api/rate-limits) | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and ask again | | `503` | `upstream_unavailable` | A service behind Mapier did not answer; retry with backoff | ## Guide [#guide] - [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) - [List messages](https://docs.mapier.ai/convo/api/conversations/list-messages) - [List conversations](https://docs.mapier.ai/convo/api/conversations/list) # List messages (https://docs.mapier.ai/convo/api/conversations/list-messages) > A conversation's history, newest first, both ways **GET** `/v1/conversations/{conversationId}/messages` A conversation's history, newest first, both ways: what the contact sent you and what you sent them. This is how to read what was said before you were streaming — the stream starts from now, or from an event id you already hold. Catching up after a dropped connection is still [`Last-Event-ID`](https://docs.mapier.ai/convo/api/events/stream#resuming-with-last-event-id) on the stream, which replays every event, not only messages; to read every event back across conversations, use [`GET /v1/events`](https://docs.mapier.ai/convo/api/events/list). ```bash curl "https://api.mapier.ai/v1/conversations/a0000000-0000-4000-8000-000000000001/messages?limit=2" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```json title="200 OK" { "messages": [ { "conversationId": "a0000000-0000-4000-8000-000000000001", "from": "+14155550100", "text": "is it here yet?", "externalId": "5D1B7E0A-2F3C-4B8E-9A61-1C2D3E4F5A6B", "replyToExternalId": null, "occurredAt": "2026-08-24T18:03:11.000Z", "attachmentIds": [], "attachments": [], "messageId": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22", "direction": "inbound", "status": null, "commandId": null }, { "conversationId": "a0000000-0000-4000-8000-000000000001", "from": "+14155550142", "text": "Your order is on its way.", "externalId": "8C2E4A61-3B7D-4F90-A1C5-6D8E0F2B4A73", "replyToExternalId": null, "occurredAt": "2026-08-24T18:01:02.000Z", "attachmentIds": [], "attachments": [], "messageId": "0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a99", "direction": "outbound", "status": "delivered", "commandId": "3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71" } ], "nextCursor": "eyJiZWZvcmUiOiIyMDI2LTEwLTExVDA5OjEyOjQwWiJ9" } ``` ## Parameters [#parameters] - conversationId: string (UUID, in the path) — A conversation id this key can read — the conversationId of a message or command event. - cursor?: string (at most 200 characters) — The nextCursor of the page before, to read the next, older page. Omit it for the newest page. - limit?: integer (1 to 100, default 25) — How many messages a page holds. A `conversationId` comes from `message` events, command results, the `conversation.created` event and [`GET /v1/conversations`](https://docs.mapier.ai/convo/api/conversations/list), which lists a line's conversations. [`GET /v1/conversations/{conversationId}`](https://docs.mapier.ai/convo/api/conversations/get) reads the conversation itself: a group's name, members and status. Page with `cursor`: pass each answer's `nextCursor` back until it is `null`. A cursor past the last page answers an empty page. A cursor is opaque: never build or parse one. ## Response [#response] `messages` is one page, newest first, and `nextCursor` is the cursor for the next, older page, or `null` on the last. Each row is the stream's [`message` event](https://docs.mapier.ai/convo/api/events/stream#event-message), with the same ids — `messageId` is the one to reply to, and `lineId` the line the message is on (the line an inbound one arrived on, or the one an outbound one went out from), plus three fields. An inbound row carries what its `message` event carried — `addressed`, `fromDisplayName`, `platform`, `replyTo`, `contactId` and the rest — except `optedOut`, which was the sender's choice at that moment, and an attachment's `isSticker`. An older row may lack a field: there a missing `addressed` means it was not recorded, not that the message was for your line. `contactId` is absent when this project no longer has the sender as a contact. - direction: string (inbound | outbound) — inbound for a message the contact sent you, outbound for one you (or the console) sent. - status: string | null — Where an outbound message stands now: queued and sending before the channel took it, sent once it did, delivered and read as the receipts arrived, failed when it did not go, and needs_reconcile when it may have gone out and the channel never confirmed it. Null for an inbound message. - commandId: string | null — The commandId the 202 handed back for this send. Null for an inbound message, and for an outbound one no channel ever took. On a row, `from` is the contact's address for an inbound message and your line's address for an outbound one, and empty when no sender address was recorded. ## How long history is kept [#how-long-history-is-kept] History is complete: messages are kept forever, where the stream replays 90 days of events. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | A conversation this key cannot read — another project's — the same answer a made-up id gets | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | A parameter outside the bounds above, or an `x-mapier-version` that is not a published version | | `429` | `rate_limited` | Over 120 requests a minute for this key — see [Rate limits](https://docs.mapier.ai/convo/api/rate-limits) | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and ask again | | `503` | `upstream_unavailable` | A service behind Mapier did not answer; retry with backoff | ## Guide [#guide] - [Stream events](https://docs.mapier.ai/convo/api/events/stream) - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # List conversations (https://docs.mapier.ai/convo/api/conversations/list) > Every conversation your key can read, newest first **GET** `/v1/conversations` The conversations your key can read, newest first by when Mapier first saw them: every group conversation a line is in, and every person a line talks to. Use it to find the groups a line is in when your integration starts, or after it was away, instead of waiting for each group's next message. ```bash curl "https://api.mapier.ai/v1/conversations?lineId=0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d&kind=group&limit=2" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```json title="200 OK" { "conversations": [ { "conversationId": "a0000000-0000-4000-8000-000000000002", "channel": "imessage", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "kind": "group", "title": "Trip to Lisbon", "status": "active", "statusReason": null, "peerAddress": null, "participantCount": 4, "createdAt": "2026-10-18T17:55:02.000Z", "lastMessageAt": "2026-10-18T18:03:11.000Z" }, { "conversationId": "a0000000-0000-4000-8000-000000000003", "channel": "imessage", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "kind": "group", "title": null, "status": "closed", "statusReason": "removed", "peerAddress": null, "participantCount": 2, "createdAt": "2026-10-11T09:12:40.000Z", "lastMessageAt": "2026-10-12T21:40:05.000Z" } ], "nextCursor": "eyJiZWZvcmUiOiIyMDI2LTEwLTExVDA5OjEyOjQwWiJ9" } ``` ## Parameters [#parameters] - lineId?: string (UUID) — Only this line's conversations: one of the lines GET /v1/whoami lists. A line that is not one of this key's is a 403 line_not_allowed. - kind?: string (direct | group) — direct for one-to-one conversations, group for group conversations. - status?: string (active | closed) — active, or closed for conversations your line can no longer send to (statusReason says why). - cursor?: string (at most 200 characters) — The nextCursor of the page before, to read the next, older page. Omit it for the newest page. - limit?: integer (1 to 100, default 25) — How many conversations a page holds. `lineId`, `kind` and `status` are optional and combine. Page with `cursor`: pass each answer's `nextCursor` back until it is `null`. A cursor is opaque: never build or parse one. Conversations are ordered by when Mapier first saw them, so a page does not shift when a conversation gets a new message. ## Response [#response] `conversations` is one page, newest first, and `nextCursor` is the cursor for the next, older page, or `null` on the last. Each item is the conversation as [`GET /v1/conversations/{conversationId}`](https://docs.mapier.ai/convo/api/conversations/get) reads it, with `participantCount` in place of `participants`. Read one conversation for a group's members. - conversationId: string (UUID) — Mapier's id for the conversation, the target.conversationId a send names. - channel: string (imessage | whatsapp) — The channel the conversation is on. - lineId: string | null (UUID, or null) — The line the conversation is on. Null only when that line was released from the project. - kind: string (direct | group) — direct: one person and your line. group: a group conversation your line is in. - title: string | null — The group's name as the channel shows it. Null for a direct conversation, and for a group with no name. - status: string (active | closed) — active, or closed when your line can no longer reach the group. A send into a closed conversation is refused with 409 conversation_closed. - statusReason: string | null (removed | deleted | archived | suspended, or null) — Why the group is closed. Null while the conversation is active. - peerAddress: string | null — The person a direct conversation is with, as the channel names them. Null for a group. - participantCount: integer — How many members of a group Mapier knows, your line excluded — the length of participants on the one-conversation read. 0 for a direct conversation. - createdAt: string (ISO 8601) — When Mapier first saw the conversation. - lastMessageAt: string | null (ISO 8601, or null) — When the newest message in it was sent or received. Null when it has none. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `403` | `line_not_allowed` | A `lineId` that is not one of this key's lines | | `404` | `not_found` | With a personal access token, an `x-mapier-project` it cannot reach | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | A parameter outside the values above, or an `x-mapier-version` that is not a published version | | `429` | `rate_limited` | Over 120 requests a minute for this key, shared with the conversation and history reads — see [Rate limits](https://docs.mapier.ai/convo/api/rate-limits) | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and ask again | | `503` | `upstream_unavailable` | A service behind Mapier did not answer; retry with backoff | ## Guide [#guide] - [Get a conversation](https://docs.mapier.ai/convo/api/conversations/get) - [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) # Mark as read (https://docs.mapier.ai/convo/api/conversations/mark-read) > Show the person that their messages were read **POST** `/v1/commands/conversation.mark_read` _Works on iMessage, WhatsApp_ Marks a one-to-one conversation read on the line: the whole conversation, in one the person has written in. On WhatsApp, the person sees blue ticks on their messages, unless they turned read receipts off. On iMessage, the person sees "Read" under their message only when the line has read receipts turned on. With them off, the command still ends `succeeded` and the person sees nothing. Honors `Idempotency-Key`: a retry under the same key returns the first command and nothing is sent twice. On an iMessage line Mapier ends the command itself from the channel's answer, and never retries it. So the `202` is followed by a `command` event, `type: "message.read"`, `messageId: null`. ## Body [#body] ### Target [#target] - target.kind?: "conversation" — Optional. The conversationId alone names the target. - target.conversationId: string (UUID of a one-to-one conversation the person has written in) On an iMessage line the conversation at `target.conversationId` must be a one-to-one conversation the person has written in, as for `typing.start`. Each of these is `422 validation_failed` at `target.conversationId` before anything is sent: - a group chat; - a conversation the person has never written in; - a conversation the line has not yet confirmed is with one person, with `reason: conversation_not_confirmed` — send the person a text first; - a person's address instead of a conversation: a read is done in a conversation. ### Payload [#payload] - payload.externalId?: string (optional) — The message read up to. On iMessage, by the externalId its message event carried or by its messageId; it is checked, and the whole conversation is marked read whichever message it names. On another channel, by the externalId its message event carried, and the line marks read up to it. `payload` may be `{}` or absent. `payload.externalId` is a `422 validation_failed` at `payload.externalId` when it is not an id or names a message of another conversation. ## What happens [#what-happens] The `202` says the command was accepted. On an iMessage line, the `command` event then says: - `succeeded` once the channel took it. That does not promise the person saw it. - `failed`, with the code of what the channel answered instead: `not_found`, `rate_limited` or `upstream_unavailable` (the line is offline). It is never retried. Every `conversation.mark_read` is sent, so a message that arrived since the last read is marked read too. ### The budget it shares with typing.start [#the-budget-it-shares-with-typingstart] On an iMessage line, `typing.start` and `conversation.mark_read` share the channel's budget of 12 signals per conversation in 60 seconds, counted from the first. Past it, either is accepted and ends `failed` with `rate_limited` without being sent. A `typing.start` held back inside its own five-second window uses none of the budget. Marking a conversation read and then showing the typing bubble uses two. This command is the line reading the person's messages. The person reading the line's messages is a different thing: it arrives as a `receipt` event on a stream opened with `?events=receipts`, and as the `message.read` webhook. See [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery). ## On a WhatsApp line [#on-a-whatsapp-line] Address the person's one-to-one conversation at `target.conversationId`. A group is `422 validation_failed` at `target.conversationId`. There is no confirmation step and no shared budget. The line marks the conversation read up to the message `payload.externalId` names, by the `externalId` its `message` event carried, or up to the person's newest message when it names none. WhatsApp marks the messages before it read too. Marking read is refused outside 24 hours of the person's last message, with [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) and `reason: outside_service_window`, before anything is sent. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/conversation.mark_read \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: read-0192a7c4" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000001" } }' ``` ```ts tab="TypeScript" // One key per read you mean to mark: a retry of it reuses the key. async function markRead(conversationId: string, idempotencyKey: string) { const res = await fetch(`https://api.mapier.ai/v1/commands/conversation.mark_read`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "conversation", conversationId } }), }); return res.json(); } ``` A common pattern: when a `message` event arrives, mark the conversation read, then show the typing bubble while the answer is written. ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-5e80-7164-c295-70bd3e6fa154", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then, on the response stream: ```json title="event: command — succeeded" { "commandId": "0192b3e2-5e80-7164-c295-70bd3e6fa154", "logicalActionId": "read-0192a7c4", "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000001", "type": "message.read", "messageId": null, "failureClass": null } ``` `message.read` is deprecated. Use `conversation.mark_read`. Results and events still carry `type: "message.read"`. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.conversationId` for a group chat, a conversation the person has never written in, or one the line has not confirmed (with `reason: conversation_not_confirmed`), and for a person's address. - `422 validation_failed` at `payload.externalId` when it is not an id or names a message of another conversation. - `404 unsupported_command` with `reason: not_on_channel` on a line whose channel does not carry it. Result codes you will see for this command: `not_found`, `rate_limited`, `upstream_unavailable`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Show typing](https://docs.mapier.ai/convo/api/conversations/show-typing) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) - [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it) # Remove a background (https://docs.mapier.ai/convo/api/conversations/remove-background) > Remove a conversation's background **POST** `/v1/commands/chat_background.remove` _Works on iMessage_ Removes the background of an iMessage conversation. It is done in a one-to-one conversation the person has written in, or in a group chat. Takes no arguments: `payload` is `{}` or absent. Honors `Idempotency-Key`: a retry under the same key returns the first command rather than removing the background again. A remove and a [`chat_background.set`](https://docs.mapier.ai/convo/api/conversations/set-background) each take a key of their own — see [One key for each command](#one-key-for-each-command). Every background change, this command's or one a person makes on their own phone, is reported as a `conversation.background_changed` event, opt-in, and as a `chat_background` event on a stream opened with `?events=chat_backgrounds`. A line on older software instead leaves a message with no text — see [What a change reports](#what-a-change-reports). ## Body [#body] ### Target [#target] - target.kind?: "conversation" — Optional. The conversationId alone names the target. - target.conversationId: string (UUID of a confirmed one-to-one conversation, or of a group chat) — A one-to-one conversation the person has written in, or a group chat. Each of these is `422 validation_failed` at `target.conversationId` before anything is sent: - a conversation no message has arrived in yet; - a one-to-one conversation the line has not yet confirmed, with `reason: conversation_not_confirmed` — send the person a text first; - in place of a conversation, the address of someone this project has already exchanged messages with. The address of someone this project has never exchanged messages with is refused at the field you wrote it at, as on every command done in a conversation. ### Payload [#payload] None. Send `{}` or leave `payload` out. Any field is `422 validation_failed` at that field (`payload.`) before anything is sent, `payload.preset`, `payload.colors` and `payload.photoUrl` included: only a `chat_background.set` takes them. ## What comes back [#what-comes-back] At once, beside the refusals above, the line can answer `503 upstream_unavailable`: - with `details.reason: "connector_unavailable"` while the line is offline; - with `details.reason: "outbound_paused"` while sending on the line is paused. Otherwise `202`, then one `command` event on the [response stream](https://docs.mapier.ai/convo/api/events/stream): - `succeeded` — the line made the change and confirmed it, or there was no background to remove. The result does not say which. A remove sent again where nothing is left to remove ends `succeeded` and changes nothing. - `failed` with `gateway_rejected` — the line refused before changing anything: it was busy with another background change, could not find the conversation, or was not ready to change a background. Nothing changed, and the remove can be sent again under a new `Idempotency-Key`. - `failed` with `stale_target` — the line could not find the group chat with the members it last saw, as happens right after the membership changed and before the group's next message. - `failed` with `capability_not_negotiated` — the line does not support removing a background. Setting and removing are supported separately. - `expired` with `command_expired_before_execution` — the line did not reach the change in time. Nothing changed. - `ambiguous` with `chat_background_unverified` — the line began the change and could not confirm it. It may or may not have been made. Rarely, a remove ends `ambiguous` with `gateway_timeout` instead, when the attempt failed before the line could say what it did. Read it as `chat_background_unverified`. This API cannot read a background back. Ask someone in the conversation whether the background is gone before you send the remove again. ### While a change is under way [#while-a-change-is-under-way] A background change lets the line's other waiting commands go first. Once it has started, the line runs nothing else until the change is confirmed or given up on, so anything sent meanwhile but a `typing.start`, into any conversation on the line, waits for it. A message on the [conversation path](https://docs.mapier.ai/convo/api/messages/send#who-gets-it), a reaction, a `profile.share` or a `poll.vote` that waits longer than that path's 30 seconds ends `expired`. ## What a change reports [#what-a-change-reports] Every change to a conversation's background, this command's or one a person makes on their own phone, is reported as a `conversation.background_changed` event, and as a `chat_background` event on a stream opened with `?events=chat_backgrounds`. Both are opt-in: subscribe a webhook endpoint to the type by name, or open the stream with the option. Your own change arrives there with `fromMe: true` and `from` set to the line's own address, as well as in this command's `command` event: one change, reported twice, so do not count it twice. `background` is `null` for a removal. On a set it names the preset, or `null` when the line could not tell which background was set — so a set followed at once by another can report `preset: null` — and a `photo` by its preset, with the picture's `attachmentId` to fetch from [`GET /v1/attachments/{attachmentId}`](https://docs.mapier.ai/convo/api/messages/download-attachment) when the line could export it. A change in a group chat is reported the same way, on the group's conversation. See [Chat background events](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds). ### On a line that predates the event [#on-a-line-that-predates-the-event] A line whose device is on older software reports a background change in a conversation with one person differently: it leaves a message from that person with no text, whoever made the change — this command, or the person on their own phone. It is a `message` event and a `message.received` webhook whose `text` is `null`. It is stored in the conversation, counted as a received message, and leaves the conversation awaiting a reply in the console until the line next sends. Nobody wrote anything, so there is nothing to answer. Skip a received message that has no text and no attachment rather than reply to it — see [Inbound message events](https://docs.mapier.ai/convo/guides/receive/incoming-messages#not-every-message-has-text) and [Webhooks](https://docs.mapier.ai/convo/guides/receive/receive-events#receive-webhooks). On such a line, a change the line makes in a group chat produces no message and no event. ## One key for each command [#one-key-for-each-command] Give a remove and a set a key each. The two count as one command for the key: one `Idempotency-Key` reused across a set and a remove is answered with the first command and changes nothing more. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/chat_background.remove \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: background-remove-order-2481" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": {} }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // Send the same key again on a retry. Never pass a key a chat_background.set used. async function removeBackground(conversationId: string, idempotencyKey: string) { const res = await fetch(`${BASE}/v1/commands/chat_background.remove`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "conversation", conversationId }, payload: {} }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-4d7f-7053-b184-6fac2d5e9043", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then, on the response stream: ```json title="event: command — succeeded" { "commandId": "0192b3e2-4d7f-7053-b184-6fac2d5e9043", "logicalActionId": "background-remove-order-2481", "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000001", "type": "chat_background.remove", "messageId": null, "externalId": null, "namePhoto": null, "projectId": "b0000000-0000-4000-8000-000000000002", "environment": "live", "failureClass": null } ``` ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.conversationId` for a conversation no message has arrived in, a one-to-one conversation the line has not confirmed (with `reason: conversation_not_confirmed`), or the address of someone this project has already exchanged messages with, in place of a conversation. - `422 validation_failed` at `payload.` for any key in the payload, `expectedBackgroundGuid` among them. - `503 upstream_unavailable` with `details.reason: "connector_unavailable"` while the line is offline, or `"outbound_paused"` while sending on the line is paused. - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. Result codes you will see for this command: `gateway_rejected`, `stale_target`, `capability_not_negotiated`, `command_expired_before_execution`, `chat_background_unverified` and `gateway_timeout`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Set a background](https://docs.mapier.ai/convo/api/conversations/set-background) - [Chat backgrounds](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) - [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Set a background (https://docs.mapier.ai/convo/api/conversations/set-background) > Set a conversation's background to a preset, two colors or a photo **POST** `/v1/commands/chat_background.set` _Works on iMessage_ Sets the background of an iMessage conversation, by the background's name at `payload.preset`: one of Apple's own backgrounds, `custom` with two colors you choose, or `photo` with a picture of your own at a link. It is done in a one-to-one conversation the person has written in, or in a group chat. Honors `Idempotency-Key`: a retry under the same key returns the first command without fetching the link again, rather than setting the background again, even when the retry names another `photoUrl`. A set and a [`chat_background.remove`](https://docs.mapier.ai/convo/api/conversations/remove-background) each take a key of their own — see [One key for each command](#one-key-for-each-command). Every background change, this command's or one a person makes on their own phone, is reported as a `conversation.background_changed` event, opt-in, and as a `chat_background` event on a stream opened with `?events=chat_backgrounds`. A line on older software instead leaves a message with no text — see [What a change reports](#what-a-change-reports). ## Body [#body] ### Target [#target] - target.kind?: "conversation" — Optional. The conversationId alone names the target. - target.conversationId: string (UUID of a confirmed one-to-one conversation, or of a group chat) — A one-to-one conversation the person has written in, or a group chat. Each of these is `422 validation_failed` at `target.conversationId` before anything is sent: - a conversation no message has arrived in yet; - a one-to-one conversation the line has not yet confirmed, with `reason: conversation_not_confirmed` — send the person a text first; - in place of a conversation, the address of someone this project has already exchanged messages with. The address of someone this project has never exchanged messages with is refused at the field you wrote it at, as on every command done in a conversation. ### Payload [#payload] - preset: string (One of the published presets, exactly as written) — The background's name: one of the presets below. - colors?: string[] (Exactly two colors, each "#RRGGBB") — The two colors of a custom gradient. Required with preset "custom", and refused with any other preset. - photoUrl?: string (https link of at most 2048 characters to a JPEG, PNG, HEIC/HEIF or WebP image of at most 8 MiB and 100 megapixels) — The picture of a photo background, fetched by Mapier before anything is sent. Required with preset "photo", and refused with any other preset. #### Presets [#presets] A preset's name is lower-case and sent exactly as written here. | Preset | What it is | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | | `gradient` | Apple's default background. | | `color_mango`, `color_ice`, `color_plum`, `color_deep_sea`, `color_green_apple`, `color_cherry`, `color_bubblegum`, `color_tangerine`, `color_magenta`, `color_lime`, `color_silver`, `color_carbon`, `color_stone` | Apple's two-color gradients, by Apple's name for each. | | `custom` | A gradient of the two colors you give at `colors`. | | `aurora_green`, `aurora_purple`, `aurora_pink` | Apple's animated aurora backgrounds. | | `sky_dusk`, `sky_haze`, `sky_sunset`, `sky_clear`, `sky_sunrise`, `sky_dawn` | Apple's animated sky backgrounds. | | `water_light`, `water_dark` | Apple's animated water backgrounds. | | `glitter_gold`, `glitter_copper`, `glitter_silver` | Apple's animated glitter backgrounds. | | `photo` | A picture of your own, from the link at `photoUrl`. | #### Colors of your own [#colors-of-your-own] `custom` is a gradient of two colors, given at `payload.colors` as an array of exactly two strings, each `#RRGGBB`: ```json { "preset": "custom", "colors": ["#008080", "#FFE600"] } ``` Every other preset has its own colors and takes no `colors`. #### A photo of your own [#a-photo-of-your-own] `photo` makes a picture of your own the background. Give it at `payload.photoUrl`, as an https link: ```json { "preset": "photo", "photoUrl": "https://example.com/backgrounds/harbour.jpg" } ``` - The link is https and at most 2048 characters. - The picture is a JPEG, PNG, HEIC/HEIF or WebP image of at most 8 MiB and 100 megapixels, no side over 65,535 px. A GIF is refused. - Mapier fetches the link and hands the picture to the line before anything is sent. A link it cannot use is refused at once, and nothing is sent. The line re-encodes it as a JPEG whose long side is at most 3,072 px. Transparent areas become white. The person sees it behind the messages, cropped to fill the screen, in Apple's Original look with no color filter. To know what they will see, send a JPEG of at most 3,072 px on its long side, with no transparency. Every other preset takes no `photoUrl`. #### What is refused [#what-is-refused] Each of these is `422 validation_failed` before anything is sent: - a preset that is missing or not on that list, at `payload.preset`; - a `custom` set without exactly two `#RRGGBB` colors, at `payload.colors`; - `colors` beside any other preset, at `payload.colors`; - a `photo` set without an https link of at most 2048 characters, at `payload.photoUrl`; - `photoUrl` beside any other preset, at `payload.photoUrl`; - a link that cannot be fetched, or a file that is not a JPEG, PNG, HEIC/HEIF or WebP image, is over 8 MiB or 100 megapixels, or has a side over 65,535 px, at `payload.photoUrl`, its `reason` one of the link refusals a media send meets: `media_fetch_refused`, `media_fetch_failed`, `media_too_large` or `unsupported_media_type`. Rarely, the line refuses a picture Mapier took, and the `reason` is `image_too_large` or `unreadable_image`; - any other key, at that key (`payload.`). ## What comes back [#what-comes-back] At once, beside the refusals above, the line can answer `503 upstream_unavailable`: - with `details.reason: "connector_unavailable"` while the line is offline; - with `details.reason: "outbound_paused"` while sending on the line is paused. Otherwise `202`, then one `command` event on the [response stream](https://docs.mapier.ai/convo/api/events/stream): - `succeeded` — the line made the change and confirmed it. - `failed` with `gateway_rejected` — the line refused before changing anything: it was busy with another background change, could not find the conversation, or was not ready to change a background. Nothing changed, and the set can be sent again under a new `Idempotency-Key`. For a photo it can also mean the line could not read the picture: sending the same picture again fails the same way. - `failed` with `transfer_not_landed` — a photo set only: the picture did not reach the line within five minutes. Nothing changed. - `failed` with `invalid_target` — a photo set only: the picture was no longer on the line when the change began. Nothing changed. - `failed` with `stale_target` — the line could not find the group chat with the members it last saw, as happens right after the membership changed and before the group's next message. - `failed` with `capability_not_negotiated` — the line does not support setting a background. Setting and removing are supported separately. - `failed` with `capability_constraint_violation` — the line does not carry that preset. Nothing changed. See [A preset the line does not carry](#a-preset-the-line-does-not-carry). - `expired` with `command_expired_before_execution` — the line did not reach the change in time. Nothing changed. - `ambiguous` with `chat_background_unverified` — the line began the change and could not confirm it. It may or may not have been made. Rarely, a set ends `ambiguous` with `gateway_timeout` instead, when the attempt failed before the line could say what it did. Read it as `chat_background_unverified`. This API cannot read a background back. Ask someone in the conversation whether the background changed before you send the set again. A phone can keep a background from a sender it has no contact for and show nothing. This is most likely in a new conversation with one person, until the line is a saved contact on their phone. `succeeded` says the line made the change and confirmed it, not that the person sees it. When it matters, ask them. ### A preset the line does not carry [#a-preset-the-line-does-not-carry] A line on older software supports fewer backgrounds. A set of a preset the line does not support is accepted and then ends `failed` with `capability_constraint_violation` and `failureClass: "capability"`. Nothing changed. `gradient` is on every line that sets a background, so it is the one to fall back to. `photo` is the newest. A line that has not been updated for it ends a photo set `failed` with `capability_constraint_violation`. Nothing changed. ### While a change is under way [#while-a-change-is-under-way] A background change lets the line's other waiting commands go first. Once it has started, the line runs nothing else until the change is confirmed or given up on, so anything sent meanwhile but a `typing.start`, into any conversation on the line, waits for it. A message on the [conversation path](https://docs.mapier.ai/convo/api/messages/send#who-gets-it), a reaction, a `profile.share` or a `poll.vote` that waits longer than that path's 30 seconds ends `expired`. ## What a change reports [#what-a-change-reports] Every change to a conversation's background, this command's or one a person makes on their own phone, is reported as a `conversation.background_changed` event, and as a `chat_background` event on a stream opened with `?events=chat_backgrounds`. Both are opt-in: subscribe a webhook endpoint to the type by name, or open the stream with the option. Your own change arrives there with `fromMe: true` and `from` set to the line's own address, as well as in this command's `command` event: one change, reported twice, so do not count it twice. `background` is `null` for a removal. On a set it names the preset, or `null` when the line could not tell which background was set — so a set followed at once by another can report `preset: null` — and a `photo` by its preset, with the picture's `attachmentId` to fetch from [`GET /v1/attachments/{attachmentId}`](https://docs.mapier.ai/convo/api/messages/download-attachment) when the line could export it. A change in a group chat is reported the same way, on the group's conversation. See [Chat background events](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds). ### On a line that predates the event [#on-a-line-that-predates-the-event] A line whose device is on older software reports a background change in a conversation with one person differently: it leaves a message from that person with no text, whoever made the change — this command, or the person on their own phone. It is a `message` event and a `message.received` webhook whose `text` is `null`. It is stored in the conversation, counted as a received message, and leaves the conversation awaiting a reply in the console until the line next sends. Nobody wrote anything, so there is nothing to answer. Skip a received message that has no text and no attachment rather than reply to it — see [Inbound message events](https://docs.mapier.ai/convo/guides/receive/incoming-messages#not-every-message-has-text) and [Webhooks](https://docs.mapier.ai/convo/guides/receive/receive-events#receive-webhooks). On such a line, a change the line makes in a group chat produces no message and no event. ## One key for each command [#one-key-for-each-command] Give a set and a remove a key each. The two count as one command for the key: one `Idempotency-Key` reused across a set and a remove is answered with the first command and changes nothing more. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/chat_background.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: background-set-order-2481" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "preset": "sky_dusk" } }' ``` ```bash tab="cURL — two colors of your own" curl https://api.mapier.ai/v1/commands/chat_background.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: background-set-order-2482" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "preset": "custom", "colors": ["#008080", "#FFE600"] } }' ``` ```bash tab="cURL — a photo" curl https://api.mapier.ai/v1/commands/chat_background.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: background-set-order-2483" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "preset": "photo", "photoUrl": "https://example.com/backgrounds/harbour.jpg" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // A named preset, "custom" with two "#RRGGBB" colors, or "photo" with an https link. type Background = | { preset: string } | { preset: "custom"; colors: [string, string] } | { preset: "photo"; photoUrl: string }; // Send the same key again on a retry. Never pass a key a chat_background.remove used. async function setBackground( conversationId: string, background: Background, idempotencyKey: string ) { const res = await fetch(`${BASE}/v1/commands/chat_background.set`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "conversation", conversationId }, payload: background, }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-70a2-7386-e4b7-92df5081c376", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then, on the response stream: ```json title="event: command — succeeded" { "commandId": "0192b3e2-70a2-7386-e4b7-92df5081c376", "logicalActionId": "background-set-order-2481", "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000001", "type": "chat_background.set", "messageId": null, "externalId": null, "namePhoto": null, "projectId": "b0000000-0000-4000-8000-000000000002", "environment": "live", "failureClass": null } ``` ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.conversationId` for a conversation no message has arrived in, a one-to-one conversation the line has not confirmed (with `reason: conversation_not_confirmed`), or the address of someone this project has already exchanged messages with, in place of a conversation. - `422 validation_failed` at `payload.preset`, `payload.colors`, `payload.photoUrl` or `payload.`, as [above](#what-is-refused). - `503 upstream_unavailable` with `details.reason: "connector_unavailable"` while the line is offline, or `"outbound_paused"` while sending on the line is paused. - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. Result codes you will see for this command: `gateway_rejected`, `transfer_not_landed`, `invalid_target`, `stale_target`, `capability_not_negotiated`, `capability_constraint_violation`, `command_expired_before_execution`, `chat_background_unverified` and `gateway_timeout`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Remove a background](https://docs.mapier.ai/convo/api/conversations/remove-background) - [Chat backgrounds](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) - [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Show typing (https://docs.mapier.ai/convo/api/conversations/show-typing) > Show the typing bubble on the person's phone **POST** `/v1/commands/typing.start` _Works on iMessage, WhatsApp_ Shows the typing bubble on the other person's phone, the dots their app draws while somebody is writing, in a one-to-one conversation the person has written in. Takes no arguments: `payload` is `{}` or absent. On an iMessage line Mapier ends the command itself from the channel's answer, and never retries it. So the `202` is followed within the second by a `command` event, `type: "typing.start"`, `messageId: null`. Honors `Idempotency-Key`: a retry under the same key returns the first command and nothing is sent twice. Separately, on an iMessage line a second signal to the same conversation within five seconds ends `succeeded` and sends nothing. ## Body [#body] ### Target [#target] - target.kind?: "conversation" — Optional. The conversationId alone names the target. - target.conversationId: string (UUID of a one-to-one conversation the person has written in) On an iMessage line the conversation at `target.conversationId` must be a one-to-one conversation the person has written in. A group chat, a conversation the person has never written in, and one the line has not yet confirmed is with one person are each `422 validation_failed` at `target.conversationId` before anything is sent. The last carries `reason: conversation_not_confirmed` — send the person a text first. ## What happens [#what-happens] The `202` says the command was accepted. On an iMessage line, the `command` event then says: - `succeeded` once the channel took it. That does not promise the phone drew the bubble. - `failed`, with the code of what the channel answered instead: `not_found`, `rate_limited` (past the budget `typing.start` shares with [`conversation.mark_read`](https://docs.mapier.ai/convo/api/conversations/mark-read), 12 signals per conversation in 60 seconds; the signal is not sent) or `upstream_unavailable` (the line is offline). It is never retried. On iMessage the bubble shows for about twelve seconds, or until the line sends into the conversation. There is no call that takes it down; to hold it up, send `typing.start` again. On an iMessage line, at most one signal per conversation per five seconds is sent. Another inside that window is accepted and ends `succeeded` without being sent, since the bubble the first one raised is still up. So a loop that signals every few seconds while an answer is being written uses one signal per five seconds, whatever its pace. A signal held back inside that window uses none of the budget it shares with `conversation.mark_read`. A person's own typing is not reported: no stream event or webhook says a person is typing. The signal only goes out. ## On a WhatsApp line [#on-a-whatsapp-line] The iMessage rules above do not apply there: there is no confirmation step, no five-second window and no shared budget. Address the person's one-to-one conversation at `target.conversationId`. A group is `422 validation_failed` at `target.conversationId`. WhatsApp shows the dots until the line replies, or for 25 seconds, whichever comes first. The same call marks the person's newest message read, and the messages before it. Typing is refused outside 24 hours of the person's last message, with [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) and `reason: outside_service_window`, before anything is sent. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/typing.start \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: typing-0192a7c4" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000001" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // One key per signal you mean to send: a retry of it reuses the key. async function showTyping(conversationId: string, idempotencyKey: string) { const res = await fetch(`${BASE}/v1/commands/typing.start`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "conversation", conversationId } }), }); return res.json(); } ``` A common pattern: signal once when you start preparing the answer, send it when it is ready. For an answer that takes longer than the bubble lasts, signal again every ten seconds or so until the send goes out. ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-b4e6-77ca-a8fb-d61394c507ba", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then, on the response stream: ```json title="event: command — succeeded" { "commandId": "0192b3e2-b4e6-77ca-a8fb-d61394c507ba", "logicalActionId": "typing-0192a7c4", "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000001", "type": "typing.start", "messageId": null, "failureClass": null } ``` ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.conversationId` for a group chat, a conversation the person has never written in, or one the line has not confirmed (with `reason: conversation_not_confirmed`). - `404 unsupported_command` with `reason: not_on_channel` on a line whose channel does not carry it. Result codes you will see for this command: `not_found`, `rate_limited`, `upstream_unavailable`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Mark as read](https://docs.mapier.ai/convo/api/conversations/mark-read) - [Share the profile](https://docs.mapier.ai/convo/api/line-profile/share) - [Send a message](https://docs.mapier.ai/convo/api/messages/send) - [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it) # Check an address (https://docs.mapier.ai/convo/api/discovery/check-an-address) > Deprecated: use Check reachability with registered=true **POST** `/v1/handle-check` _Works on iMessage_ [`GET /v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability#asking-the-channel-live) with `registered=true` asks the channel the same question and answers it as `registered`. Asks the channel behind a line whether an address can receive on its channel — on an iMessage line, Apple's directory. Use it to avoid sending to an address that cannot receive: a number that is Android-only, or an Apple ID that does not exist. On a WhatsApp line the answer is usually `available: null`: WhatsApp does not let a business check whether a number uses WhatsApp before writing to it. Unlike commands, this is a **synchronous read**. The answer is in the HTTP response; nothing arrives on the stream. A check is not a send: it does not pin the address to a line or count against a line's limit of people. ## Request [#request] - address: string (1 to 320 characters) — The address to ask about, in any form the channel accepts. It is parsed by that channel's own rules, and one the channel cannot read is 422 validation_failed at address. - channel?: string (imessage | whatsapp) — Which channel to ask. Leave it out when your project has lines on one channel only. The same address can have different answers on two channels. ```bash tab="cURL" curl https://api.mapier.ai/v1/handle-check \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ -H "Content-Type: application/json" \ -d '{ "address": "+14155550100", "channel": "imessage" }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/handle-check`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", "Content-Type": "application/json", }, body: JSON.stringify({ address: "+14155550100", channel: "imessage" }), }); // available is true, false or null — and null is not false. const { available, reason } = await res.json(); ``` ## Response [#response] ```json title="200 — reachable" { "address": "+14155550100", "channel": "imessage", "available": true, "reason": null } ``` ```json title="200 — not reachable" { "address": "+14155550100", "channel": "imessage", "available": false, "reason": "not_reachable" } ``` On an iMessage line, `available: false` means Apple's directory said the address is not on iMessage. When Apple's lookup cannot give an answer for the address, the check does not answer `false`: it fails with `503 line_unavailable` — see [When the check cannot run](#when-the-check-cannot-run). - address: string — The address as Mapier normalized it. - channel: string (imessage | whatsapp) — The channel this answer is about, whether you named it or not. - available: boolean | null — Whether the channel says this address can receive. Null is not false: it means the channel cannot check this at once. Never show null as unreachable. - reason: string | null — Why not, when available is false, or why the channel could not say, when it is null. A channel may add a note to a yes too, so branch on available, not on reason. ## When the check cannot run [#when-the-check-cannot-run] A `503 line_unavailable` carries `details.reason`. **None of these reasons says whether the address can receive**: the question either never reached the channel or came back unusable. Mapier's reasons are listed under [Error codes](https://docs.mapier.ai/convo/api/errors); on an iMessage line the channel may send its own, which reach you as `details.reason` unchanged: ```json title="503" { "error": { "code": "line_unavailable", "message": "…", "details": { "reason": "read_in_flight" } } } ``` On an iMessage line, when Apple's directory has no current answer for an address, Mapier looks it up again. If that lookup still gives no answer, the check fails with `details.reason: "read_failed"` rather than answering `available: false`. Ask again later. Reads run one at a time per line, so `read_in_flight` is common under concurrency. Check addresses serially, or cache the result — reachability rarely changes. ## Errors [#errors] | Status | Code | Cause | | ------ | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | The body is not JSON, or the channel refused the request as malformed (`details.reason` is its word); or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:send` scope | | `404` | `not_found` | The channel answered not found, with its reason in `details.reason`; a project with no line to ask is the `503 no_line` below | | `404` | `unsupported_command` | `reason: shared_line`: the line is a test line on a shared number, which does not answer this check | | `409` | `project_archived` | The project is archived | | `413` | `payload_too_large` | Body over 65,536 bytes | | `422` | `validation_failed` | `address` is missing or not a form the channel accepts | | `429` | `rate_limited` | 30 requests per minute, per key; the `Retry-After` header says how long to wait (a channel's own rate limit may give the same seconds in `details.retryAfter` too) | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `no_line` · `line_unavailable` · `upstream_unavailable` | No line, the line cannot ask right now (see [When the check cannot run](#when-the-check-cannot-run)), or the channel did not answer | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | ## Guide [#guide] - [Check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send) # Check reachability (https://docs.mapier.ai/convo/api/discovery/check-reachability) > Whether a message from this line would reach this person now, and what to do if not **GET** `/v1/reachability` Whether a message from one line would reach one person right now, and if not, why and what to do. It applies the same rules a send does, in the same order: the person is blocked, paused or opted out; the channel needs them to write first and they have not written to this line; the channel's reply window has closed on this line; the channel has handed the conversation to another app. Nothing is sent and nothing is written. `reasons` lists every rule that stands, `canSend` sums them up, and `remedy` says what to do about the first. Each line keeps its own window and its own first message, so two lines on one channel can answer differently for one person. A refused send carries this same object at `details.reachability`. ```bash curl "https://api.mapier.ai/v1/reachability?lineId=0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d&to=%2B14155550100" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```json title="200 OK" { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "channel": "imessage", "recipient": "+14155550100", "to": "+14155550100", "canSend": { "freeform": false, "template": null }, "reasons": [ { "code": "opted_out", "reason": "opted_out", "docUrl": "https://docs.mapier.ai/convo/api/errors#recipient_not_allowed.opted_out" } ], "serviceWindow": { "applies": false, "expiresAt": null }, "initiation": { "required": "none", "satisfied": null }, "consent": { "optedOut": true, "scope": "person" }, "remedy": null, "evidenceAt": "2026-10-18T18:04:00.000Z" } ``` On WhatsApp, to a person who last wrote more than 24 hours ago, only a template goes, and `remedy` names it: ```json title="200 OK — WhatsApp, outside the window" { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2e", "channel": "whatsapp", "recipient": "+447700900123", "to": "+447700900123", "canSend": { "freeform": false, "template": true }, "reasons": [ { "code": "outside_service_window", "reason": "outside_service_window", "docUrl": "https://docs.mapier.ai/convo/api/errors#recipient_not_allowed.outside_service_window" } ], "serviceWindow": { "applies": true, "expiresAt": "2026-10-17T18:04:00.000Z" }, "initiation": { "required": "template", "satisfied": false }, "consent": { "optedOut": false, "scope": "person" }, "remedy": { "type": "whatsapp.template.send" }, "evidenceAt": "2026-10-18T18:04:00.000Z" } ``` `to` and `recipient` carry the same address, and `reasons[].code` the same word as `reasons[].reason`. `recipient` and `code` are deprecated. Read `to` and `reason` instead. ## Query [#query] | Parameter | | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `lineId` | Optional. A line id this key can see, as `GET /v1/whoami` lists it under `lines`. | | `channel` | Required when `lineId` is left out: the channel to ask on, such as `imessage`. Beside a `lineId` it is not read — the line says its channel. | | `to` | The person's address on that channel, written as a send's `target.to` is. One of `to` and `recipient` is required. | | `recipient` | Deprecated: use `to`. The same address under its old name. If both are sent with a `lineId`, `recipient` is used. | | `registered` | Optional, `true` or `false` (the default). `true` also asks the channel live whether the address can receive, as [`POST /v1/handle-check`](https://docs.mapier.ai/convo/api/discovery/check-an-address) asks it. | ### Without a line [#without-a-line] Leave `lineId` out and name `channel` instead. The answer is then about the line a `message.send` naming no line would send from now: the line the person last wrote in on, else the one they are pinned to, else the one a first message would be handed. No line is reserved. When no line can take the person, the answer is the refusal that send would get. ```bash curl "https://api.mapier.ai/v1/reachability?channel=imessage&to=%2B14155550100" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ### Asking the channel live [#asking-the-channel-live] Add `registered=true` and the answer also carries `registered` and `registeredReason`, asked on the line the answer is about. It needs the `messages:send` scope, and it counts against the address-check budget of 30 requests a minute per key — see [Rate limits](https://docs.mapier.ai/convo/api/rate-limits). - `registered` is `true` or `false`, or `null` when the channel cannot answer the question at once. Null is not false. - `registeredReason` says why not when `registered` is false, or why the channel could not say when it is null. Branch on `registered`, not on `registeredReason`. Each `reasons[].reason` is a `details.reason` a send would be refused with, and its `docUrl` is that refusal's row in [Error codes](https://docs.mapier.ai/convo/api/errors). A person this project has never messaged is answered like anyone else: they have not written yet, and no reply window is open. ## Errors [#errors] | Status | Code | Cause | | ------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | The channel refused a `registered=true` check as malformed; or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | A line this key cannot see, or none | | `409` | `project_archived` | The project is archived | | `413` | `payload_too_large` | The request is over the size limit | | `422` | `validation_failed` | Neither `to` nor `recipient`, no `channel` without a `lineId`, an address the channel cannot read, or an unknown `x-mapier-version` | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier or the channel did not answer; retry with backoff | | `503` | `no_line` · `capacity_exhausted` · `line_unavailable` | With no `lineId`: no line can take this person now, the refusal a `message.send` would get | # Get key details (https://docs.mapier.ai/convo/api/discovery/get-key-details) > Your key's project, lines and limits **GET** `/v1/whoami` The first call a new integration makes: it tells you which project and lines your key reaches without sending anything to anybody. It takes no body and no query parameters, and it spends no rate-limit budget of its own. ```bash curl https://api.mapier.ai/v1/whoami \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```json title="200 OK" { "projectId": "0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b", "environment": "live", "keyId": "0192a7b0-2d3e-7f40-9b5c-6d7e8f9a0b1c", "key": { "id": "0192a7b0-2d3e-7f40-9b5c-6d7e8f9a0b1c", "scopes": ["messages:send", "messages:read"] }, "lines": [ { "id": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "channel": "imessage", "address": "+14155550142", "status": "active", "capabilities": [ "message.send.text", "reaction.tapback", "name_photo.share", "typing.start", "message.read", "message.edit", "message.unsend", "handle_check", "receipts", "events.delivered", "events.read" ], "mode": null, "contactsAssigned": 12, "maxContacts": 300, "takesNewContacts": true, "reputation": null } ], "limits": { "commandsPerMinute": 600 } } ``` ## The response [#the-response] - projectId: string (UUID) — The project this key belongs to. - environment: string (live | test) — `live` for every key you create. - keyId: string (UUID) — The id of the key you authenticated with — not the key itself. - key: object ({ id, scopes }) — The key you authenticated with: id, the same value as keyId, and scopes, what this key may do — messages:send, messages:read, lines:write and webhooks:write. A route that needs a scope the key lacks answers 403 insufficient_scope. A key keeps its scopes for life; to change them, create a new key. - lines: object[] — What this project can send from: every line that has not been released. Each object is below. - limits: object — The request quotas this key's project is held to. The object is below. ### `lines[]` item [#lines-item] - id: string (UUID) — This line's id. - channel: string (imessage | whatsapp) — The channel this line is on. - address: string | null — The address your recipients see this line's messages come from, in the channel's own form. Null while the line is still being provisioned. - status: string (provisioning | active | paused | released) — Only active can carry a message. A paused line is one you paused and can resume; a released line has been retired from this project and never returns, so whoami never lists one. - capabilities: string[] — What this line can do: command types it will carry, plus features like handle_check, receipts and service_window. Branch on this, and treat a value you do not recognize as a capability you do not use: the list grows. - mode: string | null — How this line's account is attached, where the channel has such a thing. Null for a channel where the distinction does not apply — iMessage among them — and for a line whose account has no mode recorded yet. Branch on capabilities, never on this. - contactsAssigned: integer — How many people this line counts: everyone pinned to it, plus anyone pinned to another of your lines who has a conversation on this one. Each person counts once, and groups do not count. It can exceed maxContacts: somebody who writes to a full line is still answered on it and counted. - maxContacts: integer — How many people this line can hold. A line at or past it gets no new person: no first send to somebody new goes out from it. People already on it keep their conversations, and a person who texts it first still lands on it, so contactsAssigned can pass this figure. - takesNewContacts: boolean — Whether a first send to somebody new can be given this line right now: true when the line is active, its connection is not down, and it has room. GET /v1/lines/available names the line a new person would get. - reputation: object | null — The line's latest reputation reading in brief: status (HEALTHY | AT_RISK | CRITICAL | FLAGGED), confidence (ok | insufficient) and computedAt. Null when the line has not been read yet. The full reading, with every measure beside its limit and what to do, is GET /v1/lines/{lineId}/health. - shared?: object ({ maxPeople }) — Present only on a test line on a shared number, which Mapier connects people to one project at a time; maxPeople is how many people can be connected to it at once. On such a line people write first, and some commands are refused with reason shared_line. ### `limits` [#limits] - commandsPerMinute: integer — How many commands (POST /v1/commands/{type}) this project may send in a minute. Every key of the project spends the same budget; a command past it is a 429 rate_limited, and the Retry-After header says when the minute ends. Your project's own ceiling when one has been set for it, and the default otherwise. ## Feature-detect on `capabilities` [#feature-detect-on-capabilities] A command type the API documents is one Mapier knows, not one this line can carry. `lines[].capabilities` is the list to branch on: read it once at start-up, and again after a line changes, rather than trying a command to find out. A command type the line's **channel** never carries is refused before anything is queued (`404 unsupported_command`, `details.reason: "not_on_channel"`). One the channel carries and this line cannot is refused the same way with `details.reason: "not_on_line"`; on an iMessage line it is accepted and ends `failed` on the [stream](https://docs.mapier.ai/convo/api/events/stream). See [Channel support](https://docs.mapier.ai/convo/api/channel-support). `lines` excludes released lines: a released line has been retired from the project and cannot carry a message. A `paused` line is listed, and sends through it are refused until it is resumed. ## Room for new people [#room-for-new-people] Each line can hold a fixed number of contacts. `contactsAssigned` is how many it has and `maxContacts` is how many it can hold. `takesNewContacts` puts the rest together: it is `true` only when the line is active, its connection is not down, and it is still below `maxContacts`. A full line still carries messages for the people already on it, and Mapier sends no first message to somebody new from it. It does not turn anybody away: a person who texts a full line first is pinned to it and counted anyway, so `contactsAssigned` can read past `maxContacts`. Somebody already pinned to another of your lines who writes to this one first stays pinned where they are, and is counted here too. To ask which line somebody new would get, call [`GET /v1/lines/available`](https://docs.mapier.ai/convo/api/lines/get-next-line). See [Lines](https://docs.mapier.ai/convo/guides/lines/lines). ## How each line is doing [#how-each-line-is-doing] `lines[].reputation` is each line's latest health reading in a word: `HEALTHY`, `AT_RISK`, `CRITICAL` or `FLAGGED`, with its `confidence` and when it was computed. It is `null` on a line that has not been read yet; a reading is taken about every 15 minutes. For every measure beside its limit, and what to do about it, call [`GET /v1/lines/{lineId}/health`](https://docs.mapier.ai/convo/api/lines/get-line-health). ## The command ceiling [#the-command-ceiling] `limits.commandsPerMinute` is your project's command budget: one budget shared by every key of the project. Read it rather than hard-coding a figure: it is your project's own ceiling when Mapier has set one, and the default otherwise. See [Rate limits](https://docs.mapier.ai/convo/api/rate-limits#limits). ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------------- | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support; `details.supported` lists the ones it does | | `429` | `rate_limited` | Too many failed authentications from your calling address — this route spends no budget of the key's own | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | ## Guide [#guide] - [Rate limits](https://docs.mapier.ai/convo/api/rate-limits) - [Versions](https://docs.mapier.ai/convo/api/versions) - [Authentication](https://docs.mapier.ai/convo/guides/get-started/authentication) # List capabilities (https://docs.mapier.ai/convo/api/discovery/list-capabilities) > What works where: every command and feature on every channel, with each channel's limits **GET** `/v1/capabilities` Every command type and capability, with its cell on every channel Mapier offers or plans to: `yes` (it works), `coming_soon` (not yet) or `not_supported` (the channel has no such thing). A command whose cell on a channel is not `yes` is refused there with `404 unsupported_command`: `reason: not_on_channel`, or `not_on_line` where only some of the channel's lines carry it. Each channel also lists its `restrictions`, the limits and rules that apply there, each with the refusal a call that breaks it gets. Its `textLimit` is the most text one message carries there, `max` in `unit`; a longer text is `422 validation_failed`, naming the limit. On iMessage the 65,536-byte body limit is reached first, with `413 payload_too_large`. Text is never split. Read it before a call you are not sure of; [`POST /v1/commands/{type}/check`](https://docs.mapier.ai/convo/api/commands/check) then answers for one exact call. What one line can do is [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details)'s `lines[].capabilities`. Any key can read this, whatever its scopes. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/capabilities \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK — trimmed" { "schemaVersion": 2, "factsHash": "sha256:…", "channels": [ { "channel": "imessage", "label": "iMessage", "releaseState": "ga", "textLimit": { "max": 65536, "unit": "utf8_bytes", "advice": null }, "cells": { "message.send.text": "yes", "reaction.set": "yes", "receipts": "yes", … }, "restrictions": [ … ], … }, … ], "features": [ … ], "refusals": [ … ] } ``` The body is the same at every `x-mapier-version`, and `factsHash` changes whenever anything in it does: cache it for the five minutes `Cache-Control` allows, and key your code on the keys, cell values and numbers, never on the text, which may be reworded. These docs are built from the same data, so a cell here and a cell on a channel's page say the same thing. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Channel support](https://docs.mapier.ai/convo/api/channel-support) - [Check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send) # List channels (https://docs.mapier.ai/convo/api/discovery/list-channels) > Which channels are available; needs no key **GET** `/v1/public/channel-availability` Every channel, in a fixed order, and whether every customer can use it. It **needs no key** and reads no `x-mapier-version`. - `offered` is `true` only when the channel is turned on for every project. A channel turned on for some projects only reads `false` here. - `tag` is the channel's release word, such as `Beta`, for display. It is `null` when the channel has none. What your own project can use is [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) and [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities), not this route. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/public/channel-availability ``` ## Response [#response] ```json title="200 OK — trimmed" { "channels": [ { "key": "imessage", "offered": true, "tag": "Available" }, … ] } ``` The answer carries `Cache-Control: public, max-age=60`, so it may be reused for a minute. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------- | ------------------------- | | `500` | `internal_error` | Mapier failed on its side | ## Guide [#guide] - [Channel support](https://docs.mapier.ai/convo/api/channel-support) # bad_request (https://docs.mapier.ai/convo/api/errors/bad_request) > The request could not be read `400` · **Retry: no.** The body is not valid JSON, the channel could not read the request, or a header the call needs is missing. Nothing was sent. ## Reasons [#reasons] This table lists every reason Mapier sets, and the fix. Any other `details.reason` is the channel's own word. | `details.reason` | Means | Fix | | ---------------- | ------------------------------------------------------------------------ | ------------------------------------------------------ | | `missing_header` | A personal access token called a route about one project, and named none | Send the project's id in the `x-mapier-project` header | ## Example [#example] ```json title="400 Bad Request" { "error": { "code": "bad_request", "message": "The body is not valid JSON, or the channel rejected the request as malformed.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#bad_request", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # capacity_exhausted (https://docs.mapier.ai/convo/api/errors/capacity_exhausted) > Every line is full for new people `503` · **Retry: no.** People you already talk to are not affected. Request another line. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ---------------- | --------------------------------- | -------- | -------------------- | | `all_lines_full` | Every line is full for new people | All | Request another line | ## Example [#example] ```json title="503 Service Unavailable" { "error": { "code": "capacity_exhausted", "message": "Every line is full for new people.", "details": { "reason": "all_lines_full" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#capacity_exhausted.all_lines_full", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # channel_not_entitled (https://docs.mapier.ai/convo/api/errors/channel_not_entitled) > This channel is not turned on for your project `403` · **Retry: no.** Use a channel your project has, or ask support to turn this one on. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ---------------- | ---------------------------------------------- | -------- | ------------------------- | | `not_entitled` | This channel is not turned on for your project | All | Ask support to turn it on | | `planned` | This channel is not open to customers yet | All | — | ## Example [#example] ```json title="403 Forbidden" { "error": { "code": "channel_not_entitled", "message": "This channel is not turned on for your project.", "details": { "reason": "not_entitled" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#channel_not_entitled.not_entitled", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # conflict (https://docs.mapier.ai/convo/api/errors/conflict) > The request clashes with an earlier one, or with the current state `409` · **Retry: only `idempotency_key_in_flight` and `card_update_in_flight`.** Read `details.reason`: it says whether to wait, resend under a new key, or change the request. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ---------------------------- | --------------------------------------------------------------- | -------- | -------------------------------------------------------- | | `idempotency_key_in_flight` | The first attempt with this key is still running | All | Wait, then send again with the same key | | `idempotency_key_failed` | Nothing was sent for this key's `message.send` | All | Send again under a new key | | `idempotency_key_unresolved` | The key named a `message.send` whose result is unknown | All | Check the conversation before any resend | | `idempotency_key_reused` | The key already named a different command | All | Send the original body, or use a new key | | `no_command` | No command was ever accepted under this id | All | There is no result to read | | `card_update_in_flight` | The app card's first send or latest update has not finished yet | iMessage | Wait for its `command` event, then send the update again | | `details.reason` | Means | Channels | Fix | | ----------------------- | --------------------------------------------- | -------- | -------------------------- | | `number_on_mapier_line` | The number is, or was, a Mapier iMessage line | WhatsApp | Connect a different number | ## Example [#example] ```json title="409 Conflict" { "error": { "code": "conflict", "message": "The first attempt with this key is still running.", "details": { "reason": "idempotency_key_in_flight" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#conflict.idempotency_key_in_flight", "retryable": true } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # conversation_closed (https://docs.mapier.ai/convo/api/errors/conversation_closed) > Your line can no longer send into this group `409` · **Retry: no.** Your line can no longer reach this group. Stop sending into it; `conversation.status_changed` says when it is active again. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ---------------- | ---------------------------------------------------------------------- | -------- | ------------------------------- | | `removed` | Your line is no longer in the group: it was removed or lost its access | All | Add the line back to send again | | `deleted` | The group was deleted | All | — | | `archived` | The group was archived | All | Unarchive it to send again | | `suspended` | The channel suspended the group | All | — | ## Example [#example] ```json title="409 Conflict" { "error": { "code": "conversation_closed", "message": "Your line is no longer in the group: it was removed or lost its access.", "details": { "reason": "removed" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#conversation_closed.removed", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # forbidden (https://docs.mapier.ai/convo/api/errors/forbidden) > The credential may not make this call here `403` · **Retry: no.** The key or token may not make this call here. `details.reason` says why. Nothing was done. ## Reasons [#reasons] This table lists every reason, and the fix. | `details.reason` | Means | Fix | | ------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | | `personal_token_required` | The route takes a personal access token, and a project API key was sent | Call it with a personal access token | | `personal_token_not_supported` | The route does not take a personal access token | Call it with a project API key | | `environment` | The token was not made for the environment the call names, or for `live` | Send `x-mapier-environment` naming an environment the token was made for | | `role` | The token's owner no longer holds a role that allows this | Ask an admin for the role, or use a token of somebody who has it | A token is never more than its owner: it needs the scope a route names and the same right in its owner's role now, read on every call. A token made for `test` alone gets `environment` when it sends no `x-mapier-environment`, because a call that names none is `live`. See [Personal access tokens](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens). ## Example [#example] ```json title="403 Forbidden" { "error": { "code": "forbidden", "message": "This route takes a personal access token.", "details": { "reason": "personal_token_required" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#forbidden.personal_token_required", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Authentication](https://docs.mapier.ai/convo/guides/get-started/authentication) # Errors (https://docs.mapier.ai/convo/api/errors) > The error body, what retryable means, and every code A refused request gets a 4xx or 5xx status and the same JSON body every time. Usually nothing was sent; `details.messageId` and `details.sentParts` say when something was. ## The error body [#the-error-body] ```json title="403 Forbidden" { "error": { "code": "recipient_not_allowed", "message": "This person opted out of your messages.", "details": { "reason": "opted_out" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#recipient_not_allowed.opted_out", "retryable": false } } ``` | Field | Means | | ---------------------- | -------------------------------------------------------------------------- | | `code` | What went wrong, the value to switch on | | `details.reason` | Which case of that code, from a fixed list per code | | `details` on a `422` | A list: each field at fault, with `path`, `message` and sometimes `reason` | | `details.retryAfter` | Seconds to wait, when known | | `details.messageId` | A message that may have gone out: read its result, don't resend | | `details.sentParts` | Parts of a split message already sent | | Other `details` fields | Some codes add their own, listed on the code's page | | `message` | A sentence for people, never for parsing | | `requestId` | Give this to support | | `docUrl` | This code's row on this page, at the reason when there is one | | `retryable` | `true` when the same request can succeed later | ## When `retryable` is true [#when-retryable-is-true] Only six cases are retryable. Every other refusal needs a fix first. - `429 rate_limited`, and `503 service_busy`. - `503 line_unavailable` with reason `transport_down`: the line's connection to the channel is down for now. - `503 upstream_unavailable` when nothing reached the channel. - `409 conflict` with reason `idempotency_key_in_flight`, and with reason `card_update_in_flight` once the card's last send has finished. [Retries](https://docs.mapier.ai/convo/guides/production/retries) says which `Idempotency-Key` to send in each case. ## Every code [#every-code] This table lists every code, and whether `retryable` can be `true`. | Status | Code | Means | `retryable` | | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------ | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | The request could not be read, or a header it needs is missing | No | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | The key or token is missing, unknown, revoked or expired | No | | 403 | [`channel_not_entitled`](https://docs.mapier.ai/convo/api/errors/channel_not_entitled) | This channel is not turned on for your project | No | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | The key or token may not make this call here | No | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | The key or token lacks the scope for this call | No | | 403 | [`line_not_allowed`](https://docs.mapier.ai/convo/api/errors/line_not_allowed) | The line does not belong to this project | No | | 403 | [`recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | You may not send this to this person now | No | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | Nothing exists at that id | No | | 404 | [`unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) | This channel or line cannot do that, or the name is retired | No | | 409 | [`conflict`](https://docs.mapier.ai/convo/api/errors/conflict) | The request clashes with an earlier one, or with the current state | Only `idempotency_key_in_flight` and `card_update_in_flight` | | 409 | [`conversation_closed`](https://docs.mapier.ai/convo/api/errors/conversation_closed) | Your line can no longer send into this group | No | | 409 | [`limit_reached`](https://docs.mapier.ai/convo/api/errors/limit_reached) | A test line's daily cap, your paid lines, or another count is reached | No | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | The project is archived | No | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | The request body is over 64 KiB | No | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | A field is missing or wrong | No | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | Too many requests | Yes | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | Mapier failed on its side | No | | 503 | [`capacity_exhausted`](https://docs.mapier.ai/convo/api/errors/capacity_exhausted) | Every line is full for new people | No | | 503 | [`line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable) | The line cannot send right now | Only `transport_down` | | 503 | [`no_line`](https://docs.mapier.ai/convo/api/errors/no_line) | Your project has no active line on that channel | No | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | Mapier is busy and did nothing | Yes | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | The channel did not answer | Only before anything was sent | Older API versions use other words for some codes and reasons: see [Older versions](https://docs.mapier.ai/convo/api/versions). ## Next [#next] - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # insufficient_scope (https://docs.mapier.ai/convo/api/errors/insufficient_scope) > The key or token lacks the scope for this call `403` · **Retry: no.** In the console, create a key or token with the scope this call needs. Nothing was done. ## Example [#example] ```json title="403 Forbidden" { "error": { "code": "insufficient_scope", "message": "The key or token does not carry the scope this route needs.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#insufficient_scope", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # internal_error (https://docs.mapier.ai/convo/api/errors/internal_error) > Mapier failed on its side `500` · **Retry: no.** Mapier has been alerted. If this was a send, read its result before you resend with the same `Idempotency-Key`. ## Example [#example] ```json title="500 Internal Server Error" { "error": { "code": "internal_error", "message": "Mapier failed on its side, and has been alerted.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#internal_error", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # invalid_credentials (https://docs.mapier.ai/convo/api/errors/invalid_credentials) > The key or token is missing, unknown, revoked or expired `401` · **Retry: no.** Send a working key or personal access token in `Authorization: Bearer`. A token whose owner left the organization gets this too, and so does every refused [renewal of a terminal sign-in](https://docs.mapier.ai/convo/api/sign-in/renew). Nothing was sent. ## Example [#example] ```json title="401 Unauthorized" { "error": { "code": "invalid_credentials", "message": "The API key is missing, malformed, unknown, revoked or expired.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#invalid_credentials", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # limit_reached (https://docs.mapier.ai/convo/api/errors/limit_reached) > A test line's daily cap, your paid lines, or another count is reached `409` · **Retry: no.** A limit is reached. `details.limit` says which one, and `details.maximum` is its value. ## Limits [#limits] This table lists every limit, the request it answers, and the fix. | `details.limit` | Answers | Fix | | ---------------------------- | ------------------------------------- | --------------------------------------------- | | `sharedLineSendsPerDay` | A command on a test line | Wait until 00:00 UTC, when it resets | | `sharedLineNonRepliesPerDay` | A command on a test line | Wait until 00:00 UTC, when it resets | | `purchasedLines` | `POST /v1/line-setups` for a new line | Add lines on your organization's Billing page | A test line is one on a shared number: its `Line` in `GET /v1/whoami` carries `shared`. The lines you already hold are never affected by `purchasedLines`. Two more counts answer `limit_reached` without a `details.limit` from the table: | Answers | Fix | | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | | [`POST /v1/webhook-endpoints`](https://docs.mapier.ai/convo/api/webhook-endpoints/create): a sixth endpoint in one environment | Delete or reuse an endpoint | | [`POST /v1/cli/logins/token`](https://docs.mapier.ai/convo/api/sign-in/poll-login): the person already holds ten active tokens | Revoke one; the next poll succeeds while the login lasts | ## Example [#example] ```json title="409 Conflict" { "error": { "code": "limit_reached", "message": "This test line has sent its 500 messages for today. The count resets at 00:00 UTC.", "details": { "limit": "sharedLineSendsPerDay", "maximum": 500 }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#limit_reached", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # line_not_allowed (https://docs.mapier.ai/convo/api/errors/line_not_allowed) > The line does not belong to this project `403` · **Retry: no.** Pick a line from `GET /v1/whoami`, or leave `target.lineId` out. Nothing was sent. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ---------------- | ------------------------------------------------------ | -------- | --------------------------------- | | `not_owned` | The line belongs to another project, or does not exist | All | Pick a line from `GET /v1/whoami` | ## Example [#example] ```json title="403 Forbidden" { "error": { "code": "line_not_allowed", "message": "The line belongs to another project, or does not exist.", "details": { "reason": "not_owned" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#line_not_allowed.not_owned", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # line_unavailable (https://docs.mapier.ai/convo/api/errors/line_unavailable) > The line cannot send right now `503` · **Retry: only `transport_down`.** Read `details.reason`: it says whether to wait or act. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ---------------------------------------------------------------------------- | ------------------------------------------- | -------- | -------------------------------------------------------- | | `line_paused` | The line is paused | All | Resume the line in the console | | `line_retired` | The line was retired from your project | All | Start a new conversation with the person on another line | | `transport_down` | The line cannot reach its channel right now | All | Retry with backoff and the same key | | `transport_unconfigured` | The line is not fully set up yet | All | Contact support if this lasts | | `channel_not_available` | The project has no line on this channel | All | — | ## Example [#example] ```json title="503 Service Unavailable" { "error": { "code": "line_unavailable", "message": "The line is paused.", "details": { "reason": "line_paused" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#line_unavailable.line_paused", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # no_line (https://docs.mapier.ai/convo/api/errors/no_line) > Your project has no active line on that channel `503` · **Retry: no.** Add a line in the console. Nothing was sent. ## Example [#example] ```json title="503 Service Unavailable" { "error": { "code": "no_line", "message": "The project has no active line on that channel.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#no_line", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # not_found (https://docs.mapier.ai/convo/api/errors/not_found) > Nothing exists at that id `404` · **Retry: no.** Use an id from your own events, with a key from the same project. ## Example [#example] ```json title="404 Not Found" { "error": { "code": "not_found", "message": "Nothing with that id exists in this project.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#not_found", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # payload_too_large (https://docs.mapier.ai/convo/api/errors/payload_too_large) > The request body is over 64 KiB `413` · **Retry: no.** Shorten the request, and send files by link. Nothing was sent. ## Example [#example] ```json title="413 Content Too Large" { "error": { "code": "payload_too_large", "message": "The body is over 65,536 bytes.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#payload_too_large", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # project_archived (https://docs.mapier.ai/convo/api/errors/project_archived) > The project is archived `409` · **Retry: no.** Restore the project in the console, or use a key from a live project. ## Example [#example] ```json title="409 Conflict" { "error": { "code": "project_archived", "message": "The key's project is archived.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#project_archived", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # rate_limited (https://docs.mapier.ai/convo/api/errors/rate_limited) > Too many requests `429` · **Retry: yes.** Wait the seconds in the `Retry-After` header, then send the same request. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ------------------- | ------------------------------------------------------------------------------------------------------ | -------- | ---------------------------------------------------------------------------------------------- | | `too_many_streams` | The key holds as many open streams as it may | All | Close one, then wait `details.retryAfter` seconds | | `error_budget` | The channel kept rejecting this line's sends, so Mapier refuses new sends from it for about 10 minutes | All | Wait `details.retryAfter` seconds, then retry | | `shared_line` | This test line is on a shared number, and its budget for your project is spent for now | iMessage | Wait, then retry | | `card_update_limit` | This app card has had 50 updates in the past hour | iMessage | Wait `details.retryAfter` seconds, then send the update again under the same `Idempotency-Key` | ## Example [#example] ```json title="429 Too Many Requests" { "error": { "code": "rate_limited", "message": "The key holds as many open streams as it may.", "details": { "reason": "too_many_streams" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#rate_limited.too_many_streams", "retryable": true } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # recipient_not_allowed (https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) > You may not send this to this person now `403` · **Retry: no.** A channel rule, the person, or your own console setting blocks this send. Nothing was sent. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | --------------------------------------------------------------- | | `opted_out` | The person opted out | All | Wait until they [opt back in](https://docs.mapier.ai/convo/guides/production/opt-out) | | `outside_service_window` | The reply window has closed; `details.serviceWindowExpiresAt` says when it did | WhatsApp | Send an approved template | | `blocked` | You blocked this person in the console | All | Unblock them in the console | | `paused` | You paused this person in the console | All | Resume them in the console | | `recipient_must_write_first` | Nobody but your line has written in this conversation, so an app card cannot go in. Or, on a test line on a shared number, the person has not texted the line, is no longer connected, or has left 20 turns or 100 messages unanswered since they last texted | iMessage | Wait until someone writes | | `app_card_needs_imessage` | The newest message in this conversation did not go by iMessage, or none has been seen | iMessage | Wait until the person writes by iMessage | | `group_member_not_test_contact` | A group on a test line on a shared number takes only this project's connected Test contacts, and someone in it is not one. Where the refusal names an address, it is the first in sort order of those that stopped the group | iMessage | Connect them as Test contacts, or leave them out of the group | With `outside_service_window`, `details.remedy` says what to do instead. `details.reachability` is what [`GET /v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability) returns for this person. ## Example [#example] ```json title="403 Forbidden" { "error": { "code": "recipient_not_allowed", "message": "The person opted out, and every send to them is rejected until they opt back in.", "details": { "reason": "opted_out" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#recipient_not_allowed.opted_out", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out) - [Check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send) # service_busy (https://docs.mapier.ai/convo/api/errors/service_busy) > Mapier is busy and did nothing `503` · **Retry: yes.** Nothing was done. Wait `details.retryAfter` seconds, then send the same request. ## Example [#example] ```json title="503 Service Unavailable" { "error": { "code": "service_busy", "message": "Mapier is busy and did nothing with this request.", "details": {}, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#service_busy", "retryable": true } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # unsupported_command (https://docs.mapier.ai/convo/api/errors/unsupported_command) > This channel or line cannot do that, or the name is retired `404` · **Retry: no.** Check the command against the line's channel. Nothing was sent. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ----------------- | -------------------------------------------------------------------- | -------- | ---------------------------------------------------- | | `not_on_channel` | The line's channel does not support this command type | All | `details.channel` and `details.capability` say which | | `command_retired` | The command type was retired | All | `details.use` names the one to send instead | | `not_on_line` | This line does not support the command type, though its channel does | All | Check the line's `capabilities` in `GET /v1/whoami` | | `shared_line` | A test line on a shared number does not carry this command | iMessage | Send it from a line of your own | ## Example [#example] ```json title="404 Not Found" { "error": { "code": "unsupported_command", "message": "The line's channel does not support this command type.", "details": { "reason": "not_on_channel" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#unsupported_command.not_on_channel", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # upstream_unavailable (https://docs.mapier.ai/convo/api/errors/upstream_unavailable) > The channel did not answer `503` · **Retry: only before anything was sent.** Read `details.reason`. When nothing was sent, retry with backoff; give a resent message a new key. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ------------------- | ------------------------------------------------- | -------- | ---------------------- | | `network` | Mapier could not reach the channel | All | Retry with backoff | | `redirect` | The channel answered with a redirect | All | Retry with backoff | | `status_5xx` | The channel answered with a server error | All | Retry with backoff | | `timeout` | The channel did not answer in time | All | Retry with backoff | | `unexpected_status` | The channel gave an answer Mapier could not use | All | Retry with backoff | | `unspecified` | The channel rejected the command without a reason | All | Retry with backoff | | `media_not_staged` | The channel lost the file before sending it | All | Send the message again | ## Example [#example] ```json title="503 Service Unavailable" { "error": { "code": "upstream_unavailable", "message": "Mapier could not reach the channel.", "details": { "reason": "network" }, "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#upstream_unavailable.network", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # validation_failed (https://docs.mapier.ai/convo/api/errors/validation_failed) > A field is missing or wrong `422` · **Retry: no.** `details` names each field at fault, at its `path`. Fix each one, then send again. ## Reasons [#reasons] This table lists every reason, the channels it applies to, and the fix. | `details.reason` | Means | Channels | Fix | | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------------------------------------- | | `conversation_not_confirmed` | The person has not written in this conversation yet | All | Send a plain text, and wait for them to reply | | `media_fetch_refused` | Mapier would not fetch the file's link | All | Use a public `https` link | | `media_fetch_failed` | Mapier could not fetch the file in time | All | Check that the link works, then retry | | `media_too_large` | The file is over the channel's size limit | All | Send a smaller file | | `unsupported_media_type` | The channel does not take this kind of file, or the file is not the type it says | All | Send another type | | `invalid_target` | The message named is not one this line sent in that conversation | All | — | | `not_yet_addressable` | The channel has not confirmed this message yet | All | Wait for its `command` event, then try again | | `window_elapsed` | The time to change this message has passed | All | — | | `card_not_updatable` | The app card cannot be updated: it failed or was never confirmed, Messages gave it no id, the person started it, its app was disabled, or the conversation moved to another line | iMessage | Send a new card | ## Example [#example] ```json title="422 Unprocessable Content" { "error": { "code": "validation_failed", "message": "The person has not written in this conversation yet.", "details": [ { "path": "target.conversationId", "message": "The person has not written in this conversation yet.", "reason": "conversation_not_confirmed" } ], "requestId": "0192c4e1-…", "docUrl": "https://docs.mapier.ai/convo/api/errors#validation_failed.conversation_not_confirmed", "retryable": false } } ``` ## Next [#next] - [Errors](https://docs.mapier.ai/convo/api/errors) - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # Event types (https://docs.mapier.ai/convo/api/events/event-types) > Every event your project receives, and where each is described Every event has the same id on [Stream events](https://docs.mapier.ai/convo/api/events/stream) and [List events](https://docs.mapier.ai/convo/api/events/list). List events names each by its webhook type (`message.received` for a `message` event, `command.settled` for a `command` event). Each event below links to its fields. | Event | When it arrives | | -------------------------------------------------------------------- | ------------------------------------------------------------------------ | | [`command`](https://docs.mapier.ai/convo/api/events/stream#event-command) | A command you sent has its final result | | [`message`](https://docs.mapier.ai/convo/api/events/stream#event-message) | A person wrote to your line | | [`message.received`](https://docs.mapier.ai/convo/api/events/stream#event-messagereceived) | A person wrote to your line, in the webhook's shape, when you ask for it | | [`receipt`](https://docs.mapier.ai/convo/api/events/stream#event-receipt) | A message you sent was delivered or read | | [`delivery_failed`](https://docs.mapier.ai/convo/api/events/stream#event-delivery_failed) | A message you sent did not reach the person | | [`location`](https://docs.mapier.ai/convo/api/events/stream#event-location) | A person shared their location | | [`moderation`](https://docs.mapier.ai/convo/api/events/stream#event-moderation) | A message was edited or unsent | | [`poll`](https://docs.mapier.ai/convo/api/events/stream#event-poll) | A poll was created, or someone voted | | [`reaction`](https://docs.mapier.ai/convo/api/events/stream#event-reaction) | Someone reacted to a message | | [`conversation`](https://docs.mapier.ai/convo/api/events/stream#event-conversation) | A conversation or group changed | | [`chat_background`](https://docs.mapier.ai/convo/api/events/stream#event-chat_background) | A conversation's background changed | | [`gap`](https://docs.mapier.ai/convo/api/events/stream#event-gap) | Some of a line's messages may be missing from a window of time | | [`error`](https://docs.mapier.ai/convo/api/events/stream#event-error) | The stream stopped with an error | Some events arrive only when you ask for them with `?events=`. [Stream events](https://docs.mapier.ai/convo/api/events/stream) lists each option. ## Guide [#guide] [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) # List events (https://docs.mapier.ai/convo/api/events/list) > Read back your project's events, newest first **GET** `/v1/events` Your project's event history, newest first: the events your webhooks and your stream receive, read back. Use it to catch up on what happened before you were listening. The stream starts from now or from an id you already hold, and a webhook endpoint is sent only what happens after it subscribes; neither reads back. ```bash tab="cURL" curl "https://api.mapier.ai/v1/events?type=message.received,command.settled&limit=2" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // Every message received since a moment, newest first, one page at a time. let cursor: string | null = null; do { const params = new URLSearchParams({ type: "message.received", from: "2026-08-24T18:00:00.000Z", }); if (cursor) params.set("cursor", cursor); const res = await fetch(`${BASE}/v1/events?${params}`, { headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", }, }); const page = await res.json(); for (const event of page.events) console.log(event.id, event.type, event.data.text); cursor = page.nextCursor; } while (cursor); ``` ```json title="200 OK" { "events": [ { "id": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d10", "type": "message.received", "occurredAt": "2026-08-24T18:03:11.000Z", "data": { "conversationId": "a0000000-0000-4000-8000-000000000001", "from": "+14155550100", "text": "is it here yet?", "externalId": "5D1B7E0A-2F3C-4B8E-9A61-1C2D3E4F5A6B", "replyToExternalId": null, "occurredAt": "2026-08-24T18:03:11.000Z", "attachmentIds": [], "attachments": [], "messageId": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "contactId": "c0000000-0000-4000-8000-000000000003", "optedOut": false } }, { "id": "0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a37", "type": "command.settled", "occurredAt": "2026-08-24T18:01:02.000Z", "data": { "commandId": "3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71", "logicalActionId": "order-2481", "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000001", "type": "message.send", "messageId": "0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a99", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "externalId": null, "namePhoto": null, "projectId": "b0000000-0000-4000-8000-000000000002", "environment": "live", "failureClass": null } } ], "nextCursor": "eyJiZWZvcmUiOiIyMDI2LTEwLTExVDA5OjEyOjQwWiJ9" } ``` ## Parameters [#parameters] - type?: string (event types, comma-separated) — The event types to list. Omit it for the default subscription (below). A value that is not an event type is a 422 validation_failed at type whose entry names it in unknown. - resourceId?: string (UUID) — Only the events about one thing: a message's messageId (its receipts, reactions, edits and the command.settled of the send that wrote it), a conversation's conversationId (conversation.created, its locations and its polls), a line's lineId, or a contact's contactId (contact.opt_out_changed). - from?: string (ISO 8601 with its zone) — Only events recorded at or after this instant, to the millisecond, like 2026-10-17T04:00:12.345Z. A value with no zone, or one after to, is a 422 at from. - to?: string (ISO 8601 with its zone) — Only events recorded at or before this instant. Alone, it starts the list there: the first page is the newest events recorded by then. A value with no zone is a 422 at to. - cursor?: string (at most 200 characters) — The nextCursor of the page before, to read the next, older page. Omit it for the newest page. - limit?: integer (1 to 100, default 25) — How many events a page holds. Omit `type` and the list is the types a new webhook endpoint is subscribed to by default. The ten opt-in types are listed only when `type` names them, as a webhook endpoint and the stream treat them: `location.share_started`, `location.updated`, `location.share_ended`, `message.edited`, `message.unsent`, `poll.created`, `poll.options_changed`, `poll.voted`, `poll.vote_cleared` and `conversation.background_changed`. `from` and `to` filter on when an event was **recorded**. For most events that is its `occurredAt`. An inbound event — a message, a receipt, a reaction — is recorded later, by however long the channel took to report it: usually seconds, longer after a connection outage. So a `to` copied from an inbound event's `occurredAt` can leave that event out. Page with `cursor`: pass each answer's `nextCursor` back, with the same filters, until it is `null`. A cursor past the last page answers an empty page. A cursor is opaque: never build or parse one. ## Response [#response] `events` is one page, newest first, and `nextCursor` is the cursor for the next, older page, or `null` on the last. - id: string (UUID) — The event's id: the same id the stream sends it with, and the id (and mapier-event-id header) a webhook endpoint receives it under. Deduplicate across all three on it. - type: string — What happened. The same string a webhook subscription names. - occurredAt: string (ISO 8601, UTC) — When it happened, to the millisecond. For an inbound event this is the channel's own instant, which can be earlier than when the event was recorded. - data: object — The event's own fields, by type: for a type the stream sends, exactly that stream event's data; for any other type, the data a webhook subscribed to it receives. Each type the stream also sends carries that stream event as its `data`: | `type` | `data` is the stream's | | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | | `message.received` | [`message` event](https://docs.mapier.ai/convo/api/events/stream#event-message) | | `command.settled` | [`command` event](https://docs.mapier.ai/convo/api/events/stream#event-command) | | `message.delivered`, `message.read` | [`receipt` event](https://docs.mapier.ai/convo/api/events/stream#event-receipt) | | `message.delivery_failed` | [`delivery_failed` event](https://docs.mapier.ai/convo/api/events/stream#event-delivery_failed) | | `location.share_started`, `location.updated`, `location.share_ended` | [`location` event](https://docs.mapier.ai/convo/api/events/stream#event-location) | | `message.edited`, `message.unsent` | [`moderation` event](https://docs.mapier.ai/convo/api/events/stream#event-moderation) | | `poll.created`, `poll.options_changed`, `poll.voted`, `poll.vote_cleared` | [`poll` event](https://docs.mapier.ai/convo/api/events/stream#event-poll) | | `conversation.background_changed` | [`chat_background` event](https://docs.mapier.ai/convo/api/events/stream#event-chat_background) | Every other type — `message.sent`, `message.failed`, `reaction.added`, `conversation.created`, `line.status_changed` and the rest — carries the `data` a [webhook](https://docs.mapier.ai/convo/guides/receive/receive-events) subscribed to it receives. ## Read back, then follow [#read-back-then-follow] Any `id` you read here is a `Last-Event-ID` that [`/v1/response_stream`](https://docs.mapier.ai/convo/api/events/stream#resuming-with-last-event-id) resumes after, so you can read back and then follow. Resume from an id a few seconds older than the newest you read, and deduplicate on `id`: an event can appear a moment after one with a newer `id`. ## How long events are kept [#how-long-events-are-kept] Events are kept for at least 90 days. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | With a personal access token, an `x-mapier-project` it cannot reach | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | A `type` that is not an event type, a `resourceId` that is not a UUID, a bad `from`, `to` or `cursor`, or an `x-mapier-version` that is not a published version | | `429` | `rate_limited` | 120 requests per minute, per key; the `Retry-After` header says how long to wait | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and ask again | | `503` | `upstream_unavailable` | A service behind Mapier did not answer; retry with backoff | ## Guide [#guide] - [Stream events](https://docs.mapier.ai/convo/api/events/stream) - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) - [List messages](https://docs.mapier.ai/convo/api/conversations/list-messages) # Stream events (https://docs.mapier.ai/convo/api/events/stream) > Everything that happens to your project, as it happens **GET** `/v1/response_stream` One long-lived [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) connection carries what happens to your key's project. By default it sends two events: every incoming message as a `message` event, and every command's result as a `command` event. Ask for more with `?events=` ([Asking for more events](#asking-for-more-events)): receipts, delivery failures, shared locations, edits and unsends, polls, reactions, conversation changes, gaps in a line's messages and chat background changes. A stream that ends because your key or your project stopped working says so in an `error` event before it closes. Every event but the closing `error` carries an `id:` you can resume from. Every event carries an `id:`, and reconnecting with `Last-Event-ID` resumes where you left off; see [Resuming](#resuming-with-last-event-id). To read back events from before you held an id, use [`GET /v1/events`](https://docs.mapier.ai/convo/api/events/list). ## Anatomy of a connection [#anatomy-of-a-connection] ```bash curl -N https://api.mapier.ai/v1/response_stream \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ -H "Accept: text/event-stream" ``` Response headers: ```http HTTP/1.1 200 OK content-type: text/event-stream; charset=utf-8 cache-control: no-store x-accel-buffering: no ``` The first bytes on the wire are a reconnect hint and a comment confirming the stream is live: ``` retry: 3000 : connected ``` Then, every 25 seconds, a heartbeat — on a fixed interval, whether or not events were written in between: ``` : ping ``` Lines starting with `:` are SSE comments, not events. Five are written: `: connected`, `: ping`, `: catching up` and `: replay window exceeded` (the last two under [Resuming](#resuming-with-last-event-id)), and `: bye` when the server is being replaced during a deploy — reconnect on the `retry:` it gave you. A client that acts only on `event:` and `data:` lines ignores all of them. Every event but `error` names the line it happened on at `lineId`, the line's `id` as [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists it under `lines[]`. Only what happens after a line joins Mapier is sent: its messages, polls and conversations from before then are never sent, on a live connection or on a resume. See [Read what was said](https://docs.mapier.ai/convo/guides/conversations/conversations#read-what-was-said). ## Query parameters and headers [#query-parameters-and-headers] | Parameter | In | | | ------------------ | ------ | --------------------------------------------------------------------------------------------------------------------- | | `events` | query | Events to add beyond `message` and `command`, comma-separated. See [Asking for more events](#asking-for-more-events). | | `channel` | query | Send only the events about conversations on this channel. One value. See [Narrowing a stream](#narrowing-a-stream). | | `conversationId` | query | Send only the events about this conversation. One value, a UUID. | | `lineId` | query | Send only the events about this line. One value, a UUID. | | `Last-Event-ID` | header | The `id:` of the last event you processed. See [Resuming](#resuming-with-last-event-id). | | `x-mapier-version` | header | Read on every route; nothing this operation does differs between the [versions](https://docs.mapier.ai/convo/api/versions) yet. | A value `events`, `channel`, `conversationId` or `lineId` does not accept is a `422 validation_failed` before the stream opens. Pass `events` once, as one comma-separated value: `?events=receipts&events=delivery_failures` repeats the parameter, and only the first is read, so no `delivery_failed` event arrives and nothing says why. A repeated `channel`, `conversationId` or `lineId`, by contrast, is refused. A `Last-Event-ID` that is not a UUID is ignored rather than refused (see [Resuming](#resuming-with-last-event-id)). ### Asking for more events [#asking-for-more-events] Omit `events` and the stream is exactly two events, `message` and `command`. Each value adds one event: | `events` value | Adds the event | For every message | | ------------------- | ------------------ | -------------------------------------------------------------------------------------------------------- | | `receipts` | `receipt` | a recipient's device reported delivered or read | | `delivery_failures` | `delivery_failed` | the channel accepted it and later reported it not delivered, such as Apple's "Not Delivered" on iMessage | | `locations` | `location` | a contact's shared location started, moved or ended | | `moderation` | `moderation` | a contact edited or unsent a message they sent | | `polls` | `poll` | a poll was created, its choices changed, someone voted or took their vote back | | `reactions` | `reaction` | a reaction was put on or taken off a message, in a direct conversation or a group | | `conversations` | `conversation` | a conversation started, or a group's name, members or status changed | | `gaps` | `gap` | some of a line's messages may be missing from a window of time | | `message.received` | `message.received` | an incoming message, in the webhook's shape — in place of its `message` event | | `chat_backgrounds` | `chat_background` | a conversation's background was set or removed — by a person, or by the line | `message.received` replaces the `message` event rather than adding one beside it. The values combine: `?events=receipts,delivery_failures,locations,moderation,polls,reactions,conversations,gaps,message.received,chat_backgrounds`. A value not listed here is a `422` whose `details` entry names it in `unknown` and lists the values this stream sends in `supported`: ```json title="GET /v1/response_stream?events=receipt — 422" { "error": { "code": "validation_failed", "message": "That is not a stream option.", "details": [ { "path": "events", "message": "`events` takes a comma-separated list of: receipts, delivery_failures, locations, moderation, polls, reactions, conversations, gaps, message.received, chat_backgrounds.", "unknown": ["receipt"], "supported": [ "receipts", "delivery_failures", "locations", "moderation", "polls", "reactions", "conversations", "gaps", "message.received", "chat_backgrounds" ] } ] } } ``` ### Narrowing a stream [#narrowing-a-stream] `channel` sends only the events about conversations on that channel, and takes one of `imessage` · `whatsapp`. An event's channel is its conversation's, so a `command` event for a command that names no conversation is sent only on a stream with no `channel`. `conversationId` sends only the events about one conversation: its inbound messages, the commands that name it and — on a stream opened with an `events` value — the `receipt`, `delivery_failed`, `location`, `moderation`, `poll`, `reaction`, `conversation`, `gap`, `message.received` and `chat_background` events about it. A `gap` that names no conversation is about every conversation on its line, so it is sent too. It must be a conversation in your key's project, and on `channel` when you give both. Otherwise the answer is a `422`: at `conversationId` for a conversation this key cannot stream, or at `channel` — carrying the channel the conversation is on in the entry's own `channel` — when the two disagree. More than one value for either parameter is a `422` too. `lineId` sends only the events about one line: its `id` as [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists it, the `lineId` every event carries — at the top level of its `data:`, and inside `data` on a `message.received` event. A line this key cannot use is a `403 line_not_allowed`. With `channel` it must be on that channel, and with `conversationId` it must be that conversation's line; otherwise the answer is a `422` naming the field. The three filters combine: an event is sent when it matches every one given. A filter narrows what a stream **sends**, not what it reads: a narrowed stream reads the project's events as an unnarrowed one does and sends the events that match, so it costs what any stream costs and counts toward the same four open streams. Narrow by channel, or follow one conversation; to follow many, open one stream and read `conversationId` off the `message`, `command`, `location`, `moderation`, `poll`, `reaction`, `conversation` and `chat_background` events. A `gap` names its conversations in `conversationIds`. The `receipt` and `delivery_failed` events carry none: correlate them by `commandId` or `messageId`. ## Resuming with `Last-Event-ID` [#resuming-with-last-event-id] Every event but `error` carries an `id:` line before its `event:` line. Keep the `id:` of the last event you finished processing, and send it as `Last-Event-ID` when you reconnect: ```bash curl -N https://api.mapier.ai/v1/response_stream \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ -H "Accept: text/event-stream" \ -H "Last-Event-ID: 0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a37" ``` - **At most 500 are replayed per batch.** The stream sends the events after that id, 500 at a time, in order. If you were further behind, nothing is dropped: the rest follows on the same connection, and a `: catching up` comment marks each batch that stopped at the cap, so 500 events and then silence is not mistaken for having caught up. - **Events are kept for 90 days**, which is how far back an id can resume. An id older than that is not an error: you are sent everything that remains after it, preceded by a `: replay window exceeded` comment so you can tell it from a quiet period. - **On a narrowed stream the 500 counts the events a batch read**, not the events it sent, so a batch may send fewer events and still be followed by `: catching up`. - **A `Last-Event-ID` that is not a UUID is ignored.** Every `id:` this stream writes is one, so anything else did not come from it: the stream starts at the live edge rather than refusing it, because a browser's `EventSource` re-sends the same header on every reconnect and a refusal would come back forever. An event can therefore arrive twice across a reconnect: the one you were reading when the connection dropped. Apply events by `id` and a repeat is a no-op. [Reconnection and delivery guarantees](https://docs.mapier.ai/convo/guides/receive/receive-events) has a loop that keeps the id and a parser that reads it. To read back events from before you ever held an id, list them with [`GET /v1/events`](https://docs.mapier.ai/convo/api/events/list): every `id` it answers is a `Last-Event-ID` this stream resumes after. ## Event: `command` [#event-command] A command reached its terminal status. Emitted once per command. ``` id: 0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a37 event: command data: {"commandId":"3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71","logicalActionId":"order-2481","status":"succeeded","errorCode":null,"conversationId":"a0000000-0000-4000-8000-000000000001","type":"message.send","messageId":"0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a99","externalId":null,"projectId":"b0000000-0000-4000-8000-000000000002","environment":"live","failureClass":null,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - commandId: string — The commandId the 202 handed back. Match results by it. - logicalActionId: string — Your Idempotency-Key for this command, or the one made for you when you sent none. On an iMessage line a group.create carries a copy of its commandId instead. A message.send on the recipient path whose answer was lost carries the channel's own id. Match results by commandId. - status: string (succeeded | failed | ambiguous | no_effect | cancelled | expired) — Terminal, and emitted once. ambiguous and no_effect are outcomes rather than failures: the channel took the command and could not prove what it changed. - errorCode: string | null — The channel's own code, verbatim, when the command did not succeed — so a support thread can quote it — and null otherwise. An open string: switch on failureClass, and read this for the detail. - conversationId?: string | null (UUID, or null) — The conversation this command acted on: for a reaction, the conversation holding the message it names, and for any command sent to a target.conversationId, that conversation. Null when no conversation is known for it yet, as for a group.create, whose new group is in group. - type: string | null (message.send | reaction.set | reaction.remove | message.read | typing.start | message.edit | message.unsend | name_photo.get | name_photo.set | poll.vote | chat_background.set | chat_background.remove | app_card.update | reaction.tapback | name_photo.share | group.create | group.update | group.leave | whatsapp.template.send | whatsapp.interactive.send | whatsapp.location.send | whatsapp.contacts.send | whatsapp.group.create | messenger.interactive.send | null) — The command type you sent, the {type} of POST /v1/commands/{type}. A command sent under a second name is reported under the older one: conversation.mark_read as message.read, profile.* as name_photo.*. Null only for a result Mapier cannot match to a command it sent, which can happen to a group.create on an iMessage line. - messageId: string | null (UUID, or null) — Mapier's id for the message this command wrote — the one GET /v1/messages/{messageId}/receipts takes and a later target.replyToMessageId names. Null for a command that writes no message, such as a reaction or a group command. - externalId: string | null — Deprecated: read platformMessageId instead, which carries the same value; this field stays and is never removed. The channel's own id for the message this command wrote. Null when the command wrote no message, when it did not succeed, and when the channel's result named no id for the message it created. - group: object | null ({ conversationId, inviteLink? }, or null) — The new group on a succeeded command that made one, such as group.create: its conversationId and, where people join it by link, the inviteLink. Keep the link: it works as long as this result is kept. Null on every other result. - namePhoto: object | null ({ name, firstName, lastName, hasPhoto }, or null) — The line's own Name and Photo card on a succeeded name_photo.get (the card as it is) or name_photo.set (the card read back after the change). The photo itself is not returned. Null on every other result. - appCard: object | null ({ updatable }, or null) — On a succeeded iMessage app card, whether it can be updated later with app_card.update: false means Messages gave the card no id, so send a new card to change it. Null on every other result. - projectId: string (UUID) — The project the key that sent the command belongs to. - environment: string (live | test) — The environment the command was sent in. A stream sends only its own key's events. - failureClass: string | null (target | content | capability | line | rate_limited | not_run | transport | unknown | null) — What kind of failure this was, from a closed set, so a handler can decide without learning any channel's vocabulary. Null unless status is failed, cancelled or expired. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. - platformMessageId?: string | null — The channel's own id for the message this command wrote — the same id a message event carries at platformMessageId for a message the contact sent, so you can correlate with anything the channel shows you and name the message in a later command, such as reaction.set at payload.targetExternalId. Reply to it by messageId, not by this. Null when the command wrote no message, when it did not succeed, and when the channel's result named no id for the message it created. externalId carries the same value; absent only on an answer from before the field. A `202` — an adopted one included — says the command was queued; this event says how it ended. For `message.send`, `succeeded` is the channel's result of the send and not a delivery receipt. Delivery is a [`receipt`](#event-receipt) event on a stream opened with `?events=receipts`, and a channel's later "not delivered" is a [`delivery_failed`](#event-delivery_failed) event, which moves no status. ### Switch on `failureClass` [#switch-on-failureclass] `errorCode` is the channel's own word and the set is open; `failureClass` is closed, the same for every channel, and it is the one to branch on. What each value means is in [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery#why-a-command-failed). The same class is on the `command.settled` and `message.failed` webhooks, and the `409` that hands a retried `Idempotency-Key` the first attempt's code. ## Event: `message` [#event-message] Someone sent a message to one of your lines. Your own sends do not echo here. ``` id: 0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d10 event: message data: {"conversationId":"a0000000-0000-4000-8000-000000000001","from":"+14155550100","text":"is it here yet?","externalId":"5D1B7E0A-2F3C-4B8E-9A61-1C2D3E4F5A6B","replyToExternalId":null,"occurredAt":"2026-08-24T18:03:11.000Z","attachmentIds":[],"attachments":[],"messageId":"0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22","lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d","contactId":"c0000000-0000-4000-8000-000000000003","optedOut":false} ``` - conversationId: string (UUID) — The conversation this arrived in. Send back to it with this id. - from: string — The contact's address, normalized — never one of your own lines. - text: string | null — Null for a message that carried no text — attachments alone, for one. On iMessage it is also null for the message a chat background change leaves in a conversation with one person on a line whose device predates the chat_background event, and for a poll message that arrived before its poll.created event. - externalId: string — Deprecated: read platformMessageId instead, which carries the same value; this field stays and is never removed. The channel's own id for this message, so you can correlate with anything you already hold. It falls back to Mapier's id when the channel supplied none. - replyToExternalId: string | null — The message being replied to. Unlike externalId this is always Mapier's message id, never the channel's — the id you were handed when that message was created, so it is the one you can look up. Null when the message is not a reply. - occurredAt: string (ISO 8601 with Z) — When the channel says it happened, which is not when you received this event. - attachmentIds: string[] — Fetch each with GET /v1/attachments/{id}. - messageId: string (UUID) — Mapier's id for this message. Reply to it by naming it at target.replyToMessageId, and match a later message's replyToExternalId against it. - lineId: string (UUID) — The line the message arrived on — its id as GET /v1/whoami lists it under lines, and the line a reply into the conversation goes out on. - attachments: object[] ({ id, mimeType, filename, byteSize, isSticker?, kind? }) — What attachmentIds lists, one entry per id in the same order, with what the sender's device said about each: mimeType, filename (or null), byteSize (or null), isSticker, absent when the channel did not say, and kind, voice_note when the message is a voice memo and this is its recording — never read an absent kind as not a voice note. mimeType is the type the device declared, or the type its declared kind (Apple's UTI) names — audio/x-caf for a voice memo — and null when neither says. - isVoiceMemo?: boolean — true when the channel reported the message as a voice memo — the recording is among its attachments, and text may carry the channel's transcript. Absent otherwise: never read absent as false. - effect?: string — The effect the sender chose, as the channel names it — on iMessage a bubble or screen effect by its short name (impact, confetti, shootingstar, …), or Apple's own identifier for one the sender's device does not know: tolerate a value you do not recognize. Absent when there was none, or the channel did not say. - isGroup?: boolean — Whether the conversation this message arrived in is a group chat, as the channel reported it: true for a group, false for a one-to-one conversation, and absent when the channel has not said. A group's messages arrive under the group's own conversationId, never under the sender's one-to-one conversation. - addressed?: boolean — On a group message, whether it is for your line: true when it names your line, replies to a message your line sent, or sits in a thread your line posted in. false only where the channel read the message and found none of these. Absent means nobody could tell — on iMessage, a group message that neither mentions nor replies to your line — so treat the message as addressed. Only false means it was not addressed to the line. Never on a one-to-one message. - service?: string (iMessage | SMS | RCS) — On an iMessage line, the service the line received this message over, as the line recorded it: iMessage, or SMS or RCS when the sender's phone sent it through their carrier instead. Absent when the line did not say (an older message, another channel, or a service it does not name), so never read absent as iMessage. - channel?: string (imessage | whatsapp) — The channel the message is on — the `channel` of its line as `GET /v1/whoami` lists it, and of its conversation, such as `imessage`. Absent only on some older events. - contactId?: string — Mapier's id for the contact who sent the message: the `contactId` the `location.*` events, reactions and the console name them by. Absent on some older messages, and on a history row whose sender is no longer this project's contact. - fromDisplayName?: string — The name the sender’s platform shows for them, as it said it. A label to show, never an identity: anyone can change it, so match people by `from` or `contactId`. Absent when the channel gave none. - interactiveReply?: object — With `kind` `interactive_reply`: the button, quick reply or action the person tapped. Absent otherwise. - appCard?: object ({ app, url, interactive, layout, updates }) — With `kind` `app_card`, on an iMessage line: the card a person sent from an iMessage app. `text` is null, `attachments` is empty and the card is never a reply. `updates` is the `messageId` of the first card this one replaces, when the app linked it, and null otherwise. Treat `url` as untrusted input. Absent on every other message. See [App cards](https://docs.mapier.ai/convo/guides/send/app-cards#receive-a-card). - kind?: string (text | media | location | contact | system | unsupported | template | interactive | interactive_reply | template_reply | sticker | rich_link | multipart | location_request | poll | app_card | reaction) — What the message is, where the channel said: `text`, `media`, `location`, `contact`, `interactive_reply` (a button or quick reply the person tapped; see `interactiveReply`), `template_reply`, `app_card` (a card from an iMessage app; see `appCard`) and so on. Absent when the channel did not say. New kinds may be added: treat one you do not recognize as `unsupported`. - optedOut?: boolean — Whether the sender is opted out once this message is recorded. `true` when this message, or an earlier one it did not undo, was an opt-out keyword on a phone channel: the whole message, in capitals, one of STOP, UNSUBSCRIBE, OPTOUT, CANCEL, END or QUIT, ignoring spaces around it and any trailing `.`, `!` or `?`. A near-miss — "stop", "Stop" or "STOP please" — changes nothing. A send to them is then refused with `recipient_not_allowed`. `false` otherwise — including when this message opted them back in: START or UNSTOP, or anything else they wrote one-to-one that carries no opt-out word. A keyword typed in a group chat changes nothing. Absent on a message received before the field existed, and on a conversation history row. - platformMessageId?: string — The channel’s own id for this message, so you can correlate with anything you already hold, and name the message by it in a later command, such as `reaction.set`. It falls back to our `messageId` only when the channel supplied none. Reply by `messageId`, not by this. `externalId` carries the same value; absent only on an event from before the field. - platform?: object — The arriving channel’s own ids for the message, under that channel’s key alone, `platform.`. A message written in a thread or a forum topic also names it there. Keys may be added. Absent when there are none. - replyTo?: object — The message this one replies to, and how. Absent when it is not a reply Mapier can name. - textFormat?: string (plain | slack_mrkdwn | discord_markdown | telegram_html) — The markup `text` is written in, as the channel delivered it: `plain`, or the channel’s own markup. Absent means plain. New formats may be added; `textPlain` always reads without markup. - textPlain?: string — `text` with the markup taken out, when `textFormat` is not `plain`. Absent otherwise. `text` is always present in the JSON and can be `null`. A photo sent with no caption arrives with `text: null` and a populated `attachmentIds`, so code that reaches straight for `event.text.toLowerCase()` throws the first time someone sends one. A null `text` does not promise an attachment either. An iMessage line reports a change to a conversation's chat background as a [`chat_background`](#event-chat_background) event, but a line whose device predates that event instead leaves a message from the person with no text for a change in a conversation with one person, whoever made it — a [`chat_background.set`](https://docs.mapier.ai/convo/api/conversations/set-background) or a [`chat_background.remove`](https://docs.mapier.ai/convo/api/conversations/remove-background) of yours, or the person on their own phone. Skip a received message that has no text and no attachment rather than reply to it. ## Event: `receipt` [#event-receipt] Sent only on a stream opened with `?events=receipts`. A recipient's device reported a message delivered or read. ``` id: 0192a7c4-7d55-7a90-b3e1-4c6a8f2d9e04 event: receipt data: {"commandId":"3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71","messageId":"0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65","status":"delivered","occurredAt":"2026-08-24T18:03:14.000Z","simulated":false,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - commandId: string | null — The commandId the 202 handed back for the send this receipt is about — the correlator. Null only on a receipt recorded before this field existed. - messageId: string — Mapier's id for the message, as GET /v1/messages/{messageId}/receipts names it. - status: string (delivered | read) — What the recipient's device reported. A receipt never walks a message backwards: once a message is read, a late delivered for it moves nothing and sends nothing. - occurredAt: string (ISO 8601 with Z) — When the device reported it, not when you received this event. - simulated: boolean — Always false. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. - deliveryService?: string (iMessage | SMS | RCS) — The service an iMessage line’s send went out over, as the line recorded it: `iMessage`, or `SMS` or `RCS` when it went through the carrier instead. Absent when the line did not say — another channel, or a service it does not name — so never read absent as `iMessage`. - deliveryError?: string — The iMessage line’s own error code for the delivery, as text — `4` — for quoting to support. Absent when there was none. Never branch on it: the status says what happened. Each channel reports what it can, and an iMessage line reports from Apple's status of the send, which is first asked about 75 seconds after the send and last about 10 minutes after it, so on iMessage a delivery or a read later than that is never sent, and a read arrives only from a recipient who shares read receipts. A WhatsApp line sends them as Meta reports them. To ask about one message now, whatever the stream said, call [`GET /v1/messages/{messageId}/receipts`](https://docs.mapier.ai/convo/api/messages/receipts). ## Event: `delivery_failed` [#event-delivery_failed] Sent only on a stream opened with `?events=delivery_failures`. The channel accepted a message and later reported it not delivered — Apple's "Not Delivered" on iMessage and Meta's `failed` after `sent` on WhatsApp. It is the same fact as the [`message.delivery_failed`](https://docs.mapier.ai/convo/guides/receive/receive-events#receive-webhooks) webhook. ``` id: 0192a7c4-8e20-7f43-a1b6-9d3c5e7f0a28 event: delivery_failed data: {"commandId":"3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71","messageId":"0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65","occurredAt":"2026-08-24T18:05:02.000Z","simulated":false,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - commandId: string — The commandId the 202 handed back for the send this event is about. Never null. - messageId: string — Mapier's id for the message, as GET /v1/messages/{messageId}/receipts names it. - occurredAt: string (ISO 8601 with Z) — When the channel reported the message not delivered, not when you received this event. - simulated: boolean — Always false. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. - deliveryService?: string (iMessage | SMS | RCS) — The service an iMessage line’s send went out over, as the line recorded it: `iMessage`, or `SMS` or `RCS` when it went through the carrier instead. Absent when the line did not say — another channel, or a service it does not name — so never read absent as `iMessage`. - deliveryError?: string — The iMessage line’s own error code for the delivery, as text — `4` — for quoting to support. Absent when there was none. Never branch on it: the status says what happened. That send is **not** a failed one. The message keeps its status, the event carries no `status`, `errorCode` or `failureClass`, and the send's own `command` event still arrives, possibly **after** this one, because the channel can report the failure before its result arrives. Correlate by `commandId`, and do not assume you recorded the send before the verdict came. ## Event: `location` [#event-location] Sent only on a stream opened with `?events=locations`. A contact sharing their location with the line started, sent a new position, or stopped — on iMessage from Apple's Find My, about every 30 seconds per person sharing, a repeated position sent once. The same facts as the `location.share_started`, `location.updated` and `location.share_ended` webhooks. ``` id: 0192a7c4-9b31-7c02-8d44-2f6e1a3b5c70 event: location data: {"type":"location.updated","conversationId":"a0000000-0000-4000-8000-000000000001","contactId":"c0000000-0000-4000-8000-000000000003","latitude":40.76203,"longitude":-73.985918,"horizontalAccuracyM":12,"capturedAt":"2026-09-30T18:07:00.000Z","occurredAt":"2026-09-30T18:07:00.000Z","simulated":false,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - type: string (location.share_started | location.updated | location.share_ended) — Which moment of the share this is — the webhook event type, verbatim. - conversationId: string (UUID) — The one-to-one conversation with the person sharing. Never a group. - contactId: string (UUID) — The person sharing. - latitude: number | null — Degrees. Always set on location.updated; null on a start that arrived before the first position, or an end that carried no last one. - longitude: number | null — Degrees; null exactly when latitude is. - horizontalAccuracyM: number | null — The radius of uncertainty around the position, in meters; null exactly when latitude is. - altitudeM?: number — Metres, where the device reported it. Absent otherwise. - speedMps?: number — Metres a second, where the device reported a valid speed. Absent otherwise. - coarseAddress?: string — A coarse place name such as a city, where Mapier gave one. Absent otherwise. - capturedAt: string | null (ISO 8601, or null) — When the device took this position; null exactly when latitude is. - occurredAt: string (ISO 8601) — The position's own instant, or when the start or end was observed. - simulated: boolean — Always false. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. A location is sent only for a one-to-one conversation with someone who is already this project's contact, so a person who shares before any message between you produces no event. The coordinates are a person's, and you are responsible for how you store and use them. See [Location events](https://docs.mapier.ai/convo/guides/send/location#receive-a-location). ## Event: `moderation` [#event-moderation] Sent only on a stream opened with `?events=moderation`. A contact edited or unsent a message they sent to the line. One event name for both, told apart by `type`: the same facts as the `message.edited` and `message.unsent` webhooks. ``` id: 0192a7c4-a412-7e19-b0c5-3d7f2a9e6b18 event: moderation data: {"type":"message.edited","messageId":"0192a7c4-6c02-7d4e-9a13-5b8f2c1d0e44","conversationId":"a0000000-0000-4000-8000-000000000001","externalId":"5D1B7E0A-2F3C-4B8E-9A61-1C2D3E4F5A6B","text":"See you at 7","previousText":"See you at 6","editedAt":"2026-09-30T18:10:04.000Z","simulated":false,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` Each names the message by the `messageId` and `externalId` its `message` event carried. Mapier keeps the message's original text (an edit's new `text` arrives here alone), and does not delete an unsent message. Only a message Mapier has recorded produces these events, so an edit of one sent before the line joined Mapier produces none. Only an edit that changed the text produces one: an edit that left it as it was, as when only an attachment was removed, does not. On a channel where a moderator can delete people's messages, `message.unsent` is also a message a moderator deleted. The line's own edits and unsends are `command` events, never these. ### `message.edited` [#messageedited] - type: "message.edited" — The webhook event type, verbatim. - messageId: string (UUID) — Mapier's id for the message the person edited: the messageId its message event carried. - conversationId: string (UUID) — The conversation the message is in. - externalId: string — Deprecated: read platformMessageId instead, which carries the same value; this field stays and is never removed. The channel's id for the message: the externalId its message event carried. - text: string — The message as it reads after the edit. - previousText?: string — The text before the edit, where Mapier kept it. Absent otherwise; never empty. - editedAt: string (ISO 8601) — When the person edited the message, as the channel reports it. - simulated: boolean — Always false. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. - platformMessageId?: string — The channel's id for the message — the platformMessageId its message event carried. externalId carries the same value; absent only on an event from before the field. ### `message.unsent` [#messageunsent] - type: "message.unsent" — The webhook event type, verbatim. - messageId: string (UUID) — Mapier's id for the message the person unsent: the messageId its message event carried. - conversationId: string (UUID) — The conversation the message is in. - externalId: string — Deprecated: read platformMessageId instead, which carries the same value; this field stays and is never removed. The channel's id for the message: the externalId its message event carried. - unsentAt: string (ISO 8601) — When the person unsent the message, as the channel reports it. - simulated: boolean — Always false. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. - platformMessageId?: string — The channel's id for the message — the platformMessageId its message event carried. externalId carries the same value; absent only on an event from before the field. See [Edits and unsends](https://docs.mapier.ai/convo/guides/send/edit-and-unsend). ## Event: `poll` [#event-poll] Sent only on a stream opened with `?events=polls`. A poll in a conversation was created, had its choices changed, got a vote, or had a vote taken back — a contact's poll, or the line's own. One event name for all four, told apart by `type`: the same facts as the `poll.created`, `poll.options_changed`, `poll.voted` and `poll.vote_cleared` webhooks. ``` id: 0192a7c4-b5e3-7a41-9c28-4e1f6a0b2d93 event: poll data: {"type":"poll.created","conversationId":"a0000000-0000-4000-8000-000000000001","actor":"line","contactId":null,"pollExternalId":"2F6B1C3D-8E4A-4B5C-9D7E-0A1B2C3D4E5F","question":"Lunch?","options":[{"optionExternalId":"A1B6D8F0-9C2E-4D5F-8A4B-6C8D0E1F2A3B","text":"Tacos"},{"optionExternalId":"B2C7E9A1-0D3F-4E6A-8B5C-7D9E1F2A3B4C","text":"Ramen"}],"occurredAt":"2026-10-01T18:11:40.000Z","simulated":false,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - type: string (poll.created | poll.options_changed | poll.voted | poll.vote_cleared) — Which moment of the poll this is: it was created, its choices changed, a participant voted, or a participant took their vote back — the webhook event type, verbatim. - conversationId: string (UUID) — The conversation the poll is in: a one-to-one conversation or a group's. - actor: string (line | contact) — line when this line did it — created the poll, voted, or added a choice, so a poll.created with actor line is your own poll's ids coming back — and contact when a participant did. - contactId: string | null (UUID, or null) — The participant, where this project holds a contact for them; null when the actor is the line, and for a participant this project holds no contact for. - pollExternalId: string — The channel's id for the poll, which every later moment of the same poll repeats — and what poll.vote takes at payload.pollExternalId. - question?: string — The poll's question. Present on poll.created alone. - options?: { optionExternalId: string; text: string }[] — The poll's choices, in order, each with the id a vote names. Present on poll.created, and on poll.options_changed as the whole current list — replace what you hold, never append. Absent on the other two. - selectedOptionExternalIds?: string[] — Every choice the voter holds after this vote. Present on poll.voted alone; a poll.vote_cleared means they hold none. - occurredAt: string (ISO 8601) — When it happened, as the channel reports it. - simulated: boolean — Always false. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. Your own poll streams here too, with `actor: line`: its `pollExternalId` and its choices' `optionExternalId`s — what `poll.vote` takes — arrive on this event and nowhere else. ## Event: `reaction` [#event-reaction] Sent only on a stream opened with `?events=reactions`. A reaction was put on or taken off a message, by a person or by your line, in a direct conversation or a group. One event name for both, told apart by `type`: the same facts as the `reaction.added` and `reaction.removed` webhooks. ``` id: 0192a7c4-c7a1-7b02-8e13-5d2f9a0b6c41 event: reaction data: {"type":"reaction.added","messageId":"0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22","conversationId":"a0000000-0000-4000-8000-000000000002","channel":"imessage","actor":"+14155550100","contactId":"0192a7c0-4444-7555-8666-777788889999","isGroup":true,"emoji":"❤️","providerReactionId":null,"occurredAt":"2026-10-23T17:02:11.000Z","lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - type: string (reaction.added | reaction.removed) — Whether the reaction was put on or taken off — the webhook event type, verbatim. - messageId: string (UUID) — Mapier's id for the message reacted to: the messageId its event carried. - conversationId: string (UUID) — The conversation the message is in, a group's included. - channel?: string (imessage | whatsapp) — The channel the conversation is on. Absent only on some older reactions. - actor: string — Who reacted: the person's address, as from names them on their messages, or your line's own address when the line reacted. - contactId: string | null (UUID, or null) — Mapier's id for the person who reacted. Null when your line reacted, for a group member who is not this project's contact, and on some older reactions. - isGroup?: boolean — true for a group, false for a direct conversation, absent when the channel has not said — as on the conversation's messages. - emoji: string — The reaction, in Mapier's own spelling. - providerReactionId: string | null — The channel's id for the reaction, where it gives one. Null otherwise. - occurredAt: string (ISO 8601) — When the reaction was put on or taken off, as the channel reports it. - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. - partIndex?: integer — The part of the message the reaction is on, counted from 0 in the order the channel lays out the message's parts — the number reaction.tapback's partIndex takes. Absent when it is on the whole message or the channel did not say. iMessage only. A removal that comes from a reaction being replaced carries none. Only a reaction to a message Mapier has recorded produces an event. Where a channel keeps one reaction per person per message, a new one arrives with the one it replaced taken off. ## Event: `conversation` [#event-conversation] Sent only on a stream opened with `?events=conversations`. A conversation started on your line, or a group's name, members or status changed. One event name for all three, told apart by `type`: the same facts as the `conversation.created`, `conversation.updated` and `conversation.status_changed` webhooks. [Conversation events](https://docs.mapier.ai/convo/guides/conversations/groups) says when each fires on each channel. ``` id: 0192a7c4-d8b2-7c13-9f24-6e3a0b1c7d52 event: conversation data: {"type":"conversation.updated","conversationId":"a0000000-0000-4000-8000-000000000002","channel":"imessage","title":"Trip to Lisbon","changed":["title","participants"],"participantsAdded":[{"address":"+14155550123","contactId":null,"displayName":null}],"participantsRemoved":[],"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` ### `conversation.created` [#conversationcreated] Your line saw a conversation for the first time: a person's first message, a group's first message, or your line being added to a group. - type: "conversation.created" — The webhook event type, verbatim. - conversationId: string (UUID) — Mapier's id for the conversation: the conversationId its messages arrive under and a reply names. - kind: string (direct | group) — direct for a conversation with one person, group for a group chat. - channel: string (imessage | whatsapp) — The channel the conversation is on. - peerAddress: string | null — The person's address in a direct conversation. Null for a group. - title: string | null — The group's name, where it has one. Null for a direct conversation. - lineId: string (UUID) — The line the conversation is on — its `id` as `GET /v1/whoami` lists it. ### `conversation.updated` [#conversationupdated] A group's name or members changed. It names what changed and who joined or left, never the whole membership: read that with [`GET /v1/conversations/{conversationId}`](https://docs.mapier.ai/convo/api/conversations/get). - type: "conversation.updated" — The webhook event type, verbatim. - conversationId: string (UUID) — Mapier's id for the group. - channel: string (imessage | whatsapp) — The channel the group is on. - title: string | null — The group's name now. Null when it has none. - changed: string[] (title, participants) — What changed, in this order: title, then participants. Never empty. - participantsAdded: object[] ({ address, contactId, displayName }) — Who joined: each member's address as their messages' from, Mapier's contactId for them or null, and the name the channel shows for them or null. Empty when nobody joined. - participantsRemoved: object[] ({ address, contactId, displayName }) — Who left, in the same shape. Empty when nobody left. - lineId: string (UUID) — The line the group is on — its `id` as `GET /v1/whoami` lists it. ### `conversation.status_changed` [#conversationstatus_changed] A group closed for your line, or opened again. A send into a closed group is [`409 conversation_closed`](https://docs.mapier.ai/convo/api/errors/conversation_closed). - type: "conversation.status_changed" — The webhook event type, verbatim. - conversationId: string (UUID) — Mapier's id for the group. - channel: string (imessage | whatsapp) — The channel the group is on. - from: string (active | closed) — The status before this change. - to: string (active | closed) — The status now. - reason?: string (removed | deleted | archived | suspended) — Why the group closed: removed — your line is no longer in it; deleted — the channel deleted it; archived — the group was archived; suspended — the channel suspended it. Present only when to is closed. - lineId: string (UUID) — The line the group is on — its `id` as `GET /v1/whoami` lists it. ## Event: `gap` [#event-gap] Sent only on a stream opened with `?events=gaps`. Some of a line's messages may be missing from a window of time: the channel rate-limited the line, or the line's connection to the channel was lost. The same fact as the `line.gap` webhook. It is sent once, after recovery has finished. Every message that could be recovered from the window has already arrived as an ordinary `message` event, with the time it was sent, and is in the conversation's history. A window that lost nothing sends no `gap`. [Reconnection and delivery guarantees](https://docs.mapier.ai/convo/guides/receive/receive-events#reconnect-without-missing-anything) says what each channel recovers. ``` id: 0192a7c4-e9c3-7d24-8a35-7f4b1c2d8e63 event: gap data: {"type":"line.gap","channel":"imessage","from":"2026-10-23T17:00:04.000Z","to":"2026-10-23T17:06:31.000Z","cause":"disconnected","conversationIds":null,"recovered":2,"complete":false,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - lineId: string (UUID) — The line this happened on: its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it. The only event that can carry null here is `contact.opt_out_changed`, when the change was made in the console. - type: "line.gap" — The webhook event type, verbatim. - channel: string (imessage | whatsapp) — The line's channel. - from: string (ISO 8601) — The start of the window messages may be missing from. - to: string (ISO 8601) — The end of the window. - cause: string (rate_limited | disconnected) — rate_limited — the channel, or Mapier, held the line's messages back for a while; disconnected — the line's connection to the channel was lost. - conversationIds: string[] | null (UUIDs, or null) — The conversations the window touched, where the channel said which. Null when any of the line's conversations may be missing messages. - recovered: integer — How many messages from the window were recovered. Each already arrived as an ordinary message, with the time it was sent, before this event. - complete: boolean — Whether everything in the window was re-read. When false, some messages may be missing for good: read the conversations' history, or ask the people in them. ## Event: `message.received` [#event-messagereceived] Sent only on a stream opened with `?events=message.received`. Each incoming message arrives under the name and in the shape of the [`message.received`](https://docs.mapier.ai/convo/guides/receive/receive-events) webhook, **instead of** its `message` event on this connection, so each incoming message arrives once, as one or the other. Without the option the `message` event is unchanged. The event is the webhook's body less the two keys that name a delivery attempt, `deliveryId` and `attempt`. Use it when one handler should read both the stream and your [webhooks](https://docs.mapier.ai/convo/guides/receive/receive-events). ``` id: 0192a7c4-fad4-7e35-9b46-8a5c2d3e9f74 event: message.received data: {"id":"0192a7c4-fad4-7e35-9b46-8a5c2d3e9f74","type":"message.received","environment":"live","occurredAt":"2026-10-23T17:02:11.000Z","data":{"projectId":"0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b","environment":"live","lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d","…":"…"}} ``` - id: string (UUID) — The event's id: the same value as this event's SSE id:, the webhook's id and its mapier-event-id header. Deduplicate on it. - type: "message.received" — The webhook event type, verbatim. - environment: string (live | test) — The key's environment. - occurredAt: string (ISO 8601) — When the event was recorded, as the webhook's occurredAt. - data: object — The message.received event's payload, verbatim — the data a webhook endpoint subscribed to message.received is sent, with projectId, environment and lineId on it. The message's `lineId` is inside `data`, not at the top level; `?lineId=` narrows these events as it does every other. ## Event: `chat_background` [#event-chat_background] Sent only on a stream opened with `?events=chat_backgrounds`. A conversation's chat background was set or removed on an iMessage line — by a person in the conversation, or by this line. The same fact as the `conversation.background_changed` webhook. ``` id: 0192a7c4-c6f4-7b52-8d39-5f2a7b1c3e04 event: chat_background data: {"type":"conversation.background_changed","conversationId":"a0000000-0000-4000-8000-000000000001","from":"+14155550100","fromMe":false,"background":{"preset":"sky_dusk"},"occurredAt":"2026-11-02T18:20:31.000Z","simulated":false,"lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` - type: "conversation.background_changed" — The webhook event type, verbatim. - conversationId: string (UUID) — The conversation whose background changed: a one-to-one conversation or a group's. - from: string — The address of whoever changed it: the person's, or this line's own when fromMe is true. - fromMe: boolean — true when this line made the change — your own chat_background.set or chat_background.remove comes back here as well as finishing as a command event, so do not count it twice — and false when a person in the conversation did. - background: object | null ({ preset, colors?, attachmentId? }, or null) — The background now set, or null when it was removed. preset is one of the presets chat_background.set takes, or null when the line could not tell which: it names the look only when it can tie it to this change, so a set followed at once by another, or read back after a later one, has preset null. photo is a picture someone chose, and may carry attachmentId: the id of that picture, fetched with GET /v1/attachments/{attachmentId} like a message's attachment — a 404 there means it is still uploading, so retry shortly. attachmentId is absent when the line could not export the picture, a line on older software among them, and on every other preset. colors is a custom background's two #RRGGBB colors, where the line read them, and absent on every other preset. - occurredAt: string (ISO 8601) — When the change happened, as the channel reports it. - simulated: boolean — Always false. - lineId: string (UUID) — The line this happened on — its `id` as `GET /v1/whoami` lists it. Every event and every webhook about something on a line names it, so a key holding several lines never has to look a conversation up to tell which number an event belongs to. It is sent only from a line whose device reports the change. A line on older software instead leaves a `message` with no text for a change in a one-to-one conversation; see [Event: `message`](#event-message). A change in a conversation Mapier has no record of produces no event. A change in a group chat is reported the same way, on the group's `conversationId`. See [Chat background events](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds). ## Event: `error` [#event-error] The stream is ending, and this is why. The socket closes after it, and the event carries no `id:` — there is nothing after it to resume. ``` event: error data: {"code":"invalid_credentials","message":"That API key has been revoked."} ``` - code: string — An error code from the closed set every refusal uses. Switch on this. - message: string — A sentence for a person, explaining why the stream is ending. Never parse it. The credential is re-proved every 60 seconds, so a revoked or expired key, or an archived project, closes the stream within a minute, with `invalid_credentials` or `project_archived` here rather than a dropped connection. Reconnecting does not fix either. A connection that closes with no `error` event (a network drop, or a `: bye` comment) is ordinary: reconnect with your `Last-Event-ID`. ## Forward compatibility [#forward-compatibility] Fields are added to events without a version change, and an event can carry keys this page does not list. Two habits keep a client working: - **Read the fields you need by name.** Do not reject an event for an extra key. - **Tolerate unknown values and unknown `event:` names.** `errorCode` is open, and a new event name is ignored rather than thrown on. Give every `switch` a default: ```ts switch (event.status) { case "succeeded": markSucceeded(event.commandId); // succeeded, not delivered break; case "failed": case "cancelled": case "expired": markNotDone(event.commandId, event.failureClass, event.errorCode); break; case "ambiguous": case "no_effect": markOutcomeUnproven(event.commandId, event.errorCode); break; default: markOutcomeUnproven(event.commandId, event.errorCode); } ``` ## Reconnecting [#reconnecting] The stream drops periodically even when healthy, so the outer loop is unconditional: connect with the last id you processed, consume until the socket closes, wait, connect again. The `429` in the table below counts **connections**, not events. ```ts const BASE = "https://api.mapier.ai"; const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); const onEvent = (name: string, data: unknown) => { console.log(name, data); }; const MIN_DELAY = 6_000; const MAX_DELAY = 30_000; let lastEventId: string | undefined; // keep this somewhere durable let delay = MIN_DELAY; for (;;) { const startedAt = Date.now(); try { const res = await fetch(`${BASE}/v1/response_stream?events=receipts,delivery_failures`, { headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", Accept: "text/event-stream", ...(lastEventId ? { "Last-Event-ID": lastEventId } : {}), }, }); if (res.status === 429) { await res.body?.cancel(); await sleep(Math.max((Number(res.headers.get("retry-after")) || 1) * 1_000, MIN_DELAY)); continue; } if (!res.ok || !res.body) { await res.body?.cancel(); throw new Error(`stream status ${res.status}`); } await consume(res.body, (id, name, data) => { onEvent(name, data); if (id) lastEventId = id; // only once the event is handled }); } catch (err) { console.warn("stream dropped, reconnecting", err); } delay = Date.now() - startedAt > 30_000 ? MIN_DELAY : Math.min(delay * 2, MAX_DELAY); await sleep(delay + Math.random() * delay); } ``` The parser behind `consume`, and what to do with a command whose result you never saw, are in [Reconnection and delivery guarantees](https://docs.mapier.ai/convo/guides/receive/receive-events). ## Multiple connections [#multiple-connections] A key may hold four streams open at once; a connection past that is refused with `429 rate_limited` and `details.reason: "too_many_streams"`, whose short `details.retryAfter` means close a stream rather than wait. Every connection receives every event its filters admit: they are a broadcast, not a work queue. One stream per project is all an integration needs; two workers on one stream's events should deduplicate on the event's `id`. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `line_not_allowed` | A `lineId` that is not one of this key's lines | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | With a personal access token, an `x-mapier-project` it cannot reach | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `events` value this stream does not accept, a `channel` it does not carry or more than one, a `conversationId` this key cannot stream, a `lineId` that does not match `channel` or `conversationId`, or an `x-mapier-version` that is not a published version; `details` names the field | | `429` | `rate_limited` | 10 connects per minute, per key; or more than 4 open at once (`details.reason: "too_many_streams"`, whose short `details.retryAfter` means close a stream rather than wait) | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `upstream_unavailable` | A service behind Mapier did not answer; connect again with backoff | | `503` | `service_busy` | Mapier was too busy to open the stream; wait `details.retryAfter` seconds and connect again | ## Quick reference [#quick-reference] | | | | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Events | `message`, `command`, `error`; `receipt`, `delivery_failed`, `location`, `moderation`, `poll`, `reaction`, `conversation`, `gap`, `message.received` and `chat_background` on request (`?events=`) | | Narrowing | `?channel=`, `?conversationId=`, `?lineId=` — one value each | | Heartbeat | `: ping` every 25 seconds | | Resume | `Last-Event-ID`; at most 500 per batch; events kept 90 days | | Revocation | re-proved every 60 seconds; an `error` event, then the close | | Concurrent streams | allowed, all receive every event their filters admit | | Rate limit | 10 connects per minute, per key; 4 open at once, per key | ## Guide [#guide] - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) - [Get receipts](https://docs.mapier.ai/convo/api/messages/receipts) - [Versions](https://docs.mapier.ai/convo/api/versions) - [Chat backgrounds](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) # Create a group (https://docs.mapier.ai/convo/api/groups/create) > Start a group chat with an opening message **POST** `/v1/commands/group.create` _Works on iMessage_ Creates a group chat and sends its first message in one operation. iMessage has no concept of an empty group, so the opening message is required. Once the group exists it is a conversation too. A message someone writes in it arrives under the group's own `conversationId`, with `isGroup: true`; on that id you can [send into the group](https://docs.mapier.ai/convo/guides/conversations/groups#send-to-a-group), rename it or change its members with [`group.update`](https://docs.mapier.ai/convo/api/groups/update), and leave it with [`group.leave`](https://docs.mapier.ai/convo/api/groups/leave). Honors `Idempotency-Key`: a retry under the same key returns the first command, so a retried `group.create` never makes a second group. ## Body [#body] ### Target [#target] - target.kind?: "new_group" — Optional. The participant list alone names the target. - target.participantExternalIds: string[] (2 to 32 people, each an E.164 phone number or a lower-case Apple ID email of at most 512 characters) — Everyone except you. target.participants is accepted as another name for this field. Order does not matter, and each address is sent in its canonical form and counted once. - target.lineId?: string (UUID — a line's id, as GET /v1/whoami lists it in lines[].id) — Optional. The line the group is created from, which also names the channel. Left out, the first participant's line is used — the one they already talk to this project from, or one Mapier picks for a new person. An id that is not one of your lines is 403 line_not_allowed; a line on another channel than target.channel names is 422 validation_failed at target.lineId. A group created from a line its first participant is not on does not count toward that line's new people. Mapier reads each participant the way the channel reads an address (a phone number to E.164, an email lower-cased) and checks the list before anything is sent. The first participant is read first: the command's line is the one that person is on. A participant that is refused, the first included, is reported at the list's own field (the one you wrote, `participantExternalIds` or `participants`) and its index. Each refusal is `422 validation_failed`, the line's `channel` in the entry: - a participant the channel cannot read, at `target.participantExternalIds[i]` (or `target.participants[i]`); - any participant, the first included, that is an email with a control character in it, over 512 characters or not in composed Unicode (NFC), at `target.participantExternalIds[i]` (or `target.participants[i]`); - fewer than 2 or more than 32 people once a repeat — the same person written two ways — is counted once, at `target.participantExternalIds` (or `target.participants`). A first participant who opted out, is blocked or is paused is `403 recipient_not_allowed`, with `details.reason` saying which, as a send to them would be. ### Payload [#payload] - firstMessage: string (1 to 16,384 bytes, measured as UTF-8) — Sent as the group's opening message. Trimmed before it is measured; empty or oversized is rejected with 422 validation_failed, reason invalid_text. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/group.create \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: create-trip-planning-group" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "new_group", "channel": "imessage", "participantExternalIds": ["+14155550100", "+14155550111"] }, "payload": { "firstMessage": "kickoff" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/commands/group.create`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "create-trip-planning-group", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "new_group", channel: "imessage", participantExternalIds: ["+14155550100", "+14155550111"], }, payload: { firstMessage: "kickoff" }, }), }); ``` Retry under the **same** `Idempotency-Key`. A new key is a new command, and a new `group.create` makes a second group. If a `group.create` times out, wait for the result on the stream before deciding whether to retry. ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-92c4-75a8-86d9-b4f172a3e598", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` A `succeeded` `command` event names the new group: `conversationId` is its id, and `group` carries the same id. A `conversation.created` of `kind: "group"` announces it too. Keep the id: it is the `target.conversationId` that sends into the group. ```json title="event: command" { "commandId": "0192b3e2-92c4-75a8-86d9-b4f172a3e598", "logicalActionId": "0192b3e2-92c4-75a8-86d9-b4f172a3e598", "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000002", "failureClass": null, "group": { "conversationId": "a0000000-0000-4000-8000-000000000002" } } ``` ## `whatsapp.group.create` [#whatsappgroupcreate] Makes a new group on a WhatsApp line. Only a number Meta has made an Official Business Account can make one, and the command is accepted only on a number Mapier has confirmed is one: on any other it is [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) with `reason: not_on_line`, and nothing is written. `GET /v1/whoami` lists it among a line's capabilities once the number is confirmed. Nobody is added: people join by the group's invite link, which the result carries. Honors `Idempotency-Key`. ### Target [#target-1] Address the line at `target.lineId`. `target.participants` is a `422 validation_failed` at that field. ### Payload [#payload-1] | Field | | | ------------- | ---------------------------------------------------------- | | `subject` | Required. The group's name, 1 to 128 characters. | | `description` | Optional. The group's description, up to 2,048 characters. | ### Request [#request] ```bash curl -X POST https://api.mapier.ai/v1/commands/whatsapp.group.create \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: launch-group-1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d" }, "payload": { "subject": "Launch day" } }' ``` ### Result [#result] The answer is a `202`, and the command ends when WhatsApp reports the group: - `succeeded`, with `group: { conversationId, inviteLink }` on the `command` event and on [`GET /v1/commands/{commandId}`](https://docs.mapier.ai/convo/api/commands/get), and a `conversation.created` of `kind: group` for the new conversation. Send into it by that `conversationId`, and send the invite link to the people who should join. The link works for 90 days; keep it. - `failed` with `groups_not_eligible`: Meta refused the group; the number cannot use groups. - `ambiguous` with `group_create_unconfirmed`: WhatsApp did not confirm the group in time. Sent to a line of another channel, the type is [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) with `reason: not_on_channel`. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - No participants is `422 validation_failed` at `target.participants`, before a line is resolved; a participant list the channel cannot take is refused as [above](#target), before anything is sent. - `firstMessage` empty or over 16,384 bytes: `422 validation_failed`, reason `invalid_text`. - On a test line on a shared number, `404 unsupported_command` with `reason: shared_line` unless group chats are turned on for your organization. Once they are, 2 to 10 people who are all this project's connected Test contacts, or `403 recipient_not_allowed` with `group_member_not_test_contact` (or `recipient_must_write_first` for a member who must text first). Sent again under its `Idempotency-Key`, the same people are the same group, never a second one, and other people are `409 conflict` with `idempotency_key_reused`. See [Groups on a test line](https://docs.mapier.ai/convo/guides/conversations/groups#groups-on-a-test-line). Result codes you will see for this command: `gateway_rejected` when iMessage refuses the group. `group_content_unverified` is **not** a failure: its `command` event ends `ambiguous`, and it means the line could not confirm the group was created, not that it was not. A blind retry there makes a second group. See [Groups](https://docs.mapier.ai/convo/guides/conversations/groups). ## Guide [#guide] - [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) - [Update a group](https://docs.mapier.ai/convo/api/groups/update) # Leave a group (https://docs.mapier.ai/convo/api/groups/leave) > Take your line out of a group chat **POST** `/v1/commands/group.leave` _Works on iMessage_ Takes the line out of an iMessage group chat. It is done only in a group chat. Takes no arguments: `payload` is `{}` or absent. Apple lets a member leave only a group of at least 4 people, the line among them. In a smaller group a `group.leave` is sent, changes nothing and still ends `succeeded`. And no leave is confirmed, so after a `succeeded` or an `ambiguous` leave the line may still be in the group: check on a phone in the group before you send a leave again. A leave that did happen cannot be undone. Honors `Idempotency-Key`: a retry under the same key returns the first leave rather than sending a second. ## Body [#body] ### Target [#target] - target.kind?: "conversation" — Optional. The conversationId alone names the target. - target.conversationId: string (UUID of a group chat) — A group chat. Its message events say isGroup: true. Each of these is `422 validation_failed` at `target.conversationId` before anything is sent: - a conversation with one person; - a conversation no message has arrived in yet; - in place of a conversation, the address of someone this project has already exchanged messages with. The address of someone this project has never exchanged messages with is refused at the field you wrote it at, as on every command done in a conversation. ### Payload [#payload] None. Any key in `payload` is `422 validation_failed` at that key (`payload.`) before anything is written. ## What comes back [#what-comes-back] At once, beside the refusals above: `503 upstream_unavailable` with `details.reason: "connector_unavailable"` while the line is offline. Otherwise `202`, then one `command` event on the [response stream](https://docs.mapier.ai/convo/api/events/stream): - `succeeded` — the line sent the leave without an error. That means **sent, not confirmed**: no leave is confirmed. In a group of fewer than 4 people, the line among them, the leave is sent, changes nothing and still ends `succeeded`: Apple lets a member leave only a group of at least 4. - `ambiguous` with `group_leave_unverified` — the line's sending errored, so the line may still be in the group. - `failed` with `stale_target` — the group was addressed right after its membership changed, before its next message. Wait for the next `message` event from the group, then send the leave again under a new `Idempotency-Key`. - `expired` with `command_expired_before_execution` — sending on the line was paused: the line held the leave, and its time ran out before sending resumed. Nothing changed. Treat `succeeded` and `ambiguous` alike: neither proves the line has left the group. After either, check on a phone in the group before you send a leave again. A `succeeded` leave also closes the group for your line at once: a `conversation.status_changed` to `closed` with `reason: "removed"`, and a send into it is then `409 conversation_closed`. If the line is still in the group, the group's next message opens it again. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/group.leave \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: leave-trip-planning" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000002" }, "payload": {} }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // A leave cannot be undone. On a retry after a lost response, send the same key again. async function leaveGroup(conversationId: string, idempotencyKey: string) { const res = await fetch(`${BASE}/v1/commands/group.leave`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "conversation", conversationId }, payload: {} }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-81b3-7497-f5c8-a3e06192d487", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then, on the response stream, the result of a leave whose sending errored: ```json title="event: command — ambiguous" { "commandId": "0192b3e2-81b3-7497-f5c8-a3e06192d487", "logicalActionId": "leave-trip-planning", "status": "ambiguous", "errorCode": "group_leave_unverified", "conversationId": "a0000000-0000-4000-8000-000000000002", "type": "group.leave", "messageId": null, "externalId": null, "namePhoto": null, "projectId": "b0000000-0000-4000-8000-000000000002", "environment": "live", "failureClass": null } ``` ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.conversationId` for a conversation with one person, one no message has arrived in, or the address of someone this project has already exchanged messages with, in place of a conversation. - `422 validation_failed` at `payload.` for any key in the payload. - `503 upstream_unavailable` with `details.reason: "connector_unavailable"` while the line is offline. - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. - On a test line on a shared number, `404 unsupported_command` with `reason: shared_line` unless group chats are turned on for your organization, and `403 recipient_not_allowed` with `group_member_not_test_contact` or `recipient_must_write_first` while someone in the group is not a connected Test contact. See [Groups on a test line](https://docs.mapier.ai/convo/guides/conversations/groups#groups-on-a-test-line). Result codes you will see for this command: `group_leave_unverified`, `stale_target` and `command_expired_before_execution`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) - [Update a group](https://docs.mapier.ai/convo/api/groups/update) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Update a group (https://docs.mapier.ai/convo/api/groups/update) > Rename a group, or add or remove one member **POST** `/v1/commands/group.update` _Works on iMessage_ Renames an iMessage group chat, or adds or removes one member. One action per command. It is done only in a group chat. Honors `Idempotency-Key`: a retry under the same key returns the first command rather than making the change twice. ## Body [#body] ### Target [#target] - target.kind?: "conversation" — Optional. The conversationId alone names the target. - target.conversationId: string (UUID of a group chat) — A group chat. Its message events say isGroup: true. A group's `conversationId` reaches you on the `message` events from the group: every message someone writes there arrives under the group's own id, with `isGroup: true`. Each of these is `422 validation_failed` at `target.conversationId` before anything is sent: - a conversation with one person; - a conversation no message has arrived in yet; - in place of a conversation, the address of someone this project has already exchanged messages with. The address of someone this project has never exchanged messages with is refused at the field you wrote it at, as on every command done in a conversation. ### Payload [#payload] One action, at `payload.action`. - action: "rename" | "add_participant" | "remove_participant" — What to change. set_photo is refused. - name?: string (At most 128 characters, not blank, no ASCII control character) — With rename, and only with it: the group's new name. - participantExternalId?: string (An E.164 phone number, or a lower-case Apple ID email of at most 512 characters) — With add_participant or remove_participant, and only with them: the one person to add or remove. No ASCII control character, and in composed Unicode (NFC). Sent in its canonical form. Each of these is `422 validation_failed` before anything is written: - no action, or one that is not `rename`, `add_participant` or `remove_participant`, at `payload.action`; - a name that is missing, blank, over 128 characters or holds an ASCII control character, at `payload.name`; - an address the channel cannot read, or one with an ASCII control character, over 512 characters or not in composed Unicode (NFC), at `payload.participantExternalId`; - any key the action does not take, at that key (`payload.`). #### `rename` [#rename] ```json { "action": "rename", "name": "Trip planning" } ``` #### `add_participant` and `remove_participant` [#add_participant-and-remove_participant] ```json { "action": "add_participant", "participantExternalId": "+14155550122" } ``` One person per command. Mapier reads the address the way the channel reads one — a phone number to E.164, an email lower-cased — and sends it in that canonical form. A group the channel has seen no message in yet refuses an `add_participant` or a `remove_participant` at once: `409 conflict` with `details.reason: "group_has_no_messages_yet"`. Send a message into the group, then change its members. A `rename` is not held back. Adding someone already in the group, or removing someone who is not in it, is accepted and then ends `failed` with `command_claim_invalid`. The line judges that against the members as it last saw them. `action: "set_photo"` is `422 validation_failed` at `payload.action` before anything is sent: a group's photo cannot be set through the API. ## What comes back [#what-comes-back] At once, beside the refusals above: - `409 conflict` with `details.reason: "group_has_no_messages_yet"` — an add or a remove into a group the channel has seen no message in yet. - `503 upstream_unavailable` with `details.reason: "connector_unavailable"` — the line is offline. Otherwise `202`, then one `command` event on the [response stream](https://docs.mapier.ai/convo/api/events/stream): - `succeeded` — the line made the change and confirmed it. - `failed` with `command_claim_invalid` — an add of someone already in the group, or a remove of someone who is not. - `failed` with `stale_target` — the group was addressed right after its membership changed, before its next message. Until that message arrives, a `group.update`, a `group.leave` or a message sent into the group ends this way. Wait for the next `message` event from the group, then send again under a new `Idempotency-Key`. - `failed` with `gateway_rejected` — the line refused the change before making it. A removal that would leave the group smaller than Apple allows is one. - `failed` with `capability_constraint_violation`, `failureClass: capability` — an add or a remove on a line that does not support member changes. Nothing changed. - `expired` with `command_expired_before_execution` — sending on the line was paused: the line held the command, and its time ran out before sending resumed. Nothing changed. - `ambiguous` with `group_update_unverified` — the line sent the change and could not confirm it. It may or may not have happened. Read the group with [`GET /v1/conversations/{conversationId}`](https://docs.mapier.ai/convo/api/conversations/get), or ask someone in it, before you send the change again. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/group.update \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: rename-trip-planning-1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000002" }, "payload": { "action": "rename", "name": "Trip planning" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // Send the same key again on a retry, and the first rename is adopted. async function renameGroup(conversationId: string, name: string, idempotencyKey: string) { const res = await fetch(`${BASE}/v1/commands/group.update`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "conversation", conversationId }, payload: { action: "rename", name }, }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-a3d5-76b9-97ea-c50283b4f6a9", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then, on the response stream: ```json title="event: command — succeeded" { "commandId": "0192b3e2-a3d5-76b9-97ea-c50283b4f6a9", "logicalActionId": "rename-trip-planning-1", "status": "succeeded", "errorCode": null, "conversationId": "a0000000-0000-4000-8000-000000000002", "type": "group.update", "messageId": null, "externalId": null, "namePhoto": null, "projectId": "b0000000-0000-4000-8000-000000000002", "environment": "live", "failureClass": null } ``` ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.conversationId` for a conversation with one person, one no message has arrived in, or the address of someone this project has already exchanged messages with, in place of a conversation. - `422 validation_failed` at `payload.action`, `payload.name`, `payload.participantExternalId` or `payload.`, as [above](#payload). - `409 conflict` with `details.reason: "group_has_no_messages_yet"` for an add or a remove into a group the channel has seen no message in yet. - `503 upstream_unavailable` with `details.reason: "connector_unavailable"` while the line is offline. - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. - On a test line on a shared number, `404 unsupported_command` with `reason: shared_line` unless group chats are turned on for your organization, and `403 recipient_not_allowed` with `group_member_not_test_contact` or `recipient_must_write_first` while someone in the group is not a connected Test contact. See [Groups on a test line](https://docs.mapier.ai/convo/guides/conversations/groups#groups-on-a-test-line). Result codes you will see for this command: `command_claim_invalid`, `stale_target`, `gateway_rejected`, `capability_constraint_violation`, `command_expired_before_execution` and `group_update_unverified`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) - [Leave a group](https://docs.mapier.ai/convo/api/groups/leave) - [Create a group](https://docs.mapier.ai/convo/api/groups/create) - [Send a message](https://docs.mapier.ai/convo/api/messages/send) # Overview (https://docs.mapier.ai/convo/api) > Reference for the Mapier messaging API, HTTP routes over lines such as iMessage. The base URL, how requests and answers look, and every endpoint The Mapier API is a set of HTTP routes over your lines on iMessage and WhatsApp. You send **commands**, and you read their results on one **event stream** or as **signed webhooks**. One OpenAPI document describes everything a key or a token can reach. Every example in these docs is a plain `fetch` or `curl` you can paste into a terminal, and any generator turns the document into a typed client. ## Base URL [#base-url] ``` https://api.mapier.ai ``` Every path starts with `/v1`. A future `/v2` would sit beside `/v1`, not replace it. Within `/v1`, a change that could break a working integration, such as a renamed word, ships behind a new dated version. You choose it with the `x-mapier-version` header, which every route that takes a key or a token reads. [Versions](https://docs.mapier.ai/convo/api/versions) explains. ## The OpenAPI document [#the-openapi-document] ``` https://api.mapier.ai/openapi.json ``` It describes `/v1` and only `/v1`: every field, and every error code each operation can return, with its status. | Operation | | | ------------------------------------------------------- | ----------------------------------------------------------------- | | `POST /v1/commands/{type}` | Send a command; the 202 gives its `commandId`. | | `POST /v1/commands/{type}/check` | Ask whether a command would be accepted, without sending it. | | `GET /v1/commands/{commandId}` | What happened to a command. | | `GET /v1/response_stream` | Results, incoming messages and, on request, more events (SSE). | | `GET /v1/events` | The project's events, read back, newest first. | | `GET /v1/whoami` | What this key is, what it can send from, and its command ceiling. | | `GET /v1/capabilities` | What works where, on every channel. | | `GET /v1/public/channel-availability` | Which channels are on for everyone. Needs no key. | | `GET /v1/reachability` | Whether a line can write to a person now, and why not. | | `POST /v1/handle-check` | Test whether an address is reachable. | | `POST /v1/conversation-lookup` | A line's conversation with an address, by its id. | | `GET /v1/attachments/{id}` | Fetch an attachment. | | `GET /v1/messages/{messageId}/receipts` | Ask what one message's receipts say, now. | | `GET /v1/conversations` | A line's conversations, newest first, by kind and status. | | `GET /v1/conversations/{conversationId}` | A conversation as it stands: a group's name, members and status. | | `GET /v1/conversations/{conversationId}/messages` | Read a conversation's history, newest first. | | `GET /v1/contacts/{contactId}` | One address of one person. | | `GET /v1/people/{personId}` | A person and every address they have. | | `POST /v1/contacts/{contactId}/consent` | Record that a person asked you to stop. | | `GET /v1/lines/available` | Which of your lines somebody new would get now. | | `GET /v1/lines/{lineId}/health` | How one of your lines is doing, measure by measure. | | `GET /v1/lines/{lineId}/reputation` | The same answer under its old name; deprecated. | | `GET /v1/lines/{lineId}/templates` | A line's message templates. | | `POST /v1/line-setups` | Start adding a line. | | `GET /v1/line-setups/{setupId}` | A line setup as it stands. | | `POST /v1/line-setups/{setupId}/checks` | Run a line setup's checks again. | | `POST /v1/line-setups/{setupId}/cancel` | Cancel an open line setup. | | `GET /v1/webhook-endpoints` | A project's webhook endpoints. Personal access token. | | `POST /v1/webhook-endpoints` | Add a webhook endpoint. Personal access token. | | `GET /v1/webhook-endpoints/{endpointId}` | One webhook endpoint. Personal access token. | | `PATCH /v1/webhook-endpoints/{endpointId}` | Change a webhook endpoint. Personal access token. | | `DELETE /v1/webhook-endpoints/{endpointId}` | Delete a webhook endpoint. Personal access token. | | `POST /v1/webhook-endpoints/{endpointId}/rotate-secret` | Make a new signing secret. Personal access token. | | `GET /v1/webhook-endpoints/{endpointId}/deliveries` | Each attempt to deliver to one endpoint. Personal access token. | | `GET /v1/projects` | The projects a personal access token reaches. | | `GET /v1/projects/{projectId}` | One of those projects. | | `GET /v1/members` | Everyone in the organization. Personal access token. | | `GET /v1/audit-logs` | The organization's audit log. Personal access token. | | `POST /v1/cli/logins` | Start a sign-in from a terminal. Needs no credential. | | `POST /v1/cli/logins/token` | Poll that sign-in for its tokens. Needs no credential. | | `POST /v1/cli/tokens/renew` | Renew a terminal sign-in with its refresh token. | | `POST /v1/cli/tokens/revoke` | Sign out with a refresh token. | | `POST /v1/personal-tokens/current/revoke` | Revoke the personal access token that calls. | ## The shape of every request [#the-shape-of-every-request] ```bash curl https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: hello-1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "channel": "imessage", "to": "+14155550100" }, "payload": { "kind": "text", "text": "hello" } }' ``` Three things are always true of a command request: - It is a `POST` whose body, when it has one, is a JSON **object**. A body that is not JSON is `400 bad_request`. JSON that is not an object, such as an array, a string or a number, is `422 validation_failed`. - The body has two top-level keys: `target` (who) and `payload` (what). Both are objects; a command that needs neither may leave the body out. See [Send a message › Who gets it](https://docs.mapier.ai/convo/api/messages/send#who-gets-it). - The body is at most **65,536 bytes**. A larger one is refused with `413 payload_too_large` before it is read, and before the key is checked. See [Authentication](https://docs.mapier.ai/convo/guides/get-started/authentication) for how requests are identified. ## The shape of every response [#the-shape-of-every-response] Successful command submissions return `202 Accepted`: ```json { "commandId": "3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` - commandId: string — The id to match results against. The command event carries it as commandId, and so do the receipt and delivery_failed events for a send. - status: string (queued) — Always 'queued', an adopted repeat included. The 202 says the command was accepted, never how it ended. The result arrives on the response stream. - disposition: string (queued | adopted) — Deprecated: read repeated instead, which says the same thing; this field stays and is never removed. adopted when an Idempotency-Key matched a send already made. commandId is then the first send's, and nothing new was queued: a retry is not a second message. - repeated?: boolean — true when an Idempotency-Key matched a send already made: commandId is then the first send's, and nothing new was queued. false when this request queued the command. - lineId: string (UUID) — The line this command went out on — its id as GET /v1/whoami lists it under lines. Every later event about the command is about this line. - lineSelection: string (named | reused_active_chat | new_best_line) — Why that line. named: you named it at target.lineId (a command done to a line always does). reused_active_chat: the line the person already talks to, which is the conversation's own line, else the line of the message a reply answers, else the active line they last wrote to, else the line their first conversation with this project began on. new_best_line: the person is new to this project, and Mapier picked a working line, the one with the fewest new people today, then the most room. - adaptations?: object[] — With `options.degrade: "adapt"`: each part of the message that was changed to fit the channel. Absent when nothing was changed. - channel?: string (imessage | whatsapp) — The channel of that line, such as `imessage`, so a send that named no `target.channel` says where it went. - parts?: object[] — When the send went out as several messages — a caption sent on its own with `options.degrade: "adapt"` — each one’s command, in order. `commandId` is the first’s, and its result covers that part alone: the whole message went out only when every part’s result is `succeeded`, so watch each `commandId` here. Parts go out in order, each once the one before it was accepted. One the channel refuses, or never answers, stops the rest, and the request answers with that refusal instead, its `details.sentParts` naming the parts already sent. A retry with the same key never sends a part again. Absent on a single message. The `202` is always `queued`. The result arrives as the [`command` event](https://docs.mapier.ai/convo/api/events/stream#event-command): `succeeded`, `failed`, `cancelled` or `expired`, or `ambiguous` or `no_effect` when the channel took the command and could not prove what it changed. Every refusal is one envelope: ```json { "error": { "code": "not_found", "message": "That conversation does not exist." } } ``` Switch on `code`: it is a closed set and each value maps to exactly one HTTP status. `message` is a sentence for a person and may change; never parse it. `details` is optional. On a `422 validation_failed` it is an **array**, one `{ path, message, … }` entry per field that failed. On other refusals it is an **object**, usually with a `reason` to switch on (as on `503 line_unavailable`) and the fields that go with it. A `429` from a route's own quota also carries a `Retry-After` header. [Errors](https://docs.mapier.ai/convo/api/errors) lists every code. ## `202` does not mean it worked [#202-does-not-mean-it-worked] A `202` means the command was **queued**, not that it was delivered. The line carries it out on its channel, and the result, success or failure, arrives on the [response stream](https://docs.mapier.ai/convo/api/events/stream) as a `command` event, usually within a few seconds. Not every payload is checked before the `202`. A `message.send` payload is checked before anything is written: a payload field the line cannot carry is a `422 validation_failed` at `payload.`, never dropped. A `reaction.set`, `profile.share` or `group.create` payload can be accepted with `202` and then end `failed` on the stream when the channel refuses it. See [what is checked before anything is queued](https://docs.mapier.ai/convo/api/commands#what-is-checked-before-anything-is-queued). If you are testing a new payload shape, watch the stream. ## Endpoints [#endpoints] | Method | Path | Purpose | | -------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | `POST` | [`/v1/commands/:type`](https://docs.mapier.ai/convo/api/commands) | Queue a command | | `POST` | [`/v1/commands/:type/check`](https://docs.mapier.ai/convo/api/commands/check) | Ask whether a command would be accepted | | `GET` | [`/v1/commands/:commandId`](https://docs.mapier.ai/convo/api/commands/get) | Read a command's outcome | | `GET` | [`/v1/response_stream`](https://docs.mapier.ai/convo/api/events/stream) | Results, incoming messages and, on request, more events (SSE) | | `GET` | [`/v1/events`](https://docs.mapier.ai/convo/api/events/list) | Catch up on events | | `GET` | [`/v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) | What this key is, its lines, and its command ceiling | | `GET` | [`/v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities) | What works where | | `GET` | [`/v1/public/channel-availability`](https://docs.mapier.ai/convo/api/discovery/list-channels) | Which channels are on for everyone; needs no key | | `GET` | [`/v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability) | Whether a line can reach a person now | | `POST` | [`/v1/handle-check`](https://docs.mapier.ai/convo/api/discovery/check-an-address) | Test whether an address is reachable | | `POST` | [`/v1/conversation-lookup`](https://docs.mapier.ai/convo/api/conversations/find) | Find a line's conversation with an address | | `GET` | [`/v1/attachments/:id`](https://docs.mapier.ai/convo/api/messages/download-attachment) | Download an inbound attachment | | `GET` | [`/v1/messages/:messageId/receipts`](https://docs.mapier.ai/convo/api/messages/receipts) | Ask what one message's receipts say, now | | `GET` | [`/v1/conversations`](https://docs.mapier.ai/convo/api/conversations/list) | List a line's conversations | | `GET` | [`/v1/conversations/:conversationId`](https://docs.mapier.ai/convo/api/conversations/get) | Read a conversation: a group's name, members and status | | `GET` | [`/v1/conversations/:conversationId/messages`](https://docs.mapier.ai/convo/api/conversations/list-messages) | Read a conversation's history, newest first | | `GET` | [`/v1/contacts/:contactId`](https://docs.mapier.ai/convo/api/people/get-contact) | Read a contact | | `GET` | [`/v1/people/:personId`](https://docs.mapier.ai/convo/api/people/get-person) | Read a person | | `POST` | [`/v1/contacts/:contactId/consent`](https://docs.mapier.ai/convo/api/people/opt-out-contact) | Opt a person out | | `GET` | [`/v1/lines/available`](https://docs.mapier.ai/convo/api/lines/get-next-line) | Which of your lines somebody new would get now | | `GET` | [`/v1/lines/:lineId/health`](https://docs.mapier.ai/convo/api/lines/get-line-health) | Read a line's health | | `GET` | [`/v1/lines/:lineId/reputation`](https://docs.mapier.ai/convo/api/lines/get-line-reputation) | The same, under its old name; deprecated | | `GET` | [`/v1/lines/:lineId/templates`](https://docs.mapier.ai/convo/api/lines/list-templates) | List a line's message templates | | `POST` | [`/v1/line-setups`](https://docs.mapier.ai/convo/api/line-setups/start) | Start adding a line | | `GET` | [`/v1/line-setups/:setupId`](https://docs.mapier.ai/convo/api/line-setups/get) | Read a line setup | | `POST` | [`/v1/line-setups/:setupId/checks`](https://docs.mapier.ai/convo/api/line-setups/rerun-checks) | Run a setup's checks again | | `POST` | [`/v1/line-setups/:setupId/cancel`](https://docs.mapier.ai/convo/api/line-setups/cancel) | Cancel a line setup | | `GET` | [`/v1/webhook-endpoints`](https://docs.mapier.ai/convo/api/webhook-endpoints/list) | List webhook endpoints | | `POST` | [`/v1/webhook-endpoints`](https://docs.mapier.ai/convo/api/webhook-endpoints/create) | Create a webhook endpoint | | `GET` | [`/v1/webhook-endpoints/:endpointId`](https://docs.mapier.ai/convo/api/webhook-endpoints/get) | Read a webhook endpoint | | `PATCH` | [`/v1/webhook-endpoints/:endpointId`](https://docs.mapier.ai/convo/api/webhook-endpoints/update) | Update a webhook endpoint | | `DELETE` | [`/v1/webhook-endpoints/:endpointId`](https://docs.mapier.ai/convo/api/webhook-endpoints/delete) | Delete a webhook endpoint | | `POST` | [`/v1/webhook-endpoints/:endpointId/rotate-secret`](https://docs.mapier.ai/convo/api/webhook-endpoints/rotate-secret) | Rotate its signing secret | | `GET` | [`/v1/webhook-endpoints/:endpointId/deliveries`](https://docs.mapier.ai/convo/api/webhook-endpoints/list-deliveries) | List its delivery attempts | | `GET` | [`/v1/projects`](https://docs.mapier.ai/convo/api/organization/list-projects) | List projects | | `GET` | [`/v1/projects/:projectId`](https://docs.mapier.ai/convo/api/organization/get-project) | Read a project | | `GET` | [`/v1/members`](https://docs.mapier.ai/convo/api/organization/list-members) | List members | | `GET` | [`/v1/audit-logs`](https://docs.mapier.ai/convo/api/organization/list-audit-logs) | List audit log entries | | `POST` | [`/v1/cli/logins`](https://docs.mapier.ai/convo/api/sign-in/start-login) | Start a sign-in from a terminal | | `POST` | [`/v1/cli/logins/token`](https://docs.mapier.ai/convo/api/sign-in/poll-login) | Poll a sign-in from a terminal | | `POST` | [`/v1/cli/tokens/renew`](https://docs.mapier.ai/convo/api/sign-in/renew) | Renew a terminal sign-in | | `POST` | [`/v1/cli/tokens/revoke`](https://docs.mapier.ai/convo/api/sign-in/sign-out) | Sign out with a refresh token | | `POST` | [`/v1/personal-tokens/current/revoke`](https://docs.mapier.ai/convo/api/sign-in/revoke-token) | Revoke the token that calls | Every one of them reads [`x-mapier-version`](https://docs.mapier.ai/convo/api/versions) but the five that take no credential: `GET /v1/public/channel-availability` and the four `/v1/cli/` routes a terminal signs in with. Most routes take a project API key, and most of those take a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) too; the webhook endpoint, organization and sign-out routes take a personal access token only. ## Conventions [#conventions] **Identifiers.** Phone numbers are E.164 (`+14155550100`). Email addresses are lowercase and NFC-normalized. Conversation ids are Mapier UUIDs, not a channel's own ids — you get them from inbound message events. **Timestamps.** ISO 8601 with a `Z` suffix. `occurredAt` on an inbound message is when the channel says it was sent, not when Mapier received it. **Forward compatibility.** Fields are added to responses and events without a version bump. Parse defensively: ignore keys you do not recognize, and treat enum values you do not recognize — especially `errorCode` — as unknown rather than impossible. A change your integration could not absorb that way, such as a request handled differently or a renamed word, waits for a new dated [version](https://docs.mapier.ai/convo/api/versions). ## Guide [#guide] - [Quickstart](https://docs.mapier.ai/convo/guides/get-started/quickstart) - [Key concepts](https://docs.mapier.ai/convo/guides/get-started/key-concepts) - [How commands work](https://docs.mapier.ai/convo/api/commands) - [Stream events](https://docs.mapier.ai/convo/api/events/stream) - [Get key details](https://docs.mapier.ai/convo/api/discovery/get-key-details) - [Versions](https://docs.mapier.ai/convo/api/versions) - [Errors](https://docs.mapier.ai/convo/api/errors) # Get the profile (https://docs.mapier.ai/convo/api/line-profile/get) > Read the name and photo people see for your line **POST** `/v1/commands/profile.get` _Works on iMessage_ Reads the iMessage line's own Name and Photo card: the name and photo every person the line writes to sees. It is not a vCard, and it is not anyone else's contact. It messages nobody. Honors `Idempotency-Key`. The `202` is followed by a `command` event carrying the card as `namePhoto`. ## Target [#target] The line itself, never a conversation or a person. - target.lineId: string (A line's id, as GET /v1/whoami lists it in lines[].id) — A line of this project. Any other id is 403 line_not_allowed, with details.lineId naming the id sent. ## Payload [#payload] None. Send `{}` or leave `payload` out. Any key in it is `422 validation_failed` at `payload.`. ## Request [#request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/profile.get \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: card-read-1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // A fresh key for each read: a reused key returns the earlier read. async function readCard(lineId: string, idempotencyKey: string) { const res = await fetch(`${BASE}/v1/commands/profile.get`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { lineId } }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "cmd-5", "status": "queued", "disposition": "queued", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "named" } ``` Then, on the response stream, a `succeeded` event with the card: ```json title="event: command — succeeded" { "commandId": "cmd-5", "logicalActionId": "card-read-1", "status": "succeeded", "errorCode": null, "conversationId": null, "type": "name_photo.get", "messageId": null, "namePhoto": { "name": "Ada Lovelace", "firstName": "Ada", "lastName": "Lovelace", "hasPhoto": true }, "failureClass": null } ``` - name: string | null — The name people see on the line's messages — Messages' display name. Null when none is set. - firstName: string | null — The card's given name, or null. - lastName: string | null — The card's family name, or null. - hasPhoto: boolean — Whether the card carries a photo. The photo itself is not returned. There is no way to read it back: to change it, set a new one. `namePhoto` is `null` on every result but a `succeeded` get or set. On a line that cannot read or set its Name and Photo card, the command ends `failed` with a capability `errorCode` and `failureClass: capability`, and nothing changes. `name_photo.get` is deprecated. Use `profile.get`. Results and events still carry `type: "name_photo.get"`. ## Errors [#errors] A command answers the one set of HTTP refusals [`POST /v1/commands/{type}` publishes](https://docs.mapier.ai/convo/api/commands#errors), so that table is the one to handle. What is particular to this type: - `403 line_not_allowed` for a `target.lineId` that is not a line of the key's project — `details.reason: not_owned`, `details.lineId` the id sent. - `422 validation_failed` at `payload.` for any key. - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. - `503 line_unavailable` for a paused or released line. ## Guide [#guide] - [Set the profile](https://docs.mapier.ai/convo/api/line-profile/set) - [Name and photo](https://docs.mapier.ai/convo/guides/lines/name-and-photo) - [Get key details](https://docs.mapier.ai/convo/api/discovery/get-key-details) # Set the profile (https://docs.mapier.ai/convo/api/line-profile/set) > Change the name and photo people see for your line **POST** `/v1/commands/profile.set` _Works on iMessage_ Sets the iMessage line's own Name and Photo card — what every person the line writes to sees. It does not edit a vCard, and it does not change anyone else's contact. Honors `Idempotency-Key`: a retry under the same key returns the first command without fetching the link again. While the line's sending is paused a set is refused at once, `503 upstream_unavailable` with `reason: outbound_paused`, and nothing is queued. ## Target [#target] The line itself, as on [`profile.get`](https://docs.mapier.ai/convo/api/line-profile/get). - target.lineId: string (A line's id, as GET /v1/whoami lists it in lines[].id) — A line of this project. Any other id is 403 line_not_allowed, with details.lineId naming the id sent. ## Payload [#payload] At least one of these. A set naming nothing to change is `422 validation_failed` at `payload`. - name?: string (Not blank, at most 128 characters) — The name people see. - firstName?: string (Not blank, at most 128 characters) — The card's given name. With lastName and no name, the two are joined for display. - lastName?: string (Not blank, at most 128 characters) — The card's family name. - photoUrl?: string (https link to a JPEG, PNG, GIF, WEBP or HEIC image of at most 8 MiB) — Fetched by Mapier and handed to the line before anything is sent. Leave it out to keep the current photo. Each of these is `422 validation_failed` before anything is sent: - any other key, a blank or over-long name, or a link that is not https, at `payload.`; - a link that cannot be fetched, or a file that is not such an image or is over 8 MiB, at `payload.photoUrl`, its `reason` one of the link refusals a media send meets: `media_fetch_refused`, `media_fetch_failed`, `media_too_large` or `unsupported_media_type`. If the line rejects an image Mapier accepted, the `reason` is `image_too_large` or `unreadable_image`. A `target.lineId` that is not a line of this project is `403 line_not_allowed`, with `details.lineId` naming the id sent. ## Request [#request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/profile.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: card-set-2026-09-30" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d" }, "payload": { "name": "Northwind Support", "photoUrl": "https://example.com/brand/avatar.png" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // One key per change you mean to make: a retry of that change reuses it. async function setCard(lineId: string, name: string, photoUrl: string, idempotencyKey: string) { const res = await fetch(`${BASE}/v1/commands/profile.set`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { lineId }, payload: { name, photoUrl } }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "cmd-6", "status": "queued", "disposition": "queued", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "named" } ``` The set ends `succeeded` once the line has read the change back, and its `command` event carries the card as read: `namePhoto`, with `name`, `firstName`, `lastName` and `hasPhoto`, as on [`profile.get`](https://docs.mapier.ai/convo/api/line-profile/get#response). The photo itself is never returned. ```json title="event: command — succeeded" { "commandId": "cmd-6", "status": "succeeded", "type": "name_photo.set", "namePhoto": { "name": "Northwind Support", "firstName": null, "lastName": null, "hasPhoto": true }, "failureClass": null } ``` A set the line could not confirm ends `ambiguous`: the card may or may not have changed. Read it with [`profile.get`](https://docs.mapier.ai/convo/api/line-profile/get) before you set it again — and check a new photo on a phone, since `hasPhoto` is `true` for the old photo and the new one alike. On a line that cannot read or set its Name and Photo card, the command ends `failed` with a capability `errorCode` and `failureClass: capability`, and nothing changes. `name_photo.set` is deprecated. Use `profile.set`. Results and events still carry `type: "name_photo.set"`. ## Errors [#errors] A command answers the one set of HTTP refusals [`POST /v1/commands/{type}` publishes](https://docs.mapier.ai/convo/api/commands#errors), so that table is the one to handle. What is particular to this type: - `403 line_not_allowed` for a `target.lineId` that is not a line of the key's project — `details.reason: not_owned`, `details.lineId` the id sent. - `422 validation_failed` at `payload`, `payload.` or `payload.photoUrl`, as [above](#payload). - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. - `503 line_unavailable` for a paused or released line, and `503 upstream_unavailable` with `reason: outbound_paused` while the line's sending is paused. ## Guide [#guide] - [Get the profile](https://docs.mapier.ai/convo/api/line-profile/get) - [Name and photo](https://docs.mapier.ai/convo/guides/lines/name-and-photo) - [Share the profile](https://docs.mapier.ai/convo/api/line-profile/share) # Share the profile (https://docs.mapier.ai/convo/api/line-profile/share) > Offer your line's name and photo in a direct message **POST** `/v1/commands/profile.share` _Works on iMessage_ Offers your iMessage name and photo to the other person in a direct message, the same prompt Messages shows when you share your contact card. Honors `Idempotency-Key`. ## Target [#target] - target.kind?: "conversation" — Optional and ignored: conversationId alone picks the target. - target.conversationId: string (UUID of a DM conversation) On an iMessage line, `target.conversationId` must be a conversation the person has already written in. A share addressed by a phone number or an email instead, or into a conversation the person has not written in, is `422 validation_failed` at `target.conversationId`, and nothing is sent. If the person first wrote from a group, the conversation is the group's, and a share into it is refused with `400 bad_request` and `details.reason: "invalid_target"`. A share goes to one person. ## Payload [#payload] Empty — but the key is still required: ```json {} ``` ## Request [#request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/profile.share \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: share-card-a0000000" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "conversation", "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": {} }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; await fetch(`${BASE}/v1/commands/profile.share`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "share-card-a0000000", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "conversation", conversationId: "a0000000-0000-4000-8000-000000000001", }, payload: {}, }), }); ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "cmd-4", "status": "queued", "disposition": "queued", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` The command ends `succeeded` both when the card was offered and when iMessage declined to show the prompt — usually because the recipient already has the card — and the result does not tell the two apart. This result does not carry `namePhoto`; [`profile.get`](https://docs.mapier.ai/convo/api/line-profile/get) and [`profile.set`](https://docs.mapier.ai/convo/api/line-profile/set) do. `name_photo.share` is deprecated. Use `profile.share`. Results and events still carry `type: "name_photo.share"`. ## Errors [#errors] A command answers the one set of HTTP refusals [`POST /v1/commands/{type}` publishes](https://docs.mapier.ai/convo/api/commands#errors) — every type the same codes, `service_busy` and `capacity_exhausted` among them — so that table is the one to handle. What is particular to this type: - `422 validation_failed` at `target.conversationId`, and `400 bad_request` with `details.reason: "invalid_target"` for a group's conversation (above), both before anything is sent. A share the line could not offer ends on the stream, not as an HTTP refusal. ## Guide [#guide] - [Name and photo](https://docs.mapier.ai/convo/guides/lines/name-and-photo) - [Get the profile](https://docs.mapier.ai/convo/api/line-profile/get) # Cancel a setup (https://docs.mapier.ai/convo/api/line-setups/cancel) > Stop an open line setup; its link stops working **POST** `/v1/line-setups/{setupId}/cancel` Stops an open setup; its one-time setup link stops working. Cancelling a setup that is already closed returns it unchanged. A setup that bound its line is refused with a `409`: disconnect the line in the console instead. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/line-setups/0192a7d0-7a8b-7c9d-8eaf-b0c1d2e3f405/cancel \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "x-mapier-version: 2026-12-01" \ -d '{}' ``` ## Response [#response] ```json title="200 OK" { "id": "0192a7d0-7a8b-7c9d-8eaf-b0c1d2e3f405", "channel": "imessage", "method": "operator", "purpose": "connect", "state": "cancelled", "checks": { "credentials": { "state": "pending", "detail": "Mapier is attaching a number.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "webhook": { "state": "pending", "detail": "Waiting for the line to connect.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "platform_approval": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "policy_ack": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "inbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "outbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null } }, "nextStep": null, "handoffUrl": null, "handoffExpiresAt": null, "identity": null, "lineId": null, "number": null, "failureReason": null, "createdAt": "2026-10-18T17:02:11.000Z", "updatedAt": "2026-10-18T17:10:00.000Z", "expiresAt": null } ``` ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `lines:write` scope | | `404` | `not_found` | A setup this key cannot see, or none | | `409` | `conflict` | The setup bound its line; disconnect the line instead | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Connect iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) # Get a setup (https://docs.mapier.ai/convo/api/line-setups/get) > A line setup as it stands: its state, its checks, and the next step **GET** `/v1/line-setups/{setupId}` The setup as it stands: its state, its checks, the step a person must take next, and the line it bound. `verified` means the line is added and takes new contacts; `failed` names its reason in `failureReason`. `handoffUrl` is always null here: it appears only in the response that created the setup. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/line-setups/0192a7d0-7a8b-7c9d-8eaf-b0c1d2e3f405 \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "id": "0192a7d0-7a8b-7c9d-8eaf-b0c1d2e3f405", "channel": "imessage", "method": "operator", "purpose": "connect", "state": "verifying", "checks": { "credentials": { "state": "pending", "detail": "Mapier is attaching a number.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "webhook": { "state": "pending", "detail": "Waiting for the line to connect.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "platform_approval": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "policy_ack": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "inbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "outbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null } }, "nextStep": { "kind": "wait", "reason": "operator_attaching", "etaSeconds": null }, "handoffUrl": null, "handoffExpiresAt": null, "identity": null, "lineId": null, "number": null, "failureReason": null, "createdAt": "2026-10-18T17:02:11.000Z", "updatedAt": "2026-10-18T17:02:11.000Z", "expiresAt": null } ``` Poll it within this route's [budget](https://docs.mapier.ai/convo/api/rate-limits), or take the `line.setup_changed` webhook instead. What each `state` means and what each `nextStep` asks of a person are in [What happens next](https://docs.mapier.ai/convo/api/line-setups/start#what-happens-next). From `ready` on, `lineId` is the line the setup bound, as [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists it; the line takes new contacts once `state` is `verified`. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `lines:write` scope | | `404` | `not_found` | A setup this key cannot see, or none | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Connect iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) # Rerun checks (https://docs.mapier.ai/convo/api/line-setups/rerun-checks) > Run every check a line setup can run now, again **POST** `/v1/line-setups/{setupId}/checks` Runs again every check that can run now, and returns the setup. Use it after the person has fixed what a failed check named. Once per setup every ten seconds; sooner is a `429` with `details.retryAfter`. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/line-setups/0192a7d0-7a8b-7c9d-8eaf-b0c1d2e3f405/checks \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "x-mapier-version: 2026-12-01" \ -d '{}' ``` ## Response [#response] ```json title="200 OK" { "id": "0192a7d0-7a8b-7c9d-8eaf-b0c1d2e3f405", "channel": "imessage", "method": "operator", "purpose": "connect", "state": "verifying", "checks": { "credentials": { "state": "pending", "detail": "Mapier is attaching a number.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "webhook": { "state": "pending", "detail": "Waiting for the line to connect.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "platform_approval": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "policy_ack": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "inbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "outbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null } }, "nextStep": { "kind": "wait", "reason": "operator_attaching", "etaSeconds": null }, "handoffUrl": null, "handoffExpiresAt": null, "identity": null, "lineId": null, "number": null, "failureReason": null, "createdAt": "2026-10-18T17:02:11.000Z", "updatedAt": "2026-10-18T17:02:11.000Z", "expiresAt": null } ``` ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `lines:write` scope | | `404` | `not_found` | A setup this key cannot see, or none | | `409` | `conflict` | The channel's service refused the check for its own reason (`details.reason`); wait `details.retryAfter` seconds when it gives one | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits), or checks run again within ten seconds; wait `details.retryAfter` seconds | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `line_unavailable` | Mapier cannot reach the channel's service right now; `details.reason` says why | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | The channel's service did not answer; retry with backoff | ## Guide [#guide] - [Connect iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) # Start a setup (https://docs.mapier.ai/convo/api/line-setups/start) > Start adding a line, with a link for the person who holds the account **POST** `/v1/line-setups` Starts adding a line on one channel, by one method. `key` names both, as `/`, such as `imessage/operator`; each channel's page in [What works where](https://docs.mapier.ai/convo/api/channel-support) lists its methods and their keys under Connect, and [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities) lists them under each channel's `setupMethods`. The body takes only what is not secret. The key you call with must carry the `lines:write` scope. When the method needs secrets — a token, an app secret — the answer carries `handoffUrl`, a page where the person who holds the account pastes them. Give them the link; do not ask them for the token. A body naming a secret's field (`appSecret`, `botToken`, `configToken`, `pageToken`, `signingSecret`, `token`) is a `422` at that field with `expected: "handoff"`. Nothing is bought and no account is created until the person finishes on that page. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/line-setups \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: setup-support-line" \ -H "x-mapier-version: 2026-12-01" \ -d '{"key": "imessage/operator"}' ``` ## Response [#response] ```json title="201 Created" { "id": "0192a7d0-7a8b-7c9d-8eaf-b0c1d2e3f405", "channel": "imessage", "method": "operator", "purpose": "connect", "state": "verifying", "checks": { "credentials": { "state": "pending", "detail": "Mapier is attaching a number.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "webhook": { "state": "pending", "detail": "Waiting for the line to connect.", "reason": null, "retryable": true, "checkedAt": null, "docUrl": "https://docs.mapier.ai/convo/guides/connect/imessage#request-a-line", "fixUrl": null, "sub": null }, "platform_approval": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "policy_ack": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "inbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null }, "outbound_proof": { "state": "n/a", "detail": "Not needed.", "reason": null, "retryable": false, "checkedAt": null, "docUrl": null, "fixUrl": null, "sub": null } }, "nextStep": { "kind": "wait", "reason": "operator_attaching", "etaSeconds": null }, "handoffUrl": null, "handoffExpiresAt": null, "identity": null, "lineId": null, "number": null, "failureReason": null, "createdAt": "2026-10-18T17:02:11.000Z", "updatedAt": "2026-10-18T17:02:11.000Z", "expiresAt": null } ``` ## What happens next [#what-happens-next] Follow the setup with [`GET /v1/line-setups/{setupId}`](https://docs.mapier.ai/convo/api/line-setups/get) or the `line.setup_changed` webhook. Its `checks` say what has passed, and a check the method does not need is `n/a`. Each failed check's `docUrl` opens the step on the channel's Connect page that fixes it. A line it binds takes new contacts once the setup is `verified`. | `state` | Means | | ---------------- | -------------------------------------------------------------------------------------------- | | `awaiting_input` | A person must act: `nextStep` or `handoffUrl` says what. | | `awaiting_human` | Waiting on the person who holds the account. | | `verifying` | Mapier is checking, or a person at Mapier is setting up an iMessage number; nothing to do. | | `ready` | Every check passed and the line is bound. It becomes `verified` on its own, within a minute. | | `verified` | The line is added and takes new contacts. | | `failed` | It stopped; `failureReason` says why. Start a new setup. | | `cancelled` | You cancelled it. | `handoffUrl` appears only in the response that created the setup: a retry with the same `Idempotency-Key` returns the same setup with `handoffUrl: null`. Without an `Idempotency-Key`, every request starts a new setup. ### The next step [#the-next-step] `nextStep` is the one thing a person does next, or `null` when nobody has anything to do or `handoffUrl` covers it. Show it to the person who holds the account as it is. | `nextStep.kind` | The person | | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `oauth_authorize` | Opens `url` and approves the app, before `expiresAt`. | | `deep_link` | Opens `url` in the channel's own app, such as a chat with its setup bot, before `expiresAt`. | | `invite` | Opens `url` to add the bot to a server they manage. | | `paste_back` | Copies `callbackUrl` and `verifyToken` into the channel's webhook settings, in the fields `fields` names. `verifyToken` appears only in the response that created the step, and is `null` after it. | | `message_us` | Sends a message to `address` from their own account, as `hint` says. | | `wait` | Nothing. `reason` is `number_ordering`, `otp_pending` or `operator_attaching`; `etaSeconds` is an estimate, or `null`. | ### The body each method takes [#the-body-each-method-takes] Every method takes `key`, an optional `displayName` and, to reconnect a line you have, its `lineId`. The rest is per method: each channel's Connect page gives its methods' bodies under **From the API**, such as [Connect iMessage](https://docs.mapier.ai/convo/guides/connect/imessage#from-the-api), with what each field means, and the OpenAPI document's `createLineSetup` request lists them all. A field a method requires and the body leaves out is `422 validation_failed` at that field. Some fields are the account owner's own answers, such as a policy they accept: ask the account owner for those, and never fill them in yourself. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | | `400` | `bad_request` | The body is not JSON; or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `channel_not_entitled` | This channel is not turned on for your project yet; `details.reason` says why | | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `lines:write` scope | | `404` | `not_found` | A `lineId` to reconnect that this key cannot see | | `409` | `conflict` | The channel's service refused the account for its own reason (`details.reason`); wait `details.retryAfter` seconds when it gives one. For a dedicated iMessage line, also while a payment has failed, until it is paid | | `409` | `limit_reached` | A dedicated iMessage line past the lines your organization pays for (`details.limit` is `purchasedLines`); add lines on the Billing page | | `409` | `project_archived` | The project is archived | | `413` | `payload_too_large` | The body is over 65,536 bytes | | `422` | `validation_failed` | A body this method does not take — a secret's field (`expected: "handoff"`), a missing field — or an unknown `x-mapier-version` | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `line_unavailable` | Mapier cannot reach the channel's service right now; `details.reason` says why | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | The channel's service did not answer; retry with backoff | ## Guide [#guide] - [Connect iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) - [Lines](https://docs.mapier.ai/convo/guides/lines/lines) # Get line health (https://docs.mapier.ai/convo/api/lines/get-line-health) > How one of your lines is doing, what to do about it, and the last seven days **GET** `/v1/lines/{lineId}/health` Use this to see a slow-down coming before it happens. An iMessage line is graded on two axes: **load**, what it sends before anyone reacts (new conversations, sends per day and per hour, people reached), and **quality**, how recipients and Apple react (delivered share, sends with no known result, reply rate, opt-outs). Every measure is published beside its limit, so a reading such as "38 of 50 new chats" is one you can act on before the status moves. A line not on iMessage answers `reputation: null`. A **cold** conversation is one your line opens with someone who has not written to it; a **warm** one is one where they have written. The status is the worse of the two axes: | Status | What to do | | ---------- | ---------------------------------------------------------------- | | `HEALTHY` | Send normally. | | `AT_RISK` | Open fewer cold conversations, and keep replying. | | `CRITICAL` | Stop opening cold conversations. Replies and warm ones are fine. | | `FLAGGED` | Rest the line, and use another line for new conversations. | `actionItems` says what to do in words, most important first. A reading is taken about every 15 minutes. [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) carries each line's status in a word under `lines[].reputation`; this route is the full reading. Find the `lineId` in `whoami` under `lines[].id`, or in the console under **Channels › iMessage**. `GET /v1/lines/{lineId}/reputation` is deprecated. It returns the same answer, and the two routes share one budget: 60 requests a minute, per key — see [Rate limits](https://docs.mapier.ai/convo/api/rate-limits). ```bash tab="cURL" curl https://api.mapier.ai/v1/lines/0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d/health \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const lineId = "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"; const res = await fetch(`${BASE}/v1/lines/${lineId}/health`, { headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", }, }); const { reputation } = await res.json(); // null until the line's first reading. if (reputation && reputation.status !== "HEALTHY") { for (const item of reputation.actionItems) console.log(item.title, "—", item.detail); } ``` ## Request [#request] - lineId: string (UUID) — A line this key can see: an id GET /v1/whoami lists under lines. A line of another project is a 404, the same answer an id that never existed gets. ## Response [#response] ```json title="200 OK (one measure per axis shown)" { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "reputation": { "status": "AT_RISK", "confidence": "ok", "confidenceReasons": [], "computedAt": "2026-10-16T14:15:00.000Z", "policyVersion": "2026-10-15b", "primaryDriver": { "axis": "load", "key": "cold_new_chats_24h", "summary": "20 of 30 new chats opened by the line in the last 24 hours" }, "load": { "status": "AT_RISK", "components": [ { "key": "cold_new_chats_24h", "value": 20, "limit": 30, "unit": "count", "status": "warn", "note": "New conversations the line opened in 24 hours, new groups included." } ] }, "quality": { "status": "HEALTHY", "components": [ { "key": "cold_reply_rate_7d", "value": 0.29, "limit": 0.15, "unit": "share", "status": "ok" } ] }, "chats": { "active": 186, "counts": { "HEALTHY": 171, "AT_RISK": 9, "CRITICAL": 2, "OPTED_OUT": 4 } }, "actionItems": [ { "key": "pace_new_chats", "title": "Pace new chats", "detail": "20 of 30 new chats opened by the line in the last 24 hours. Hold new cold chats until the count falls; replies and warm chats are fine." } ] }, "history": [ { "computedAt": "2026-10-16T14:00:00.000Z", "status": "HEALTHY" }, { "computedAt": "2026-10-16T14:15:00.000Z", "status": "AT_RISK" } ] } ``` - lineId: string (UUID) — The line this reading is about. - reputation: object | null — The latest reading, below. Null when the line has not been read yet. - history: object[] ({ computedAt, status }) — Every reading of the last 7 days, oldest first — about one every 15 minutes. Empty when there are none. ### `reputation` [#reputation] - status: string (HEALTHY | AT_RISK | CRITICAL | FLAGGED) — How the line is doing with recipients and Apple: the worse of its load and its quality. The table at the top of this page says what each asks of you. - confidence: string (ok | insufficient) — insufficient when the line has too little recent traffic to grade it well: fewer than 20 checked sends or 10 active conversations in 7 days, or a gap in what the line received. Low confidence never lowers the status. - confidenceReasons: string[] — Why the confidence is insufficient, as short keys. Empty when it is ok. - computedAt: string (ISO 8601 with Z) — When the reading was computed. - policyVersion: string — The grading policy the reading was computed under. It changes when a band or a limit moves. - primaryDriver: object | null ({ axis, key, summary }) — What drives the status: its axis (load, quality or terminal), the measure's key, and one sentence with the numbers. Null on a healthy line. - load: object ({ status, components }) — What the line sends before anyone reacts. status is this axis on its own (HEALTHY, AT_RISK or CRITICAL); components lists every measure on it, each beside its limit, below. - quality: object ({ status, components }) — How recipients and Apple react, in the same shape as load. - chats: object ({ active, counts }) — The line's one-to-one conversations: active is how many had a message in the last 7 days, and counts splits those active ones by their own grade (HEALTHY, AT_RISK, CRITICAL, OPTED_OUT). - actionItems: object[] ({ key, title, detail }) — What to do about the reading, most important first: a stable key, what to do in a few words, and why and how in a sentence. Empty on a healthy line. ### `components[]` item [#components-item] - key: string — Which measure this is, for example cold_new_chats_24h or cold_reply_rate_7d. The list grows: show a key you do not recognize rather than failing on it. - value: number | null — The measured value. Null when the window held too little to measure it. - limit: number | null — For a count, a ceiling: status is warn from 60% of it and hard above it. For a rate, a floor. Null for a measure shown for information only. - unit: string (count | ratio | share | seconds | days) — What value and limit are measured in. - status: string (ok | warn | hard | unknown) — warn is inside the warning band, and hard is past the limit. - note?: string — What the limit is and any gate on it, in a sentence. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | ----------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | A personal access token without the `lines:read` scope | | `404` | `not_found` | No line this key can see has that id: it never existed, or it is another project's | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | `lineId` is not a UUID, or an `x-mapier-version` the API does not support | | `429` | `rate_limited` | 60 requests per minute, per key, shared with the reputation route; the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Get key details](https://docs.mapier.ai/convo/api/discovery/get-key-details) - [Lines › Line health](https://docs.mapier.ai/convo/guides/lines/lines#line-health) # Get line reputation (https://docs.mapier.ai/convo/api/lines/get-line-reputation) > Deprecated: use Get line health **GET** `/v1/lines/{lineId}/reputation` [`GET /v1/lines/{lineId}/health`](https://docs.mapier.ai/convo/api/lines/get-line-health) returns the same answer and describes every field. The two routes share one budget: 60 requests a minute, per key. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/lines/0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d/reputation \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | A personal access token without the `lines:read` scope | | `404` | `not_found` | No line this key can see has that id: it never existed, or it is another project's | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | `lineId` is not a UUID, or an `x-mapier-version` the API does not support | | `429` | `rate_limited` | 60 requests per minute, per key; the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Get line health](https://docs.mapier.ai/convo/api/lines/get-line-health) - [Lines › Line health](https://docs.mapier.ai/convo/guides/lines/lines#line-health) # Get the next line (https://docs.mapier.ai/convo/api/lines/get-next-line) > Which of your lines someone new would get right now **GET** `/v1/lines/available` Use this when a person is about to write to you first — on a sign-up page, in an app, on a printed card — and you need to tell them which number to text. If your project has several lines, it answers with the one Mapier would give somebody new right now. It picks the line the same way a first send to a new person does. It considers only your active lines on the channel whose connection is up and that still have room for new people. Among those, it prefers, in order: 1. the line with the healthiest connection; 2. a line that has not reached today's pace for new people; 3. the line with the most room left before its limit; 4. the oldest line. Lines that are paused, full or whose connection is down are never picked. **It reserves nothing.** Two people shown the same number can both text it, and a send in between can change the answer. Ask again each time you show a number, rather than caching one. If the person is new to your project, texting that number pins them to that line, and the line counts them. If they are already on another of your lines, they stay pinned there, and this line counts them too. Later sends that name no line go out on the line they last wrote to, so on this one. The whole order is in [Replying](https://docs.mapier.ai/convo/guides/lines/lines#replying). ```bash tab="cURL" curl "https://api.mapier.ai/v1/lines/available?channel=imessage" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/lines/available?channel=imessage`, { headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", }, }); // Show `address` to the person. Do not store it: ask again next time. const { lineId, address, channel } = await res.json(); ``` ## Request [#request] - channel?: string (imessage | whatsapp) — Which channel's lines to pick from. Omit it when your project sends on one channel only; a project with lines on more than one channel must name one. ## Response [#response] ```json title="200 OK" { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "address": "+14155550142", "channel": "imessage" } ``` - lineId: string (UUID) — The line's id, as GET /v1/whoami lists it under lines. - address: string — The number to show the person — the address your line's messages come from. - channel: string — The line's channel: the one you asked for, or the only one your project has. ## When no line can take somebody new [#when-no-line-can-take-somebody-new] When every line on that channel is full, paused or down, this answers with the same `503` a first send to somebody new would get: - `no_line` when there is no active line at all; - `capacity_exhausted` when every line is full; - `line_unavailable` with `details.reason: "transport_down"` when every line's connection is down. Show the person something other than a number until it clears. [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) shows each line's room in `contactsAssigned`, `maxContacts` and `takesNewContacts`. ## Errors [#errors] | Status | Code | Cause | | ------ | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | A personal access token without the `lines:read` scope | | `404` | `not_found` | With a personal access token, an `x-mapier-project` it cannot reach | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | `channel` is not a channel the API knows, or is omitted on a project with lines on more than one channel, which `details[].channels` lists | | `429` | `rate_limited` | 120 requests per minute, per key; the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `no_line` · `capacity_exhausted` · `line_unavailable` | No line can take somebody new right now; see [When no line can take somebody new](#when-no-line-can-take-somebody-new) | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Lines](https://docs.mapier.ai/convo/guides/lines/lines) - [Get key details](https://docs.mapier.ai/convo/api/discovery/get-key-details) # List templates (https://docs.mapier.ai/convo/api/lines/list-templates) > The message templates of a WhatsApp line, as Meta lists them **GET** `/v1/lines/{lineId}/templates` The message templates of the WhatsApp Business Account behind a WhatsApp line, as Meta lists them: name, language, status, category and how many parameters each takes. Only an `APPROVED` template can be sent with [`whatsapp.template.send`](https://docs.mapier.ai/convo/api/messages/send), and you need one to message someone who has not written to you in the last 24 hours. ```bash curl https://api.mapier.ai/v1/lines/0192a7b1-5b6c-7d7e-9f80-a1b2c3d4e5f6/templates \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```json title="200 OK" { "templates": [ { "name": "booking_reminder", "language": "en_GB", "status": "APPROVED", "category": "UTILITY", "paramCount": 1 } ] } ``` `status` and `category` are Meta's own words and may gain new values: treat a status you do not know as not usable yet. Create and edit templates in WhatsApp Manager; the list follows within minutes. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | --------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | Meta rejected the request as malformed; or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | A line this key cannot see, or none | | `404` | `unsupported_command` | A line of another channel (`reason: not_on_channel`) | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits), or Meta's; wait `Retry-After` or `details.retryAfter` | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `line_unavailable` | The line cannot be reached right now; `details.reason` says why | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Meta did not answer; retry with backoff | # Download an attachment (https://docs.mapier.ai/convo/api/messages/download-attachment) > Download the file someone sent you **GET** `/v1/attachments/{id}` Returns the raw bytes of one inbound attachment. Ids come from `attachmentIds` on a [`message` event](https://docs.mapier.ai/convo/api/events/stream#event-message), whose `attachments` gives each file's `mimeType`, `filename` and `byteSize`; `content-type` on this response is read from the bytes, so the two can differ. There is no CDN URL on the event. A photo background's picture is fetched here too, by the `attachmentId` its [`chat_background` event](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) or `conversation.background_changed` webhook may carry. ## Example request [#example-request] ```bash tab="cURL" curl -o attachment.bin \ https://api.mapier.ai/v1/attachments/8f2c1a4e-6b3d-4c71-9a05-2e7d8f1b3c64 \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/attachments/${attachmentId}`, { headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", }, }); if (!res.ok) throw new Error(`attachment ${res.status}`); const bytes = new Uint8Array(await res.arrayBuffer()); const etag = res.headers.get("etag"); ``` The id is the whole path segment. There are no sub-paths and no size, format or thumbnail parameter, so a query string is ignored rather than selecting a rendition. ### Conditional requests [#conditional-requests] Pass the `etag` you stored previously to skip re-downloading: ```http If-None-Match: "9f3c2a7e41b0d58c6e9f3a1b7c2d4e5f60718293a4b5c6d7e8f9012a3b4c5d6e" ``` A match returns `304 Not Modified` with no body. ## Response [#response] ```http HTTP/1.1 200 OK content-type: image/heic content-length: 1048576 etag: "9f3c2a7e41b0d58c6e9f3a1b7c2d4e5f60718293a4b5c6d7e8f9012a3b4c5d6e" cache-control: private, max-age=31536000, immutable ``` The response carries these four headers: - content-type?: string — Whatever the channel reported. On an iMessage line the channel sniffs it from the bytes themselves, not from a stored label, and HEIC is served as-is — never transcoded. - content-length?: string — The size in bytes, when the channel gave one and the body was not re-encoded on the way. - etag?: string — The channel's validator. On an iMessage line, the SHA-256 of the content, quoted — content-addressed, so it never changes for a given attachment. - cache-control?: string — The channel's. On an iMessage line, private, max-age=31536000, immutable: safe to cache locally forever, never in a shared cache. There is no `content-disposition`, so no filename: the event carries none either, and a client names the file itself. Files are served as sent. iPhone photos commonly arrive as **HEIC**, which browsers other than Safari cannot display. Convert server-side if you need to render them. ## Lifetime and access [#lifetime-and-access] The URL is permanent and unsigned — it is not a presigned link that expires. Access is controlled by your credential on every request, so the URL is safe to store but **not** safe to hand to a browser or a third party as-is. An attachment of another project returns `404`, the same answer as one that does not exist. An attachment that has not finished transferring also returns `404`; retry shortly. The API publishes no maximum download size. Stream large responses rather than buffering them if you cannot bound the size. ## Errors [#errors] | Status | Code | Cause | | ------ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | The id could not be decoded; or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | Unknown attachment, another project's, or not yet available | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` that is not a published version | | `429` | `rate_limited` | 120 requests per minute, per key; the `Retry-After` header says how long to wait (a channel's own rate limit may give the same seconds in `details.retryAfter` too) | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `line_unavailable` · `upstream_unavailable` | The line holding it cannot serve it right now, or the channel did not answer | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and fetch again | ## Guide [#guide] - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # Edit a message (https://docs.mapier.ai/convo/api/messages/edit) > Change the text of a message your line sent, within 15 minutes **POST** `/v1/commands/message.edit` _Works on iMessage_ Changes the text of a message this line sent. The person sees the new text in place, marked **Edited**. An edit is allowed within **15 minutes** of the message being sent. Honors `Idempotency-Key`. Mapier keeps the message's original text: reading the conversation back returns the text as first sent, and the new text is only in your request. ## Body [#body] ### Target [#target] Name the message at `target.messageId` by the `messageId` its send's `command` event carried, in the conversation at `target.conversationId`. | Field | Type | Required | Description | | --- | --- | --- | --- | | `conversationId` | string (uuid) | Yes | The conversation the message is in. A group's is allowed. | | `messageId` | string (uuid) | Yes | Mapier's id for a message this line sent, the `messageId` its send's `command` event carried, never the channel's `externalId`. | | `lineId` | string (uuid) | No | The line to act from, as `GET /v1/whoami` lists it. Optional | ### Payload [#payload] | Field | Type | Required | Description | | --- | --- | --- | --- | | `text` | string | Yes | The message's new text. Not blank, at most 65,536 bytes as UTF-8. | ## What is refused before anything is sent [#what-is-refused-before-anything-is-sent] Each is `422 validation_failed`, and nothing reaches the line: | Field | `reason` | When | | ------------------ | --------------------- | --------------------------------------------------------------------------------- | | `target.messageId` | `invalid_target` | The message is not in that conversation, or was not sent from this line | | `target.messageId` | `not_yet_addressable` | The channel has not given the message an id: it is still being sent, or it failed | | `target.messageId` | `window_elapsed` | More than 15 minutes have passed since the message was sent | | `payload.text` | | Blank, or over 65,536 bytes | | `payload.` | | Any key but `text` | The window is measured from when the message was sent. The line checks it again when it runs the edit, so an edit let through seconds before the window closes may still finish `failed` with `stale_target`. While the line's sending is paused an edit is refused at once, `503 upstream_unavailable` with `reason: outbound_paused`, rather than held past its window. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/message.edit \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-2481-shipped-fix" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001", "messageId": "0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65" }, "payload": { "text": "Your order shipped. It arrives Thursday." } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; // One key per edit you mean to make: a retry of that edit reuses it, a new edit gets a new one. async function editMessage( conversationId: string, messageId: string, text: string, idempotencyKey: string ) { const res = await fetch(`${BASE}/v1/commands/message.edit`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId, messageId }, payload: { text } }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-1a4c-7d20-8e51-3c7f9a2b6d10", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then a `command` event, `type: "message.edit"`: - `succeeded` once the line confirmed the change. - `failed` with `stale_target` when the line no longer finds the message inside its window, or with `invalid_target`. - `ambiguous` with `errorCode: "moderation_unverified"` when the line could not prove what happened. The message may or may not have been edited. Ask the person, or check the conversation on a device in it, before you edit it again. Do not wait for a later result: none may follow. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.messageId`, `payload.text` or `payload.`, [above](#what-is-refused-before-anything-is-sent). - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. - `503 upstream_unavailable` with `reason: outbound_paused` while the line's sending is paused. Result codes you will see for this command: `stale_target`, `invalid_target`, `moderation_unverified`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Unsend a message](https://docs.mapier.ai/convo/api/messages/unsend) - [Edit and unsend](https://docs.mapier.ai/convo/guides/send/edit-and-unsend) - [Send a message](https://docs.mapier.ai/convo/api/messages/send) # Get receipts (https://docs.mapier.ai/convo/api/messages/receipts) > Ask what one message's delivery and read receipts say now **GET** `/v1/messages/{messageId}/receipts` Asks the channel behind a message's line what it can prove about that message **now**, and answers with what it said. Nothing is stored, and the answer does not change the message's status. For receipts as they happen, open the [stream](https://docs.mapier.ai/convo/api/events/stream) with `?events=receipts`. ```bash curl https://api.mapier.ai/v1/messages/0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65/receipts \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ```json title="200 OK" { "messageId": "0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65", "upstreamMessageId": "8C2E4A61-3B7D-4F90-A1C5-6D8E0F2B4A73", "delivered": true, "read": null, "checkedAt": "2026-08-24T18:09:40.000Z", "upstreamStatus": "delivered" } ``` `messageId` in the path is Mapier's id for a message this key can read — the `messageId` a `receipt` or `delivery_failed` event carries, or the one a `message.*` webhook names. ## Response [#response] - messageId: string (UUID) — The message asked about: Mapier's id for it, the one in the path — never the channel's. - upstreamMessageId?: string | null — The channel's own id for this message (on iMessage, its GUID), as the channel named it in this answer. Null when it named none. Store and ask with messageId, never this. - delivered: boolean | null — Null means the channel does not know — a real answer, such as from a line that was offline, and not the same as false. Folding null into false would report a delivered message as undelivered. - read: boolean | null — Null carries the same meaning as on delivered. - checkedAt: string (ISO 8601 with Z) — When this answer was obtained. Receipts are never stored, so this is always the time of your request. - upstreamStatus: string | null — The channel's own status word, verbatim, so a support thread can quote it. - deliveryService?: string (iMessage | SMS | RCS) — The service an iMessage line’s send went out over, as the line recorded it: `iMessage`, or `SMS` or `RCS` when it went through the carrier instead. Absent when the line did not say — another channel, or a service it does not name — so never read absent as `iMessage`. `delivered` and `read` are three-valued. `null` is "the channel does not know", not "no". A client that writes `if (!answer.delivered)` reports a delivered message as undelivered the first time the channel answers `null`. ## When there is nothing to ask about [#when-there-is-nothing-to-ask-about] - **`409 conflict` with `details.reason: "no_command"`** — the message is real and this key may read it, but it was never handed to a channel, so there are no receipts to ask for. That is every inbound message, and every outbound one whose channel never accepted it. - **`404 not_found` with a `details.reason`** is the channel's answer: `not_settled` means the channel knows the message and has not finished sending it, so ask again shortly. `not_a_send` and `no_echo_guid` mean this message will never have receipts. - **`404 not_found` with no reason** is a message this key cannot read, or one the channel does not know. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | The channel refused the question; `details.reason` is its own word; or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | No such message for this key, or the channel's `not_settled`, `not_a_send` or `no_echo_guid` (above) | | `409` | `conflict` | `details.reason: "no_command"` — the message was never handed to a channel. A channel's own reason may add `details.retryAfter`: the seconds to wait before asking again | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | `messageId` is not a UUID, or an `x-mapier-version` that is not a published version | | `429` | `rate_limited` | More than 60 reads a minute on this key (`Retry-After`), the channel's own rate limit (`details.retryAfter` when it gave a wait), or too many failed authentications from your calling address | | `500` | `internal_error` | An unexpected error on Mapier's side; quote the error's `requestId` to support | | `503` | `line_unavailable` | The message's line cannot be asked right now; `details.reason` says why | | `503` | `upstream_unavailable` | The channel did not answer, or answered with something Mapier could not use | | `503` | `service_busy` | Mapier was too busy to take the request and did nothing; wait `details.retryAfter` seconds and ask again | Each call asks the line's channel, so the route has a budget of its own: 60 requests per minute, per key — see [Rate limits](https://docs.mapier.ai/convo/api/rate-limits). To follow receipts as they arrive, open the stream with `?events=receipts` instead of asking again and again. Every refusal is the one envelope described in [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Stream events](https://docs.mapier.ai/convo/api/events/stream) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) - [Versions](https://docs.mapier.ai/convo/api/versions) # Send a message (https://docs.mapier.ai/convo/api/messages/send) > Send a message, such as an iMessage, with one POST. Text, files or another kind, to a person or a conversation **POST** `/v1/commands/message.send` Sends one message on any channel. The result arrives later as an event. ## Behavior [#behavior] - Returns `202` when accepted. The result arrives later as a `command` event on the [stream](https://docs.mapier.ai/convo/api/events/stream), or a `command.settled` webhook. - A repeated [`Idempotency-Key`](https://docs.mapier.ai/convo/guides/production/retries) returns the first `202`, with `"repeated": true`. - 600 commands a minute per project. [Rate limits](https://docs.mapier.ai/convo/api/rate-limits) lists every limit. - `media` holds one file, up to the size in [Files](#files). Several photos go as one `multipart` message, on iMessage. - Every refusal below comes back at once, before anything is sent, except a first text the line itself refuses (see [Who gets it](#who-gets-it)). A field the line cannot carry is `422 validation_failed`. Nothing is dropped with a `202`. ## Headers [#headers] | Header | Required | Value | | --- | --- | --- | | `Authorization` | Yes | `Bearer mp_live_…`, your [API key](https://docs.mapier.ai/convo/guides/get-started/authentication) | | `Content-Type` | Yes | `application/json` | | `Idempotency-Key` | No, but always send one | Your id for this send, 1 to 200 characters | | `x-mapier-version` | No | The API version date, such as `2026-12-01` | Without `x-mapier-version`, you get your project's default. [Versions](https://docs.mapier.ai/convo/api/versions) explains. ## Body [#body] | Field | Type | Required | Description | | --- | --- | --- | --- | | `target.conversationId` | string (uuid) | In the `conversation` form | Send into this conversation, from its line | | `target.recipientExternalId` | string | In the `recipient` form | The person's address, in the form shown below. `target.to` is the same field | | `target.channel` | `imessage` or `whatsapp` | No | The channel the person is on, such as `imessage` | | `target.lineId` | string (uuid) | No | Send from this line | | `target.replyToMessageId` | string (uuid) | No | Quote this message, in its conversation | | `payload.kind` | `text`, `media`, `sticker`, `multipart`, `location_request`, `poll`, `app_card`, `link`, `template`, `choices`, `location` or `contact` | No | What to send, one of the kinds below | | `options.degrade` | `strict` or `adapt` | No | `strict` (default) or `adapt` to fit the channel | With `adapt`, Mapier drops or splits what the channel cannot carry, and lists each change in `adaptations`. A payload field the line does not carry, and that carries a value, is refused. `body` is read as a second spelling of `text`, and a field set to `null` is skipped. ### Who gets it [#who-gets-it] Use **one** of these. [Lines](https://docs.mapier.ai/convo/guides/lines/lines) explains how a line is picked. | You have | Send | | ---------------------------------- | ------------------------------------------------- | | A conversation | `target.conversationId` | | A message to quote | `target.replyToMessageId` | | An address and a line to send from | `target.lineId` and `target.to` | | An address and a channel | `target.channel` and `target.to` | | An address only | `target.to`, if all your lines are on one channel | `target.to` is also read as `target.recipientExternalId`, `target.address`, `target.handle` or `target.recipient`. A conversation named at `target.conversationId` wins over an address. On an iMessage line the conversation decides what a send can carry, not the target you name. Each conversation is on one of two paths: - **The conversation path:** a conversation the person has written in, or a group chat. Every kind goes, with `effect` and `subject` beside `text`, and a reply named at `target.replyToMessageId` is quoted. If the line does not take the send within 30 seconds, its result is `expired`. While the line is offline the send is refused at once with `503 upstream_unavailable`. While you have paused the line, the send is accepted and its result is `expired`. - **The recipient path:** any other conversation, such as a first message to someone new. The message is `text` alone, with no effect, subject, quoted reply or file, at most 16,384 bytes. Its result can take up to five minutes. The line refuses a blank or longer text after Mapier has recorded the send, so send the fixed text under a new key. Send a text first; once the person answers, the conversation is on the conversation path. What a conversation cannot carry is refused with `422 validation_failed` before anything is sent. [Errors](#errors) lists each refusal and the field it names. Honors `Idempotency-Key`: a retry with the same key is never sent twice. If the answer to a first message to someone new was lost, Mapier does not send it again: check the conversation, then send it under a new key if it did not arrive. ### Address forms [#address-forms] | Channel | `target.to` | Example | | --------- | ------------------------------------------------------- | --------------------------------------------------------------- | | iMessage | Phone number with `+` and country code | `+15550100100` | | iMessage | Ten digits without `+`, read as a US number | `5550100100` | | iMessage | Apple ID email, in an existing conversation only | `jordan@example.com` | | WhatsApp | Phone number with `+` and country code | `+15550100100` | | WhatsApp | WhatsApp user ID from Meta, when there is no phone | `US.Ab12` | ### Kinds [#kinds] | `kind` | Fields | Guide | | ------------------ | --------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | `text` | `text` | [Text](https://docs.mapier.ai/convo/guides/send/text) | | `media` | `url`, optional `caption` | [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files) | | `multipart` | `parts`, each a `text` or a `media` `url` | [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files) | | `sticker` | `url` or `emoji` | [Stickers](https://docs.mapier.ai/convo/guides/send/stickers) | | `link` | `url` | [Links](https://docs.mapier.ai/convo/guides/send/links) | | `location` | `latitude`, `longitude`, optional `name`, `address` | [Location](https://docs.mapier.ai/convo/guides/send/location) | | `location_request` | nothing beside it | [Location](https://docs.mapier.ai/convo/guides/send/location) | | `contact` | `contacts` | [Contact cards](https://docs.mapier.ai/convo/guides/send/contact-cards) | | `poll` | `question`, `options` | [Polls](https://docs.mapier.ai/convo/guides/send/polls) | | `app_card` | `app`, `url`, `layout`, optional `interactive` | [App cards](https://docs.mapier.ai/convo/guides/send/app-cards) | | `choices` | `interactive`, or `text` with `quickReplies` or `buttons` | [Buttons and lists](https://docs.mapier.ai/convo/guides/send/buttons-and-lists) | | `template` | `name`, `language`, `components` | [Templates](https://docs.mapier.ai/convo/guides/send/templates) | `kind: "rich_link"` is deprecated. Use `kind: "link"`. A kind the line's channel does not carry is `404 unsupported_command` with `reason: not_on_channel`. [Channel support](https://docs.mapier.ai/convo/api/channel-support) shows which kind works where. Each kind in detail: `kind: "text"`, or no `kind` at all. `effect`, `subject` and `textFormatting` are optional on the conversation path, and a `422` at `payload.` on the recipient path. - text: string (1 to 65,536 bytes, measured as UTF-8) — What the body allows. On the recipient path the line refuses a text that is blank or over 16,384 bytes, with invalid_text, after the send is recorded. - effect?: string (impact | loud | gentle | invisibleink | confetti | lasers | fireworks | balloons | sparkles | spotlight | echo | love | celebration) — A bubble or full-screen animation, on the conversation path; sparkles is a second name for celebration. A name outside the thirteen is 422 validation_failed at payload.effect; on the recipient path every effect is. See the effects guide. - subject?: string (1 to 1024 characters) — The iMessage subject line, on the conversation path. Outside that length it is 422 validation_failed at payload.subject; on the recipient path every subject is. - textFormatting?: object[] (1 to 256 ranges: { start, length, styles?, effect?, mention? }) — Formatting for ranges of the text, on the conversation path. start and length are in UTF-16 code units of text, inside it and cutting no character in two, with at least one of styles (any of bold, italic, underline, strikethrough), effect (one of bounce, stretch, squish, scaleRipple, big, bloom, somersault, nod, shake, jitter, small, explode) and mention. A range that breaks a rule is 422 validation_failed at payload.textFormatting[i]; a list that is not 1 to 256 ranges, formatting on anything but a text, or formatting on the recipient path is 422 at payload.textFormatting. ```json { "text": "hello" } ``` ```json { "text": "You are in. See you Saturday.", "subject": "Saturday", "effect": "confetti" } ``` A photo or file by link. On iMessage it goes on the conversation path alone. The guide is [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files). - kind: "media" - url: string (https link, at most 2048 characters) — The file. On iMessage Mapier fetches it before anything is written: https only, at most 8 MiB, from a server that answers promptly, every redirect re-checked and none into a private network, an image, a PDF, common audio or video, or a vCard contact card (.vcf) whose declared type matches its bytes. A link it cannot use is 422 validation_failed at payload.url with media_fetch_refused, media_fetch_failed, media_too_large or unsupported_media_type as the entry's reason. - caption?: string (1 to 1,024 characters) — Words sent with the file, where the line's channel takes them. On iMessage a caption is 422 validation_failed at payload.caption. ```json { "kind": "media", "url": "https://example.com/orders/4821/receipt.pdf" } ``` What goes beside `url`: - On iMessage nothing else goes beside it: a `caption` is a `422` at `payload.caption`, and an `effect` or a `subject` at that key. - The media keys are checked for shape before the line is known — `url` or `caption` without `kind: "media"`, a link that is not https — so that `422` names the key and carries no `channel`. On WhatsApp a `caption` may go beside it, and anything else is a `422` at that key. WhatsApp fetches the link itself. When Mapier is busy: - While your project, or Mapier, is already sending as many files as it can at once, the send is `503 service_busy` with `retryAfter`. - Neither that nor a refused link writes a message, so the same `Idempotency-Key` may be sent again. A `503 upstream_unavailable` after the line was asked is different: the key is spent. A picture sent in place of the text. The guide is [Stickers](https://docs.mapier.ai/convo/guides/send/stickers). - **On iMessage:** one emoji, or an image by https link, on its own as a bubble or stuck onto a message the person sent at a spot you choose on that bubble. It goes on the conversation path alone: into a conversation the person has written in, or a group chat. The fields, placement and refusals below are iMessage's. **On WhatsApp:** a WebP image by link, on its own. **A sticker on WhatsApp**, below, has its rules. - kind: "sticker" - emoji?: string (Exactly one emoji, at most 64 UTF-16 units) — The picture, in place of the text: one grapheme that is an emoji, a flag or a keycap — a skin tone, a ZWJ family or a flag counts as one — with nothing before or after it. Otherwise 422 validation_failed at payload.emoji; nothing is trimmed. Exactly one of emoji and url. - url?: string (https link, at most 2048 characters, to a PNG, GIF or JPEG of at most 512,000 bytes and 618 px on a side) — The picture as an image sticker, fetched inside the send and handed to the line. Outside those bounds it is 422 validation_failed at payload.url and is never sent. Exactly one of emoji and url. - attachToMessageExternalId?: string — The message the sticker is stuck to — the externalId its message event carried. Without it the sticker is sent as its own message. Never beside target.replyToMessageId. - partIndex?: number (Integer, 0 to 64) — Which part of that message's bubble to attach to. - placement?: object ({ x?, y?, scale?, rotation? }) — Where the sticker sits on that message's bubble. Only beside attachToMessageExternalId; an empty object changes nothing. `placement` fields are plain JSON numbers, each optional, each rounded to 4 decimal places before it is checked; an omitted one keeps its default. | Field | Default | Range | Meaning | | ---------- | ------- | ----------- | ------------------------------------------------------------------------------------------------------------- | | `x`, `y` | `0.5` | −5 to 6 | The sticker's center, as a fraction of the bubble from its top-left corner. Outside 0–1 hangs off the bubble. | | `scale` | `1` | 0.1 to 5 | Multiplier of the standard size, about 48 pt wide for an emoji. | | `rotation` | `0` | −180 to 180 | Degrees, positive clockwise. | With no `placement`, the sticker lands dead center and covers a short message. Pick a corner instead: ```json { "kind": "sticker", "emoji": "👍", "attachToMessageExternalId": "5D1B7E0A-2F3C-4B8E-9A61-1C2D3E4F5A6B", "placement": { "x": 0.95, "y": 0.1, "rotation": 12 } } ``` On iMessage these are refused with `422 validation_failed` at the field named, before anything is written: - `emoji` that is not exactly one emoji (`"👍👍"`, `"👍 "`, a word, a digit), at `payload.emoji`. Nothing is trimmed. - `placement` without `attachToMessageExternalId`, a `placement` value that is not a number or is out of range, or a `partIndex` outside 0 to 64, at that field. - A reply, `target.replyToMessageId`, beside `attachToMessageExternalId`. - Both `emoji` and `url`, or neither, or any of the keys without `kind: "sticker"`, at that key. - An image link that is not a PNG, GIF or JPEG, is over 512,000 bytes or more than 618 px on a side, at `payload.url`. The file is fetched and checked, and nothing is sent. - A conversation on the recipient path, at `target.conversationId` or the recipient field you wrote, with `reason: conversation_not_confirmed`. A line that does not support emoji stickers (or placement, for a placed sticker, or replies on a sticker, for a reply) sends nothing: the command is accepted with `202`, and its result is `failed` with `capability_constraint_violation`, `failureClass: capability`. It never falls back to a centered or unplaced sticker. See [Channel support](https://docs.mapier.ai/convo/api/channel-support). **A sticker on WhatsApp** A WhatsApp sticker is an image by link and nothing else. The sample below is a 512 × 512 static WebP you can send to try it: ```json { "kind": "sticker", "url": "https://convo.mapier.ai/docs/samples/sticker.webp" } ``` - `url`: an https link of at most 2048 characters whose path ends in `.webp` (a query string may follow). - WhatsApp fetches the file itself and takes a static sticker of at most 100 KB or an animated one of at most 500 KB, 512 × 512 px. A file it does not take makes the send's result `failed`. - A reply, `target.replyToMessageId`, is allowed. - It goes to one person. Into a WhatsApp group it is a `422` at `target.conversationId`. - A missing `url` or one whose path does not end in `.webp`, and any other key (`emoji`, `attachToMessageExternalId`, `partIndex`, `placement`, `caption`, `platform.whatsapp.previewUrl`), are each a `422` at that field. A sticker to a line on any other channel is `404 unsupported_command` with `reason: not_on_channel`. A URL sent as a preview card the person's phone draws. On iMessage it goes on the conversation path alone. The guide is [Links](https://docs.mapier.ai/convo/guides/send/links). - kind: "link" - url: string (Absolute http or https URL, at most 2048 characters, no control characters) — The whole payload, in place of the text. Relative, another scheme, too long or carrying a control character is 422 validation_failed at payload.url. ```json { "kind": "link", "url": "https://example.com/launch" } ``` - Nothing else goes beside `url`: another key is a `422` at that key. - A reply is `target.replyToMessageId`, as on any send. - The result carries the link message's `externalId`, as a text's does, so a later command (a reaction, a sticker stuck to it, a reply, an edit or an unsend) can name it. - A line that does not support links (or replies on one, for a reply) sends nothing: `202`, then `failed` with `capability_constraint_violation`, `failureClass: capability`. On WhatsApp a link goes out as a text whose body is the URL, and the person's WhatsApp draws a preview of the page from its own preview tags. `platform.whatsapp.previewUrl` beside it is a `422` at that field, like any other: a link turns the preview on itself. Text and photos as one message, in the order given — a caption over a photo, an album, or text and photos interleaved — on the conversation path alone. The guide is [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files). - kind: "multipart" - parts: array (2 to 20 parts, at most 10 of them media, no link twice) — Each {kind: "text", text} or {kind: "media", url}, in the order sent. The count, the media count and a repeated link are 422 validation_failed at payload.parts; a blank text at payload.parts[i].text; a url that is not https, cannot be fetched, is too large or is not a photo, video or PDF at payload.parts[i].url, with nothing sent. - effect?: string (One of 13 effect names) — As beside a text. - subject?: string (1 to 1024 characters) — As beside a text. ```json { "kind": "multipart", "parts": [ { "kind": "text", "text": "Here they are:" }, { "kind": "media", "url": "https://example.com/listings/4821/front.jpg" }, { "kind": "media", "url": "https://example.com/listings/4821/kitchen.jpg" } ] } ``` - Every link is fetched and uploaded to the line before the message is sent, in order. One that fails refuses the whole send at that part's `url`, never a partial message. - Audio is not a part: iMessage sends it as a message of its own. - A reply is `target.replyToMessageId`, as on any send. - A line that does not support multipart sends nothing: `202`, then `failed` with `capability_constraint_violation`, `failureClass: capability`. It never sends several separate messages instead. Apple's "Share My Location?" card, asking the contact to share their location with the line. It goes on the conversation path alone, so only into a one-to-one conversation the person has written in. The guide is [Location](https://docs.mapier.ai/convo/guides/send/location). - kind: "location_request" ```json { "kind": "location_request" } ``` - Nothing goes beside `kind`: any other key, a `text` included, is `422 validation_failed` at that key before anything is written. - A reply is `target.replyToMessageId`, as on any send. - A group chat, or a conversation the person has not written in, is a `422` with `reason: conversation_not_confirmed`. What comes back: - `succeeded` means the card was sent, never that the person shared. If they tap Share, their location arrives later, apart from this command, as [location events](https://docs.mapier.ai/convo/guides/send/location#receive-a-location). - A line that does not support location requests (or replies on one, for a reply) sends nothing: `202`, then `failed` with `capability_constraint_violation` (or `capability_not_negotiated`), `failureClass: capability`. A question with 2 to 12 choices that the people in the conversation tap to vote on. It goes on the conversation path alone. The guide is [Polls](https://docs.mapier.ai/convo/guides/send/polls). - kind: "poll" - question: string (1 to 128 characters, not blank, on one line) — Outside those bounds it is 422 validation_failed at payload.question. - options: string[] (2 to 12 choices, each 1 to 128 characters, not blank, on one line) — Each choice once. The count or a repeated choice is 422 validation_failed at payload.options; a choice outside its bounds at payload.options[i]. ```json { "kind": "poll", "question": "Lunch?", "options": ["Tacos", "Ramen", "Pho"] } ``` - Nothing else goes beside `question` and `options`: any other key, a `text` included, is `422 validation_failed` at that key before anything is written. So is a `question` or `options` beside any other kind. - A reply is `target.replyToMessageId`, as on any send. - Into a conversation on the recipient path it is a `422` with `reason: conversation_not_confirmed`. What comes back: - The poll's own id and the ids its choices were given arrive as a `poll.created` with `actor: "line"` on a stream opened with `?events=polls`: the ids [`poll.vote`](https://docs.mapier.ai/convo/api/messages/vote-in-poll) names. - The send's result carries the poll's id as `externalId` when the channel gives one. - A line that does not support polls sends nothing: `202`, then `failed` with `capability_constraint_violation` (or `capability_not_negotiated`), `failureClass: capability`. A card from an iMessage app your organization holds, which the person's phone draws as that app's card. Only an organization offered app cards can send one; for any other organization it is `404 unsupported_command` with `reason: not_on_channel`. On a test line on a shared number it goes out as any message does, counted against that line's budgets. It goes on the conversation path alone. The guide is [App cards](https://docs.mapier.ai/convo/guides/send/app-cards). - kind: "app_card" - app: object ({ name, teamId, bundleId, appStoreId? }) — The app as your organization registered it: its registered name, its Apple team id, the bundle id of its Messages extension and, optionally, its App Store id. An app you do not hold, a disabled one or another name is 422 validation_failed at payload.app. - url: string (1 to 4096 characters; https, http or data) — The app's state, which its extension reads. A notification shows it in full, so it carries nothing private. - layout: object ({ caption, subcaption?, image? }, each text 1 to 4096 characters) — The words drawn where the app does not draw the card itself, and optionally its picture. A notification shows the caption. - layout.image?: string (https, up to 2048 characters) — A link to the card's picture: a JPEG, PNG, WebP, HEIC or HEIF image of up to 8388608 bytes (8 MiB). Mapier fetches it before the card is written; a link that cannot be fetched, or another file, is 422 validation_failed at payload.layout.image. Not on a reply. - interactive?: boolean — Whether an installed app draws the card itself. Defaults to false, a plain card. Set it only for an app that draws its own bubble. - summary?: string (1 to 4096 characters) — Accepted and sent; where Messages shows it is not promised. - Any other key is `422 validation_failed` at that key before anything is written. - Someone other than your line must have written in the conversation (`403`, `recipient_must_write_first`), and its newest message must have gone by iMessage (`403`, `app_card_needs_imessage`). - A card is never sent twice for one `Idempotency-Key`, at any API version. - A reply is `target.replyToMessageId`, as on any send. How a phone draws a card sent as a reply is not proven. A card with `layout.image` cannot be a reply: `422` at `payload.layout.image`. - Messages shows the picture only to a person who has your line in their contacts. Anyone else sees the card's words alone. What comes back: - The result carries `appCard.updatable`. `succeeded` means your line handed the card to Messages, not that it was delivered or drawn as a card. - `ambiguous` with `errorCode: "app_card_unverified"` means it may be in the conversation: look before you send it again. - A line whose Mac cannot send cards, or card pictures, accepts it, then settles `failed` with `capability_constraint_violation`. A card is never sent without the picture it names. - Change it later with [`app_card.update`](https://docs.mapier.ai/convo/api/messages/update-app-card). ### Files [#files] The most files one `media` message can hold, and the largest file, on each channel. | Channel | Files per message | Largest file | | --------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | | iMessage | 1, or up to 20 parts in a `multipart` | 8 MiB | | WhatsApp | 1 | Image 5 MiB (JPEG, PNG), video 16 MiB (MP4, 3GPP), audio 16 MiB, document 100 MiB | ### Channel options [#channel-options] | Field | Channel | Description | | -------------------------------------- | -------- | ------------------------------------------------------------------------- | | `payload.effect` | iMessage | A bubble or screen effect, such as `confetti` | | `payload.subject` | iMessage | A bold subject line above the text | | `payload.textFormatting` | iMessage | Up to 256 ranges: styles, text animations or mentions | | `payload.platform.whatsapp.previewUrl` | WhatsApp | `true` shows a preview of the first link | On iMessage these go beside `text`, on the conversation path. ### What a line carries [#what-a-line-carries] | Line | `message.send` carries | | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | iMessage | `text` — and, on the conversation path, `effect`, `subject` and `textFormatting` beside it; `kind: "media"` with an https link and no caption; `kind: "sticker"` with `emoji` or an image link, `attachToMessageExternalId`, `partIndex` and `placement`; `kind: "link"` with `url`; `kind: "multipart"` with `parts` (an effect and a subject beside them, as on a text); `kind: "location_request"` with nothing beside it; `kind: "poll"` with `question` and `options`; for an organization offered app cards, `kind: "app_card"` with `app`, `url`, `layout` (its picture at `payload.layout.image`), `interactive` and `summary` | | WhatsApp | `text` of at most 4,096 characters, with `platform.whatsapp.previewUrl` beside it; `kind: "media"` with an https `url`, which WhatsApp fetches itself, and an optional `caption` of 1 to 1,024 characters; `kind: "sticker"` with an https `url` to a WebP image; `kind: "link"` with `url`. Only within 24 hours of the person's last message | What every line does with the payload: - `body` is read as a second spelling of `text`. - A field set to `null`, an object holding only `null`s and an empty `attachments` or `media` list say nothing and are skipped. - Any other field that carries a value is refused with `422 validation_failed` at `payload.` before anything is queued. That `422` carries the line's `channel` and the fields it `carries` in the same entry, and `details` names the field it stopped at. - A line of another channel carries what that channel's page lists under What works, and what [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities) lists for every channel, with each channel's own limits. A field it cannot carry is the same `422`, and a kind it does not carry is `404 unsupported_command` with `reason: not_on_channel`. Photos and files go by link: - **iMessage:** `kind: "media"` with an https `url` of at most 2048 characters and no `caption`, fetched by Mapier before anything is written. Or as the parts of a `multipart`. - **WhatsApp:** `kind: "media"` with an https `url` and an optional `caption` of 1 to 1,024 characters. WhatsApp fetches the link itself. A reply names a message in the same conversation at `target.replyToMessageId`, beside the payload and never in it. On the conversation path it is quoted when it names a message the person sent, or one of yours whose result carried an `externalId`. Any other reply, and every reply on the recipient path, is refused rather than sent unquoted. Each refusal names the field it stopped at, before anything is written: - `payload.`: a field the line does not carry, or a value outside its bounds. - `payload.url`: a media link Mapier cannot use. - `payload.parts`: a multipart's count, or a link twice. A part is refused at the part, `payload.parts[i].url` or `payload.parts[i].text`. - `payload.emoji`: a sticker's `emoji` that is not exactly one emoji. - `payload.textFormatting`: formatting outside its rules, or the range that breaks one at `payload.textFormatting[i]`. - `payload.app`: an app card's app that your organization does not hold, a disabled one, or a name that differs from the one it registered. - `target.replyToMessageId`: a reply the line cannot quote. - `target.conversationId`, or the recipient field you wrote: an address or a conversation that cannot take what you sent. - `target.lineId`: a line on another channel, or not the line the conversation is on. The whole list is under [Errors](#errors). [Who gets it](#who-gets-it) says what each conversation can carry, and how a named line meets the line a person is already on. ### Deprecated command names [#deprecated-command-names] `whatsapp.template.send` is deprecated. Send `message.send` with `kind: "template"`. `whatsapp.interactive.send` is deprecated. Send `message.send` with `kind: "choices"`. `whatsapp.location.send` is deprecated. Send `message.send` with `kind: "location"`. `whatsapp.contacts.send` is deprecated. Send `message.send` with `kind: "contact"`. ## Example request [#example-request] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-ready" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "channel": "imessage", "to": "+15550100100" }, "payload": { "kind": "text", "text": "Your order is ready." } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order-4821-ready", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { channel: "imessage", to: "+15550100100" }, payload: { kind: "text", text: "Your order is ready." }, }), }); const accepted = await res.json(); // 202: { commandId, status: "queued", … } ``` ## Response [#response] | Field | Type | Sent | Description | | --- | --- | --- | --- | | `commandId` | string | Always | The id the result on the stream carries | | `status` | `"queued"` | Always | `queued`, even on a repeat: the final status is in the result | | `repeated` | boolean | When it applies | `true` when this `Idempotency-Key` was used before | | `lineId` | string (uuid) | Always | The line that sends it | | `lineSelection` | `named`, `reused_active_chat` or `new_best_line` | Always | Why that line, one of the three values below | | `channel` | `imessage` or `whatsapp` | When it applies | The channel that sends it | | `parts` | object[], each `{ commandId, index }` | When it applies | When it went out as several messages: each part's command | | `adaptations` | object[], each `{ path, action, capability?, reason }` | When it applies | With `adapt`: each change made to fit the channel | | `lineSelection` | Means | | -------------------- | ------------------------------------------------------- | | `named` | You named the line | | `reused_active_chat` | The line the person already talks to | | `new_best_line` | A new person, so Mapier picked a working line with room | ```json title="202 Accepted" { "commandId": "0192b3e1-7c2d-7a10-9b3e-4f5a6b7c8d9e", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "new_best_line", "channel": "imessage" } ``` [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) explains each final status. Each channel publishes its text limit as `textLimit` on [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities). - A longer text is `422 validation_failed` at `payload.text`, naming the limit, and nothing is sent. - On iMessage the 65,536-byte body cap answers first, with `413 payload_too_large`. - Text is never split: keep each message within the limit, or send several messages. The one send that goes out as several messages is a caption that `options.degrade: "adapt"` sends on its own. It answers with `parts`, one `{commandId, index}` per message, in order; `commandId` is the first part's. - Each part has its own result, and no result covers the whole message. It went out only when every part's result says `succeeded`, so watch each `parts[].commandId`. - Parts go in order, each once the one before it was accepted. - One the line refuses, or never answers, stops the rest, and the request answers with that refusal. Its `details.sentParts` names the parts already sent, and the refusal itself says what became of the part it is about. - A retry with the same key never sends a part again: send only the parts not in `details.sentParts`, under a new key. ## Errors [#errors] Every refusal has the [same body](https://docs.mapier.ai/convo/api/errors). | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The key is missing, unknown, revoked or expired | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key lacks `messages:send` | All | | 403 | [`line_not_allowed`](https://docs.mapier.ai/convo/api/errors/line_not_allowed) | `not_owned` | `target.lineId` is not one of your project's lines | All | | 403 | [`recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | `opted_out` | The person opted out | All | | 403 | [`recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | `blocked`, `paused` | You blocked or paused the person in the console | All | | 403 | [`recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | `outside_service_window` | The 24-hour reply window has closed. Send a template first | WhatsApp | | 403 | [`recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | `recipient_must_write_first` | An app card into a conversation nobody but your line has written in; or, from a test line on a shared number, a send to someone who has not texted the line, is no longer connected, or has left 20 turns or 100 messages unanswered since they last texted | iMessage | | 403 | [`recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | `app_card_needs_imessage` | An app card into a conversation whose newest message did not go by iMessage | iMessage | | 403 | [`recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | `group_member_not_test_contact` | A send into a group on a test line on a shared number while someone in it is not one of this project's connected Test contacts | iMessage | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | No conversation or message has that id | All | | 404 | [`unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) | `not_on_channel` | The channel has no such kind | All | | 404 | [`unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) | `not_on_line` | This line cannot send that kind | All | | 404 | [`unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) | `shared_line` | Not returned for a `message.send`: a test line on a shared number refuses only other commands with it | iMessage | | 404 | [`unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) | `command_retired` | The command type was retired. `details.use` names the one to send instead. | All | | 409 | [`conflict`](https://docs.mapier.ai/convo/api/errors/conflict) | `idempotency_key_in_flight` | The first send is still running | All | | 409 | [`conflict`](https://docs.mapier.ai/convo/api/errors/conflict) | `idempotency_key_failed` | The first send failed | All | | 409 | [`conflict`](https://docs.mapier.ai/convo/api/errors/conflict) | `idempotency_key_unresolved` | The first send may have gone out | All | | 409 | [`conflict`](https://docs.mapier.ai/convo/api/errors/conflict) | `idempotency_key_reused` | The key was used for a different send | All | | 409 | [`conversation_closed`](https://docs.mapier.ai/convo/api/errors/conversation_closed) | `removed`, `deleted`, `archived`, `suspended` | The group closed for this line | All | | 409 | [`limit_reached`](https://docs.mapier.ai/convo/api/errors/limit_reached) | | A daily cap on this test line on a shared number is reached | iMessage | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The project is archived | All | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | | The request body is over 65,536 bytes | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong; each `details` entry names one | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A link is over 2,048 characters | iMessage | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | An app card's app is not one your organization holds, is disabled, or its name differs, at `payload.app` | iMessage | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | `media_too_large` | A file is over 8 MiB | iMessage | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | `unsupported_media_type` | A file's type is not allowed | iMessage | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | `media_fetch_failed` | Mapier could not fetch a file's link | iMessage | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | `media_fetch_refused` | The link is not https, or points inside a private network | iMessage | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Over your request limit. Wait as the `Retry-After` header says | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | `error_budget` | The channel refused many recent sends from this line. Wait `details.retryAfter` | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | `shared_line` | A test line on a shared number spent its budget for your project | iMessage | | 429 | [`sandbox_budget_exhausted`](https://docs.mapier.ai/convo/api/errors#sandbox_budget_exhausted) | | Not returned today. Handle it like `rate_limited` | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side | All | | 503 | [`capacity_exhausted`](https://docs.mapier.ai/convo/api/errors/capacity_exhausted) | `all_lines_full` | Every line is full for new people | All | | 503 | [`line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable) | `transport_down` | The line's channel connection is down for now | All | | 503 | [`line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable) | `line_paused` | You paused the line | All | | 503 | [`line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable) | `channel_not_available` | The project has no line on this channel. | All | | 503 | [`line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable) | `sandbox_world_missing` | Not returned today. Handle it like `channel_not_available`. | All | | 503 | [`line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable) | `transport_unconfigured` | The line is not fully set up yet. Contact support if this lasts. | All | | 503 | [`line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable) | `line_retired` | The line was retired from your project. Start a new conversation with the person on another line. | All | | 503 | [`no_line`](https://docs.mapier.ai/convo/api/errors/no_line) | | Your project has no working line on that channel | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy, for example fetching many files. Wait `details.retryAfter` | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not answer | All | A message the channel refuses after the `202` is still recorded: its result says `failed`, with the reason. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) lists every result code. A field is wrong or missing, the payload carries a field the line does not, or an iMessage line cannot carry the address, the group, the text or the kind. `details` names the field; see [What a line carries](#what-a-line-carries). | Field | Refused | | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `payload.` | A field the line does not carry. On the recipient path, `effect` and `subject`. On the conversation path, an `effect` outside the thirteen names or a `subject` outside 1 to 1024 characters | | `payload.text` | A text over the channel's `textLimit` | | `payload.url` | A media link Mapier cannot use, with `media_fetch_refused`, `media_fetch_failed`, `media_too_large` or `unsupported_media_type` as the entry's `reason` | | `payload.caption` | A `caption` on iMessage | | `payload.parts`, `payload.parts[i].url`, `payload.parts[i].text` | A multipart's count or a link twice, at `payload.parts`; a part, at the part | | `payload.emoji`, or the sticker field | A sticker's `emoji` that is not exactly one emoji. Any of a sticker's fields without `kind: "sticker"`, at that field | | `payload.textFormatting`, `payload.textFormatting[i]` | Formatting outside its rules: the list, or the range | | `target.replyToMessageId` | On the recipient path, every reply. On the conversation path, a reply to a message that carries no iMessage id: one the person did not send and whose result carried no `externalId` | | The target field you wrote the address at | On the recipient path, an email address, at `target.recipientExternalId` or whichever of its spellings you used, or at `target.conversationId` when you named a conversation on that path. The recipient path sends to an E.164 **phone number** only | | `target.conversationId`, or the recipient field you wrote | With `reason: conversation_not_confirmed`: a `media` link, a `sticker`, a `link`, a `multipart`, a `location_request` or a `poll` into a conversation on the recipient path (send the person a text first), and a `location_request` into a group chat (send it into a member's own one-to-one conversation instead) | | `target.conversationId` | On either path, a group chat the channel has not reported yet | | `target.lineId` | A line on another channel than `target.channel` names, or not the line a `conversationId` names: a conversation stays on its line | On WhatsApp, a sticker with no `url` or one whose path does not end in `.webp` is refused at `payload.url`, and a sticker's `emoji`, `attachToMessageExternalId`, `partIndex`, `placement` or `caption` at that key. On the recipient path the line refuses a text that is blank or over 16,384 bytes after Mapier has recorded the send, with `invalid_text` as the entry's `reason`. Send the fixed text under a new key. - `413 payload_too_large` when the body is over 65,536 bytes, before the text limit is checked. - `404 unsupported_command` with `reason: not_on_channel` for a kind the line's channel does not carry. On WhatsApp that is a `multipart`, `location_request` or `poll`. - `403 recipient_not_allowed` when the person opted out, is blocked or paused, or a channel's service window has closed. `details.reason` says which: `opted_out`, `blocked`, `paused` or `outside_service_window`. On WhatsApp, outside 24 hours of the person's last message, send a template first, a `message.send` with `kind: "template"`. - `403 line_not_allowed` when `target.lineId` is not one of your project's lines (another project's, or nobody's; the API does not say which). `details.reason` is `not_owned` and `details.lineId` the id you sent. [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists the lines the key can use. - `503 capacity_exhausted` or `503 line_unavailable` about the line you named, when it is full, paused, retired or its connection is down: the same codes a send to that line meets, with an error `message` about that line rather than about every line in the project. - `409 conflict` when the `Idempotency-Key` is taken and there is nothing to adopt. `details.reason` says how: `idempotency_key_in_flight` (the first send is still running), `idempotency_key_failed` (it was refused), `idempotency_key_unresolved` (its outcome is unknown) or `idempotency_key_reused` (another command holds the key). - `503 service_busy` with `retryAfter` when your project, or Mapier, is already sending as many files by link as it can at once — nothing is written, and the same key may be sent again. - `503 upstream_unavailable` when the line did not take the send, or answered with something unusable, or the line is offline. The send was recorded first, so its key is spent: a same-key retry answers `409 conflict`, and a resend goes under a new key. When `details.reason` is `timeout`, `network` or `status_5xx`, check the conversation first, since the send may have landed. - On an iMessage line the line's own reasons for refusing a send, such as `invalid_text`, reach you as `details.reason` (or a `422` entry's `reason`) under the published code, never as the `code`. ## Guide [#guide] [Pick what to send](https://docs.mapier.ai/convo/guides/send/pick-what-to-send) # Unsend a message (https://docs.mapier.ai/convo/api/messages/unsend) > Take back a message your line sent, within 2 minutes **POST** `/v1/commands/message.unsend` _Works on iMessage_ Takes back a message this line sent. The person sees it gone from the conversation, marked **Unsent**. An unsend is allowed within **2 minutes** of the message being sent. Honors `Idempotency-Key`. Mapier keeps the message: reading the conversation back still returns it, with the text that was sent. ## Body [#body] ### Target [#target] The same as [`message.edit`](https://docs.mapier.ai/convo/api/messages/edit#target): name the message at `target.messageId` by the `messageId` its send's `command` event carried, in the conversation at `target.conversationId`. | Field | Type | Required | Description | | --- | --- | --- | --- | | `conversationId` | string (uuid) | Yes | The conversation the message is in. A group's is allowed. | | `messageId` | string (uuid) | Yes | Mapier's id for a message this line sent, the `messageId` its send's `command` event carried, never the channel's `externalId`. | | `lineId` | string (uuid) | No | The line to act from, as `GET /v1/whoami` lists it. Optional | ### Payload [#payload] None. Send `{}` or leave `payload` out. Any key is `422 validation_failed` at `payload.`, a `payload.text` included: new text is an edit. ## What is refused before anything is sent [#what-is-refused-before-anything-is-sent] Each is `422 validation_failed` at `target.messageId`, and nothing reaches the line: | `reason` | When | | --------------------- | --------------------------------------------------------------------------------- | | `invalid_target` | The message is not in that conversation, or was not sent from this line | | `not_yet_addressable` | The channel has not given the message an id: it is still being sent, or it failed | | `window_elapsed` | More than 2 minutes have passed since the message was sent | The line checks the window again from the message's own time, so an unsend let through seconds before the window closes may still finish `failed` with `stale_target`. While the line's sending is paused an unsend is refused at once, `503 upstream_unavailable` with `reason: outbound_paused`, rather than held past its window. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/message.unsend \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: unsend-0192a7c4" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001", "messageId": "0192a7c4-5a31-7bd2-8e6f-1d0c9b8a7f65" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; async function unsendMessage(conversationId: string, messageId: string) { const res = await fetch(`${BASE}/v1/commands/message.unsend`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": `unsend-${messageId}`, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId, messageId } }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-2b5d-7e31-9f62-4d8a0b3c7e21", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then a `command` event, `type: "message.unsend"`: - `succeeded` once the line confirmed the change. - `failed` with `stale_target` when the line no longer finds the message inside its window. An unsend that already worked, sent again under a new key, ends this way too: the message is no longer there to take back. - `failed` with `invalid_target`. - `ambiguous` with `errorCode: "moderation_unverified"` when the line could not prove what happened. The message may or may not be gone. Ask the person, or check the conversation on a device in it, before you send anything else about it. Do not wait for a later result: none may follow. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.messageId` or `payload.`, [above](#what-is-refused-before-anything-is-sent). - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. - `503 upstream_unavailable` with `reason: outbound_paused` while the line's sending is paused. Result codes you will see for this command: `stale_target`, `invalid_target`, `moderation_unverified`. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Edit a message](https://docs.mapier.ai/convo/api/messages/edit) - [Edit and unsend](https://docs.mapier.ai/convo/guides/send/edit-and-unsend) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Update an app card (https://docs.mapier.ai/convo/api/messages/update-app-card) > Replace an iMessage app card your line sent with a new state, in place **POST** `/v1/commands/app_card.update` _Works on iMessage_ Replaces a card your line sent from your iMessage app with a new `url`, caption and subcaption. The person's phone keeps one card and draws the newest state; no second card appears. Your organization must be offered app cards and hold the app; see [App cards](https://docs.mapier.ai/convo/guides/send/app-cards). Name the card by `target.messageId`: the first card, any update of it, or a card the person sent that replaced it (a received card whose `appCard.updates` is set). Each of them leads to the same first card, which is the one Messages updates. The app cannot change, and an update is never a reply. An update keeps the picture its card was sent with: `payload.layout.image` is a `422`. An update is a new message to Messages, not a quiet edit: each person's phone shows a new notification for it, with the caption and the full `url`. Put nothing private in either, and do not update a card more often than a person would want to be alerted. Honors `Idempotency-Key`: a repeated key adopts the first update and never sends again. ## Body [#body] ### Target [#target] - target.messageId: string (UUID) — The card to update: the messageId of your first card, of any update of it, or of a card the person sent that replaced it. Nothing else may sit beside it in the target. ### Payload [#payload] - url: string (1 to 4096 characters; https, http or data) — The card's new state, which your app's extension reads. Shown in full in the notification, so it carries nothing private. - layout.caption: string (1 to 4096 characters) — The card's first line, and the notification's text. - layout.subcaption?: string (1 to 4096 characters) — The card's second line. - interactive?: boolean — Whether your app draws the card itself on a phone that has it. Left out, the card keeps its last value. - summary?: string (1 to 4096 characters) — Accepted and sent, but where Messages shows it is not promised: in our tests it did not show for an update. ## What is refused before anything is sent [#what-is-refused-before-anything-is-sent] | Answer | When | | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `404 unsupported_command`, `reason: not_on_channel` | Your organization is not offered app cards, whether or not the message exists, or the line is not iMessage | | `404 not_found` | `target.messageId` is not a message this project holds, or not a card | | `409 conflict`, `reason: card_update_in_flight` | The card's first send or its latest update has not finished. Wait for its `command` event, then send the update again | | `422 validation_failed`, `reason: card_not_updatable` | At `target.messageId`: the first card failed or was never confirmed, Messages gave it no id, the person started it, its app was disabled, or the conversation is now on another line. Send a new card | | `422 validation_failed` | At the field that is wrong: a key beside `target.messageId` in the target, or a payload field that is missing, out of bounds or not one of those above | | `403 recipient_not_allowed`, `recipient_must_write_first` | Nobody but your line has written in the conversation. On a test line on a shared number, also: the person has not texted the line, is no longer connected, or has left 20 turns or 100 messages unanswered since they last texted | | `429 rate_limited`, `reason: card_update_limit` | The card has had 50 updates in the past hour. Wait `details.retryAfter` seconds, then send the update again under the same `Idempotency-Key` | | `429 rate_limited`, `reason: shared_line` | On a test line on a shared number, its budget for your project is spent for now. An update is counted as any message is | | `403 recipient_not_allowed`, `app_card_needs_imessage` | The newest message in the conversation did not go by iMessage, or none has been seen | Opt-out, a paused line and rate limits apply as they do on a send. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/app_card.update \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: game-7f3a-move-2" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "messageId": "0192b3e2-3c6e-7f42-a073-5e9b1c4d8f32" }, "payload": { "url": "https://games.example.com/card?game=7f3a&move=2", "layout": { "caption": "Your move", "subcaption": "Tic-tac-toe" } } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; async function updateCard(messageId: string, url: string, caption: string, key: string) { const res = await fetch(`${BASE}/v1/commands/app_card.update`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": key, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { messageId }, payload: { url, layout: { caption } }, }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-4d7f-7a10-8b21-6c0d2e3f4a5b", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then a `command` event, `type: "app_card.update"`, with the update's own `messageId`: - `succeeded` with `appCard.updatable: true` once your line handed the update to Messages. It does not mean the person's phone drew it. - `failed` on a line whose Mac cannot update cards. `/check` cannot see that beforehand: the update is accepted, settles `failed`, and never becomes a new card. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command, the refusals [above](#what-is-refused-before-anything-is-sent). ## Guide [#guide] - [App cards](https://docs.mapier.ai/convo/guides/send/app-cards) - [Stream events › Event: command](https://docs.mapier.ai/convo/api/events/stream#event-command) # Vote in a poll (https://docs.mapier.ai/convo/api/messages/vote-in-poll) > Vote for a choice in a poll, by the ids its poll event carried **POST** `/v1/commands/poll.vote` _Works on iMessage_ Votes for one choice of a poll in a conversation on an iMessage line: a poll the line sent or one a person sent. Name the poll and the choice by the ids the poll's `poll.created` event carried, on a stream opened with `?events=polls`: a choice's id arrives nowhere else. See the [`poll` event](https://docs.mapier.ai/convo/api/events/stream#event-poll). A vote **adds** its choice to the line's selection, because an iMessage poll lets each person pick several. Voting for another choice does not take the first one back: vote for Ramen, then for Pho, and the line holds both. Taking the line's vote back is not supported. Honors `Idempotency-Key`. ## Body [#body] ### Target [#target] - target.conversationId: string (UUID) — The conversation the poll is in: the conversationId its poll.created carried. A group's is allowed. A message must have arrived in it. ### Payload [#payload] - pollExternalId: string — The poll: the pollExternalId its poll.created carried. Pass it back exactly as given. - optionExternalId: string — The choice: one of the poll's options[].optionExternalId, from its poll.created or, after a choice was added, its latest poll.options_changed. Opaque: pass it back exactly as given. ## What is refused before anything is sent [#what-is-refused-before-anything-is-sent] Each is `422 validation_failed`, and nothing reaches the line: | Field | When | | -------------------------- | ----------------------------------------------------------------- | | `target.conversationId` | No message has arrived in the conversation yet | | `payload.pollExternalId` | Missing, blank, or not shaped like a poll id | | `payload.optionExternalId` | Missing, blank, or not shaped like a choice id | | `payload.remove` | Present at all: taking the line's vote back is not supported | | `payload.` | Any other key — `poll.vote` takes the two ids above and no others | ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/poll.vote \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: lunch-poll-vote-ramen" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "pollExternalId": "2F6B1C3D-8E4A-4B5C-9D7E-0A1B2C3D4E5F", "optionExternalId": "B2C7E9A1-0D3F-4E6A-8B5C-7D9E1F2A3B4C" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; async function vote( conversationId: string, pollExternalId: string, optionExternalId: string, idempotencyKey: string ) { const res = await fetch(`${BASE}/v1/commands/poll.vote`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId }, payload: { pollExternalId, optionExternalId }, }), }); return res.json(); } ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "0192b3e2-3c6e-7f42-a073-5e9b1c4d8f32", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then a `command` event, `type: "poll.vote"`: - `succeeded` once the line voted. A `poll.voted` with `actor: "line"` follows on a stream opened with `?events=polls`, carrying the line's whole selection in `selectedOptionExternalIds`. - `failed` with `stale_target` when the poll is not among the conversation's 30 newest messages, or with `failureClass: capability` (and a capability `errorCode`) on a line that cannot vote. - `ambiguous` with `errorCode: "poll_vote_unverified"` when the line could not prove the vote. ```json title="poll.voted, after voting for Ramen and then for Pho" { "type": "poll.voted", "conversationId": "a0000000-0000-4000-8000-000000000001", "actor": "line", "contactId": null, "pollExternalId": "2F6B1C3D-8E4A-4B5C-9D7E-0A1B2C3D4E5F", "selectedOptionExternalIds": [ "B2C7E9A1-0D3F-4E6A-8B5C-7D9E1F2A3B4C", "C3D8F0B2-1E4A-4F7B-9C6D-8E0F2A3B4C5D" ], "occurredAt": "2026-10-01T18:12:09.000Z", "simulated": false } ``` The vote may or may not have been made. Wait for the poll's next `poll.voted` with `actor: "line"` — its `selectedOptionExternalIds` is what the line holds — before voting again. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: - `422 validation_failed` at `target.conversationId`, `payload.pollExternalId`, `payload.optionExternalId`, `payload.remove` or `payload.`, [above](#what-is-refused-before-anything-is-sent). - `404 unsupported_command` with `reason: not_on_channel` on a line of any other channel. Result codes you will see for this command: `stale_target`, `poll_vote_unverified`, and a capability code on a line that cannot vote. See [Error codes](https://docs.mapier.ai/convo/api/errors). ## Guide [#guide] - [Stream events › Event: poll](https://docs.mapier.ai/convo/api/events/stream#event-poll) - [Polls](https://docs.mapier.ai/convo/guides/send/polls) # Read a project (https://docs.mapier.ai/convo/api/organization/get-project) > One project a personal access token reaches **GET** `/v1/projects/{projectId}` One project this personal access token reaches, by the `id` [`GET /v1/projects`](https://docs.mapier.ai/convo/api/organization/list-projects) lists. A project it does not reach (another organization's, one you cannot open, or one a token made for chosen projects was not made for) is a `404`, the same answer an id that never existed gets. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/projects/0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "id": "0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b", "slug": "support-bot", "name": "Support bot", "description": null, "archivedAt": null, "createdAt": "2026-09-02T14:05:00.000Z" } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [List projects](https://docs.mapier.ai/convo/api/organization/list-projects) # List audit log entries (https://docs.mapier.ai/convo/api/organization/list-audit-logs) > Your organization's audit log, newest first **GET** `/v1/audit-logs` Your organization's audit log, newest first: who did what, to what, and when. It needs the `audit:read` scope on the token and an admin's role now. A token whose owner stopped being an admin gets a `403 forbidden` with `reason: "role"` until they are one again. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only. ## Query [#query] | Parameter | Means | | ------------- | -------------------------------------------------------------------------------------------------------- | | `action` | Only these actions, comma-separated: `project.created,personal_token.revoked`. An unknown one is a `422` | | `actorUserId` | Only what this person did: a `userId` as [`GET /v1/members`](https://docs.mapier.ai/convo/api/organization/list-members) lists | | `cursor` | The `nextCursor` of the page before, for the next, older page. Leave it out for the newest page | | `limit` | How many entries a page holds, 1 to 100. 25 when left out | Pass each answer's `nextCursor` back until it is null. ## Example request [#example-request] ```bash curl "https://api.mapier.ai/v1/audit-logs?action=project.created&limit=50" \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "auditLogs": [ { "id": "0192a7e1-2b3c-7d4e-9f50-6b7c8d9e0f1a", "action": "project.created", "actor": { "userId": "0192a7e0-1a2b-7c3d-8e4f-5a6b7c8d9e0f", "name": "Ada Lovelace", "apiKeyId": null, "personalTokenId": null }, "targetType": "project", "targetId": "support-bot", "metadata": {}, "createdAt": "2026-09-02T14:05:00.000Z" } ], "nextCursor": null } ``` `actor` says who did it: `userId` is null when nobody signed in did, `apiKeyId` names a project key that did, and `personalTokenId` the personal access token a person used. `metadata` is what the action recorded about itself. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [List members](https://docs.mapier.ai/convo/api/organization/list-members) # List members (https://docs.mapier.ai/convo/api/organization/list-members) > Everyone in your organization, and their role now **GET** `/v1/members` Everyone in your organization and their role in it now, `member`, `developer` or `admin`, earliest to join first, in one list. It needs the `members:read` scope, which reads the whole organization, so only a token made for all projects can carry it. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/members \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "members": [ { "userId": "0192a7e0-1a2b-7c3d-8e4f-5a6b7c8d9e0f", "email": "ada@example.com", "name": "Ada Lovelace", "role": "admin", "joinedAt": "2026-09-01T10:00:00.000Z" } ] } ``` `name` is null when the person's profile has none. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [List audit log entries](https://docs.mapier.ai/convo/api/organization/list-audit-logs) # List projects (https://docs.mapier.ai/convo/api/organization/list-projects) > The projects of your organization a personal access token reaches **GET** `/v1/projects` The projects of your organization this personal access token reaches, oldest first: the ones it was made for that you can still open, or, for a token made for all projects, every project you can open now. Each `id` is what the `x-mapier-project` header takes on a call about one project. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only. A project API key gets a `403 forbidden` with `reason: "personal_token_required"`. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/projects \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "projects": [ { "id": "0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b", "slug": "support-bot", "name": "Support bot", "description": null, "archivedAt": null, "createdAt": "2026-09-02T14:05:00.000Z" } ] } ``` `archivedAt` is set when the project is archived; an archived project's keys stop working until it is restored. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Read a project](https://docs.mapier.ai/convo/api/organization/get-project) - [Authentication](https://docs.mapier.ai/convo/guides/get-started/authentication) # Get a contact (https://docs.mapier.ai/convo/api/people/get-contact) > One address of one person, on one channel **GET** `/v1/contacts/{contactId}` One address of one person, on one channel: the `contactId` every `message` event carries. `optedOut` applies to the person on every channel, not to this address alone. `personId` leads to the person and their other addresses. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/contacts/0192a7c0-2222-7333-8444-555566667777 \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "id": "0192a7c0-2222-7333-8444-555566667777", "channel": "imessage", "address": "+14155550100", "addressKind": "e164", "displayName": "Ada", "personId": "0192a7c0-1111-7222-8333-444455556666", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "optedOut": false, "firstSeenAt": "2026-10-01T09:12:00.000Z", "lastInboundAt": "2026-10-18T17:55:00.000Z", "lastOutboundAt": "2026-10-18T17:56:10.000Z" } ``` A contact in another project is a `404`, the same answer as an id that never existed. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | A contact this key cannot see, or none | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send) - [Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out) # Get a person (https://docs.mapier.ai/convo/api/people/get-person) > The person behind one or more contacts, with each address and whether each line can write to them now **GET** `/v1/people/{personId}` The person behind one or more contacts — the same human on two channels, say — with each address and, for each of your active lines on its channel, whether that line can write to them now and why not. A phone number or an email links contacts to one person automatically; any other link is made in the console. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/people/0192a7c0-1111-7222-8333-444455556666 \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "id": "0192a7c0-1111-7222-8333-444455556666", "displayName": "Ada", "optedOut": false, "optedOutAt": null, "contacts": [ { "id": "0192a7c0-2222-7333-8444-555566667777", "channel": "imessage", "address": "+14155550100", "addressKind": "e164", "reachability": [ { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "canSend": { "freeform": true, "template": null }, "reasons": [] } ] } ] } ``` Each `reachability` entry is the short form of [`GET /v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability) for one line: `canSend` and the `reasons` that stand, each with its `docUrl`. A person since merged into another answers as that one, with the id you asked for in `mergedFrom`. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | -------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | With a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:read` scope | | `404` | `not_found` | A person this key cannot see, or none | | `409` | `project_archived` | The project is archived | | `422` | `validation_failed` | An `x-mapier-version` the API does not support | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send) - [Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out) # Opt out a contact (https://docs.mapier.ai/convo/api/people/opt-out-contact) > Record that a person asked you to stop, so every later message to them is refused **POST** `/v1/contacts/{contactId}/consent` Records that a person asked you to stop, when they said so in words a keyword cannot catch — and on a channel with no keyword opt-out, this is the only way. It covers the person on every channel: every later message to any of their contacts is refused `403 recipient_not_allowed` (`opted_out`), and `contact.opt_out_changed` fires with `source: api`. The guide is [Opt-out and consent](https://docs.mapier.ai/convo/guides/production/opt-out). ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/contacts/0192a7c0-2222-7333-8444-555566667777/consent \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: optout-0192a7c0-2222-7333-8444-555566667777" \ -H "x-mapier-version: 2026-12-01" \ -d '{"optedOut": true, "reason": "Asked in chat to stop messaging"}' ``` ## Response [#response] ```json title="200 OK" { "contactId": "0192a7c0-2222-7333-8444-555566667777", "personId": "0192a7c0-1111-7222-8333-444455556666", "optedOut": true, "scope": "person", "optedOutAt": "2026-10-18T18:04:00.000Z", "source": "api" } ``` ## Body [#body] | Field | | | ---------- | --------------------------------------------------------------------------- | | `optedOut` | Required, and `true`. `false` is refused: only the person opts back in. | | `reason` | Required. Why, in your words, at most 500 characters. Kept with the record. | Calling it again for someone already opted out changes nothing and answers with the first opt-out's `optedOutAt`. `Idempotency-Key` is optional; a request without one is answered `x-mapier-idempotency: none`. ## Errors [#errors] | Status | Code | Cause | | ------ | ---------------------- | --------------------------------------------------------------------------------------------------------- | | `400` | `bad_request` | The body is not JSON; or, with a personal access token, no `x-mapier-project` header | | `401` | `invalid_credentials` | No key, or one that is unknown, revoked or expired | | `403` | `forbidden` | A personal access token not made for this environment, or whose owner's role no longer allows this | | `403` | `insufficient_scope` | The key does not carry the `messages:send` scope | | `404` | `not_found` | A contact this key cannot see, or none | | `409` | `project_archived` | The project is archived | | `413` | `payload_too_large` | The body is over 65,536 bytes | | `422` | `validation_failed` | A body this call does not take — `optedOut: false`, a missing `reason` — or an unknown `x-mapier-version` | | `429` | `rate_limited` | Over this route's [budget](https://docs.mapier.ai/convo/api/rate-limits); the `Retry-After` header says how long to wait | | `500` | `internal_error` | Mapier failed on its side; give `requestId` to support | | `503` | `service_busy` | Mapier is busy and did nothing; wait `details.retryAfter` seconds and call again | | `503` | `upstream_unavailable` | Mapier could not answer right now; retry with backoff | ## Guide [#guide] - [Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out) # Rate limits (https://docs.mapier.ai/convo/api/rate-limits) > Requests per minute, and streams open at once ## Limits [#limits] | Request | Limit | Counted per | | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | --------------- | | `POST /v1/commands/{type}`, its `/check`, `GET /v1/commands/{commandId}` | 600 a minute | Project | | [`GET /v1/response_stream`](https://docs.mapier.ai/convo/api/events/stream) | 10 connects a minute, 4 open at once | Key | | Every `/v1/line-setups` route | 30 a minute | Key | | [`GET /v1/lines/{lineId}/templates`](https://docs.mapier.ai/convo/api/lines/list-templates) | 30 a minute | Key | | [`GET /v1/messages/{messageId}/receipts`](https://docs.mapier.ai/convo/api/messages/receipts) | 60 a minute | Key | | [`GET /v1/lines/{lineId}/health`](https://docs.mapier.ai/convo/api/lines/get-line-health), `GET /v1/lines/{lineId}/reputation` | 60 a minute | Key | | `GET /v1/conversations`, `GET /v1/conversations/{conversationId}` and its `/messages` | 120 a minute | Key | | `POST /v1/conversation-lookup` | 30 a minute | Key | | [`GET /v1/events`](https://docs.mapier.ai/convo/api/events/list) | 120 a minute | Key | | [`GET /v1/attachments/{id}`](https://docs.mapier.ai/convo/api/messages/download-attachment) | 120 a minute | Key | | `/v1/people/…`, `/v1/contacts/…` | 120 a minute | Key | | [`GET /v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability), [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities) | 120 a minute | Key | | `POST /v1/handle-check`, `GET /v1/reachability?registered=true` | 30 a minute | Key | | [`GET /v1/lines/available`](https://docs.mapier.ai/convo/api/lines/get-next-line) | 120 a minute | Key | | [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) | No separate budget | Key | | [`GET /v1/projects`](https://docs.mapier.ai/convo/api/organization/list-projects), `GET /v1/projects/{projectId}`, `GET /v1/members`, `GET /v1/audit-logs` | 120 a minute | Person | | Every `/v1/webhook-endpoints` route | 60 a minute | Person | | [`POST /v1/personal-tokens/current/revoke`](https://docs.mapier.ai/convo/api/sign-in/revoke-token) | 10 a minute | Person | | [`POST /v1/cli/logins`](https://docs.mapier.ai/convo/api/sign-in/start-login) | 10 a minute | Calling address | | [`POST /v1/cli/logins/token`](https://docs.mapier.ai/convo/api/sign-in/poll-login) | 120 a minute | Calling address | | [`POST /v1/cli/tokens/renew`](https://docs.mapier.ai/convo/api/sign-in/renew) | 60 a minute | Calling address | | [`POST /v1/cli/tokens/revoke`](https://docs.mapier.ai/convo/api/sign-in/sign-out) | 10 a minute | Calling address | | Any request with a wrong key | A budget of its own | Calling address | Routes on one row share one budget. A row counted per person is spent by every [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) of one person together. The sign-in rows are counted per calling address, because the caller holds no credential yet. [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) shows your project's limit in `limits.commandsPerMinute`. To raise it, write to [support@mapier.ai](mailto:support@mapier.ai). ## Over a limit [#over-a-limit] You get [`429 rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited). Wait the number of seconds in the `Retry-After` header, then send the same request. ```http title="429 Too Many Requests" retry-after: 12 { "error": { "code": "rate_limited", "message": "Too many requests. Try again in a moment.", "details": {}, "requestId": "0192c4e1-7a2b-7c3d-8e4f-5a6b7c8d9e0f", "docUrl": "https://docs.mapier.ai/convo/api/errors/rate_limited", "retryable": true } } ``` A send can also get `429` with `details.reason: "error_budget"` when the channel refused many recent sends from this line. Wait `details.retryAfter` seconds, then send again. # Add a reaction (https://docs.mapier.ai/convo/api/reactions/add) > React to a message with one emoji **POST** `/v1/commands/reaction.set` _Works on iMessage, WhatsApp_ Reacts to a message with one emoji, with one request shape on every channel that carries reactions. Honors `Idempotency-Key`. ## Body [#body] ### Target [#target] A conversation target: the conversation the message is in, at `target.conversationId`. A reaction addressed by a phone number or another address instead is `422 validation_failed` at `target.conversationId` before anything is sent. The target may also name the message itself at `target.messageId`, by the `messageId` Mapier gave it, in place of `payload.targetExternalId`. ### Payload [#payload] | Field | Type | Required | Description | | --- | --- | --- | --- | | `targetExternalId` | string | No | The message: the `externalId` its message event carried, or, for a message the person sent, its `messageId`. Or name it at `target.messageId` by that `messageId` instead. | | `emoji` | string, 1 to 140 characters | Yes | One emoji character. A channel whose reactions are names takes its own name here too; its page lists it under Limits. | The message is named at `payload.targetExternalId`, or at `target.messageId` by its `messageId`, and the reaction at `payload.emoji`. On an iMessage line each is a `422 validation_failed` before anything is sent: at `payload.emoji` for a missing emoji or one that is not one emoji, and at `payload.` for any other field. A channel's own limits on reactions are in [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities), under that channel's `restrictions`, with what a call that breaks one answers. ## On a WhatsApp line [#on-a-whatsapp-line] WhatsApp keeps one reaction per person per message, so a second `reaction.set` on a message the line already reacted to replaces the first. Name the message by the `externalId` its `message` event carried. A reaction is refused outside 24 hours of the person's last message, with [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) and `reason: outside_service_window`, before anything is sent. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/reaction.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: react-order-2481-thumbs" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "targetExternalId": "5D1B7E0A-2F3C-4B8E-9A61-1C2D3E4F5A6B", "emoji": "👍" } }' ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then the `command` event on the [stream](https://docs.mapier.ai/convo/api/events/stream) gives the result. On a channel that does not carry the type, the request is [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) with `reason: not_on_channel`, before anything is queued. `reaction.tapback` is deprecated. Use `reaction.set`. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: the `422`s above, before anything is sent, and the result `failed` with `stale_target` when the line cannot find the message. ## Guide [#guide] - [Reactions](https://docs.mapier.ai/convo/guides/send/reactions) # Remove a reaction (https://docs.mapier.ai/convo/api/reactions/remove) > Take back a reaction your line added **POST** `/v1/commands/reaction.remove` _Works on iMessage, WhatsApp_ Takes back a reaction your line added to a message. On iMessage, name it by the same emoji you reacted with. On WhatsApp the line has one reaction per message, so a remove names no emoji. Honors `Idempotency-Key`. ## Body [#body] ### Target [#target] A conversation target: the conversation the message is in, at `target.conversationId`. A reaction addressed by a phone number or another address instead is `422 validation_failed` at `target.conversationId` before anything is sent. The target may also name the message itself at `target.messageId`, by the `messageId` Mapier gave it, in place of `payload.targetExternalId`. ### Payload [#payload] | Field | Type | Required | Description | | --- | --- | --- | --- | | `targetExternalId` | string | No | The message: the `externalId` its message event carried, or, for a message the person sent, its `messageId`. Or name it at `target.messageId` by that `messageId` instead. | | `emoji` | string, 1 to 140 characters | No | The reaction to take off, by the emoji you reacted with. An iMessage line needs it. A line that keeps one reaction per message takes that one off and refuses an emoji. | The message is named at `payload.targetExternalId`, or at `target.messageId` by its `messageId`, and, on iMessage, the reaction at `payload.emoji`. On an iMessage line each is a `422 validation_failed` before anything is sent: at `payload.emoji` for a missing emoji or one that is not one emoji, and at `payload.` for any other field. A channel's own limits on reactions are in [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities), under that channel's `restrictions`, with what a call that breaks one answers. On a WhatsApp line, name the message by the `externalId` its `message` event carried, and send no `emoji`. A remove is refused outside 24 hours of the person's last message, with [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed), like a reaction. ## Example request [#example-request] ```bash tab="cURL" curl https://api.mapier.ai/v1/commands/reaction.remove \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: unreact-order-2481-thumbs" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "targetExternalId": "5D1B7E0A-2F3C-4B8E-9A61-1C2D3E4F5A6B", "emoji": "👍" } }' ``` ## Response [#response] ```json title="202 Accepted" { "commandId": "3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat" } ``` Then the `command` event on the [stream](https://docs.mapier.ai/convo/api/events/stream) gives the result. On a channel that does not carry the type, the request is [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command) with `reason: not_on_channel`, before anything is queued. ## Errors [#errors] Every command can return the errors listed under [How commands work › Errors](https://docs.mapier.ai/convo/api/commands#errors). Specific to this command: the `422`s above, before anything is sent, and the result `failed` with `stale_target` when the line cannot find the message. ## Guide [#guide] - [Reactions](https://docs.mapier.ai/convo/guides/send/reactions) # Poll a sign-in from a terminal (https://docs.mapier.ai/convo/api/sign-in/poll-login) > Where a sign-in stands, and its tokens once it is approved **POST** `/v1/cli/logins/token` Where a sign-in [started from a terminal](https://docs.mapier.ai/convo/api/sign-in/start-login) stands, by its `deviceCode`. It takes no credential and reads no `x-mapier-version`. An unknown device code is a `404`. | `status` | Means | | ----------- | ----------------------------------------------------------- | | `pending` | Nobody has approved or denied it yet. Poll after `interval` | | `slow_down` | You polled too soon; `interval` has grown. Wait it out | | `denied` | The person denied it. Start again | | `expired` | Ten minutes passed before the tokens were handed over | | `used` | Its tokens were already handed over. Start again | | `approved` | Approved: this answer carries the tokens | `approved` is answered once, to the first poll after the approval, and carries two tokens. `accessToken` is a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) to send as the bearer, which lasts an hour. `refreshToken` is never a bearer: exchange it at [`POST /v1/cli/tokens/renew`](https://docs.mapier.ai/convo/api/sign-in/renew) for a new pair. Store both now; no request returns either again. The sign-in carries every scope the person's role allowed when they approved, every project, `live`, and ends 60 days later however often it renews. A person who already holds ten active tokens in that organization gets a `409 limit_reached`: once they revoke one, the next poll succeeds while the login lasts. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/cli/logins/token \ -H "Content-Type: application/json" \ -d '{ "deviceCode": "mp_cli_example-not-a-real-device-code" }' ``` ## Response [#response] ```json title="200 OK — before anyone approves" { "status": "pending", "interval": 5 } ``` ```json title="200 OK — approved, once" { "status": "approved", "accessToken": "mp_pat_example-not-a-real-token", "accessTokenExpiresAt": "2026-09-02T15:12:00.000Z", "refreshToken": "mp_refresh_example-not-a-real-token", "refreshTokenExpiresAt": "2026-11-01T14:12:00.000Z", "tokenId": "0192a7f3-6f70-7182-9d93-0f1a2b3c4d5e", "organization": { "id": "0192a7a0-0b1c-7d2e-8f3a-4b5c6d7e8f90", "slug": "acme", "name": "Acme" }, "role": "developer", "scopes": ["projects:read", "projects:write", "messages:read", "messages:send"] } ``` `role` is the role its owner holds in the organization now; the token never does more. `tokenId` is the sign-in as the console lists it, the same across renewals. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`limit_reached`](https://docs.mapier.ai/convo/api/errors/limit_reached) | | A limit is reached: a test line's daily cap, or the dedicated lines your organization pays for. | All | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | | The body is over 65,536 bytes. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Renew a sign-in](https://docs.mapier.ai/convo/api/sign-in/renew) # Renew a terminal sign-in (https://docs.mapier.ai/convo/api/sign-in/renew) > Exchange the newest refresh token for a new pair **POST** `/v1/cli/tokens/renew` Exchanges the newest `refreshToken` for a new pair: a new access token for the next hour, and a new refresh token that replaces the one sent. There is no bearer: the refresh token is in the body, and the route reads no `x-mapier-version`. Renew before the access token expires. An access token already issued keeps working until its own expiry, so a call or a stream holding it is not cut off. Keep only the newest refresh token. One already replaced, sent again, ends the whole sign-in, unless it comes within 30 seconds of its replacement: then it is only refused, so two processes renewing at once cost one of them a retry with the pair the other stored. Renewing never widens the sign-in's scopes, and never moves `refreshTokenExpiresAt`, when the sign-in ends. Every refusal is the same `401`, whatever its reason: an unknown, replaced or expired refresh token, a revoked sign-in, or one whose owner left the organization. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/cli/tokens/renew \ -H "Content-Type: application/json" \ -d '{ "refreshToken": "mp_refresh_example-not-a-real-token" }' ``` ## Response [#response] ```json title="200 OK" { "accessToken": "mp_pat_example-not-a-real-token-2", "accessTokenExpiresAt": "2026-09-02T16:10:00.000Z", "refreshToken": "mp_refresh_example-not-a-real-token-2", "refreshTokenExpiresAt": "2026-11-01T14:12:00.000Z", "tokenId": "0192a7f3-6f70-7182-9d93-0f1a2b3c4d5e" } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | | The body is over 65,536 bytes. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Sign out with a refresh token](https://docs.mapier.ai/convo/api/sign-in/sign-out) # Sign out: revoke this token (https://docs.mapier.ai/convo/api/sign-in/revoke-token) > Revoke the personal access token that makes the call **POST** `/v1/personal-tokens/current/revoke` Revokes the personal access token that makes the call, at once. For a terminal sign-in it ends the sign-in, its refresh token with it; with only a refresh token left, [`POST /v1/cli/tokens/revoke`](https://docs.mapier.ai/convo/api/sign-in/sign-out) does the same. Any live token may call it, with no scope, and it is recorded as revoked by its owner. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only. A project API key gets a `403 forbidden` with `reason: "personal_token_required"`. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/personal-tokens/current/revoke \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "tokenId": "0192a7f3-6f70-7182-9d93-0f1a2b3c4d5e", "revokedAt": "2026-09-03T09:00:00.000Z" } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Authentication](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) # Sign out with a refresh token (https://docs.mapier.ai/convo/api/sign-in/sign-out) > End a terminal sign-in, both its tokens at once **POST** `/v1/cli/tokens/revoke` Ends the sign-in a refresh token belongs to, both its tokens at once. Any refresh token the sign-in was answered ends it. There is no bearer, and the route reads no `x-mapier-version`. The answer is always a `204`, for an unknown token too, so it says nothing about the token. Use it once the access token has expired. While the access token is live, [`POST /v1/personal-tokens/current/revoke`](https://docs.mapier.ai/convo/api/sign-in/revoke-token) does the same. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/cli/tokens/revoke \ -H "Content-Type: application/json" \ -d '{ "refreshToken": "mp_refresh_example-not-a-real-token" }' ``` ## Response [#response] `204 No Content`, with no body. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | | The body is over 65,536 bytes. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Sign out: revoke this token](https://docs.mapier.ai/convo/api/sign-in/revoke-token) # Start a sign-in from a terminal (https://docs.mapier.ai/convo/api/sign-in/start-login) > Get a code a person approves in the console; no credential needed **POST** `/v1/cli/logins` Starts a sign-in for a command-line tool. It takes no credential and reads no `x-mapier-version`. Show the person `userCode` and `verificationUrl`, or open `verificationUrlComplete`, which has the code filled in. They sign in to the console, choose an organization and approve. Meanwhile, poll [`POST /v1/cli/logins/token`](https://docs.mapier.ai/convo/api/sign-in/poll-login) with `deviceCode` every `interval` seconds. The login works once, for 10 minutes. Keep `deviceCode` inside the tool and never show it: whoever holds it receives the token once the person approves. ## Body [#body] The body is optional. `deviceName` is what to call this machine: the token is named `CLI on `, or `CLI` without one. It keeps letters, digits, spaces and `. - _ ( ) @ '`, at most 64 characters, and drops anything else. The person approving sees it marked as sent by this request, not checked. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/cli/logins \ -H "Content-Type: application/json" \ -d '{ "deviceName": "build-box" }' ``` ## Response [#response] ```json title="201 Created" { "deviceCode": "mp_cli_example-not-a-real-device-code", "userCode": "KQ7M-2PXD", "verificationUrl": "https://convo.mapier.ai/app/cli", "verificationUrlComplete": "https://convo.mapier.ai/app/cli?code=KQ7M-2PXD", "expiresAt": "2026-09-02T14:20:00.000Z", "expiresIn": 600, "interval": 5 } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | | The body is over 65,536 bytes. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Poll a sign-in](https://docs.mapier.ai/convo/api/sign-in/poll-login) - [Authentication](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) # Versions (https://docs.mapier.ai/convo/api/versions) > The API version header, your project's default, and what each version changes The major version is in the path: `/v1`. A `/v2` would sit beside it rather than replace it. Within `/v1`, behavior that a deployed integration could trip over changes only behind a **dated version**, which you choose with one header: ```http x-mapier-version: 2026-12-01 ``` Every `/v1` route that takes a key or a personal access token reads it. A version is a date. A project defaults to the newest version dated on or before the day its first API key was created, and nothing changes under an integration that keeps sending the same version. ## The versions [#the-versions] | Version | What it changes | | ------------ | ----------------------------------------------------------------------------------------------------------------------------------- | | `2026-09-01` | The oldest. The default of a project whose first key came before `2026-10-01`. | | `2026-10-01` | A command `target` that names no `channel` is resolved from your project's lines rather than meaning iMessage. | | `2026-10-15` | Refusals use channel-neutral words: one code and three `line_unavailable` reasons are renamed. | | `2026-12-01` | A command a line reports it cannot do is refused at once, and an `Idempotency-Key` never sends a command twice. The newest version. | Fields and events are added without a new version, and a new refusal can join a status an operation already documents, so parse defensively, as [the API reference](https://docs.mapier.ai/convo/api#conventions) says. A new version is added only where an integration already deployed would otherwise get a different word for the same answer, or have the same request handled differently. The reference pages describe the newest version, `2026-12-01`. What an older version does differently is under [Older versions](#older-versions). ## When you send no header [#when-you-send-no-header] You get your **project's** default: the newest version dated on or before the day the project's first API key was created, revoked or not. So: - **Rotating a key changes nothing**: every key belongs to the same project, and the project's first key is where the default comes from. - **A project whose first key came after a change has that change without asking.** A new project defaults to whatever is newest on the day of its first key. - **Moving an integration to a new project can change its behavior.** An integration started on a project that already had keys gets that project's older default, and the same integration pointed at a new project gets the new one's. **Pin a version when you start**, and before you point an existing integration at a new project. Pinned, nothing under you moves until you change the header yourself. ## The channel of a target [#the-channel-of-a-target] On [`POST /v1/commands/{type}`](https://docs.mapier.ai/convo/api/commands) a `target` may name the channel it is on, `target.channel`. A target that names none is resolved from your project's lines, in this order: - **Active lines decide first.** When every active line is on one channel, the target means that channel. A paused line on another channel beside active iMessage lines does not make an iMessage send ambiguous. - **With no active line, the lines the project still holds decide**: every status but released, so a paused or provisioning line counts and a released one never does. Held lines on one channel mean that channel, and the send is then answered by that line's state: `503 line_unavailable` with `details.reason: "line_paused"` for a person whose line is paused, and `503 no_line` for a person not yet on any line. - **A project that holds no line at all answers `503 no_line`**, before the recipient's address is read. - **Lines on more than one channel** (active ones, or held ones when none is active) answer `422 validation_failed` at `target.channel`, listing those channels in the entry's `channels`. Name one of them. ```json title="POST /v1/commands/message.send — 422" { "error": { "code": "validation_failed", "message": "This project has lines on more than one channel.", "details": [ { "path": "target.channel", "message": "Name the channel to send on: imessage or whatsapp.", "channels": ["imessage", "whatsapp"] } ] } } ``` Name the channel whenever a target names an address (`"target": { "channel": "imessage", … }`) and this refusal can never reach you, whatever lines the project comes to hold. A conversation target is on its conversation's channel and is never refused this way. No other operation reads a target. ## The operations where nothing differs [#the-operations-where-nothing-differs] [`GET /v1/response_stream`](https://docs.mapier.ai/convo/api/events/stream) and [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) behave the same at every version listed. They read the header all the same, so a value they do not know is refused there too. [`GET /v1/public/channel-availability`](https://docs.mapier.ai/convo/api/discovery/list-channels) takes no key and reads no version. ## A version Mapier does not know [#a-version-mapier-does-not-know] Any other value is `422 validation_failed`, whose entry lists every version Mapier answers to in `supported`: ```json title="x-mapier-version: 2026-13-01 — 422" { "error": { "code": "validation_failed", "message": "That is not an API version Mapier answers to.", "details": [ { "path": "x-mapier-version", "message": "Send one of: 2026-09-01, 2026-10-01, 2026-10-15, 2026-12-01. Omit the header to keep the behavior your integration was written against.", "supported": ["2026-09-01", "2026-10-01", "2026-10-15", "2026-12-01"] } ] } } ``` The [OpenAPI document](https://docs.mapier.ai/convo/api#the-openapi-document) lists the same versions as the header's enum on every operation, with a sentence per operation on what differs. ## Older versions [#older-versions] Everything else in this reference describes `2026-12-01`. An integration pinned to an older version, or a project whose default is older, gets the behavior below instead. Move to the newest version by changing what you handle here, then sending `x-mapier-version: 2026-12-01`. ### Below `2026-12-01` [#below-2026-12-01] These differ on [`POST /v1/commands/{type}`](https://docs.mapier.ai/convo/api/commands) and its `/check`: | Request | Below `2026-12-01` | At `2026-12-01` | | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | | A command the line reports it cannot do | `202`, then the result `failed` with `unsupported_capability` | `404 unsupported_command` with `reason: not_on_line`, at once | | `typing.start` or `conversation.mark_read` the line cannot do | The same `202` that ends `failed` | `404`, or `200` with `skipped: true` when you send `options.ifUnsupported: "skip"` | | A repeated `Idempotency-Key` on `group.create`, `typing.start` or `conversation.mark_read` | On an iMessage line `Idempotency-Key` is **ignored**: the command is sent again, and a retried `group.create` makes a second group | Adopted, as on every other type: the first command is returned and nothing is sent again | | A retry of an attempt that got no answer | On a line that adopts a repeated key, sent again under the same key | `409 conflict` with `reason: idempotency_key_in_flight` while it may still be running, then `idempotency_key_unresolved`; never sent again | The first two rows are the same at every version on an iMessage line. See [Idempotency](https://docs.mapier.ai/convo/guides/production/retries). ### Below `2026-10-15` [#below-2026-10-15] The same refusals, the same statuses and the same remedies; only the word differs. You receive one word of each pair, never both: | Below `2026-10-15` | At `2026-10-15` or later | Where | | -------------------- | ------------------------ | --------------------------------------------- | | `no_line_capacity` | `capacity_exhausted` | the `503` code, on `POST /v1/commands/{type}` | | `relay_down` | `transport_down` | a `503 line_unavailable` reason | | `relay_unconfigured` | `transport_unconfigured` | a `503 line_unavailable` reason | | `line_released` | `line_retired` | a `503 line_unavailable` reason | The code pair is answered by `POST /v1/commands/{type}` alone. The reason pairs are answered wherever `line_unavailable` is: sending a command, [handle check](https://docs.mapier.ai/convo/api/discovery/check-an-address), [attachments](https://docs.mapier.ai/convo/api/messages/download-attachment) and [receipts](https://docs.mapier.ai/convo/api/messages/receipts). A client that switches on both words of each pair works at every version. ### Below `2026-10-01` [#below-2026-10-01] A command `target` that names no `channel` means iMessage, whatever lines the project holds. From `2026-10-01` it is resolved as [The channel of a target](#the-channel-of-a-target) says. ## Guide [#guide] - [Overview](https://docs.mapier.ai/convo/api) - [Errors](https://docs.mapier.ai/convo/api/errors) - [How commands work](https://docs.mapier.ai/convo/api/commands) # Create a webhook endpoint (https://docs.mapier.ai/convo/api/webhook-endpoints/create) > Add an endpoint, and get its signing secret once **POST** `/v1/webhook-endpoints` Adds an endpoint in the call's project and environment, and answers its signing secret, `signingSecret`, in this answer only: no request returns it again, so store it now, and check each delivery's signature with it. It needs the `webhooks:write` scope on the token and the developer or admin role. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only, and works in the project named by `x-mapier-project` and the environment named by `x-mapier-environment` (`live` when not sent). An endpoint of another project or environment is a `404`, the same answer an id that never existed gets. ## Body [#body] | Field | Means | | ------------- | ------------------------------------------------------------------------------------ | | `url` | Where to `POST` each event: `https` in `live`, `http` or `https` in `test`. Required | | `eventTypes` | The event types to send it, at least one. Nothing else reaches it. Required | | `description` | What it is for, up to 500 characters | No URL may carry a username or password or point at a private address. A project holds five endpoints in each environment; a sixth is a `409 limit_reached`. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/webhook-endpoints \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/mapier/webhooks", "description": "Support bot inbox", "eventTypes": ["message.received", "message.failed"] }' ``` ## Response [#response] ```json title="201 Created" { "id": "0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b", "url": "https://example.com/mapier/webhooks", "description": "Support bot inbox", "eventTypes": ["message.received", "message.failed"], "enabled": true, "signingSecretPreview": "whsec_exam", "previousSecretExpiresAt": null, "lastDeliveryAt": null, "lastDeliveryStatus": null, "createdAt": "2026-09-02T14:10:00.000Z", "updatedAt": "2026-09-02T14:10:00.000Z", "signingSecret": "whsec_example-not-a-real-secret" } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`limit_reached`](https://docs.mapier.ai/convo/api/errors/limit_reached) | | A limit is reached: a test line's daily cap, or the dedicated lines your organization pays for. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | | The body is over 65,536 bytes. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events#receive-webhooks), which says how to check a signature - [Rotate a signing secret](https://docs.mapier.ai/convo/api/webhook-endpoints/rotate-secret) # Delete a webhook endpoint (https://docs.mapier.ai/convo/api/webhook-endpoints/delete) > Stop sending to an endpoint and remove it **DELETE** `/v1/webhook-endpoints/{endpointId}` Stops sending to the endpoint and removes it from every list. Its delivery history is kept. Deleting it again is a `404`. It needs the `webhooks:write` scope on the token and the developer or admin role. To stop deliveries and keep the endpoint, [update](https://docs.mapier.ai/convo/api/webhook-endpoints/update) it with `enabled: false` instead. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only, and works in the project named by `x-mapier-project` and the environment named by `x-mapier-environment` (`live` when not sent). An endpoint of another project or environment is a `404`, the same answer an id that never existed gets. ## Example request [#example-request] ```bash curl -X DELETE https://api.mapier.ai/v1/webhook-endpoints/0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] `204 No Content`, with no body. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [List webhook endpoints](https://docs.mapier.ai/convo/api/webhook-endpoints/list) # Read a webhook endpoint (https://docs.mapier.ai/convo/api/webhook-endpoints/get) > One endpoint, without its signing secret **GET** `/v1/webhook-endpoints/{endpointId}` One endpoint, by the `id` [`GET /v1/webhook-endpoints`](https://docs.mapier.ai/convo/api/webhook-endpoints/list) lists, without its signing secret. A deleted one is a `404`. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only, and works in the project named by `x-mapier-project` and the environment named by `x-mapier-environment` (`live` when not sent). An endpoint of another project or environment is a `404`, the same answer an id that never existed gets. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/webhook-endpoints/0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "id": "0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b", "url": "https://example.com/mapier/webhooks", "description": "Support bot inbox", "eventTypes": ["message.received", "message.failed"], "enabled": true, "signingSecretPreview": "whsec_exam", "previousSecretExpiresAt": null, "lastDeliveryAt": null, "lastDeliveryStatus": null, "createdAt": "2026-09-02T14:10:00.000Z", "updatedAt": "2026-09-02T14:10:00.000Z" } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Update a webhook endpoint](https://docs.mapier.ai/convo/api/webhook-endpoints/update) - [List deliveries](https://docs.mapier.ai/convo/api/webhook-endpoints/list-deliveries) # List deliveries (https://docs.mapier.ai/convo/api/webhook-endpoints/list-deliveries) > Every attempt to deliver an event to one endpoint, newest first **GET** `/v1/webhook-endpoints/{endpointId}/deliveries` Every attempt to deliver an event to one endpoint, newest first: one row per attempt, so a retried event shows each try. Page with `cursor`, passing each answer's `nextCursor` back until it is null; `limit` sets how many attempts a page holds, 1 to 100, and 25 when left out. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only, and works in the project named by `x-mapier-project` and the environment named by `x-mapier-environment` (`live` when not sent). An endpoint of another project or environment is a `404`, the same answer an id that never existed gets. ## Example request [#example-request] ```bash curl "https://api.mapier.ai/v1/webhook-endpoints/0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b/deliveries?limit=50" \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "deliveries": [ { "id": "0192a7f1-4d5e-7f60-9b71-8d9e0f1a2b3c", "eventId": "0192a7f2-5e6f-7071-8c82-9e0f1a2b3c4d", "eventType": "message.received", "attempt": 1, "status": "succeeded", "responseStatus": 200, "responseBodySnippet": "ok", "error": null, "scheduledAt": "2026-09-02T14:12:00.000Z", "deliveredAt": "2026-09-02T14:12:00.180Z", "durationMs": 180, "createdAt": "2026-09-02T14:12:00.000Z" } ], "nextCursor": null } ``` `eventId` is the `mapier-event-id` header your receiver saw. `attempt` is 1 for the first try, then 2, 3 and so on for each retry. `responseBodySnippet` is the start of your receiver's answer, at most 1 KiB, and `error` says why an attempt that got no answer failed. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Read a webhook endpoint](https://docs.mapier.ai/convo/api/webhook-endpoints/get) # List webhook endpoints (https://docs.mapier.ai/convo/api/webhook-endpoints/list) > Every webhook endpoint of a project, newest first **GET** `/v1/webhook-endpoints` Every webhook endpoint of the project in the call's environment, newest first. A project holds five at most in each environment, so this is one list. The signing secret is never in it: `signingSecretPreview` is its first ten characters, enough to tell two apart. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only, and works in the project named by `x-mapier-project` and the environment named by `x-mapier-environment` (`live` when not sent). An endpoint of another project or environment is a `404`, the same answer an id that never existed gets. ## Example request [#example-request] ```bash curl https://api.mapier.ai/v1/webhook-endpoints \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "webhookEndpoints": [ { "id": "0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b", "url": "https://example.com/mapier/webhooks", "description": "Support bot inbox", "eventTypes": ["message.received", "message.failed"], "enabled": true, "signingSecretPreview": "whsec_exam", "previousSecretExpiresAt": null, "lastDeliveryAt": null, "lastDeliveryStatus": null, "createdAt": "2026-09-02T14:10:00.000Z", "updatedAt": "2026-09-02T14:10:00.000Z" } ] } ``` `lastDeliveryStatus` is how the last attempt ended: `pending`, `succeeded`, `failed` or `exhausted`, or null before the first. ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Create a webhook endpoint](https://docs.mapier.ai/convo/api/webhook-endpoints/create) - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events#receive-webhooks) # Rotate a signing secret (https://docs.mapier.ai/convo/api/webhook-endpoints/rotate-secret) > Make a new signing secret; the old one works for 24 hours **POST** `/v1/webhook-endpoints/{endpointId}/rotate-secret` Makes a new signing secret and answers it in this answer only. The previous one keeps working for 24 hours: until `previousSecretExpiresAt`, each delivery carries two `v1=` signatures, one per secret, so your receiver can move to the new one at its own pace. It needs the `webhooks:write` scope on the token and the developer or admin role. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only, and works in the project named by `x-mapier-project` and the environment named by `x-mapier-environment` (`live` when not sent). An endpoint of another project or environment is a `404`, the same answer an id that never existed gets. ## Example request [#example-request] ```bash curl -X POST https://api.mapier.ai/v1/webhook-endpoints/0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b/rotate-secret \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" ``` ## Response [#response] ```json title="200 OK" { "signingSecret": "whsec_example-not-a-real-secret", "signingSecretPreview": "whsec_exam", "previousSecretExpiresAt": "2026-09-04T09:00:00.000Z" } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events#receive-webhooks), which says how to check both signatures # Update a webhook endpoint (https://docs.mapier.ai/convo/api/webhook-endpoints/update) > Change an endpoint's URL, description, event types or whether it is on **PATCH** `/v1/webhook-endpoints/{endpointId}` Changes any of `url`, `description`, `eventTypes` and `enabled`, at least one; never the environment. A new URL is held to the endpoint's own environment's rules. `description: null` clears it, and `enabled: false` stops deliveries and keeps the endpoint and its history. It needs the `webhooks:write` scope on the token and the developer or admin role. This route takes a [personal access token](https://docs.mapier.ai/convo/guides/get-started/authentication#personal-access-tokens) only, and works in the project named by `x-mapier-project` and the environment named by `x-mapier-environment` (`live` when not sent). An endpoint of another project or environment is a `404`, the same answer an id that never existed gets. ## Example request [#example-request] ```bash curl -X PATCH https://api.mapier.ai/v1/webhook-endpoints/0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" \ -H "Content-Type: application/json" \ -d '{ "enabled": false }' ``` ## Response [#response] The endpoint, changed. ```json title="200 OK" { "id": "0192a7f0-3c4d-7e5f-8a60-7c8d9e0f1a2b", "url": "https://example.com/mapier/webhooks", "description": "Support bot inbox", "eventTypes": ["message.received", "message.failed"], "enabled": false, "signingSecretPreview": "whsec_exam", "previousSecretExpiresAt": null, "lastDeliveryAt": null, "lastDeliveryStatus": null, "createdAt": "2026-09-02T14:10:00.000Z", "updatedAt": "2026-09-03T09:00:00.000Z" } ``` ## Errors [#errors] | Status | Code | Reason | When | Channels | | --- | --- | --- | --- | --- | | 400 | [`bad_request`](https://docs.mapier.ai/convo/api/errors/bad_request) | | The body is not valid JSON, the channel rejected the request as malformed, or a header the call needs is missing. | All | | 401 | [`invalid_credentials`](https://docs.mapier.ai/convo/api/errors/invalid_credentials) | | The API key or personal access token is missing, malformed, unknown, revoked or expired. | All | | 403 | [`forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) | | The credential may not make this call here. `details.reason` says why. | All | | 403 | [`insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope) | | The key or token does not carry the scope this route needs. | All | | 404 | [`not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | | Nothing with that id exists in this project. | All | | 409 | [`project_archived`](https://docs.mapier.ai/convo/api/errors/project_archived) | | The key's project is archived. | All | | 413 | [`payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | | The body is over 65,536 bytes. | All | | 422 | [`validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | | A field is wrong, and `details` names each one at its `path`. | All | | 429 | [`rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | | Too many requests for this route's budget. | All | | 500 | [`internal_error`](https://docs.mapier.ai/convo/api/errors/internal_error) | | Mapier failed on its side, and has been alerted. | All | | 503 | [`service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | | Mapier is busy and did nothing with this request. `details.retryAfter` says how many seconds to wait. | All | | 503 | [`upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | | The channel did not take the command, or gave no answer Mapier could use. | All | ## Related [#related] - [Delete a webhook endpoint](https://docs.mapier.ai/convo/api/webhook-endpoints/delete) # Build with a coding agent (https://docs.mapier.ai/convo/guides/agents/build-with-a-coding-agent) > Give your coding agent one prompt, and it reads Mapier's skill file and docs for itself Copy this prompt and give it to your coding agent with your task. ```text title="Agent prompt" Read https://docs.mapier.ai/skill.md and follow it while you build this. ``` ## Connect the docs over MCP [#connect-the-docs-over-mcp] The docs are an MCP server at `https://docs.mapier.ai/mcp`. Your agent can search them and read any page as markdown while it works. The server needs no key and no sign-in. It has three tools: | Tool | What it does | | ------------ | ------------------------------------------------------------ | | `search` | Finds the pages that answer a question, with each page's URL | | `get_page` | Reads one page as markdown, by its URL | | `list_pages` | Lists every page, the same list as `llms.txt` | In Claude Code, run: ```bash claude mcp add --transport http mapier-docs https://docs.mapier.ai/mcp ``` In Cursor and other clients that read an `mcp.json`, add: ```json title="mcp.json" { "mcpServers": { "mapier-docs": { "url": "https://docs.mapier.ai/mcp" } } } ``` ## Files for agents [#files-for-agents] None of these need a key or a sign-in. - [`skill.md`](https://docs.mapier.ai/skill.md): the skill. Mapier's rules, the steps to send and receive, and links to the pages an agent needs. - [`llms.txt`](https://docs.mapier.ai/llms.txt): the index of every page. - [`llms-full.txt`](https://docs.mapier.ai/llms-full.txt): every page in one file. - [OpenAPI document](https://api.mapier.ai/openapi.json): every `/v1` request and response. - [`capabilities.json`](https://docs.mapier.ai/capabilities.json): what works on each channel, as data. - [MCP server](#connect-the-docs-over-mcp): search and read the docs from your agent. - Any page as markdown: add `.md` to its address. Every page also has a **Copy Markdown** button and an **Open** menu that opens the page in ChatGPT, Claude or Cursor. The rules your agent follows, such as waiting for each send's result and never sending twice on a retry, are in [`skill.md`](https://docs.mapier.ai/skill.md). # Connect iMessage (https://docs.mapier.ai/convo/guides/connect/imessage) > Get an iMessage number for your AI agent. Ask for a US number that texts over iMessage, in the console or from the API, and Mapier sets it up for you You need a project in the console at [convo.mapier.ai/app](https://convo.mapier.ai/app). No project yet? [Book a call with Mapier](https://cal.com/mapier-homin/30min). ### Request your line [#request-a-line] In the console, open **iMessage** and click **Request line**. Then: 1. Under **How many**, choose 1 to 5 lines. Each new line holds 200 contacts. 2. Under **Why**, choose your reason. For your first line, choose **My first line for this agent**. 3. Click **Request line** at the bottom. It reads **Request 2 lines** and so on when you ask for more. Your request shows **Waiting on us**. You can have one open request at a time. ### Wait for your number [#wait-for-your-number] A person at Mapier reviews every first request and sets up your number. You can leave the page; it updates itself. Meanwhile, read the [Quickstart](https://docs.mapier.ai/convo/guides/get-started/quickstart). ### Open your line [#open-your-line] The request reads **Line added**, and your number is on the iMessage page. The line reads **No traffic yet**, then **Live** after its first message. Text it from your phone to see the first message arrive. ## From the API [#from-the-api] Your code can request a line with [`POST /v1/line-setups`](https://docs.mapier.ai/convo/api/line-setups/start), using a key with the `lines:write` scope. Send `{"key": "imessage/operator"}`, which asks Mapier to set up an iMessage line. Three fields are optional: - `quantity`: how many lines, 1 to 5. - `reason`: why, as the console asks it: `first_line` (my first line for this agent), `capacity` (our lines are full), `dedicated` (a dedicated number), `region` (a number in another region) or `other`. - `note`: up to 500 characters, for anything Mapier should know. While a person at Mapier sets up the number, `state` is `verifying` and `nextStep` is `wait`. Follow it with [`GET /v1/line-setups/{setupId}`](https://docs.mapier.ai/convo/api/line-setups/get). When `state` is `verified`, `lineId` is the new line and `nextStep` is `null`. The line is also in [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) under `lines[]`, where `address` is its number and `status` is `active`. ## Good to know [#good-to-know] - **Texting the line adds a contact.** Whoever texts a line becomes one of its contacts, your own phone included. Test from a phone you don't mind using one of those contacts. - **The number belongs to Mapier.** You cannot move it to another provider. To stop using it, disconnect the line on its page. # Connect WhatsApp (https://docs.mapier.ai/convo/guides/connect/whatsapp) > Use your own number, WhatsApp Business Account and Meta app WhatsApp is in early access and must be turned on for your organization. Until it is, a call on WhatsApp answers [`channel_not_entitled`](https://docs.mapier.ai/convo/api/errors#channel_not_entitled). You connect WhatsApp through your own Meta app. You need a Meta business portfolio (business.facebook.com → Create a business portfolio, if you have none), then the few things below. ## Get ready in Meta [#get-ready-in-meta] Do these in Meta before you open the console. 1. **A Meta app with WhatsApp.** [App Dashboard](https://developers.facebook.com/apps/) → Create app → use case **Connect with customers through WhatsApp** → your business portfolio. Use the app only for Mapier. 2. **A number on the Cloud API**. App Dashboard → your app → Use cases → Connect on WhatsApp → Customize → Step 2 Production setup → Register your WhatsApp phone number. Not a number in the WhatsApp Business phone app, and not a Mapier iMessage number. 3. **A system user with a token.** Business settings → Users → [System users](https://business.facebook.com/settings/system-users) → Add (Admin) → Assign assets: your WhatsApp Business Account (full control) and the app → Generate new token: the app, expiration Never, `whatsapp_business_management` and `whatsapp_business_messaging`. Meta shows the token once, so copy it. One token covers every number in your business. 4. **Your app published.** Publish your app (App Dashboard → Publish). Meta needs a privacy policy URL in App settings → Basic first. An unpublished app can only message people who hold a role on it. Meta shows several IDs. Mapier asks for these: - **App ID:** your Meta app's ID. - **WhatsApp Business Account ID:** the ID of the account that holds your numbers. - **Phone number ID:** the ID of one number. Not the phone number itself, and not the account's ID. - **Business portfolio ID:** not needed. ## Use a number you already have [#own-number] For a number on the Cloud API in your WhatsApp Business Account. You keep the number if you leave. ### Connect your Meta app [#own-number-connect] In the console, open **WhatsApp** and click **Add line**. Under **Choose a number**, pick **Use my number** and click **Choose number**. On **Get ready in Meta**, click **I've done these**. Then paste these four and click **Connect Meta app**: 1. **Access token:** the token from Get ready in Meta, step 3. 2. **App secret:** [App Dashboard](https://developers.facebook.com/apps/) → your app → App settings → Basic → App secret → Show. Meta asks for your password again. 3. **App ID:** App Dashboard → your app → App settings → Basic → App ID. 4. **WhatsApp Business Account ID:** Business settings → Accounts → [Messaging accounts](https://business.facebook.com/settings/whatsapp-business-accounts) → click your account → the ID is under its name. For Meta's test number, it is the Messaging account ID on Step 1 Try it out. ### Pick your number [#own-number-pick] Paste the **Phone number ID**: App Dashboard → your app → Use cases → Connect on WhatsApp → Customize → Step 2 Production setup (Step 1 Try it out for Meta's test number). Or [WhatsApp Manager](https://business.facebook.com/latest/whatsapp_manager/phone_numbers) → Phone numbers → your account; the ID is under each number. Paste the ID, not the number. Add a **Line name** if you like. Only your team sees it. Click **Connect number**. This accepts WhatsApp's [Business Messaging Policy](https://whatsappbusiness.com/policy/), and confirms that your agent serves your own business's customers and that you will not train AI models on their messages. ### Add Mapier's webhook in Meta [#own-number-webhook] Go to App Dashboard → your app → Use cases → Connect on WhatsApp → Customize → Step 2 Production setup → Configure Webhooks. Then: 1. Paste the **Callback URL** and **Verify token** from the console. Click **Verify and save**. Use the app's main webhook, not a number's Override callback URL. 2. Under **Webhook fields**, subscribe to `messages`. It is required. 3. Also subscribe to `account_update`, `phone_number_quality_update`, `account_alerts` and `user_preferences`. They let Mapier pause sending when Meta restricts the number, and respect opt-outs. 4. If you send templates, add `message_template_status_update`, `message_template_quality_update` and `template_category_update`. For groups, add the four `group_*` fields. If your app already sends Mapier messages for another line, this step is done for you. ### Meta approval [#own-number-approval] Nothing to do. Mapier asks Meta whether the number may send. If Meta limits or blocks it, open [WhatsApp Manager](https://business.facebook.com/latest/whatsapp_manager/phone_numbers) → Phone numbers and follow Meta's advice, then click **Check again**. ### Open your line [#own-number-open] The setup page says **Line added**. Click **Open line**. ## How you know it worked [#how-you-know-it-worked] The line reads **No traffic yet**, then **Live** after its first message. Text the line from your phone to see the first message arrive. To check it reaches customers, text from a phone without a role on your Meta app. If your app is unpublished, only people with a role on it can message the line. Good to know: - **Your access token and app secret** go only into the console, or onto a one-time setup link. Mapier stores them encrypted and never shows them again. - **A number in the WhatsApp Business phone app** must leave the app first. Export the chats you want to keep, then delete the number's account in the app. - **Your display name.** Meta reviews it after the number is added. If Meta rejects it, change it in WhatsApp Manager. - **A payment method.** Messages your agent starts need one on your WhatsApp Business Account. Replies to people who wrote first do not. Add one in WhatsApp Manager → Overview → Add payment method. ## The reply window [#the-reply-window] You can reply freely for 24 hours after a person's last message. After that, send a [template](https://docs.mapier.ai/convo/guides/send/templates). ## From the API [#from-the-api] Your code can start a setup with [`POST /v1/line-setups`](https://docs.mapier.ai/convo/api/line-setups/start), using a key with the `lines:write` scope. The body never carries the access token or the app secret. The response's `handoffUrl` is a one-time setup link where the account owner pastes the token and the secret. - **Use a number you already have:** `{"key": "whatsapp/byo_meta_app", "phoneNumberId": "…", "wabaId": "…", "metaAppId": "…", "policyAck": {…}}`. All three are numeric IDs from Meta. The `policyAck` fields are the account owner's own answers. Ask the account owner for each one, and send only what they told you: | Field | What the account owner says | | -------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `policyAck.useCase` | Optional. What the agent is for: `support`, `booking`, `notifications` or `other`. | | `policyAck.useCaseOther` | Optional. With `other`, what it is for, in up to 200 characters. | | `policyAck.ownBusinessAgent` | `true`: the agent works for their own business. It is not a general-purpose assistant. | | `policyAck.noModelTraining` | `true`: they will not use what people send on WhatsApp to train AI models. | Then follow the setup with [`GET /v1/line-setups/{setupId}`](https://docs.mapier.ai/convo/api/line-setups/get), and show the account owner its `nextStep`. When the setup's `state` is `verified`, `lineId` is the new line's id. ## Setup checks [#setup-checks] The setup page checks each step as you go. If a check fails, the console says what to fix. Its **Docs** link opens its row below; fix it, then click **Check again**. | Check | What it means | What to do | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Your details | Meta did not accept your token, app secret or IDs. | Check each against its click path, then paste again: [Connect your Meta app](#own-number-connect). | | Rules | You have not accepted WhatsApp's rules yet. | Click **Connect number** ([Pick your number](#own-number-pick)). That accepts WhatsApp's [Business Messaging Policy](https://whatsappbusiness.com/policy/). | | Messages reach Mapier | Meta has not sent the number's messages to Mapier yet. | Check the callback URL, verify token and `messages` field in [Add Mapier's webhook in Meta](#own-number-webhook). Then wait a minute and click **Check again**. | | Meta approval | Meta limits or blocks the number. | Open [WhatsApp Manager](https://business.facebook.com/latest/whatsapp_manager/phone_numbers), go to **Phone numbers**, and follow Meta's advice. | # Chat backgrounds (https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) > Set or remove the picture behind a conversation, and hear when a person changes it _Works on iMessage_ A chat background is the color, gradient or photo behind the bubbles in a conversation. Your line can set one in a conversation with one person who has written to it, or in a group chat. Everyone in the conversation sees it. | You want | Send | | -------------------------- | ---------------------------------------------------------------------------------- | | One of Apple's backgrounds | [`chat_background.set`](https://docs.mapier.ai/convo/api/conversations/set-background) with its `preset` | | Two colors of your own | `preset: "custom"` with two `colors` | | A photo of your own | `preset: "photo"` with a public https `photoUrl` | | The plain background again | [`chat_background.remove`](https://docs.mapier.ai/convo/api/conversations/remove-background) | ## Set a background [#set-a-background] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/chat_background.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-background" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "preset": "sky_dusk" } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/commands/chat_background.set`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order-4821-background", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { preset: "sky_dusk" }, }), }); const { commandId } = await res.json(); ``` [Set a background](https://docs.mapier.ai/convo/api/conversations/set-background) lists every preset. For two colors of your own, send them as `#RRGGBB`: ```json { "preset": "custom", "colors": ["#008080", "#FFE600"] } ``` For a photo, give a public https link to a JPEG, PNG, HEIC or WebP image of at most 8 MiB: ```json { "preset": "photo", "photoUrl": "https://example.com/backgrounds/harbor.jpg" } ``` Keep `commandId`. Its `command` event says `succeeded` once Mapier has confirmed the change on the line. Use a new `Idempotency-Key` for each change. A remove sent under the key a set used removes nothing. ## Remove a background [#remove-a-background] Send [`chat_background.remove`](https://docs.mapier.ai/convo/api/conversations/remove-background) to the same conversation with an empty `payload`. ## Hear when a background changes [#hear-when-a-background-changes] One event reports every change, whoever made it: `conversation.background_changed`. It is opt-in. **On the stream**, open it with `?events=chat_backgrounds`, and each change arrives as one `event: chat_background`. The option combines with the others: `?events=receipts,chat_backgrounds`. **At a webhook endpoint**, select `conversation.background_changed` on the project's **Webhooks** page. It is not in the default set: a new endpoint, and **Select all**, leave it out. ```json title="conversation.background_changed" { "type": "conversation.background_changed", "conversationId": "a0000000-0000-4000-8000-000000000001", "from": "+14155550100", "fromMe": false, "background": { "preset": "custom", "colors": ["#008080", "#FFE600"] }, "occurredAt": "2026-11-02T18:26:47.000Z", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d" } ``` `from` is the address of whoever changed it: the person's, or the line's own when `fromMe` is true. ### Reading `background` [#reading-background] - **`null`** — the background was removed. - **`{ "preset": … }`** — a background was set. `preset` is one of the presets [`chat_background.set`](https://docs.mapier.ai/convo/api/conversations/set-background#presets) takes, whoever made the change. - **`preset` is `null`** — a background was set, and the line could not tell which: for example a set followed at once by another, or one the line could not read in time. Read it as "changed, look unknown", not as a removal. - **`preset` is `photo`** — a picture someone chose. The change may carry `attachmentId`, the id of that picture: download it with [`GET /v1/attachments/{attachmentId}`](https://docs.mapier.ai/convo/api/messages/download-attachment) as you would a message's attachment. It may still be uploading when the event arrives: a picture that is not there yet answers `404`, so retry shortly. `attachmentId` is absent when the line could not export the picture, on every other preset and on a removal. - **`preset` is `custom`** — two colors in `colors`, an array of two `#RRGGBB` strings, when the line could read them. `colors` is absent on every other preset. ### Your own change comes back here [#your-own-change-comes-back-here] A change your line makes with `chat_background.set` or `chat_background.remove` reports its result in its `command` event, and the change also arrives here with `fromMe: true` and `from` set to the line's own address. It is one change reported twice: do not count it twice, and do not rely on which of the two arrives first. A set can come back with `preset: null` here even though your command named one, for the reason above. ### Group chats [#group-chats] A change in a group chat is expected to be reported by the same event, on the group's `conversationId`, with the same fields: `from` names whoever changed it, and `fromMe` is `true` when it was your line. Some iMessage lines, on older software, report a change in a conversation with one person as a message from that person with no text and no attachment. Nobody wrote anything, so do not reply to it. ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ------------------------------------------------------------------------------------ | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `payload.preset` | The preset is missing or not on the list | Use a preset from [Set a background](https://docs.mapier.ai/convo/api/conversations/set-background) | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `media_fetch_failed` | Mapier could not fetch the photo link | Check the link, then retry | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `media_too_large` | The photo is too large | Send a smaller photo | | [`503 upstream_unavailable`](https://docs.mapier.ai/convo/api/errors/upstream_unavailable) | The line is offline, or sending on it is paused | Wait, then retry with the same `Idempotency-Key`; only a `message.send`'s key is spent by this error | A change can also fail after the `202`. Its `command` event then says why: for example `stale_target` for a group that changed members moments ago. Wait for the group's next message, then send again under a new key. ## Next [#next] - [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) # Conversations (https://docs.mapier.ai/convo/guides/conversations/conversations) > Find a conversation, read what was said, and reply in it A conversation is one person, or one group, on one of your lines. Every message you receive names its conversation at `conversationId`, and a reply sent to that id goes out from the same line, on the same channel. | Channel | A conversation is | | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | | iMessage | One person, or a group chat | | You want | Use | | ------------------------------------------ | ------------------------------------------------------------------------------------------------------ | | Reply to someone who wrote to you | `target.conversationId` from their [`message.received` event](https://docs.mapier.ai/convo/guides/receive/incoming-messages) | | Every conversation on a line | [`GET /v1/conversations`](https://docs.mapier.ai/convo/api/conversations/list) | | One conversation, with a group's members | [`GET /v1/conversations/{id}`](https://docs.mapier.ai/convo/api/conversations/get) | | What was said before you started listening | [`GET /v1/conversations/{id}/messages`](https://docs.mapier.ai/convo/api/conversations/list-messages) | | The conversation you have with an address | [`POST /v1/conversation-lookup`](https://docs.mapier.ai/convo/api/conversations/find) | ## Reply in a conversation [#reply-in-a-conversation] Keep the `conversationId` next to your own record of the person, such as a customer or a ticket. Send to it whenever you want to write back. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: ticket-1043-first-reply" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "text", "text": "Yes, by the window." } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/commands/message.send`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "ticket-1043-first-reply", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "text", text: "Yes, by the window." }, }), }); const { commandId } = await res.json(); ``` `conversationId` is Mapier's id for the conversation. It is not the channel's own id for one message, which arrives as `externalId`. Only `conversationId` can be sent to. A conversation id belongs to one project. An id from another project answers `404 not_found`, the same as an id that never existed. ## List a line's conversations [#list-a-lines-conversations] [`GET /v1/conversations`](https://docs.mapier.ai/convo/api/conversations/list) lists the conversations your key can read, newest first. Narrow it with `lineId`, `kind` (`direct` or `group`) and `status` (`active` or `closed`). Pass each page's `nextCursor` back to read the next one, until it is `null`. ```bash curl "https://api.mapier.ai/v1/conversations?kind=group&status=active" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` A group in the list shows how many members it has as `participantCount`. [`GET /v1/conversations/{id}`](https://docs.mapier.ai/convo/api/conversations/get) reads one conversation with its members, its name and its `status`. ## Read what was said [#read-what-was-said] [`GET /v1/conversations/{id}/messages`](https://docs.mapier.ai/convo/api/conversations/list-messages) reads a conversation's history, newest first, in both directions. Each row has `direction`, and a message you sent also has its `status` and the `commandId` from its `202`. Use it to load what was said before you started listening. A new line starts with no history. Messages from before the line was connected to Mapier never arrive, and a conversation first appears with its first message after that. ## Find the conversation for an address [#find-the-conversation-for-an-address] To reply to someone before they write again, for example when you move your own history onto Mapier, ask [`POST /v1/conversation-lookup`](https://docs.mapier.ai/convo/api/conversations/find) for the line's conversation with their address. It sends nothing. It finds any conversation your line has had through Mapier, and on iMessage also one from before the line joined Mapier. ## When a conversation starts or changes [#when-a-conversation-starts-or-changes] Open the stream with `?events=conversations`, or subscribe a webhook endpoint, to hear when a conversation starts and when a group changes: | Event | When | | ----------------------------- | -------------------------------------------------------------------------------- | | `conversation.created` | A person's first message, a group's first message, or your line added to a group | | `conversation.updated` | A group was renamed, or people joined or left it | | `conversation.status_changed` | A group closed for your line, or opened again | [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) explains each one. ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ------------------------------------------------------------------ | ---------------------------------------------- | ------------------------------------------------------------------------------ | | [`404 not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | The id is wrong, or belongs to another project | Use a `conversationId` from your own events | | [`403 line_not_allowed`](https://docs.mapier.ai/convo/api/errors/line_not_allowed) | The `lineId` is not one of this key's lines | Use a line that [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists | | [`409 conversation_closed`](https://docs.mapier.ai/convo/api/errors/conversation_closed) | Your line can no longer reach this group | Wait for `conversation.status_changed` back to `active` | ## Next [#next] - [Groups](https://docs.mapier.ai/convo/guides/conversations/groups) - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # Groups (https://docs.mapier.ai/convo/guides/conversations/groups) > Group chats from the API. Start an iMessage group chat, send to it, rename it, change who is in it, and leave it _Works on iMessage_ A group chat is a conversation too. A message someone writes in a group arrives under the group's own `conversationId`, with `isGroup: true`. Send to that id, and the message reaches every member. | You want | Send | | ---------------------------------- | ----------------------------------------------------------------------------------------- | | A new group with its first message | [`group.create`](https://docs.mapier.ai/convo/api/groups/create) | | A message to everyone in a group | [`message.send`](https://docs.mapier.ai/convo/api/messages/send) to its `conversationId` | | A new name for the group | [`group.update`](https://docs.mapier.ai/convo/api/groups/update) with `rename` | | Someone added or removed | [`group.update`](https://docs.mapier.ai/convo/api/groups/update) with `add_participant` or `remove_participant` | | Your line out of the group | [`group.leave`](https://docs.mapier.ai/convo/api/groups/leave) | | Channel | A group is | Your line joins one when | | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | | iMessage | A group chat | It makes one with `group.create`, or someone adds it | | WhatsApp | A group chat, but its messages do not reach your agent yet. Talk to people in direct messages | — | Only an iMessage line creates, renames and leaves groups by command. On any other channel, `group.create`, `group.update` and `group.leave` answer [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command). ## Start a group [#start-a-group] A group starts with a message, so `firstMessage` is required. Name 2 to 32 other people at `participantExternalIds`, each as a phone number with its country code or an Apple ID email. Leave your own line out. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/group.create \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: kickoff-trip-planning" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "kind": "new_group", "channel": "imessage", "participantExternalIds": ["+14155550100", "+14155550111"] }, "payload": { "firstMessage": "Kicking off trip planning here." } }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/commands/group.create`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "kickoff-trip-planning", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { kind: "new_group", channel: "imessage", participantExternalIds: ["+14155550100", "+14155550111"], }, payload: { firstMessage: "Kicking off trip planning here." }, }), }); const { commandId } = await res.json(); ``` Keep `commandId`. When the group is made, its `command` event says `succeeded` and names the new group at `group.conversationId`. A `conversation.created` event with `kind: "group"` announces it too. A group the line could not confirm ends as `ambiguous`. It may exist. Check on a phone in the group before you send `group.create` again, or you may make a second group. To make sure everyone can be reached first, [check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send). ## Send to a group [#send-to-a-group] Send [`message.send`](https://docs.mapier.ai/convo/api/messages/send) to the group's `conversationId`. Every kind works in a group except a location request, which goes in the person's own conversation. ## Rename a group, or change who is in it [#rename-a-group-or-change-who-is-in-it] [`group.update`](https://docs.mapier.ai/convo/api/groups/update) takes one change per command: ```json { "action": "rename", "name": "Trip planning" } ``` ```json { "action": "add_participant", "participantExternalId": "+14155550122" } ``` `remove_participant` takes the same shape. A name is at most 128 characters. 1. Send a message in a new group before you add or remove anyone. Until someone writes in it, a member change is refused at once. 2. After someone is added or removed, wait for the group's next message before you send anything else to it. Until then, a command to the group fails with `stale_target`, so a message never reaches the wrong people. 3. Check the result. `succeeded` means Mapier confirmed the change on the line. `ambiguous` means it was sent and Mapier could not confirm it, so check on a phone before you send it again. ## Leave a group [#leave-a-group] [`group.leave`](https://docs.mapier.ai/convo/api/groups/leave) takes your line out of the group. A leave cannot be undone. iMessage lets a member leave only a group of at least 4 people, your line among them. In a smaller group the leave changes nothing and still reports `succeeded`. Mapier cannot confirm a leave. `succeeded` means the leave was sent without an error, not that it worked. A leave that hit an error reports `ambiguous` with `group_leave_unverified`. After either, check on a phone in the group before you send a leave again. Once your line has left, the group closes for it, and a `conversation.status_changed` event says so. ## Follow a group's changes [#follow-a-groups-changes] Open the stream with `?events=conversations`, or select the conversation events on a webhook endpoint: - `conversation.created`: your line first sees the group. - `conversation.updated`: someone renamed the group, or a member joined or left. It names who joined and who left, never the whole group; read that with [`GET /v1/conversations/{id}`](https://docs.mapier.ai/convo/api/conversations/get). - `conversation.status_changed`: the group closed for your line, or opened again. A closed group opens again when your line is added back or a message arrives in it. A person who writes in a group is added to its members without an event, so match a message's sender by `from` or `contactId`. ## Messages meant for your line [#messages-meant-for-your-line] A group message carries `addressed: true` when it mentions your line or replies to a message your line sent: | Channel | Also `true` for | A message not for your line | | ----------------------------------------- | ----------------------------------------- | --------------------------- | | iMessage | — | `addressed` absent | Absent means the channel could not tell, so treat the message as addressed. To answer only when someone talks to your agent, skip messages with `addressed: false`. ## Groups on a test line [#groups-on-a-test-line] A test line on a shared number answers `group.create`, `group.update` and `group.leave` with `404 unsupported_command` and `reason: shared_line`, unless group chats are turned on for your organization. Once they are: - `group.create` takes 2 to 10 people, and each must be one of this project's connected Test contacts. - Every command into the group (a message, a reaction, an edit or unsend, a vote, `group.update`, `group.leave`) goes out only while everyone in it still is. Otherwise it is `403 recipient_not_allowed` with `group_member_not_test_contact`, or with `recipient_must_write_first` for a member who must text the line first or has gone too long without answering. An address the refusal names is the first, in sort order, of those that stopped the group, which need not be the first one you listed. - When someone outside the member list writes in the group, those commands are refused the same way for 24 hours after their last message, unless a newer member list arrives first. - A group message counts as one send toward the line's limits and toward each member's. - A `group.create` sent again under its `Idempotency-Key` is answered from the first: with the same people it is the same group, never a second one, and with other people it is `409 conflict` with `idempotency_key_reused`. ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | A person's address, the member count or the name is not valid | Fix the field the error names | | [`409 conflict`](https://docs.mapier.ai/convo/api/errors/conflict), `group_has_no_messages_yet` | No one has written in the group yet | Send a message in the group first | | [`409 conversation_closed`](https://docs.mapier.ai/convo/api/errors/conversation_closed) | Your line can no longer reach the group | Wait for `conversation.status_changed` back to `active` | | [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed), `group_member_not_test_contact` | On a test line on a shared number, someone in the group is not one of this project's connected Test contacts | Connect them as Test contacts, or leave them out | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `shared_line` | Group chats are not turned on for your organization, on a test line on a shared number | Use a line of your own | ## Next [#next] - [Chat backgrounds](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) # Authentication (https://docs.mapier.ai/convo/guides/get-started/authentication) > Send your API key on every request, and keep it out of your code and logs Every request carries an API key in the `Authorization` header. ```bash curl https://api.mapier.ai/v1/whoami \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" ``` A request with no key, or with a key that was revoked or has expired, is refused before anything else happens: ```json title="401 Unauthorized" { "error": { "code": "invalid_credentials", "message": "That API key is not valid." } } ``` ## What a key looks like [#what-a-key-looks-like] A key starts with `mp_live_`, then 43 letters and digits: ``` mp_live_9Kq2… ``` Every key sends from your project's lines. The prefix makes a key easy to spot when one lands in a log. ## Create a key [#create-a-key] 1. Open the console at [convo.mapier.ai/app](https://convo.mapier.ai/app) and go to the **Keys** page. 2. Click **Create key**, and give it a name. You can also set when it expires. 3. Copy the key into your secret manager before you close the dialog. It is shown once. Mapier keeps only a hash of it, so nobody can show it to you again. The **Keys** page shows when each key was last used, so you can spot a key you do not recognize. Revoke a key on the same page; its next request is refused with `401`. ## What a key reaches [#what-a-key-reaches] A key belongs to one **project**, and it sends from every line the project holds, on every channel. You do not have to choose a line: a person is answered on the line they last wrote to, and someone new gets the line Mapier picks. To choose, name the line at `target.lineId`. See [Lines](https://docs.mapier.ai/convo/guides/lines/lines). - **Everything belongs to a project.** A conversation or attachment id from another project returns `404`, the same as one that does not exist. - **Keys share the project's budget.** All keys in a project spend one command budget, so a second key adds no capacity. See [Rate limits](https://docs.mapier.ai/convo/api/rate-limits). ## What a key may do [#what-a-key-may-do] A key carries scopes, chosen when it is created and fixed from then on. To change them, create another key. A new key gets all four scopes unless you pick fewer. It can only get scopes its creator holds. | Scope | Lets the key | | ---------------- | ----------------------------------------------------------------------------------- | | `messages:send` | Send commands, check whether an address can be reached, and record an opt-out | | `messages:read` | Read the stream, events, receipts, history, attachments, contacts and people | | `lines:write` | Add and set up lines through [`POST /v1/line-setups`](https://docs.mapier.ai/convo/api/line-setups/start) | | `webhooks:write` | Manage webhook endpoints in the console. No route takes it from a key | Any key can call [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details), [`GET /v1/capabilities`](https://docs.mapier.ai/convo/api/discovery/list-capabilities) and the routes that read lines. A route the key has no scope for returns [`403 insufficient_scope`](https://docs.mapier.ai/convo/api/errors/insufficient_scope). `GET /v1/whoami` lists the key's scopes. ## Personal access tokens [#personal-access-tokens] A personal access token is a person's credential in one organization, where a key is a project's. It starts with `mp_pat_`, is made in the console and shown once, and goes in the same `Authorization: Bearer` header. A command-line tool gets one by signing in from a terminal: see [`POST /v1/cli/logins`](https://docs.mapier.ai/convo/api/sign-in/start-login). - **It never does more than its owner.** A call needs the scope the route names on the token, and the same right in its owner's role now. A token whose owner lost that right gets [`403 forbidden`](https://docs.mapier.ai/convo/api/errors/forbidden) with `reason: "role"`; one whose owner left the organization gets `401`. - **It names its project on every call about one.** Send the project's id, as [`GET /v1/projects`](https://docs.mapier.ai/convo/api/organization/list-projects) lists it, in `x-mapier-project`. Without it the call is `400 bad_request` with `reason: "missing_header"`. A project the token cannot reach is a `404`. - **It names its environment when it is not `live`.** Send `x-mapier-environment: test` for test. An environment the token was not made for is `403 forbidden` with `reason: "environment"`. ```bash curl https://api.mapier.ai/v1/conversations \ -H "Authorization: Bearer $MAPIER_TOKEN" \ -H "x-mapier-project: 0192a7b0-1c2d-7e3f-8a4b-5c6d7e8f9a0b" \ -H "x-mapier-version: 2026-12-01" ``` Each route's page says which credential it takes. The [webhook endpoint](https://docs.mapier.ai/convo/api/webhook-endpoints/list) and [organization](https://docs.mapier.ai/convo/api/organization/list-projects) routes take a token only, and a key there gets `403 forbidden` with `reason: "personal_token_required"`. A key ignores `x-mapier-project` and `x-mapier-environment`. ## Keep the key safe [#keep-the-key-safe] ### Store it outside your code [#store-it-outside-your-code] Put it in an environment variable or a secret manager. Never commit it, and never send it to a browser: the API is for your server, and no key is safe to expose in a browser. ```bash export MAPIER_API_KEY="mp_live_…" ``` ### Read it once at startup [#read-it-once-at-startup] ```ts const MAPIER_API_KEY = process.env.MAPIER_API_KEY; if (!MAPIER_API_KEY) throw new Error("MAPIER_API_KEY is not set"); ``` A missing key then stops your app at once, not with a `401` under load. ### Keep it out of logs [#keep-it-out-of-logs] The key travels in a header, so anything that prints request headers prints the key. Hide `Authorization` in your logging, and take care with verbose tools: `curl -v` prints the header in full. ## A small client [#a-small-client] Everything in these docs is plain HTTP, so a wrapper is a few lines: ```ts const BASE = "https://api.mapier.ai"; export async function mapier(path: string, init: RequestInit = {}) { const res = await fetch(`${BASE}${path}`, { ...init, headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "x-mapier-version": "2026-12-01", ...init.headers, }, }); if (!res.ok) { const body = await res.json().catch(() => ({})); throw new Error(`${res.status} ${body.error?.code ?? "request failed"}`); } return res; } ``` Every request and response shape is in the OpenAPI document at `https://api.mapier.ai/openapi.json`, which any generator turns into a typed client. # Key concepts (https://docs.mapier.ai/convo/guides/get-started/key-concepts) > The terms of the Mapier messaging API in plain words. A line, such as an iMessage number, a conversation, a command and the event stream These words carry the rest of these docs. Nothing here needs code. ## Line [#line] A **line** is one sender on one channel, such as a phone number. A project can hold many lines, and one API key sends from all of them. [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists them under `lines[]`, each with its `id`, its `address` and its `channel`. [Lines](https://docs.mapier.ai/convo/guides/lines/lines) says which line a message goes out on. A conversation never moves to another channel, and Mapier never moves a message to another channel on its own. Your WhatsApp line always has a different number from your iMessage lines: Mapier's iMessage numbers cannot be added to a WhatsApp Business Account. The people you talk to can be the same person on both channels. ## Address [#address] An **address** is how a channel reaches a person, and each channel has its own form. Mapier reads an address the way its channel does, and refuses one it cannot read with [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed). | Channel | Address | | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | iMessage | A phone number in E.164 form, with a leading `+` (`+14155550100`), or an email address. Formatting is stripped, a bare ten-digit number is read as a US one, and an email address is lowercased. | | WhatsApp | A phone number with its country code. | A phone number fits both iMessage and WhatsApp, so a project with lines on both names `target.channel` on a new send, or replies by `conversationId`. A well-formed address is not proof that the person can be reached. [`GET /v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability) asks before you send to an address a person typed. ## Conversation [#conversation] A **conversation** is the messages between your line and one person, or a group chat, on one line. Mapier names it with a `conversationId`. That id is Mapier's own, and it is never the channel's id for the conversation. You cannot make up a conversation id. It reaches you on each incoming message, and in the result of a command that acted on a conversation. To start a conversation with someone new, send to their address; later messages, and the result of that send, carry the conversation id. A group chat is a conversation too: a message in a group arrives under the group's own `conversationId`, and a send to that id reaches everyone in it. Who may start a conversation depends on the channel: | Channel | Who writes first | | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | iMessage | Your agent. | | WhatsApp | Your agent, with an approved template. | ## Message [#message] A **message** is one bubble. Mapier names it with a `messageId`. A reply, an edit, an unsend, a reaction and a receipt lookup name a message by it. Each message also carries `platformMessageId`, the channel's own id for it, so you can match it with anything you already hold. `occurredAt` on a message is when the channel says it was sent, not when Mapier received it. Your own sends do not come back to you as incoming messages. ## Command [#command] A **command** is how you change anything: send a message, add a reaction, start a group. Each one is a `POST` to `/v1/commands/`, with a body of two parts: ```json { "target": {}, "payload": {} } ``` `target` says who the command acts on. `payload` says what it does. A command whose type says everything needs no body at all. The whole body is at most 65,536 bytes. Mapier answers `202 Accepted` with a `commandId`. **A `202` means accepted, not sent.** Mapier checked the request and recorded it; most mistakes in a `message.send`, such as text the channel cannot carry, are refused here with a `422` and nothing is sent. Whether the message then reached the channel arrives later, as the command's result. [Send a message](https://docs.mapier.ai/convo/api/messages/send) lists what is checked first. ## Result [#result] Each command ends in one **result**, which reaches you on the stream (and as a webhook), never in the `202`. Match it to your command by `commandId`. It is one of six statuses: | Status | Means | | ----------- | ------------------------------------------------------------------------------------------------------- | | `succeeded` | The channel took it. For a message, the channel now has it; that is not a delivery receipt. | | `failed` | It did not happen. `failureClass` says what kind of failure, and `errorCode` gives the channel's words. | | `ambiguous` | The channel took it, but could not confirm what happened. Treat it as unknown; do not resend blindly. | | `no_effect` | The channel took it, and found no change it could confirm. Handle it exactly like `ambiguous`. | | `cancelled` | It stopped before it ran. | | `expired` | It waited too long to run, and never did. | Branch on the status first, then on `failureClass`, which is one of `target`, `content`, `capability`, `line`, `rate_limited`, `not_run`, `transport` (Mapier could not reach the channel) or `unknown`. Read `errorCode` for the detail, and quote it when you ask for help. Delivered and read do not change a result. They arrive later as their own events, when you ask for them. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) explains each one. ## The stream [#the-stream] The **stream** is one long-lived connection, [`GET /v1/response_stream`](https://docs.mapier.ai/convo/api/events/stream), that carries every incoming message and every command's result for your project. You can ask it for more, such as receipts, reactions and polls. Each event carries an `id:`. Keep the last one you handled, and reconnect with it as the `Last-Event-ID` header: the stream sends what you missed, up to 500 events at a time and as far back as 90 days. The connection drops now and then even when all is well, so reconnect every time it closes. Two open streams both receive every event, so handle each event once, by its `id`. [Webhooks](https://docs.mapier.ai/convo/guides/receive/receive-events) carry the same events to your server instead. ## Idempotency key [#idempotency-key] An **idempotency key** is a name you choose for one action, so a retried request does not do it twice. Send it in the `Idempotency-Key` header. Send the same request again with the same key and Mapier does not do it twice: you get the same `commandId`, with `repeated: true`. Leave the header off and every request is new, so a retry sends twice. [Retries](https://docs.mapier.ai/convo/guides/production/retries) explains when a repeat is refused instead. ## Version [#version] Send `x-mapier-version` on every request. It pins the behavior your code is written against, so a change to the API never changes your integration on its own. Start on the newest version, `2026-12-01`, as every example here does. [Versions](https://docs.mapier.ai/convo/api/versions) lists them all. # Quickstart (https://docs.mapier.ai/convo/guides/get-started/quickstart) > Send your first message with the Mapier messaging API. Text your line, such as an iMessage number, then reply from the API Access to Mapier is by approval. New to Mapier? [Book a call](https://cal.com/mapier-homin/30min) and Mapier sets up your account during the call. If someone invited you, the invitation is the approval. **Before you start**, you need a line in the console, such as an iMessage number, a WhatsApp number. No line yet? [Connect a line](https://docs.mapier.ai/convo/guides/connect/imessage). ### Create an API key [#create-an-api-key] Create one on the **Keys** page. It is shown once. ```bash export MAPIER_API_KEY="mp_live_…" ``` ### Text your line [#text-your-line] Open a second terminal and leave this running. Incoming messages arrive here, and so does every command's result, whatever `events=` asks for. ```bash export MAPIER_API_KEY="mp_live_…" curl -N "https://api.mapier.ai/v1/response_stream?events=message.received" \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ -H "Accept: text/event-stream" ``` ```text title="Stream output" retry: 3000 : connected ``` A `: ping` line follows every 25 seconds. It means the connection is alive. Then send your line a message: | Channel | How to message your line | | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | | iMessage | Text it from your phone | | WhatsApp | Message it on WhatsApp | The message arrives on the stream: ```text title="Stream output" id: 0192… event: message.received data: {"id":"0192…","type":"message.received","occurredAt":"…","data":{"conversationId":"a000…0001","lineId":"…","from":"+14155550142","text":"Is this real?","attachments":[],…}} ``` Copy the `conversationId`. ### Reply [#reply] The reply names only the conversation. Mapier sends it from the same line, on the same channel. ```bash curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: first-reply" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a000…0001" }, "payload": { "kind": "text", "text": "Hi! This came from the Mapier API." } }' ``` ```json title="202 Accepted" { "commandId": "…", "status": "queued", "repeated": false, "lineId": "…", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` `202` means Mapier accepted the request. The result follows on the stream: ```text title="Stream output" id: 0192… event: command data: {"commandId":"…","type":"message.send","status":"succeeded","messageId":"…","conversationId":"a000…0001","lineId":"…"} ``` `succeeded` means the channel now has the message. It lands on your phone. A retry with the same `Idempotency-Key` never sends twice. Leave the header off and every request is new, so two requests with no header are two messages. [Retries](https://docs.mapier.ai/convo/guides/production/retries) explains. Delivered and read arrive later, as their own events. The stream sends them once you add `receipts` to `events`: `?events=message.received,receipts`. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) explains each status. Which receipts follow depends on the channel: | Channel | Receipts after `succeeded` | | ------------------------------------------- | -------------------------- | | iMessage | Delivered and read | | WhatsApp | Delivered and read | ## Next [#next] Connect another line on [iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) or [WhatsApp](https://docs.mapier.ai/convo/guides/connect/whatsapp). Your code does not change. # Lines (https://docs.mapier.ai/convo/guides/lines/lines) > Which line a message goes out on, how to pick one, and how to keep each line healthy A **line** is one sender your messages come from, such as a phone number or a bot. A project can hold many lines, and one key sends from all of them. [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists them under `lines[]`, each with its `id`, its `address`, its `status` and how much room it has for new people. | Channel | A line is | | ------------------------------------------- | ------------------------------------------------ | | iMessage | An iMessage number | | WhatsApp | A WhatsApp number | Most integrations never pick a line. This page says what Mapier does when you do not, and how to pick one when you need to. ## How a send picks a line [#how-a-send-picks-a-line] **A person stays on the first line they meet.** That is the line your first message to them went out from, or the line they first wrote to. It never changes on its own, so the person never sees the sender change. **Someone new gets the best line you have.** Of your active lines on the channel that are online and have room for new people, Mapier picks the one with the healthiest connection, then one still under its daily target for new people, then the one with the most room, then the oldest. Paused, full and offline lines are skipped. Every `202` names the line the command went out on, and why: ```json title="202 Accepted" { "commandId": "0192b3e1-8a4c-7d2e-9f10-3c5b7a9d1e42", "status": "queued", "repeated": false, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "new_best_line", "channel": "imessage" } ``` | `lineSelection` | Means | | -------------------- | ----------------------------------------------------------------------------- | | `named` | Your target named the line at `target.lineId` | | `reused_active_chat` | A line the person already talks to you on, chosen as in [Replying](#replying) | | `new_best_line` | The person is new to this project, and Mapier picked this line for them | ## Send from a specific line [#send-from-a-specific-line] Put the line's `id` at `target.lineId`. Someone new is reached from that line and stays on it. A person already on another line gets a **second conversation** on the line you named, beside the first, and now hears from two lines of one business. Channels can read that as spam, so do it sparingly. ## Replying [#replying] A send goes out on the first of these that applies: 1. **The line you named** at `target.lineId`. 2. **The conversation's line**, for a send to `target.conversationId`. 3. **The line of the message you are answering**, for a reply that names `target.replyToMessageId`. If that line is paused or retired, the reply is refused rather than moved to another line. 4. **The line they last wrote to**, for any other send to the person's address. A line whose connection is down still counts, and the send fails there if it cannot go out. A paused or retired line is skipped. 5. **The line their conversation began on.** If that line is paused or retired, the send is refused with [`503 line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable). Someone new has no line yet, so Mapier picks one as in [How a send picks a line](#how-a-send-picks-a-line). A reaction or read receipt that names a message must reach the conversation holding it, so send those by `target.conversationId`. ## Which line a person wrote to [#which-line-a-person-wrote-to] Every event that happens on a line carries that line's `lineId`: on [the stream](https://docs.mapier.ai/convo/api/events/stream), on every [webhook](https://docs.mapier.ai/convo/guides/receive/receive-events) and in [`GET /v1/events`](https://docs.mapier.ai/convo/api/events/list). Match it against the `id` values in `GET /v1/whoami`. With more than one line, route every event by its `lineId`. The one exception is `contact.opt_out_changed`, whose `lineId` is `null` when the change was made in the console. A new line starts with no history: it reports only what arrives after it joins your project. ## Which address to show someone new [#which-address-to-show-someone-new] When a person will text you first, from a sign-up page or an app, call [`GET /v1/lines/available`](https://docs.mapier.ai/convo/api/lines/get-next-line) and show them the `address` it returns. It picks the line a first send to someone new would get. It reserves nothing, so ask each time you show a number. If every line is full, paused or down, it answers with the same `503` a send would. ## Line status [#line-status] A send from a paused line is refused with `503 line_unavailable`, reason `line_paused`. | `status` | Means | | -------------- | ------------------------------------ | | `active` | It can send | | `provisioning` | Mapier is still setting it up | | `paused` | It sends nothing until it is resumed | A **retired** line has left your project for good, and `whoami` does not list it. You cannot send in its old conversations: start a new conversation with the person. `GET /v1/whoami` also says whether each line takes new people now (`takesNewContacts`), how many people it holds (`contactsAssigned`) and the most it can hold (`maxContacts`). A new iMessage line holds 200 people. A line added earlier keeps its own limit. People already on a full line keep their conversations. ## Line health [#line-health] Apple publishes no sending limits for iMessage, and gives no warning before it stops delivering for a line. So every iMessage line carries a **health reading**, and Mapier tells you when to ease off. A reading blocks nothing: every send goes through whatever it says. Read it in the console on the line's page, or with [`GET /v1/lines/{lineId}/health`](https://docs.mapier.ai/convo/api/lines/get-line-health). A line is read about every 15 minutes. A line on any other channel has no reading, and `GET /v1/lines/{lineId}/health` answers `reputation: null`. | Status | What to do | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------- | | `HEALTHY` | Nothing. Send as you do. | | `AT_RISK` | Ease off new outreach, and let people reply before you send them more. It clears by itself once the line calms down. | | `CRITICAL` | Stop starting new conversations from this line today, and keep answering people who write to you. Name another line for new people. | | `FLAGGED` | The channel has stopped delivering from this line, or appears to have. Stop sending from it. Mapier is already looking at it. | What moves a line: how many people you text first in a day, how fast you send, how many messages go to people who do not reply, whether your sends are delivered, and how many people opt out. Replies to people who wrote to you first weigh far less. Some channels publish their own sending limits: | Channel | Limit | | ----------------------------------------- | ----------------------------------------------------------------------------- | | iMessage | None published: follow the health reading | ## Add a line [#add-a-line] Add a line when your lines run out of room for new people, or when you want another: | Channel | In the console | | ------------------------------------------------------------------------------ | ---------------------------------------------- | | [iMessage](https://docs.mapier.ai/convo/guides/connect/imessage) | **Request line** on the iMessage page | Each channel's Connect page, linked above, walks through it. You can add a WhatsApp line to a working iMessage agent without changing your API version. Before it answers there, check four things: 1. **Name `target.channel` on every new send, or reply by `conversationId`.** A phone number fits both iMessage and WhatsApp, so a send with neither is refused with [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) at `target.channel`. 2. **Read `channel` on every incoming message.** Send each reply back the same way it came. 3. **Branch on what a line carries, not on its channel's name.** `GET /v1/whoami` lists each line's `capabilities`. 4. **Respect the reply window.** On WhatsApp, a message after 24 hours of silence needs an approved [template](https://docs.mapier.ai/convo/guides/send/templates). # Name and photo (https://docs.mapier.ai/convo/guides/lines/name-and-photo) > Set the name and photo people see for your line, and offer them in a chat _Works on iMessage_ Three commands work with the name and photo people see for your line in their messages app. | Command | What it does | | ------------------------------------------------ | -------------------------------------------- | | [`profile.get`](https://docs.mapier.ai/convo/api/line-profile/get) | Read the name and photo. It messages no one. | | [`profile.set`](https://docs.mapier.ai/convo/api/line-profile/set) | Change the name, the photo, or both | | [`profile.share`](https://docs.mapier.ai/convo/api/line-profile/share) | Offer them to a person in a one-to-one chat | `name_photo.get`, `name_photo.set` and `name_photo.share` are deprecated. Use `profile.get`, `profile.set` and `profile.share`. Results and events name the command `name_photo.get`, `name_photo.set` or `name_photo.share`. Without a share, a person sees whatever their own contacts hold for your line's address. For someone new, that is only the address. | Channel | People see | | ------------------------------------------- | ---------------------------------------------------------- | | iMessage | What these commands set, once you share it | On any channel but iMessage, `profile.get`, `profile.set` and `profile.share` answer [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command). ## Set the name and photo [#set-the-name-and-photo] Get and set act on the line, not on a conversation. Name the line by its `lineId` from [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details). ```bash curl -X POST https://api.mapier.ai/v1/commands/profile.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: profile-northwind-1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d" }, "payload": { "name": "Northwind Support", "photoUrl": "https://example.com/northwind.png" } }' ``` Send at least one of `name`, `firstName`, `lastName` and `photoUrl`. A `photoUrl` is an `https` link to a JPEG, PNG, GIF, WEBP or HEIC image of at most 8 MiB, which Mapier fetches before anything changes. A photo you leave out is kept. The result carries what the line now shows, as `namePhoto`: ```json title="namePhoto" { "name": "Northwind Support", "firstName": null, "lastName": null, "hasPhoto": true } ``` When Mapier cannot confirm the change, the result is `ambiguous`, and the name and photo may or may not have changed. Read them with `profile.get` before you set them again. `hasPhoto` is `true` for the old photo and the new one alike. ## Read the name and photo [#read-the-name-and-photo] `profile.get` takes no payload. Its result carries `namePhoto`, as above. The photo itself is never returned. ## Offer them in a chat [#offer-them-in-a-chat] `profile.share` shows the person the prompt their messages app offers when you start talking to someone new. It works only in a one-to-one conversation the person has already written in: name its `conversationId`, and send an empty payload. A group, a phone number, or a conversation the person has not written in is refused with [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) at `target.conversationId`, and nothing is sent. The result is `succeeded` whether or not the prompt was shown. Messages often skips it when the person has already seen your card, and nothing tells the two apart. All three commands take an `Idempotency-Key`, so a retry does not act twice. If your line cannot show a name and photo yet, a get or a set fails, and nothing changes. # Check before you send (https://docs.mapier.ai/convo/guides/production/check-before-you-send) > Ask whether a line can reach a person now, and what to do when it cannot A send to someone your line cannot reach is refused, or goes out and never arrives. [`GET /v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability) asks first, by the same rules a send follows. It sends nothing and writes nothing. | You want to know | Read | | -------------------------------------------- | ------------------------------------------------- | | Whether an ordinary message would go out now | `canSend.freeform` | | Why not | `reasons`, one entry per rule | | What to do about it | `remedy` | | Who has to write first | `initiation` | | Whether the address is on the channel at all | `registered`, when you ask with `registered=true` | ## Ask about one person [#ask-about-one-person] Name the line with `lineId`, or name `channel` and let Mapier pick the line a send would use. Put the person's address in `to`. ```bash tab="cURL" curl -G https://api.mapier.ai/v1/reachability \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ --data-urlencode "channel=imessage" \ --data-urlencode "to=+14155550100" ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const query = new URLSearchParams({ channel: "imessage", to: "+14155550100" }); const res = await fetch(`${BASE}/v1/reachability?${query}`, { headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", }, }); const answer = await res.json(); if (!answer.canSend.freeform) console.log(answer.reasons, answer.remedy); ``` When nothing stands in the way, `reasons` is empty and `canSend.freeform` is `true`. A refused send carries the same answer at `details.reachability`, so you can read it there too. Each line keeps its own record of who has written to it, so two lines can answer differently for one person. ## Why a send would be refused [#why-a-send-would-be-refused] Each entry in `reasons` has a `reason` and a `docUrl` to its row on the [Errors](https://docs.mapier.ai/convo/api/errors) page. | `reason` | Channel | Means | What to do | | ---------------------------- | ------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | | `opted_out` | All | The person asked you to stop | Do not send. See [Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out) | | `blocked`, `paused` | All | The person is blocked or paused in the console | Unblock or resume them in the console | | `outside_service_window` | WhatsApp | More than 24 hours since the person last wrote on WhatsApp | Send an approved [template](https://docs.mapier.ai/convo/guides/send/templates). `canSend.template` says whether one would go out | ## Ask the channel whether an address exists [#ask-the-channel-whether-an-address-exists] Add `registered=true` to also ask the channel, live, whether the address can receive at all. - `registered: true` means the channel says yes. - `registered: false` means the channel says no. - `registered: null` means the channel cannot answer before a message is sent. It is not a no. | Channel | What `registered` answers | | ------------------------------------------- | --------------------------------------------------------------- | | iMessage | Whether the number or email is on iMessage, as Apple reports it | This live check needs the `messages:send` scope, and each key may make 30 a minute. Checks run one at a time on each line, so check addresses one after another rather than all at once, and keep the answer: whether a number is on iMessage rarely changes. `POST /v1/handle-check` is deprecated. Use `registered=true` instead. ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ------------------------------------------------------------------------------ | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- | | [`404 not_found`](https://docs.mapier.ai/convo/api/errors/not_found) | The `lineId` is not one this key can see | Use a line that [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | The address is not one the channel accepts | Write the address in the channel's form, as [Key concepts](https://docs.mapier.ai/convo/guides/get-started/key-concepts#address) shows | | [`503 line_unavailable`](https://docs.mapier.ai/convo/api/errors/line_unavailable), `read_in_flight` | Another live check is running on that line | Wait a moment, then ask again | | [`429 rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited) | More than 30 live checks a minute | Wait `retry-after` seconds | A `503` from a live check never means the address is unreachable. Only a `200` with `registered: false` does. ## Next [#next] - [Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Opt-out (https://docs.mapier.ai/convo/guides/production/opt-out) > How a person stops your messages, and how your app opts someone out A person who asks you to stop is opted out of your whole project, on every line and channel they share with you. Mapier records it and refuses every later send to them. Only the person can opt back in. | A person… | What happens | | ------------------------------------------- | -------------------------------------------------------------------------------------------------------- | | Sends a stop word on a phone channel | Mapier opts them out for you | | Asks your agent to stop, in their own words | Your app opts them out with [`POST /v1/contacts/{contactId}/consent`](https://docs.mapier.ai/convo/api/people/opt-out-contact) | | Writes to you again later | They are opted back in | ## By keyword, on phone channels [#by-keyword-on-phone-channels] On iMessage and WhatsApp, a message that is only one of these words, in capitals, opts the person out: `STOP` · `UNSUBSCRIBE` · `OPTOUT` · `CANCEL` · `END` · `QUIT` Spaces around the word and a final `.`, `!` or `?` do not matter. Capitals do matter. `stop` and `STOP please` change nothing. | They send | Result | | --- | --- | | `STOP` | Opted out | | `STOP.` | Opted out | | `STOP!` | Opted out | | `stop` | Nothing changes | | `Stop` | Nothing changes | | `STOP please` | Nothing changes | | `OPT OUT` | Nothing changes | | `cancel my order please` | Nothing changes | | `START` | Opted back in, if they had opted out | | `hey are you there` | Opted back in, if they had opted out | A person opts back in by sending `START` or `UNSTOP`. Any other one-to-one message from them opts them back in too, unless it contains a word such as stop, cancel or quit. A message in a group chat changes nothing. A phone number belongs to one person, so a stop word on one line stops every line that reaches the same number. ## Opt someone out from your app [#opt-someone-out-from-your-app] When a person asks your agent to stop, opt them out yourself. `contactId` is on every incoming message. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/contacts/$CONTACT_ID/consent \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: optout-$CONTACT_ID" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "optedOut": true, "reason": "Asked in chat to stop messaging" }' ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; export async function optOut(contactId: string, reason: string) { const res = await fetch(`${BASE}/v1/contacts/${contactId}/consent`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": `optout-${contactId}`, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ optedOut: true, reason }), }); return res.json(); } ``` The key needs the `messages:send` scope. A second call for someone already opted out answers `200` with the first `optedOutAt`. ## Hear when someone opts out [#hear-when-someone-opts-out] Select `contact.opt_out_changed` on a webhook endpoint. `optedOut` says whether the person is now opted out, and `source` says what changed it: `inbound` for the person's own message, `api` for your app, `console` for a change in the console. New values can appear; treat one you do not know as a change you did not make. ## After an opt-out [#after-an-opt-out] Every later send to the person is refused at once, and nothing is sent. [`GET /v1/reachability`](https://docs.mapier.ai/convo/api/discovery/check-reachability) says so before you send; see [Check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send). ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ----------------------------------------------------------------------------------- | --------------------- | -------------------------------------------- | | [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed), `opted_out` | This person opted out | Do not send again. Only they can opt back in | ## Next [#next] - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # Retries (https://docs.mapier.ai/convo/guides/production/retries) > Send a request again safely, so a person never gets the same message twice A connection drops, a `503` comes back, your process restarts mid-send. Send the request again with the same `Idempotency-Key`, and Mapier answers with the first command instead of sending a second one. | What happened | Send again with | | -------------------------------------------------------- | ----------------------------------------- | | No answer, a dropped connection, a restart | The **same** key | | `409 conflict`, `idempotency_key_in_flight` | The **same** key, after a short wait | | `429`, or any other `503` | The **same** key, after the wait it gives | | A `message.send` refused with `503 upstream_unavailable` | A **new** key: that key is spent | | A result you saw: `failed` or `expired` | A **new** key, once you fix the cause | | A result you saw: `ambiguous` | Nothing yet. Check the conversation first | | `400` or `422` | Nothing. Fix the request | ## Send with a key [#send-with-a-key] Make the key from what you are doing, so the same work always gives the same key: `order-4821-photo`, `ticket-1043-first-reply`. A random key made at each attempt protects nothing. ```bash curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-8842-confirmation" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "text", "text": "Your order is on its way." } }' ``` In code, [the client below](#a-client-that-retries-for-you) sends with a key and retries safely. A key is any string of up to 200 characters: no spaces at either end. It belongs to one project. If you send no key, Mapier makes one for that request alone, so a retry without a key is a new message. ```json title="202 Accepted" { "commandId": "0192b3e1-8a4c-7d2e-9f10-3c5b7a9d1e42", "status": "queued", "repeated": true, "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` `repeated: true` means the key matched an earlier send. `commandId` is the first send's, and nothing new was queued. The result is still the first command's `command` event; reconnect with `Last-Event-ID` if you missed it. Every command honors the key on `2026-12-01`, the version these pages use. [Older versions](https://docs.mapier.ai/convo/api/versions) lists what differs before it. ## When a key is refused [#when-a-key-is-refused] When Mapier cannot answer with the first command, a repeat is refused with `409 conflict`, and nothing is sent. `details.reason` says why: | `details.reason` | Means | What to do | | ---------------------------- | -------------------------------------------------------- | --------------------------------------------------------------------------------- | | `idempotency_key_in_flight` | The first request with this key is still running | Wait, then send again with the same key | | `idempotency_key_failed` | The first send was refused and nothing went out | Send again with a new key. If `details.sentParts` lists parts, send only the rest | | `idempotency_key_unresolved` | Mapier could not confirm whether the first send went out | Check the conversation first, or the person may get it twice | | `idempotency_key_reused` | The key already named a different command | Use a new key | ## Send again after a result [#send-again-after-a-result] A key stays with its command for good. Once you have seen a `failed` or `expired` result and want the message sent, that is a new command: 1. Fix what `failureClass` named. 2. Make a new key from the old one, such as `order-8842-confirmation-2`. 3. Send with the new key. Only make a new key for a result you have seen. For a `202` you lost track of, or an `ambiguous` result, a new key can send the message twice. A `chat_background.set` and a `chat_background.remove` need a key each: one key reused across a set and a remove is answered with the first command and changes nothing more. The same goes for two different messages. Give each its own key. ## A client that retries for you [#a-client-that-retries-for-you] This client reads each refusal and waits as long as `Retry-After` says. It tries a `500` once more, waits out a `409 idempotency_key_in_flight`, and caps every loop at five retries. It sends the same `Idempotency-Key` on every attempt, so a repeat answers with the first command. It does not retry a `message.send` refused with `upstream_unavailable`: that key is spent, so the error goes back to the caller, and sending again needs a new key. ```ts const BASE = "https://api.mapier.ai"; export class MapierError extends Error { constructor( readonly status: number, readonly code: string ) { super(`${status} ${code}`); } } export async function command(type: string, body: unknown, idempotencyKey: string) { let serverErrorRetries = 0; for (let attempt = 0; ; attempt++) { const res = await fetch(`${BASE}/v1/commands/${type}`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey, "x-mapier-version": "2026-12-01", }, body: JSON.stringify(body), }); if (res.status === 202) return res.json(); // queued, NOT delivered const answer = (await res.json().catch(() => ({}))) as { error?: { code?: string; details?: { retryAfter?: number; reason?: string } }; }; const code = answer.error?.code ?? "unknown"; // A 429 and a 503 service_busy both say how long to wait. Wait that long, // then send the same request. if ((res.status === 429 || code === "service_busy") && attempt < 5) { const wait = Number(res.headers.get("retry-after") ?? answer.error?.details?.retryAfter ?? 1); await sleep(wait * 1000); continue; } // A message.send the line did not take is recorded against this key: the // key is spent, and a retry under it sends nothing. Hand it back — sending // again needs a new key. const spent = type === "message.send" && code === "upstream_unavailable"; // A 409 whose reason is idempotency_key_in_flight: the first attempt under // this key is still running. Wait, then send it again under the same key. // The other 409 reasons have no first command to return; hand them back. const inFlight = res.status === 409 && answer.error?.details?.reason === "idempotency_key_in_flight"; // Any other 503 is transient; a 500 gets exactly one retry. const transient = !spent && (res.status === 503 || inFlight || (res.status === 500 && serverErrorRetries++ < 1)); if (transient && attempt < 5) { await sleep(Math.min(2 ** attempt * 500, 8_000)); continue; } throw new MapierError(res.status, code); } } const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); ``` ## Webhook retries [#webhook-retries] When your endpoint does not answer, Mapier tries again for just under three days. Each attempt has the same event `id`, so store events by `id` and skip one you already have. [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events#when-your-endpoint-does-not-answer) has the schedule. ## Next [#next] - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Support (https://docs.mapier.ai/convo/guides/production/support) > Reach the Mapier team for access, a higher limit, or anything the API cannot tell you Some things are done by a person at Mapier, such as raising a limit or looking into a line. Email support for any of them. Write to [support@mapier.ai](mailto:support@mapier.ai) for everything on this page. | You need | Include | | ------------------------------ | ----------------------------------------------------------------------------------------- | | Access | [Book a demo](https://cal.com/mapier-homin/30min); Mapier sets up your access on the call | | A higher command limit | Your `projectId`, the steady rate and peak you need a minute, and what you are building | | Help with a message or command | The `commandId`, the `Idempotency-Key`, about when you sent it, and the full result | | A `503` that does not clear | The line, the error and when it started | | Fast help with a leaked key | Say "leaked key" in the subject | ## Get access and a line [#get-access-and-a-line] 1. [Book a demo](https://cal.com/mapier-homin/30min). Access is by approval, and Mapier sets it up on the call. 2. Sign in at [convo.mapier.ai/app](https://convo.mapier.ai/app) and create a project. 3. [Connect a line](https://docs.mapier.ai/convo/guides/connect/imessage). A person at Mapier reviews each iMessage line, so it is not instant. 4. Create a key on the **Keys** page, then follow the [Quickstart](https://docs.mapier.ai/convo/guides/get-started/quickstart). Write to support if a line request has been open longer than you expected. ## Ask for a higher command limit [#ask-for-a-higher-command-limit] Each project has one command limit, set by Mapier. There is no control for it in the console or the API. [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) shows your `projectId` and your limit. [Rate limits](https://docs.mapier.ai/convo/api/rate-limits) has the details. ## Report a line that will not send [#report-a-line-that-will-not-send] A `503` that clears within a few minutes needs nothing: wait and send again. [Retries](https://docs.mapier.ai/convo/guides/production/retries) says which key to use. One that lasts longer will not clear from your side. Send support the line and the error. ## Rotate a key [#rotate-a-key] Create a new key and revoke the old one on the **Keys** page. If the key leaked, write to support too, with "leaked key" in the subject, and Mapier handles it first. ## Before you write [#before-you-write] - A `failed` result whose `failureClass` is `content` or `target` is about the request. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery#why-a-command-failed) says what to fix. - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) answers the most common questions. # Troubleshooting (https://docs.mapier.ai/convo/guides/production/troubleshooting) > What to check when a message does not arrive, a retry misbehaves or the stream goes quiet Find what you see, then follow its steps. Most answers come down to reading the command's result on the [stream](https://docs.mapier.ai/convo/guides/receive/receive-events). A `202` means queued, not delivered. 1. Find the `command` event with the `commandId` from the `202`. 2. If it says `failed`, read `failureClass`. See [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery#why-a-command-failed). 3. If it says `succeeded`, the channel took the message. Whether it reached the phone is a receipt, on a stream opened with `?events=receipts`. 4. If you sent to an address, [check before you send](https://docs.mapier.ai/convo/guides/production/check-before-you-send) that the person can get messages on that channel. Which receipts follow depends on the channel: | Channel | Receipts after `succeeded` | | ------------------------------------------- | -------------------------- | | iMessage | Delivered and read | | WhatsApp | Delivered and read | Your own messages never arrive as incoming messages. What arrives is a `command` event with the send's result. 1. Open the stream before you send. 2. If you missed the result, reconnect with `Last-Event-ID` set to an `id` from before the send. 3. If there is still nothing after a few minutes, treat the send as unknown, and [ask support](https://docs.mapier.ai/convo/guides/production/support) with its `commandId`. The person last wrote more than 24 hours ago, or never. Send an approved [template](https://docs.mapier.ai/convo/guides/send/templates). Once they reply, write freely again. The command named something the line no longer sees. 1. A reaction to an old message: react to a recent one instead. 2. A command to a group right after someone joined or left: wait for the group's next message, then send again with a new `Idempotency-Key`. See [Groups](https://docs.mapier.ai/convo/guides/conversations/groups#rename-a-group-or-change-who-is-in-it). An id from another project answers exactly like one that does not exist. 1. Check that the id came from your own events, not from a log or another project. 2. Check that it is `conversationId`, not the message's `externalId`. That is normal. Reconnect in a loop, with `Last-Event-ID` set to the last `id` you handled, and wait a few seconds between connects: each key may connect 10 times a minute. A stream that ends with an `error` event means your key or project stopped working, and reconnecting will not help. Reconnect with `Last-Event-ID` set to the last `id` you finished handling. The stream sends everything after it, up to 90 days back. Without it, the stream starts from now. Save the `id` somewhere that survives a restart. That can happen after a reconnect, and with webhooks. Handle each event once, by its `id`. On some iMessage lines, on older software, a message with no text and no attachment means the chat background changed. Skip a received message that has no text and no attachment rather than reply to it. The retry did not carry the first attempt's `Idempotency-Key`. Use one key per piece of work, and the same key on every attempt. See [Retries](https://docs.mapier.ai/convo/guides/production/retries). The key belonged to a command that already had a result, so the `202` says `repeated: true` and nothing new was sent. To send again after a result you have seen, use a new key. See [Retries](https://docs.mapier.ai/convo/guides/production/retries#send-again-after-a-result). 1. Wait the number of seconds in `retry-after`, then send again. 2. If the stream is the cause, hold one stream open instead of reconnecting often. 3. If commands are the cause, remember every key in a project shares one limit. [Rate limits](https://docs.mapier.ai/convo/api/rate-limits) says how to ask for more. Your request is fine; the project cannot send right now. 1. `no_line`: connect a line in the console. 2. `capacity_exhausted`: every line is full. Connect another line. 3. `line_unavailable`: the line is paused, retired or offline. Its page in the console shows why. 4. Wait, then send again with the same `Idempotency-Key`. If it lasts more than a few minutes, [ask support](https://docs.mapier.ai/convo/guides/production/support). Mapier is busy, and nothing was done. Wait the seconds in `retry-after`, then send the same request again. Photos from iPhones are often HEIC, and Mapier does not convert them. Convert the file after you download it. See [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages#download-a-file). ## Still stuck [#still-stuck] 1. Find the command's result. A command with no result and one that `failed` need different answers. 2. Check the line can send this at all: [Channel support](https://docs.mapier.ai/convo/api/channel-support) lists what each channel carries. 3. [Ask support](https://docs.mapier.ai/convo/guides/production/support) with the `commandId`, the `Idempotency-Key` and the full result. ## Next [#next] - [Support](https://docs.mapier.ai/convo/guides/production/support) # Incoming messages (https://docs.mapier.ai/convo/guides/receive/incoming-messages) > Receive an iMessage or any other incoming message. Read what the person sent, download their files, and reply in the same conversation When someone writes to one of your lines, a `message` event arrives on the [stream](https://docs.mapier.ai/convo/guides/receive/receive-events), and a `message.received` event reaches your webhook endpoint. Both name the same message. ```json title="message.received data" { "messageId": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22", "conversationId": "a0000000-0000-4000-8000-000000000001", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d", "channel": "imessage", "from": "+14155550100", "text": "Is my table ready?", "contactId": "c0000000-0000-4000-8000-000000000003", "optedOut": false, "attachments": [] } ``` | You want | Read | | ----------------------------- | ------------------------------------------------------------------------------ | | Somewhere to reply | `conversationId`: send to it with [`message.send`](https://docs.mapier.ai/convo/api/messages/send) | | A message to quote in a reply | `messageId`: send it as `target.replyToMessageId` | | Who wrote | `from`, their address, and `contactId`, Mapier's id for them | | Which line got it | `lineId`, as [`GET /v1/whoami`](https://docs.mapier.ai/convo/api/discovery/get-key-details) lists it | | Their files | `attachments` | | Whether it was a group | `isGroup: true` | ## Reply to a message [#reply-to-a-message] Send to the message's `conversationId`. Your reply goes out from the same line, on the same channel. ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; type Incoming = { conversationId: string; messageId: string; text: string | null; attachments: unknown[]; }; export async function reply(message: Incoming, text: string) { // No text and no attachment: nobody wrote anything, so send nothing. if (!message.text?.trim() && message.attachments.length === 0) return; const res = await fetch(`${BASE}/v1/commands/message.send`, { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": `reply-${message.messageId}`, "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: message.conversationId }, payload: { kind: "text", text }, }), }); if (res.status !== 202) throw new Error(`send refused: ${res.status}`); return res.json(); } ``` Using the incoming `messageId` in the `Idempotency-Key` means a retry of the same reply is never sent twice. Your own messages never come back as incoming messages, so a reply cannot set off another reply. ## Not every message has text [#not-every-message-has-text] `text` is `null` when the message is only a file. Check `text` and `attachments` together before you read either. Some iMessage lines, on older software, report some changes, such as a new chat background, as a message with no text and no attachment. Nobody wrote anything: skip a received message that has no text and no attachment rather than reply to it. An app card a person sends from an iMessage app has no text and no attachment either, but it carries `kind: "app_card"` and an `appCard` block. Read the card there; [App cards](https://docs.mapier.ai/convo/guides/send/app-cards#receive-a-card) shows how. `text` arrives with the channel's own markup. `textFormat` names that markup, and `textPlain` holds the same words without it: | `text` has | `textFormat` | | ------------------------------------------------ | ------------------ | | No markup | `plain`, or absent | ## Download a file [#download-a-file] Each entry in `attachments` has an `id`, and `mimeType`, `filename` and `byteSize` as the person's device declared them, or `null`. A voice note adds `"kind": "voice_note"`, and a sticker adds `"isSticker": true`. Download a file with [`GET /v1/attachments/{id}`](https://docs.mapier.ai/convo/api/messages/download-attachment): ```bash curl https://api.mapier.ai/v1/attachments/0192e4f2-0000-4000-8000-000000000001 \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ -o receipt.jpg ``` - A `404` for a file that arrived moments ago usually means it is still uploading. Try again shortly. - The download's `content-type` is read from the file itself. A HEIC photo stays HEIC, so convert it before you show it in a browser. - The link needs your API key, so do not hand it to a browser or another service. ## When it was sent, and in what order [#when-it-was-sent-and-in-what-order] `occurredAt` is when the person sent the message, from the channel. Sort by it to show a conversation. Messages can still arrive out of order, for example after a line reconnects. ## Other things people do [#other-things-people-do] Each of these is its own event. Ask for it with `?events=` on the stream, or select it on a webhook endpoint. | A person… | Event | Guide | | ------------------------------ | -------------------------------------------- | ---------------------------------------------------------------- | | Reacts to a message | `reaction.added`, `reaction.removed` | [Reactions](https://docs.mapier.ai/convo/guides/send/reactions) | | Edits or unsends their message | `message.edited`, `message.unsent` | [Edit and unsend](https://docs.mapier.ai/convo/guides/send/edit-and-unsend) | | Votes in a poll | `poll.voted` | [Polls](https://docs.mapier.ai/convo/guides/send/polls) | | Shares their location | `location.share_started`, `location.updated` | [Location](https://docs.mapier.ai/convo/guides/send/location) | | Changes the chat background | `conversation.background_changed` | [Chat backgrounds](https://docs.mapier.ai/convo/guides/conversations/chat-backgrounds) | | Asks you to stop | `contact.opt_out_changed` | [Opt-out](https://docs.mapier.ai/convo/guides/production/opt-out) | Not every channel sends all of these: | Channel | What arrives | Opting a person out | | ------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------ | | iMessage | Everything above | A typed STOP, or the API | | WhatsApp | Reactions | A typed STOP, or the API | To opt a person out through the API, send [`POST /v1/contacts/{contactId}/consent`](https://docs.mapier.ai/convo/api/people/opt-out-contact). Nothing reports that a person is typing. ## Read what came before [#read-what-came-before] The stream starts from now. To read a conversation's earlier messages, both ways, use [`GET /v1/conversations/{id}/messages`](https://docs.mapier.ai/convo/api/conversations/list-messages). ## Next [#next] - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) - [Conversations](https://docs.mapier.ai/convo/guides/conversations/conversations) # Receive events (https://docs.mapier.ai/convo/guides/receive/receive-events) > Get a webhook for each incoming message, such as an iMessage, and each send's result, or read the same events on one open stream A send answers `202` the moment Mapier queues it. Everything after that (the send's result, a person's reply, a read receipt) arrives as an event. You get events in one of two ways, and both carry the same facts. | You want | Use | | ---------------------------------------------------- | ----------------------------------------------------------- | | Events as they happen, on a connection you hold open | [`GET /v1/response_stream`](https://docs.mapier.ai/convo/api/events/stream) | | Events posted to your own server | A webhook endpoint, made on the console's **Webhooks** page | | What happened before you were listening | [`GET /v1/events`](https://docs.mapier.ai/convo/api/events/list) | [Event types](https://docs.mapier.ai/convo/api/events/event-types) lists every event. ## Open the stream [#open-the-stream] The stream is server-sent events over HTTPS, so you can watch it with `curl`. `-N` shows each event as it arrives. ```bash tab="cURL" curl -N https://api.mapier.ai/v1/response_stream \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "x-mapier-version: 2026-12-01" \ -H "Accept: text/event-stream" ``` ```ts tab="TypeScript" const BASE = "https://api.mapier.ai"; const res = await fetch(`${BASE}/v1/response_stream`, { headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "x-mapier-version": "2026-12-01", Accept: "text/event-stream", }, }); if (!res.ok || !res.body) throw new Error(`stream status ${res.status}`); const reader = res.body.getReader(); const decoder = new TextDecoder(); let buffer = ""; for (;;) { const { value, done } = await reader.read(); if (done) break; buffer += decoder.decode(value, { stream: true }); const lines = buffer.split("\n"); buffer = lines.pop() ?? ""; // keep half a line for the next read for (const line of lines) { if (line.startsWith("data:")) console.log(JSON.parse(line.slice(5))); } } ``` ```txt title="Stream output" : connected id: 0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d10 event: message data: {"conversationId":"a0000000-0000-4000-8000-000000000001","from":"+14155550100","text":"Is my table ready?","messageId":"0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22","lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} : ping ``` Lines that start with `:` are not events. `: connected` says the stream is open, and `: ping` arrives every 25 seconds to keep it open. Two events are always on the stream: `message`, a person writing to your line, and `command`, the result of a command you sent. Add more with `?events=`, for example `?events=receipts,reactions`: | `events=` | Adds | | ------------------- | ---------------------------------------------------- | | `receipts` | A message was delivered or read | | `delivery_failures` | A message was not delivered | | `reactions` | A reaction was added or removed | | `moderation` | A person edited or unsent a message | | `polls` | A poll was created, changed or voted on | | `locations` | A person shared their location | | `conversations` | A conversation started, or a group changed | | `chat_backgrounds` | A conversation's background changed | | `gaps` | Some of a line's messages may be missing for a while | | `message.received` | Incoming messages in the webhook's shape | On some channels, some options add nothing: | Channel | Adds nothing | | ------------------------------------------- | ------------------------------------------------------------- | | iMessage | — | `?channel=`, `?conversationId=` and `?lineId=` narrow the stream to one channel, conversation or line. New event names can appear at any time: ignore a name you do not know, and keep the stream open. ## Reconnect without missing anything [#reconnect-without-missing-anything] The connection drops now and then, even when all is well. Reconnect in a loop, and send the `id:` of the last event you handled as `Last-Event-ID`. The stream sends what you missed, up to 90 days back, then carries on. 1. Save each event's `id` once you have handled it, somewhere that survives a restart. 2. When the stream ends, wait a few seconds. Each key may connect 10 times a minute. 3. Reconnect with `Last-Event-ID` set to the saved `id`. 4. Handle events by `id`, so one that arrives twice is handled once. A stream that ends with an `error` event is different: your key or project stopped working, and reconnecting will not help. If Mapier missed some of a line's messages for a while, a `line.gap` event says so, after every message it recovered has reached you. ## Receive webhooks [#receive-webhooks] A webhook endpoint gets each event as an HTTPS `POST`. Make one on the console's **Webhooks** page and pick the event types it gets, or with a personal access token through [`POST /v1/webhook-endpoints`](https://docs.mapier.ai/convo/api/webhook-endpoints/create). ```http title="What arrives" POST /your/endpoint HTTP/1.1 content-type: application/json mapier-event-id: 0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d10 mapier-timestamp: 1789378800 mapier-signature: v1=6f1a… { "id": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d10", "type": "message.received", "environment": "live", "occurredAt": "2026-09-14T09:24:31.000Z", "deliveryId": "0192a7c5-1b2c-7d3e-8f4a-5b6c7d8e9f01", "attempt": 1, "data": { "conversationId": "a0000000-0000-4000-8000-000000000001", "from": "+14155550100", "text": "Is my table ready?", "lineId": "0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d" } } ``` 1. Check the signature before you read the body. Mapier signs `"${timestamp}.${body}"` with HMAC-SHA256, using your endpoint's whole signing secret, `whsec_` included. 2. Refuse a `mapier-timestamp` more than 300 seconds from your clock. 3. Accept the request if any `v1=` entry matches. While you rotate a secret, the header carries two for 24 hours. 4. Store the event, then answer `2xx`. Do the work after. 5. Skip an event whose `id` you already stored. An event can arrive more than once, and every attempt carries the same `id`. ```ts title="verify.ts" import { createHmac, timingSafeEqual } from "node:crypto"; export function verifyWebhookSignature(input: { secret: string; // the endpoint's whole signing secret, `whsec_` included body: string | Uint8Array; // the raw request body, exactly as received timestamp: string | null | undefined; // the mapier-timestamp header signature: string | null | undefined; // the mapier-signature header toleranceSeconds?: number; }): boolean { // Return false, never throw: every input but the secret comes from the // sender, and a throw becomes a 500 that the sender retries. const { secret, body, timestamp, signature } = input; if (!secret || typeof timestamp !== "string" || typeof signature !== "string") return false; if (!/^\d{1,15}$/.test(timestamp)) return false; const tolerance = input.toleranceSeconds ?? 300; if (Math.abs(Date.now() / 1000 - Number(timestamp)) > tolerance) return false; const expected = Buffer.from( createHmac("sha256", secret).update(`${timestamp}.`).update(body).digest("hex"), "utf8" ); return signature .split(",") .map((entry) => entry.trim()) .filter((entry) => entry.startsWith("v1=")) .some((entry) => { // Compare the lower-cased hex text as bytes; never decode it, because // `Buffer.from(value, "hex")` stops silently at the first non-hex // character. Compare lengths in bytes, because `timingSafeEqual` throws // on buffers of different lengths, and non-ASCII text is longer in bytes. const presented = Buffer.from(entry.slice(3).toLowerCase(), "utf8"); return presented.length === expected.length && timingSafeEqual(presented, expected); }); } ``` Some iMessage lines, on older software, report a chat background change as a `message.received` with no text. Skip a received message that has no text and no attachment rather than reply to it. ### When your endpoint does not answer [#when-your-endpoint-does-not-answer] Each attempt has ten seconds to get a `2xx`. Anything else is tried again, 12 attempts over just under three days: after 10 seconds, 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, then every 12 hours. After the last, the console shows the delivery as **Gave up**, and **Retry now** sends it once more. A redirect counts as a failure. The event is kept for at least 90 days whatever happens, so you can still read it with [`GET /v1/events`](https://docs.mapier.ai/convo/api/events/list). The console's **Events** page shows every event, and **Inspect** shows each delivery of it. Some event types reach an endpoint only when you select them by name: a person's location, their edits and unsends, polls, group changes and chat backgrounds (`conversation.background_changed`, the stream's `chat_background`). **Select all** leaves them out. ## Next [#next] - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Results and delivery (https://docs.mapier.ai/convo/guides/receive/results-and-delivery) > Learn whether each command went out, and whether the message reached the person _Works on iMessage, WhatsApp_ A `202` says a command was queued, nothing more. Its result arrives once, as a `command` event on the stream and a `command.settled` event at your webhook. Whether the message then reached the person's phone is a separate fact, a receipt, that arrives later if the channel reports it. | You want | Read | | --------------------------------------- | ------------------------------------------------------------------------------ | | Whether a command went out | The `command` event with the `commandId` from its `202` | | Whether a message was delivered or read | A `receipt` event, on a stream opened with `?events=receipts` | | Whether a message was not delivered | A `delivery_failed` event, on a stream opened with `?events=delivery_failures` | | One message's receipts, now | [`GET /v1/messages/{messageId}/receipts`](https://docs.mapier.ai/convo/api/messages/receipts) | ## Match a result to its command [#match-a-result-to-its-command] Keep the `commandId` from each `202`. Its result names it: ```txt title="Stream output" id: 0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a37 event: command data: {"commandId":"3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71","status":"succeeded","errorCode":null,"failureClass":null,"type":"message.send","messageId":"0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a99","conversationId":"a0000000-0000-4000-8000-000000000001","lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` 1. When the `202` comes back, store its `commandId` with what you were doing. 2. When a `command` event arrives, find the stored entry by `commandId` and record the `status`. 3. A result can arrive before you read the `202`, so keep results you cannot match yet for a few minutes. 4. If no result arrives within a few minutes, reconnect with `Last-Event-ID`. Treat a command still without a result as unknown, not failed. ## What each result means [#what-each-result-means] | `status` | Did it happen? | What to do | | ------------------------ | -------------- | ------------------------------------------------------------------------------------------------ | | `succeeded` | Yes | Nothing. It went out, which is not the same as delivered | | `failed` | No | Read `failureClass`, fix what it names, then send again with a new `Idempotency-Key` | | `expired` | No | The command passed its deadline before the line took it. Send again with a new `Idempotency-Key` | | `cancelled` | No | Something stopped it on purpose. Do not send it again automatically | | `ambiguous`, `no_effect` | Unknown | Check the conversation before you send again, or the person may get it twice | `no_effect` means the channel took the command and could not show that anything changed. Treat it like `ambiguous`. `succeeded` means the channel took the message. Whether it reached the phone is a [receipt](#delivered-and-read), and a missing receipt proves nothing. ## Why a command failed [#why-a-command-failed] `failureClass` says what kind of failure it was, from a fixed list, so you can decide without learning each channel's words. `errorCode` is the channel's own word, for your logs and for [support](https://docs.mapier.ai/convo/guides/production/support). | `failureClass` | Means | What to do | | -------------- | ----------------------------------------- | ---------------------------------------------- | | `target` | The person or conversation cannot take it | Check the address or conversation | | `content` | The text or file was refused | Fix the content, then send again | | `capability` | This line cannot send this | Send something the line supports | | `line` | The line cannot send right now | Check the line in the console, then send again | | `rate_limited` | Too much, too fast | Wait, then send again | | `not_run` | It never ran | Send again | | `transport` | The channel failed on its side | Send again later | | `unknown` | Something else | Read `errorCode` | [Retries](https://docs.mapier.ai/convo/guides/production/retries) says which key to use when you send again. ### iMessage's error codes [#imessages-error-codes] On an iMessage line, `errorCode` is one of these, grouped by what to do. Log it and quote it to support; branch your code on `failureClass`. #### Fix the request, then send again [#fix-the-request-then-send-again] | `errorCode` | Meaning | | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | `invalid_target` | The line could not find the person or conversation. | | `stale_target` | The message you named is too old for this conversation, or the group just changed. Wait for its next message, then send again with a new `Idempotency-Key`. | | `payload_conflict` | The payload does not match the first command sent with this key. | | `unsupported_capability` | The line cannot carry out this command. | | `capability_not_negotiated` | The line does not support this yet. See [Channel support](https://docs.mapier.ai/convo/api/channel-support). | | `capability_constraint_violation` | The line cannot send this as written: a value is out of range, or the line does not support the feature. | | `command_claim_invalid` | The change does not fit the group as the line last saw it, such as adding someone already in it or removing someone who is not. | #### Send again: nothing changed [#send-again-nothing-changed] | `errorCode` | Meaning | | ---------------------------------- | ---------------------------------------------------------------------------------------------------- | | `gateway_rejected` | iMessage refused it. | | `send_returned_not_ok` | The send failed on the line. | | `preparation_dispatch_exhausted` | The line could not start the command in time. | | `stale_fence` | The line restarted before it ran this command. | | `expired` | The command passed its deadline before the line took it. | | `command_expired_before_execution` | The command timed out before it started; nothing changed. It usually comes with an `expired` status. | | `transfer_not_landed` | A picture the command needed did not reach the line within five minutes; nothing changed. | | `outbound_paused` | Sending was paused before the command ran. | | `invalid_session_capabilities` | A fault on the line's side, not in your request. | #### Check first: it may have happened [#check-first-it-may-have-happened] These come with an `ambiguous` result more often than a `failed` one. Do not send again without checking the conversation: the message may have been delivered. | `errorCode` | Meaning | | --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | | `outbound_echo_unconfirmed` | iMessage accepted the send, but nothing confirmed it went out. | | `connector_crash_after_effect_start` | The line stopped while sending. | | `gateway_timeout` | No answer within the deadline. | | `gateway_response_lost` | The answer was lost on the way back. | | `tapback_unverified` · `poll_vote_unverified` | The reaction or vote could not be verified afterwards. | | `group_content_unverified` · `group_update_unverified` · `group_leave_unverified` | The group operation could not be verified. | | `chat_background_unverified` | A background change started and could not be checked afterwards. Ask someone in the conversation. | | `moderation_unverified` | An edit or an unsend could not be checked afterwards. | | `name_photo_set_unverified` | A name or photo change may have started, and could not be checked afterwards. Do not send it again without checking. | | `journal_corrupt` | The line lost track of the command, so the result is unknown. | #### Cancelled by Mapier [#cancelled-by-mapier] | `errorCode` | Meaning | | -------------------- | ------------------------------------------------------------------------------------------------------------------ | | `operator_cancelled` | Someone at Mapier cancelled the command. Ask [support](https://docs.mapier.ai/convo/guides/production/support) if you did not expect it. | This list is not closed. Treat an `errorCode` you do not know as a generic failure: new codes can appear without a version change. ## Delivered and read [#delivered-and-read] Open the stream with `?events=receipts`, or select `message.delivered` and `message.read` on a webhook endpoint: ```txt title="Stream output" id: 0192a7c4-7d55-7a90-b3e1-4c6a8f2d9e04 event: receipt data: {"commandId":"3f1a0c2e-8b47-4d19-9a5e-2c6f0b8d4e71","messageId":"0192a7c4-5b1e-7c3d-9f2a-6e8d4b1c0a99","status":"delivered","occurredAt":"2026-08-24T18:03:14.000Z","lineId":"0192a7b0-3e4f-7051-8c6d-7e8f9a0b1c2d"} ``` `status` is `delivered` or `read`, and never goes backwards. What each channel reports differs: | Channel | Receipts | | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | iMessage | Mapier asks Apple about a message from about 75 seconds to about 10 minutes after it is sent. A delivery or read later than that is not reported, and a read comes only from a person who shares read receipts | | WhatsApp | As Meta reports them | ## Not delivered [#not-delivered] Open the stream with `?events=delivery_failures`, or select `message.delivery_failed` on a webhook endpoint. It means the channel took the message and later said it did not reach the person, such as Apple's "Not Delivered". 1. Do not treat it as a failed command. The command still has its own result, which can arrive after this event. 2. Match it to your send by `commandId`. 3. Nothing sends the message again for you. To try again, send a new message with a new `Idempotency-Key`. | Channel | `message.delivery_failed` | | ------------------------------------------- | ------------------------- | | iMessage | Arrives | | WhatsApp | Arrives | ## Ask about one message now [#ask-about-one-message-now] [`GET /v1/messages/{messageId}/receipts`](https://docs.mapier.ai/convo/api/messages/receipts) asks the channel what it knows about one message right now. Its `delivered` and `read` can be `null`, which means the channel does not know, not `false`. ## Next [#next] - [Retries](https://docs.mapier.ai/convo/guides/production/retries) - [Troubleshooting](https://docs.mapier.ai/convo/guides/production/troubleshooting) # App cards (https://docs.mapier.ai/convo/guides/send/app-cards) > Send a card from your own iMessage app, update it in place, and read the cards people send back _Works on iMessage_ An iMessage app lives inside Messages and posts cards into a conversation: a game move, an invitation, an order. If your company publishes one, your line can send a card as that app, replace it with a newer state, and receive the cards people send from it. A card carries your app's identity, a `url` holding the state your app's Messages extension reads, and a caption with an optional subcaption. On a phone with your app, a card marked `interactive` is drawn by your app itself. On a phone without it, Messages draws a small card with your caption and subcaption. App cards are offered to an organization on request. Until yours is, `kind: "app_card"` and `app_card.update` answer `404 unsupported_command` with `reason: not_on_channel`, and `GET /v1/whoami` does not list them. On a test line on a shared number, a card and an update go out as any message does, counted against that line's budgets. Receiving cards needs nothing turned on. ## Register your app [#register-your-app] A card goes out only as an app your organization has registered. Only an organization admin can register one: in the console, open **Channels › iMessage**, find **Apps**, and choose **Add app**. Members who are not admins see the list of apps but not **Add app**. | Field | What to enter | | --------------------- | ------------------------------------------------------------------------------------------------------------------------- | | **Name** | Your app's name. Every card you send names the app by this, and on a phone without your app it is the name the card shows | | **Team ID** | Your Apple developer Team ID: 10 capital letters and digits, under Membership details in your Apple developer account | | **Bundle Identifier** | The bundle id of your app's Messages extension, not of the app: in Xcode, the extension target's General tab | Only an organization with a dedicated live iMessage line can add an app, and it can add up to 5 apps itself. Each app belongs to one organization at a time. Register only an app your company publishes: Messages trusts the identity a card claims, and Mapier can disable an app registered by anyone else. ## Send a card [#send-a-card] Send `message.send` with `kind: "app_card"` into a conversation: ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: game-7f3a-start" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "app_card", "app": { "name": "Example Games", "teamId": "A1B2C3D4E5", "bundleId": "com.example.games.MessagesExtension" }, "url": "https://games.example.com/card?game=7f3a", "interactive": true, "layout": { "caption": "Your move", "subcaption": "Tic-tac-toe" } } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "game-7f3a-start", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "app_card", app: { name: "Example Games", teamId: "A1B2C3D4E5", bundleId: "com.example.games.MessagesExtension", }, url: "https://games.example.com/card?game=7f3a", interactive: true, layout: { caption: "Your move", subcaption: "Tic-tac-toe" }, }, }), }); const { commandId } = await res.json(); ``` - `app` is your registered app: its registered `name`, `teamId`, `bundleId` and, if you like, its `appStoreId`. Another app, a disabled one, or another name is a `422` at `payload.app`. - `url` is your app's state, `https`, `http` or `data`, up to 4096 characters. Mapier never fetches it. - `layout.caption`, and an optional `layout.subcaption`: the words Messages draws where your app does not draw the card itself. - `layout.image`, if you like: the card's picture (see [Add a picture](#add-a-picture)). - `interactive` is `false` unless you send `true`. Send `true` only for an app that draws its own bubble: Messages starts such an app as soon as the card is on screen. - `summary`, if you like: accepted and sent, though where Messages shows it is not promised (see [Limits](#limits)). - Nothing else goes beside these, not even `text`. Like any send, a card can answer a message: name it at `target.replyToMessageId`, and Mapier passes the reply on with the card. How a phone draws a card sent as a reply is not proven yet. ### Add a picture [#add-a-picture] Put an https link to the picture at `layout.image`: ```json title="payload" { "kind": "app_card", "app": { "name": "Example Games", "teamId": "A1B2C3D4E5", "bundleId": "com.example.games.MessagesExtension" }, "url": "https://games.example.com/card?game=7f3a", "layout": { "caption": "Your move", "image": "https://games.example.com/boards/7f3a.png" } } ``` - The picture is a JPEG, PNG, WebP, HEIC or HEIF image of up to 8388608 bytes (8 MiB), at a link of up to 2048 characters. Mapier fetches it and hands it to your line before the card is written. A link that cannot be fetched, or any other file, is a `422` at `payload.layout.image`, and nothing is sent. - A card with a picture cannot be a reply: `target.replyToMessageId` beside it is a `422` at `payload.layout.image`. - An update keeps the picture the card was sent with. To show another picture, send a new card. - Messages shows the picture only to a person who has your line in their contacts. Anyone else sees the card's words alone. - A line whose Mac cannot send card pictures settles the card `failed` with `capability_constraint_violation`. It never sends the card without its picture. A card goes only into a conversation that can take it: - a one-to-one conversation the line has confirmed, or a group chat it has reported; - where someone other than your line has written. A card cannot start a conversation; - whose newest message went by iMessage. A conversation that last went by SMS or RCS, or where no service has been seen yet, is refused. ### What the result means [#what-the-result-means] The send's `command` event carries `appCard.updatable`. - `succeeded` means your line handed the card to Messages. It does not mean the card was delivered, or drawn as your app's card. - `appCard.updatable: false` means Messages gave the card no id: send a new card to change it. - `ambiguous` with `errorCode: "app_card_unverified"` means the card may be in the conversation. Look before you send it again. - `failed` with `capability_constraint_violation` means the line's Mac cannot send cards, or the picture the card names. `/check` cannot see that in advance. A card is never sent twice for one `Idempotency-Key`, at any API version. ## Update a card [#update-a-card] [`app_card.update`](https://docs.mapier.ai/convo/api/messages/update-app-card) replaces a card your line sent with a new state. The person's phone keeps one card and draws the newest: ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/app_card.update \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: game-7f3a-move-2" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "messageId": "0192b3e2-3c6e-7f42-a073-5e9b1c4d8f32" }, "payload": { "url": "https://games.example.com/card?game=7f3a&move=2", "layout": { "caption": "Your move", "subcaption": "Tic-tac-toe" } } }' ``` - Name the card by the `messageId` of your first card, of any update of it, or of a card the person sent that replaced it. Every update replaces the first card, so you never track which one is newest. - The app cannot change, and an update is never a reply. Leave out `interactive` and the card keeps its last value. The picture cannot change either: `layout.image` on an update is a `422`. - One update at a time: while the card's last send has not finished, another update is a `409 conflict` with `reason: card_update_in_flight`. Wait for the `command` event, then send it again. - At most 50 updates in any hour, counting every update of one card. The next is a `429 rate_limited` with `reason: card_update_limit`: wait `details.retryAfter` seconds, then send it again under the same `Idempotency-Key`. An update that was refused or never ran does not count. - You cannot update a card the person started, a card that failed or was never confirmed, a card Messages gave no id, a card whose app was disabled, or a card in a conversation now on another line. Each is a `422` with `reason: card_not_updatable`: send a new card instead. An update is not a quiet edit. Each person in the conversation gets a new notification for every update, with sound unless their phone is silenced. Update a card when something has happened that is worth an alert, not on a timer. ## Receive a card [#receive-a-card] A card a person sends arrives as a `message.received` webhook (and a `message` event on the stream) with `kind: "app_card"`, `text: null`, no attachments, and the card under `appCard`. A received card is never a reply: ```json title="message.received, data" { "messageId": "0192b3f0-7a1c-7d22-9e3b-4c5d6e7f8a9b", "conversationId": "a0000000-0000-4000-8000-000000000001", "from": "+15555550100", "kind": "app_card", "text": null, "attachments": [], "appCard": { "app": { "name": "Example Games", "teamId": "A1B2C3D4E5", "bundleId": "com.example.games.MessagesExtension", "appStoreId": null }, "url": "https://games.example.com/card?game=7f3a&move=3", "interactive": true, "layout": { "caption": "Your move", "subcaption": "Tic-tac-toe" }, "updates": "0192b3e2-3c6e-7f42-a073-5e9b1c4d8f32" } } ``` - Any app the person has can send a card, registered with Mapier or not. - `updates` is the `messageId` of the first card this one replaces, when the app linked it. To answer on your own card, send `app_card.update` naming the received card. `updates` is best effort: an app links its card to yours only when it sends in your card's session, which is the app's choice, so `null` does not prove the card is new. - `url` is the sender's data. Treat it as untrusted input; Mapier never fetches it. - `url`, `layout` and `interactive` can each be `null`, so check each before you read it: - `url` when the card carried none, or is over 16384 characters; - `layout` when the card carried none; - all three on a card from one of Apple's own apps (team id `0000000000`), and `interactive` whenever the line could not read the card's contents. - The card's picture is not passed on. A line not yet updated to report cards delivers a card as a message with unreadable text and a picture. Skip a received message you cannot read rather than answer it. ## Limits [#limits] What Messages showed on real phones, and what that means for your cards: - **Every update alerts each person.** A card and each of its updates is its own notification. - **A notification shows the caption and the full `url`.** Put nothing private in either: no names, tokens or anything a lock screen should not show. - **`summary` is not promised.** It is accepted and sent, but in our tests Messages did not show it reliably, and never for an update. - **No pictures.** A card carries words; your app draws anything else itself. - **No delivery receipts for cards.** A card's result says your line handed it to Messages, and no `receipt` event is promised for a card or an update. In a group chat, Messages reports no card as delivered. - **No replies on a card.** The phone offers no way to reply to a card. A card your agent sends may name a reply, but how a phone draws it is not proven. - **Without `appStoreId`, a tap goes nowhere.** On a phone without your app, a tap on a card that carries no `appStoreId` cannot open anything: in our tests it ended in "cannot connect". - **A caption with a date, a time, an address or a phone number may arrive as plain text.** One card with all four stayed a card in our tests, but that is the only case we have run, so keep such details out of `layout` where you can. - **No edit or unsend.** `message.edit` and `message.unsend` refuse a card with a `422`; update it instead. - Each text is 1 to 4096 characters. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | Your organization is not offered app cards, or the line is not iMessage | Ask for app cards, or send from a live iMessage line | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) at `payload.app` | The app is not registered to your organization, is disabled, or its name differs | Register the app, or send its registered name | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | The line has not confirmed this conversation yet | Send a text first | | [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed), `recipient_must_write_first` | Nobody but your line has written in the conversation. On a test line on a shared number, also: the person has not texted the line, is no longer connected, or has left 20 turns or 100 messages unanswered since they last texted | Wait until someone writes | | [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed), `app_card_needs_imessage` | The conversation's newest message did not go by iMessage | Wait until the person writes by iMessage | | [`409 conflict`](https://docs.mapier.ai/convo/api/errors/conflict), `card_update_in_flight` | The card's last send has not finished | Wait for its `command` event, then update again | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `card_not_updatable` | This card cannot be updated | Send a new card | | [`429 rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited), `card_update_limit` | The card has had 50 updates in the past hour | Wait `details.retryAfter` seconds, then update again | | [`429 rate_limited`](https://docs.mapier.ai/convo/api/errors/rate_limited), `shared_line` | A test line on a shared number: its budget for your project is spent for now | Wait, then send again | | [`409 limit_reached`](https://docs.mapier.ai/convo/api/errors/limit_reached) | A test line's daily limit is reached | Wait until 00:00 UTC, when it resets | ## Next [#next] - [Update an app card](https://docs.mapier.ai/convo/api/messages/update-app-card) - [Send a message › `app_card`](https://docs.mapier.ai/convo/api/messages/send#kinds) - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) # Buttons and lists (https://docs.mapier.ai/convo/guides/send/buttons-and-lists) > Send choices the person taps instead of typing _Works on WhatsApp_ A `choices` message puts buttons or a list under your text. The person taps one, and their pick comes back as a message. ## Send buttons [#send-buttons] On WhatsApp, `interactive` takes Meta's shape: `type` (`button` or `list`), `body.text`, and its `action`. It holds up to three reply buttons, or a list of up to ten rows. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: booking-2481-confirm" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "choices", "interactive": { "type": "button", "body": { "text": "Still on for 7pm?" }, "action": { "buttons": [ { "type": "reply", "reply": { "id": "yes", "title": "Yes" } }, { "type": "reply", "reply": { "id": "move", "title": "Move it" } } ] } } } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "booking-2481-confirm", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "choices", interactive: { type: "button", body: { text: "Still on for 7pm?" }, action: { buttons: [ { type: "reply", reply: { id: "yes", title: "Yes" } }, { type: "reply", reply: { id: "move", title: "Move it" } }, ], }, }, }, }), }); const { commandId } = await res.json(); ``` It goes to one person, not a group, and only within 24 hours of the person's last message. **Demo: Buttons** (`message.send · kind: choices`) On WhatsApp: - Buttons: `interactive: button` - List: `interactive: list` ## Receive a pick [#receive-a-pick] A tap comes back as a `message.received` event of `kind: interactive_reply`, with what they tapped in `interactiveReply`. [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) shows the whole event. ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | | [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed), `outside_service_window` | More than 24 hours since the person's last message | Send a [template](https://docs.mapier.ai/convo/guides/send/templates) | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | Too many buttons or rows, or sent into a group | Send at most three buttons or ten rows, to one person | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not send choices | List the choices in a text | ## Next [#next] - [Templates](https://docs.mapier.ai/convo/guides/send/templates) - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # Contact cards (https://docs.mapier.ai/convo/guides/send/contact-cards) > Share your line's name and photo, or send a contact card _Works on iMessage, WhatsApp_ On iMessage, [Share the profile](https://docs.mapier.ai/convo/api/line-profile/share) offers your line's name and photo to the person. Without it, they see whatever their own contacts have for your number, usually only the number. To send anyone else's card, see [Send someone's contact card](#send-someones-contact-card). ## Share your line's card [#share-your-lines-card] Name a one-to-one conversation the person has written in. The payload is empty. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/profile.share \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: share-card-4821" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": {} }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/profile.share", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "share-card-4821", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: {}, }), }); const { commandId } = await res.json(); ``` The result is `succeeded` whether or not Messages showed the prompt. Messages often skips it when the person has already seen your card. To change the name or photo first, see [Name and photo](https://docs.mapier.ai/convo/guides/lines/name-and-photo). **Demo: Share the profile** (`profile.share`) On iMessage: - Share the profile: `profile.share` _In a browser, a small phone is here playing the agent's name and photo arriving with its first reply. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Send a contact card: `message.send · kind: contact` ## Send someone's contact card [#send-someones-contact-card] Send the name and number of another person or a business, as a card the person can save to their contacts. On iMessage, send a `.vcf` file with `message.send` and `kind: "media"`. iMessage shows it as a contact card. Serve the file as `text/vcard`, from `BEGIN:VCARD` to `END:VCARD`, in UTF-8. ```json { "kind": "media", "url": "https://example.com/team/support.vcf" } ``` It goes out like any other [file](https://docs.mapier.ai/convo/guides/send/images-and-files). On WhatsApp, `kind: "contact"` sends one or more cards. Each needs `name.formatted_name`, and can add `phones`, `emails` and the rest of Meta's contact fields. It goes to one person, not a group. ```json { "kind": "contact", "contacts": [ { "name": { "formatted_name": "Front desk" }, "phones": [{ "phone": "+14155550199", "type": "WORK" }] } ] } ``` ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | ------------------------------------------------------------------------------------ | ------------------------------------------------------- | ------------------------------------------------------------ | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | Not a one-to-one conversation the person has written in | Share in a one-to-one conversation the person has written in | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | A card has no name | Add `name.formatted_name` | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not share contact cards | Send a `.vcf` file, or the details in a text | ## Next [#next] - [Buttons and lists](https://docs.mapier.ai/convo/guides/send/buttons-and-lists) - [Name and photo](https://docs.mapier.ai/convo/guides/lines/name-and-photo) # Edit and unsend (https://docs.mapier.ai/convo/guides/send/edit-and-unsend) > Change or take back a message your line sent, and hear when a person does _Works on iMessage_ [Edit a message](https://docs.mapier.ai/convo/api/messages/edit) changes the text of a message your line sent. [Unsend a message](https://docs.mapier.ai/convo/api/messages/unsend) takes it back. Both name the message by its `conversationId` and `messageId`, from the send's result. ## Edit a message [#edit-a-message] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.edit \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: edit-0192b3e1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001", "messageId": "0192b3e1-6a02-7e11-8c4d-2b9f7e3a5d22" }, "payload": { "text": "Your table is ready at 8." } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.edit", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "edit-0192b3e1", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001", messageId: "0192b3e1-6a02-7e11-8c4d-2b9f7e3a5d22", }, payload: { text: "Your table is ready at 8." }, }), }); const { commandId } = await res.json(); ``` ## Unsend a message [#unsend-a-message] Send `message.unsend` with the same `target` and no payload. **Demo: Edit** (`message.edit`) On iMessage: - Edit: `message.edit` - Unsend: `message.unsend` _In a browser, a small phone is here playing a message being edited, a message being unsent. It is a sketch of what the contact's iPhone shows in iMessage._ ## Limits [#limits] On iMessage, an edit or unsend works only inside Apple's window after the message was sent. The copy Mapier keeps is not changed: the conversation's history still shows the first text, and an unsent message stays in it. ## When an edit fails after sending [#when-an-edit-fails-after-sending] An edit or unsend that names a message the line no longer finds inside its window ends as a `failed` result with `errorCode: "stale_target"`. A result of `ambiguous` means the line could not tell whether the message changed. Do not retry it; if it matters, send a short correction as a new message. ## Hear when a person edits or unsends [#hear-when-a-person-edits-or-unsends] A person's edit or unsend arrives as a `message.edited` or `message.unsent` event, only if you ask for it: open the stream with `?events=moderation`, or subscribe a webhook to the events by name. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | ------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ---------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `invalid_target` | The message is not in that conversation, or not from this line | Check the `messageId` | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `not_yet_addressable` | The message is still being sent, or failed | Wait for its result | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `window_elapsed` | Too long since the message was sent | Send a correction as a new message | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not edit or unsend | Send a correction as a new message | ## Next [#next] - [Show typing, mark read](https://docs.mapier.ai/convo/guides/send/typing-and-read) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # Effects (https://docs.mapier.ai/convo/guides/send/effects) > Send a text with a bubble or full-screen animation _Works on iMessage_ An effect is an animation Messages plays with a text, such as confetti across the screen. Add `effect` beside the text. It goes only into a conversation the person has written in, or a group chat. ## Send an effect [#send-an-effect] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: booking-2481-confirmed" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "text", "text": "Your table is confirmed!", "effect": "impact" } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "booking-2481-confirmed", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "text", text: "Your table is confirmed!", effect: "impact" }, }), }); const { commandId } = await res.json(); ``` **Demo: Slam** (`message.send · effect: impact`) On iMessage: - Slam: `effect: impact` - Loud: `effect: loud` - Gentle: `effect: gentle` - Invisible Ink: `effect: invisibleink` _In a browser, a small phone is here playing the bubble effects: slam, loud, gentle and invisible ink. It is a sketch of what the contact's iPhone shows in iMessage._ ## The effects [#the-effects] Four animate the bubble: | Effect | What the person sees | | -------------- | ------------------------------------------------------------------ | | `impact` | The bubble slams into the conversation. | | `loud` | The bubble swells, shakes, then settles back. | | `gentle` | The bubble arrives small, then eases up to normal size. | | `invisibleink` | The bubble hides under shifting static until the person swipes it. | Eight take over the screen: | Effect | What the person sees | | ------------- | ------------------------------------------------------ | | `confetti` | Confetti falls across the conversation. | | `lasers` | Laser beams sweep the screen. | | `fireworks` | Fireworks burst over a darkened screen. | | `balloons` | Balloons rise up the screen. | | `spotlight` | The screen dims and a spotlight picks out the message. | | `echo` | The message multiplies across the screen. | | `love` | A big heart swells out of the message, then floats up. | | `celebration` | The screen goes dark and golden sparks pour in. | `sparkles` is a second name for `celebration`. The names are Apple's, and do not always match the Messages picker: `impact` is the one shown as "Slam". Any other name is refused. _In a browser, a small phone is here playing the screen effects: confetti, lasers, fireworks, balloons, spotlight, echo, love and celebration. It is a sketch of what the contact's iPhone shows in iMessage._ ## Not everyone sees the animation [#not-everyone-sees-the-animation] People on iPhone, iPad, Mac and Apple Watch see the effect. Someone reading over SMS or RCS, or on another device, gets only the text, and so does a person who turned off auto-playing message effects. The result is still `succeeded`, and nothing says whether the animation played. Write the message so it makes sense without it. ## What a line cannot carry [#what-a-line-cannot-carry] A line whose channel has no effects refuses `effect` with `422 validation_failed` at `payload.effect`, and nothing is sent. Send `options.degrade: "adapt"` to send the text without the effect instead. ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | -------------------------------------------------------------------------------------------- | --------------------------------------------------- | ------------------------------ | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | The name is not one of the effects | Pick one from the tables above | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | The person has not written in this conversation yet | Send a plain text first | ## Next [#next] - [Reactions](https://docs.mapier.ai/convo/guides/send/reactions) - [Text](https://docs.mapier.ai/convo/guides/send/text) # Images and files (https://docs.mapier.ai/convo/guides/send/images-and-files) > Send photos, video, audio and documents by link, with optional text _Works on iMessage, WhatsApp_ Put a public https link to each file in a `media` message. Mapier or the channel fetches the file, so keep the link working until the result arrives. | You want | Send | | ----------------------------- | -------------------------------------------------------------------------- | | One photo or file | `media` with one link | | Several photos as one message | `multipart` with several photo parts, on iMessage | | Photos with text | `multipart` with photo and text parts, on iMessage | | A contact card | [`contact`](https://docs.mapier.ai/convo/guides/send/contact-cards), or a `.vcf` file in `media` | | A sticker | [`sticker`](https://docs.mapier.ai/convo/guides/send/stickers) | | Channel | Words with a file | Files in one message | | ------------------------------------------- | --------------------------------------- | --------------------------------- | | iMessage | A text part in a `multipart` | Up to 10 photos, in a `multipart` | | WhatsApp | A `caption`, up to 1,024 characters | One | ## Send a photo with text [#send-a-photo-with-text] This reply goes into a conversation the person started. To write to someone new, check [who can write first](https://docs.mapier.ai/convo/guides/production/check-before-you-send). ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-photo" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "multipart", "parts": [ { "kind": "media", "url": "https://example.com/orders/4821/table.jpg" }, { "kind": "text", "text": "Yes, by the window." } ] } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order-4821-photo", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "multipart", parts: [ { kind: "media", url: "https://example.com/orders/4821/table.jpg" }, { kind: "text", text: "Yes, by the window." }, ], }, }), }); const { commandId } = await res.json(); ``` ```json title="202 Accepted" { "commandId": "0192b3e1-…", "status": "queued", "repeated": false, "lineId": "0192a7b0-…", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` Keep `commandId`. Its result on the stream says whether the file went out. On WhatsApp, the same photo with text is one `media` message with a `caption`: ```json { "kind": "media", "url": "https://example.com/orders/4821/table.jpg", "caption": "Yes, by the window." } ``` **Demo: Photo with text** (`message.send · multipart: table.jpg · text`) On iMessage: - Photo with text: `multipart: table.jpg · text` - Photo: `media: table.jpg` - Several photos: `multipart: 4 photos` - PDF: `media: menu.pdf` _In a browser, a small phone is here playing a photo with text, a photo, four photos in one message, a PDF file. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Photo with text: `media: table.jpg · caption` - Photo: `media: table.jpg` - PDF: `media: menu.pdf` A single photo or file is `media` with one `url`. On iMessage, nothing else goes beside it: ```json { "kind": "media", "url": "https://example.com/orders/4821/receipt.pdf" } ``` A `multipart` holds 2 to 20 parts in the order you list them, at most 10 of them photos, and no link twice. Mapier fetches every link before the message goes out. If one link fails, nothing is sent and the error names the part. ## Limits [#limits] [Send a message › Files](https://docs.mapier.ai/convo/api/messages/send#files) lists the largest file and the most files per message on each channel. | Channel | Who fetches the link | What it takes | | ------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | iMessage | Mapier, before it sends | https only, at most 8 MiB: an image, a PDF, common audio or video, or a vCard (`.vcf`) whose declared type matches its bytes | On iMessage, a photo or file goes only into a conversation the person has written in, or a group chat. ## When a file fails after sending [#when-a-file-fails-after-sending] A file the channel cannot use ends as a `failed` result: ```text title="Stream output" id: 0192… event: command data: {"commandId":"0192b3f7-…","type":"message.send","status":"failed","failureClass":"content","errorCode":"…","messageId":null,"conversationId":"a0000000-…","lineId":"0192a7b0-…"} ``` `failureClass: content` means the file or text was refused. Fix the file, then send it again. `errorCode` is the channel's own word, for your logs. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) lists every class. ## Receive a file [#receive-a-file] An incoming `message.received` event lists each file in `attachments`. Download any file with [`GET /v1/attachments/{id}`](https://docs.mapier.ai/convo/api/messages/download-attachment). ```json title="message.received data, with one file" { "messageId": "0192d0a1-…", "conversationId": "a0000000-0000-4000-8000-000000000001", "lineId": "0192a7b0-…", "channel": "imessage", "from": "+15550100100", "text": "Here is my receipt.", "attachments": [ { "id": "0192e4f2-…", "mimeType": "image/jpeg", "filename": "receipt.jpg", "byteSize": 482113 } ] } ``` `mimeType`, `filename` and `byteSize` are what the person's device declared, or `null`. A voice note adds `"kind": "voice_note"`, and a sticker adds `"isSticker": true`. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. A problem Mapier cannot check up front ends as a `failed` result instead. | Error | Means | Fix | | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | --------------------------------------------------------------------------- | | [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | This person cannot get files from you yet | Check [who can write first](https://docs.mapier.ai/convo/guides/production/check-before-you-send) | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | A `multipart` on a line whose channel takes one file per message | Send one file per message | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | The person has not written in this conversation yet | Send a text first | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `media_too_large` | The file is too large | Send a smaller file | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `unsupported_media_type` | The file type is not supported | Convert the file | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `media_fetch_failed` | Mapier could not fetch the link | Check the link, then retry | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `media_fetch_refused` | The link is not https, or points inside a private network | Host the file at a public https link | | [`503 service_busy`](https://docs.mapier.ai/convo/api/errors/service_busy) | Mapier is busy fetching many files | Wait `retryAfter` seconds, then retry | ## Next [#next] - [Links](https://docs.mapier.ai/convo/guides/send/links) - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # Links (https://docs.mapier.ai/convo/guides/send/links) > Send a link that the person's phone shows as a preview card _Works on iMessage, WhatsApp_ A `link` message sends one web address. The person's phone builds the preview card itself, from the title, description and image the page publishes. ## Send a link [#send-a-link] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-link" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "link", "url": "https://example.com/orders/4821" } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order-4821-link", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "link", url: "https://example.com/orders/4821" }, }), }); const { commandId } = await res.json(); ``` ```json title="202 Accepted" { "commandId": "0192b3e1-…", "status": "queued", "repeated": false, "lineId": "0192a7b0-…", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` Nothing goes beside `kind` and `url`. **Demo: Link** (`message.send · kind: link`) On iMessage: - Link: `kind: link` _In a browser, a small phone is here playing a link with its preview card. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Link: `kind: link` ## Get a good preview [#get-a-good-preview] You send only the address. There is no field for a title, a description or an image. Give the page `og:title`, `og:description` and `og:image` tags, and the card shows all three. A page without them gets a plain card, often just the address. On WhatsApp the link goes out as a text with WhatsApp's preview turned on. ## Limits [#limits] The address is an absolute `http` or `https` link of at most 2,048 characters, with no spaces or line breaks. Shorten long tracking links rather than cutting them. On iMessage a link goes only into a conversation the person has written in, or a group chat. To start with someone new, send a text first. ## Receive a link [#receive-a-link] A link a person sends arrives as a `message.received` event with the address in `text`. [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) shows the whole event. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | -------------------------------------------------------------------------------------------- | --------------------------------------------------- | -------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | The address is not an absolute http or https link | Send the full address | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | The person has not written in this conversation yet | Send a text first | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not send link cards | Send the address in a text | ## Next [#next] - [Stickers](https://docs.mapier.ai/convo/guides/send/stickers) - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # Location (https://docs.mapier.ai/convo/guides/send/location) > Ask a person to share their location, or send a place on a map _Works on iMessage, WhatsApp_ On iMessage, a `location_request` puts a card in the conversation that asks the person to share their location. If they tap it and choose how long to share, their location arrives later as events. ## Ask for a location [#ask-for-a-location] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: pickup-4821-where" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "location_request" } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "pickup-4821-where", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "location_request" }, }), }); const { commandId } = await res.json(); ``` ```json title="202 Accepted" { "commandId": "0192b3e1-…", "status": "queued", "repeated": false, "lineId": "0192a7b0-…", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` Nothing goes beside `kind`. To say why you are asking, send a text first. `succeeded` means the card was sent, never that the person shared. **Demo: Ask for a location** (`message.send · kind: location_request`) On iMessage: - Ask for a location: `kind: location_request` - Send a place: `kind: link` _In a browser, a small phone is here playing a location request, and the contact sharing their location, an Apple Maps link drawn as a map pin. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Ask for a location: `kind: location_request` - Send a place: `kind: location` ## Send a place [#send-a-place] A place is a pin on a map, with its name. On iMessage, send an Apple Maps link with `message.send` and `kind: "link"`. iMessage shows it as a map pin. Put the latitude and longitude in `coordinate`, and the place's name, URL-encoded, in `name`: ```json { "kind": "link", "url": "https://maps.apple.com/place?coordinate=51.5136,-0.1365&name=Mapier%20Caf%C3%A9" } ``` It goes out like any other [link](https://docs.mapier.ai/convo/guides/send/links). On WhatsApp, `kind: "location"` sends a pin on a map, with an optional name and address: ```json { "kind": "location", "latitude": 51.5136, "longitude": -0.1365, "name": "Mapier Café", "address": "12 Example Street, London" } ``` ## Limits [#limits] A location request goes only into a one-to-one conversation the person has written in. A group chat, or someone new, is refused. A place goes where any link goes: a conversation the person has written in, or a group chat. ## Receive a location [#receive-a-location] A shared location reaches you only if you ask for it. Open the stream with `?events=locations`, or subscribe a webhook to the events by name: 1. `location.share_started` when the person starts sharing. 2. `location.updated` with a new position about every 30 seconds. 3. `location.share_ended` when they stop. The coordinates are a person's. You are responsible for how you store and use them. [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) explains how to subscribe. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | -------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ---------------------------------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | Not a one-to-one conversation the person has written in | Ask in a one-to-one conversation the person has written in | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | A key beside `kind`, such as `text` | Send the words as a text first | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not ask for locations | Ask in a text | ## Next [#next] - [Contact cards](https://docs.mapier.ai/convo/guides/send/contact-cards) - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) # Pick what to send (https://docs.mapier.ai/convo/guides/send/pick-what-to-send) > One command sends every kind of message. Pick the kind that fits Every message goes out through one command, `POST /v1/commands/message.send`. The body has two parts: `target` says who gets it, and `payload` says what it is. Set `payload.kind` to the kind of message. ```json title="Request" { "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "text", "text": "Yes, by the window." } } ``` ## Kinds [#kinds] | You want | `kind` | Guide | | ----------------------------------------------------------------------- | ------------------ | --------------------------------------------------------- | | Words | `text` | [Text](https://docs.mapier.ai/convo/guides/send/text) | | A photo or file | `media` | [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files) | | Text and photos as one message | `multipart` | [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files) | | A link with a preview card | `link` | [Links](https://docs.mapier.ai/convo/guides/send/links) | | A sticker | `sticker` | [Stickers](https://docs.mapier.ai/convo/guides/send/stickers) | | Ask for a location | `location_request` | [Location](https://docs.mapier.ai/convo/guides/send/location) | | A poll | `poll` | [Polls](https://docs.mapier.ai/convo/guides/send/polls) | | A card from your iMessage app | `app_card` | [App cards](https://docs.mapier.ai/convo/guides/send/app-cards) | | A place on a map | `location` | [Location](https://docs.mapier.ai/convo/guides/send/location) | | Contact cards | `contact` | [Contact cards](https://docs.mapier.ai/convo/guides/send/contact-cards) | | Buttons or a list to pick from | `choices` | [Buttons and lists](https://docs.mapier.ai/convo/guides/send/buttons-and-lists) | | An approved template | `template` | [Templates](https://docs.mapier.ai/convo/guides/send/templates) | [Channel support](https://docs.mapier.ai/convo/api/channel-support) shows which kinds each channel takes. ## Who gets it [#who-gets-it] Name a conversation, or a person. - **A conversation:** `target.conversationId`, from a `message.received` event or [List conversations](https://docs.mapier.ai/convo/api/conversations/list). Mapier sends from the same line, on the same channel. - **A person:** `target.recipientExternalId`, their address in the channel's own form. A first message to someone new opens a conversation. | Channel | Address | Who writes first | | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | iMessage | A phone number with a plus sign and country code, such as `+14155550123` | Your agent, with a plain text. Other kinds go only into a conversation the person has written in, or a group chat, so send a text first and use the `conversationId` that comes back | | WhatsApp | A phone number, as on iMessage | Your agent, with a [template](https://docs.mapier.ai/convo/guides/send/templates). Within 24 hours of the person's last message, any kind can go | ## What a line cannot carry [#what-a-line-cannot-carry] If a payload key the line does not take carries a value, the send is refused with `422 validation_failed` naming that key, and nothing is sent. A key set to `null` or to an empty list is ignored. To let Mapier drop or split what the channel cannot carry instead, such as an effect, send `options.degrade: "adapt"`. The `202` then lists what it changed in `adaptations`. ## After you send [#after-you-send] `202 Accepted` means Mapier accepted the request, not that the message arrived. The command's result says whether it went out: `event: command` on the stream, `command.settled` at a webhook. Delivered and read arrive later. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) explains each one. A retry with the same `Idempotency-Key` never sends twice; [Retries](https://docs.mapier.ai/convo/guides/production/retries) explains. ## Next [#next] - [Text](https://docs.mapier.ai/convo/guides/send/text) - [Send a message](https://docs.mapier.ai/convo/api/messages/send) # Polls (https://docs.mapier.ai/convo/guides/send/polls) > Send a poll, vote in one, and read every vote _Works on iMessage_ A `poll` message asks a question with 2 to 12 choices. Votes come back as events you ask for, and your line can vote too. ## Send a poll [#send-a-poll] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: lunch-poll-1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "poll", "question": "Where for lunch?", "options": ["Ramen", "Pho", "Tacos"] } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "lunch-poll-1", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "poll", question: "Where for lunch?", options: ["Ramen", "Pho", "Tacos"] }, }), }); const { commandId } = await res.json(); ``` ```json title="202 Accepted" { "commandId": "0192b3e1-…", "status": "queued", "repeated": false, "lineId": "0192a7b0-…", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` **Demo: Poll** (`message.send · kind: poll`) On iMessage: - Poll: `kind: poll` _In a browser, a small phone is here playing a native poll. It is a sketch of what the contact's iPhone shows in iMessage._ ## Limits [#limits] The question and each choice are 1 to 128 characters on one line, and each choice appears once. Nothing else goes beside them, not even `text`. On iMessage a poll goes only into a conversation the person has written in, or a group chat. ## Read the votes [#read-the-votes] Votes reach you only if you ask for them. Open the stream with `?events=polls`, or subscribe a webhook to the events by name: 1. `poll.created` when a poll appears, yours or the person's, with the id of each choice. 2. `poll.voted` and `poll.vote_cleared` when someone votes or takes a vote back. 3. `poll.options_changed` with the whole new list when someone adds a choice. Replace the list you hold. ## Vote in a poll [#vote-in-a-poll] [Vote in a poll](https://docs.mapier.ai/convo/api/messages/vote-in-poll) names the poll at `payload.pollExternalId` and the choice at `payload.optionExternalId`, both from `poll.created`. A vote adds a choice; it never takes one back. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | -------------------------------------------------------------------------------------------- | --------------------------------------------------------- | --------------------------------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | A question or choice is too long, or a choice is repeated | Shorten it, and list each choice once | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | The person has not written in this conversation yet | Send a text first | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not send polls | Send choices where the channel has them, or ask in a text | ## Next [#next] - [Effects](https://docs.mapier.ai/convo/guides/send/effects) - [Receive events](https://docs.mapier.ai/convo/guides/receive/receive-events) # Reactions (https://docs.mapier.ai/convo/guides/send/reactions) > React to a message with an emoji or an iMessage tapback, take it back, and see the reactions people add _Works on iMessage, WhatsApp_ [Add a reaction](https://docs.mapier.ai/convo/api/reactions/add) puts one emoji on a message, and [Remove a reaction](https://docs.mapier.ai/convo/api/reactions/remove) takes it back. ## React to a message [#react-to-a-message] Name the conversation at `target.conversationId`, the message at `target.messageId` (the `messageId` of its `message.received` event), and the emoji at `payload.emoji`. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/reaction.set \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: react-0192d0a1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001", "messageId": "0192d0a1-6a02-7e11-8c4d-2b9f7e3a5d22" }, "payload": { "emoji": "❤️" } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/reaction.set", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "react-0192d0a1", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001", messageId: "0192d0a1-6a02-7e11-8c4d-2b9f7e3a5d22", }, payload: { emoji: "❤️" }, }), }); const { commandId } = await res.json(); ``` You can also name the message by the channel's own id, its `platformMessageId`, at `payload.targetExternalId`. **Demo: Love** (`reaction.set · emoji: ❤️`) On iMessage: - Love: `emoji: ❤️` - Like: `emoji: 👍` - Dislike: `emoji: 👎` - Ha ha: `emoji: 😂` - Emphasize: `emoji: ‼️` - Question: `emoji: ❓` - Fire: `emoji: 🔥` _In a browser, a small phone is here playing a heart reaction on the contact's message, a thumbs-up reaction, a thumbs-down reaction, a laughing reaction, an emphasis reaction, a question-mark reaction, a fire reaction. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Thumbs up: `emoji: 👍` - Heart: `emoji: ❤️` - Tears of joy: `emoji: 😂` - Party popper: `emoji: 🎉` - Fire: `emoji: 🔥` - Folded hands: `emoji: 🙏` On iMessage, send one of the six tapbacks or any emoji. On WhatsApp, any emoji. Each sender has one reaction per message, so your line's new reaction replaces its earlier one. A reaction goes only within 24 hours of the person's last message. ## Take it back [#take-it-back] Send `reaction.remove` naming the same message. On iMessage, name the same emoji at `payload.emoji`. On WhatsApp, leave `emoji` out: the line's one reaction comes off. ## Receive reactions [#receive-reactions] A reaction a person adds or takes off arrives as a `reaction.added` or `reaction.removed` event, on a stream opened with `?events=reactions` or at a webhook. Each names the `messageId`, the `emoji`, and who reacted in `actor`. Changing a reaction is a `reaction.added` for the new one and a `reaction.removed` for the old. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | ----------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | The message is not in this conversation, or not named | Name the message by its `messageId` | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) at `payload.emoji` | The channel does not take that emoji, or `reaction.remove` breaks the channel's rule for `emoji` | Follow the channel's rule above | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not take reactions | Reply with a text | ## Next [#next] - [Edit and unsend](https://docs.mapier.ai/convo/guides/send/edit-and-unsend) - [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) # Stickers (https://docs.mapier.ai/convo/guides/send/stickers) > Send an emoji or an image as a sticker, on its own or stuck onto a message _Works on iMessage, WhatsApp_ A sticker is a picture drawn without a bubble. Send `kind: "sticker"` with the picture, and no text beside it. ## Send a sticker [#send-a-sticker] ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-sticker" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "sticker", "emoji": "🎉" } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order-4821-sticker", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "sticker", emoji: "🎉" }, }), }); const { commandId } = await res.json(); ``` ```json title="202 Accepted" { "commandId": "0192b3e1-…", "status": "queued", "repeated": false, "lineId": "0192a7b0-…", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` **Demo: Sticker** (`message.send · kind: sticker`) On iMessage: - Sticker: `emoji: 🎉` _In a browser, a small phone is here playing an image sticker stuck onto a message. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Sticker: `url: sticker.webp` ## Stick it onto a message [#stick-it-onto-a-message] On iMessage, give exactly one of `emoji` (one emoji) or `url` (an https link to a PNG, GIF or JPEG of at most 512,000 bytes and 618 px on a side). To stick it onto a message the person sent, add: 1. `attachToMessageExternalId`: the `platformMessageId` of their `message.received` event. 2. `partIndex` (optional): which part of a message with several parts, from 0. 3. `placement` (optional): `x` and `y` on the bubble, `scale`, and `rotation` in degrees. ```json { "kind": "sticker", "emoji": "❤️", "attachToMessageExternalId": "3F2A9C1E-7B44-4D0B-9E2A-1C5D8F0B6A77", "placement": { "x": 0.8, "y": 0.2, "scale": 1, "rotation": 15 } } ``` A sticker goes only into a conversation the person has written in, or a group chat. ## On WhatsApp [#on-whatsapp] A WhatsApp sticker is a WebP image by link, whose path ends in `.webp`, sent on its own: ```json { "kind": "sticker", "url": "https://example.com/stickers/thanks.webp" } ``` ## Receive a sticker [#receive-a-sticker] A sticker a person sends arrives in a `message.received` event's `attachments`, with `"isSticker": true`. [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files#receive-a-file) shows how to download it. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | -------------------------------------------------------------------------------------------- | --------------------------------------------------------- | ---------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | Not exactly one emoji, or the image is outside its limits | Send one emoji, or a smaller image | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | The person has not written in this conversation yet | Send a text first | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not send stickers | Send an image in `media` | ## Next [#next] - [Location](https://docs.mapier.ai/convo/guides/send/location) - [Reactions](https://docs.mapier.ai/convo/guides/send/reactions) # Templates (https://docs.mapier.ai/convo/guides/send/templates) > Send an approved template, the message that opens a conversation on WhatsApp _Works on WhatsApp_ You can reply freely for 24 hours after a person's last message. After that, or to write to someone first, send a template Meta has approved for your WhatsApp Business Account. [List templates](https://docs.mapier.ai/convo/api/lines/list-templates) lists the approved ones on a line. ## Send a template [#send-a-template] Name the template, the language it was approved in, and the values for its placeholders in Meta's `components` shape. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: booking-2481-reminder" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "channel": "whatsapp", "recipientExternalId": "+447700900123" }, "payload": { "kind": "template", "template": { "name": "booking_reminder", "language": "en_GB", "components": [{ "type": "body", "parameters": [{ "type": "text", "text": "7pm" }] }] } } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "booking-2481-reminder", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { channel: "whatsapp", recipientExternalId: "+447700900123" }, payload: { kind: "template", template: { name: "booking_reminder", language: "en_GB", components: [{ type: "body", parameters: [{ type: "text", text: "7pm" }] }], }, }, }), }); const { commandId } = await res.json(); ``` ## When a template fails after sending [#when-a-template-fails-after-sending] Mapier does not check Meta's approval before sending. A template that is not approved, or is paused, is accepted and then ends as a `failed` result. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) lists every class. **Demo: Template** (`message.send · kind: template`) On WhatsApp: - Template: `template: booking_reminder` ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ------------------------------------------------------------------------------------ | ------------------------------------------ | ---------------------------------- | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | The name or language is missing | Name the template and its language | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not send templates | Send a text | ## Next [#next] - [Polls](https://docs.mapier.ai/convo/guides/send/polls) - [Connect WhatsApp](https://docs.mapier.ai/convo/guides/connect/whatsapp#the-reply-window) # Text (https://docs.mapier.ai/convo/guides/send/text) > Send a text message, and add formatting, a subject or a quoted reply _Works on iMessage, WhatsApp_ A text is a `message.send` whose payload has `kind: "text"` and the words in `text`. It goes into any conversation, and to someone new where the channel lets your agent write first. ## Send a text [#send-a-text] This reply goes into a conversation the person started. To write to someone new, name them at `target.recipientExternalId` instead, and check [who can write first](https://docs.mapier.ai/convo/guides/production/check-before-you-send). ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-ready" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" }, "payload": { "kind": "text", "text": "Yes, by the window." } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/message.send", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "order-4821-ready", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" }, payload: { kind: "text", text: "Yes, by the window." }, }), }); const { commandId } = await res.json(); ``` ```json title="202 Accepted" { "commandId": "0192b3e1-…", "status": "queued", "repeated": false, "lineId": "0192a7b0-…", "lineSelection": "reused_active_chat", "channel": "imessage" } ``` Keep `commandId`. Its result on the stream says whether the text went out. **Demo: Text** (`message.send · kind: text`) On iMessage: - Text: `kind: text` _In a browser, a small phone is here playing a text reply. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Text: `kind: text` ## Format the text [#format-the-text] On iMessage, `textFormatting` draws parts of the text bold, italic, underlined or struck through, plays an animation on them, or mentions the person. Each range is `start` and `length` in UTF-16 code units of `text`, with at least one of `styles`, `effect` and `mention`: ```json { "kind": "text", "text": "Your table is ready.", "textFormatting": [{ "start": 14, "length": 5, "styles": ["bold"] }] } ``` A mention's range covers the name as you wrote it in `text`, and its value is the person's address: ```json { "kind": "text", "text": "Thanks, Sam!", "textFormatting": [{ "start": 8, "length": 3, "mention": "+14155550100" }] } ``` The styles are `bold`, `italic`, `underline` and `strikethrough`. The twelve animations are `bounce`, `stretch`, `squish`, `scaleRipple`, `big`, `bloom`, `somersault`, `nod`, `shake`, `jitter`, `small` and `explode`. A `mention` works only in a one-to-one conversation: its value is that person's address, and its range covers their name, never their address. A mention in a group chat is refused. `subject` adds a bold line above the text, such as an order number. A screen or bubble animation is an [effect](https://docs.mapier.ai/convo/guides/send/effects). Formatting, a subject and an effect go only into a conversation the person has written in, or a group chat. On WhatsApp, write the formatting into the text: `*bold*`, `_italic_` and `~strikethrough~`. Set `platform.whatsapp.previewUrl` to `true` to show a preview of the first link in the text. | Channel | Markup and mentions in the text | | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | **Demo: Bold** (`textFormatting · styles: bold`) On iMessage: - Bold: `styles: bold` - Italic: `styles: italic` - Underline: `styles: underline` - Strikethrough: `styles: strikethrough` - Bounce: `effect: bounce` - Explode: `effect: explode` _In a browser, a small phone is here playing a word in bold, a word in italics, an underlined word, a struck-through word, the bounce animation, the explode animation. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Bold: `text: *ready*` - Italic: `text: _ready_` - Strikethrough: `text: ~ready~` ## Reply to a message [#reply-to-a-message] Name the message you answer at `target.replyToMessageId`, the `messageId` of its `message.received` event. The line quotes it where it can. Where it cannot, the send is refused with a `422` at that key, and nothing is sent unquoted. ```json title="A message.received event's data" { "conversationId": "a0000000-0000-4000-8000-000000000001", "from": "+14155550100", "text": "Which one is the 7pm booking?", "messageId": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22" } ``` ```bash title="Request" curl -X POST https://api.mapier.ai/v1/commands/message.send \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: reply-to-0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001", "replyToMessageId": "0192a7c4-6a02-7e11-8c4d-2b9f7e3a5d22" }, "payload": { "kind": "text", "text": "The 7pm one is table 4, by the window." } }' ``` Make the `Idempotency-Key` from the message you answer. If the same event reaches you twice, the second send is the same command, not a second reply. See [Retries](https://docs.mapier.ai/convo/guides/production/retries). ## Limits [#limits] | Channel | Longest text | | ------------------------------------------- | --------------------------------------------- | | iMessage | 65,536 bytes of UTF-8 | | WhatsApp | 4,096 characters | On iMessage the limit is bytes, not characters: most accented letters take two bytes, Chinese, Japanese and Korean take three, and an emoji four or more. The whole request body is at most 65,536 bytes on every channel. Split long text into several messages. A first message to someone new on iMessage carries plain text only, at most 16,384 bytes, sent to a phone number. | Channel | How fast you can send | | ----------------------------------------- | ---------------------------------------------------------------------- | ## When a text fails after sending [#when-a-text-fails-after-sending] A text the channel refuses ends as a `failed` result, with a `failureClass` that says what to do. [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) lists every class. ## Receive a text [#receive-a-text] An incoming text arrives as a `message.received` event with the words in `text`. [Incoming messages](https://docs.mapier.ai/convo/guides/receive/incoming-messages) shows the whole event. ## Errors you may see [#errors-you-may-see] Each of these comes back at once, and nothing is sent. | Error | Means | Fix | | -------------------------------------------------------------------------------------------- | -------------------------------------------------- | --------------------------------------------------------------------------- | | [`403 recipient_not_allowed`](https://docs.mapier.ai/convo/api/errors/recipient_not_allowed) | This person cannot get messages from you yet | Check [who can write first](https://docs.mapier.ai/convo/guides/production/check-before-you-send) | | [`413 payload_too_large`](https://docs.mapier.ai/convo/api/errors/payload_too_large) | The request body is over 65,536 bytes | Split the text into several messages | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `invalid_text` | The text is blank, or too long for a first message | Send shorter text | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed), `conversation_not_confirmed` | Formatting or a subject went to someone new | Send plain text first | ## Next [#next] - [Images and files](https://docs.mapier.ai/convo/guides/send/images-and-files) - [Effects](https://docs.mapier.ai/convo/guides/send/effects) # Show typing, mark read (https://docs.mapier.ai/convo/guides/send/typing-and-read) > Show the person that a reply is coming, and that you read their messages _Works on iMessage, WhatsApp_ [Show typing](https://docs.mapier.ai/convo/api/conversations/show-typing) puts the typing dots in the conversation while you prepare a reply. [Mark as read](https://docs.mapier.ai/convo/api/conversations/mark-read) tells the person their messages were read. ## Show typing [#show-typing] Name the conversation. The payload can be left out. ```bash tab="cURL" curl -X POST https://api.mapier.ai/v1/commands/typing.start \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: typing-0192d0a1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" } }' ``` ```ts tab="TypeScript" const res = await fetch("https://api.mapier.ai/v1/commands/typing.start", { method: "POST", headers: { Authorization: `Bearer ${process.env.MAPIER_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": "typing-0192d0a1", "x-mapier-version": "2026-12-01", }, body: JSON.stringify({ target: { conversationId: "a0000000-0000-4000-8000-000000000001" } }), }); const { commandId } = await res.json(); ``` The dots stop when your reply arrives. **Demo: Typing** (`typing.start`) On iMessage: - Typing: `typing.start` - Read: `conversation.mark_read` _In a browser, a small phone is here playing a typing indicator, marking the contact's message read. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Typing: `typing.start` - Read: `conversation.mark_read` ## Mark as read [#mark-as-read] Send `conversation.mark_read` with the same `target`. It marks a one-to-one conversation read on the line. ```bash curl -X POST https://api.mapier.ai/v1/commands/conversation.mark_read \ -H "Authorization: Bearer $MAPIER_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: read-0192d0a1" \ -H "x-mapier-version: 2026-12-01" \ -d '{ "target": { "conversationId": "a0000000-0000-4000-8000-000000000001" } }' ``` ## When the line cannot do it [#when-the-line-cannot-do-it] A line whose channel has no typing dots or read marks refuses the command. To send both on every line without handling that, add `"options": { "ifUnsupported": "skip" }`: a line that cannot do it returns `200 {"skipped": true}` and sends nothing. ## Errors you may see [#errors-you-may-see] | Error | Means | Fix | | ------------------------------------------------------------------------------------ | ----------------------------------------------------- | ------------------------------------ | | [`422 validation_failed`](https://docs.mapier.ai/convo/api/errors/validation_failed) | No `conversationId`, or not a one-to-one conversation | Name a one-to-one conversation | | [`404 unsupported_command`](https://docs.mapier.ai/convo/api/errors/unsupported_command), `not_on_channel` | The line's channel does not show typing or read marks | Send `options.ifUnsupported: "skip"` | ## Next [#next] - [Conversations](https://docs.mapier.ai/convo/guides/conversations/conversations) - [Results and delivery](https://docs.mapier.ai/convo/guides/receive/results-and-delivery) # One API for every channel (https://docs.mapier.ai/convo) > A messaging API for AI agents. Send an iMessage from your line and receive the reply, with one HTTP API Mapier sends from your **lines**. A line is one account on a channel, such as a phone number. ## Send a message [#send-a-message] Reply in a conversation. Mapier sends it from the same line, on the same channel. ```http title="Request" POST /v1/commands/message.send { "target": { "conversationId": "a000…0001" }, "payload": { "kind": "text", "text": "Yes, by the window." } } ``` **Demo: Text** (`message.send · kind: text`) On iMessage: - Text: `kind: text` _In a browser, a small phone is here playing a text reply. It is a sketch of what the contact's iPhone shows in iMessage._ On WhatsApp: - Text: `kind: text` ## Get started [#get-started] **Before you start**, you need a line in the console, such as an iMessage number, a WhatsApp number. No line yet? [Connect a line](https://docs.mapier.ai/convo/guides/connect/imessage). ### Create an API key [!toc] [#create-an-api-key] Create one on the **Keys** page. It is shown once. ### Text your line [!toc] [#text-your-line] Send your line a message. The [quickstart](https://docs.mapier.ai/convo/guides/get-started/quickstart#text-your-line) shows how on each channel. Copy the `conversationId` from the message's [`message.received` event](https://docs.mapier.ai/convo/api/events/event-types). ### Reply [!toc] [#reply] Send the request above with that `conversationId`. [Quickstart](https://docs.mapier.ai/convo/guides/get-started/quickstart) walks through each step. It takes about five minutes.