Skip to main content
im.polls manages iMessage poll messages. A poll always belongs to a chat, so create(...) takes chat.guid. If you only have email addresses or phone numbers, create the chat first with im.chats.create(...). After a poll is created, store poll.pollMessageGuid. You need it to read the poll, vote, unvote, add options, and subscribe to events for that poll.

What You Can Do

Two IDs

Poll APIs use two IDs. Keep them separate and the rest of the API is straightforward: The rule is simple:
  1. Pass pollMessageGuid to say which poll you are operating on.
  2. Pass optionIdentifier when you need to choose a specific option.
Do not pass option text to vote(...). The user may see "Pizza", but the API needs that option’s optionIdentifier.

Create a Poll

The poll is sent to the chat as part of the same call. The return value is Poll:

Read and Modify

Get State

Returns the latest Poll. Use this when you need fresh option IDs or current vote state. Missing polls throw NotFoundError.

Vote

Returns the updated Poll.

Unvote

Returns the updated Poll. Missing polls throw NotFoundError.

Add an Option

Returns the updated Poll. The new option is appended to options. Missing polls throw NotFoundError.
create(...), vote(...), unvote(...), and addOption(...) accept optional { clientMessageId } for idempotent retries from your job system. Most direct calls can omit it. See error handling for details.

Poll Events

subscribeEvents(...) returns TypedEventStream<PollEvent>. Use the stream to observe changes made by other people, other devices, or another part of your system. Immediately after your code calls vote(...), unvote(...), or addOption(...), use that method’s returned Poll.

Scope

Only one poll:
All visible poll events:

Outer Event

Every poll event has type: "poll.changed". The outer fields answer which poll changed, which chat it belongs to, who triggered it, and when:

Delta Types

event.delta.type tells you what changed. Each type carries different fields:

Handle Events

Switch on event.delta.type. When you subscribe to one poll, you do not need to check pollMessageGuid again:
When you subscribe to all visible polls, use event.pollMessageGuid to identify the poll:
If the stream disconnects, use events to catch up on missed durable events, then continue consuming the live stream.

Next Steps

  1. Chats — create a chat and get chat.guid
  2. Messages — understand how poll messages appear in the message stream
  3. Events — catch up on durable events after a disconnect
  4. Error Handling — handle NotFoundError, ValidationError, and idempotent retries