Chat backgrounds

Works on
  • iMessage

Set or remove the picture behind a conversation, and hear when a person changes it

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 wantSend
One of Apple's backgroundschat_background.set with its preset
Two colors of your ownpreset: "custom" with two colors
A photo of your ownpreset: "photo" with a public https photoUrl
The plain background againchat_background.remove

Set a background

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" }
  }'

Set a background lists every preset. For two colors of your own, send them as #RRGGBB:

{ "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:

{ "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.

Give a set and a remove their own key

Use a new Idempotency-Key for each change. A remove sent under the key a set used removes nothing.

Remove a background

Send chat_background.remove to the same conversation with an empty payload.

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.

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

  • null — the background was removed.
  • { "preset": … } — a background was set. preset is one of the presets chat_background.set 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} 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

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

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.

Skip a message with no text

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

ErrorMeansFix
422 validation_failed, payload.presetThe preset is missing or not on the listUse a preset from Set a background
422 validation_failed, media_fetch_failedMapier could not fetch the photo linkCheck the link, then retry
422 validation_failed, media_too_largeThe photo is too largeSend a smaller photo
503 upstream_unavailableThe line is offline, or sending on it is pausedWait, 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