Groups

Works on
  • iMessage

Group chats from the API. Start an iMessage group chat, send to it, rename it, change who is in it, and leave it

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 wantSend
A new group with its first messagegroup.create
A message to everyone in a groupmessage.send to its conversationId
A new name for the groupgroup.update with rename
Someone added or removedgroup.update with add_participant or remove_participant
Your line out of the groupgroup.leave
ChannelA group isYour line joins one when
iMessageA group chatIt makes one with group.create, or someone adds it
WhatsAppA 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.

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.

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

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.

Wait for the result before you try again

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.

Send to a group

Send message.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

group.update takes one change per command:

{ "action": "rename", "name": "Trip planning" }
{ "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

group.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

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}.
  • 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

A group message carries addressed: true when it mentions your line or replies to a message your line sent:

ChannelAlso true forA 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

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

ErrorMeansFix
422 validation_failedA person's address, the member count or the name is not validFix the field the error names
409 conflict, group_has_no_messages_yetNo one has written in the group yetSend a message in the group first
409 conversation_closedYour line can no longer reach the groupWait for conversation.status_changed back to active
403 recipient_not_allowed, group_member_not_test_contactOn a test line on a shared number, someone in the group is not one of this project's connected Test contactsConnect them as Test contacts, or leave them out
404 unsupported_command, shared_lineGroup chats are not turned on for your organization, on a test line on a shared numberUse a line of your own

Next