Remove a background
- iMessage
Remove a conversation's background
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 each take a key of their
own — see One key for each command.
A change is reported as an event
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.
Body
Target
Prop
Type
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
None. Send {} or leave payload out. Any field is 422 validation_failed at
that field (payload.<key>) before anything is sent, payload.preset,
payload.colors and payload.photoUrl included: only a
chat_background.set takes them.
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:
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 endssucceededand changes nothing.failedwithgateway_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 newIdempotency-Key.failedwithstale_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.failedwithcapability_not_negotiated— the line does not support removing a background. Setting and removing are supported separately.expiredwithcommand_expired_before_execution— the line did not reach the change in time. Nothing changed.ambiguouswithchat_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.
chat_background_unverified: ask before you send it again
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
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, a
reaction, a profile.share or a poll.vote that waits longer than that path's
30 seconds ends expired.
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} 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.
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 and 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
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
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": {}
}'Response
{
"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:
{
"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
Every command can return the errors listed under How commands work › Errors. Specific to this command:
422 validation_failedattarget.conversationIdfor a conversation no message has arrived in, a one-to-one conversation the line has not confirmed (withreason: conversation_not_confirmed), or the address of someone this project has already exchanged messages with, in place of a conversation.422 validation_failedatpayload.<key>for any key in the payload,expectedBackgroundGuidamong them.503 upstream_unavailablewithdetails.reason: "connector_unavailable"while the line is offline, or"outbound_paused"while sending on the line is paused.404 unsupported_commandwithreason: not_on_channelon 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.