Live events
Every operation in this group: what it accepts, what it returns and the errors it can answer with.
Operations
Follow the mailbox as it changes, over one long-lived server-sent event stream, and wait for a message to arrive.
GET/live-events
Stream mailbox events as they happen
Holds the response open as text/event-stream and sends one event each time the mailbox changes, so a program stays in sync without polling. Every event is an SSE message whose event is its type, whose id is its id and whose data is the event as JSON (LiveEvent): message.received when a message is filed for an address, message.sent when a message sent from an address is filed in its Sent folder, thread.changed when a conversation gains or loses labels (read, starred, archived, moved, snoozed or labelled), thread.deleted when one is deleted for good, and message.status_changed when the receiving servers report on a sent email: delivered, delayed, bounced, complained of, failed, suppressed or cancelled. Events name the addresses, the conversation and the message they concern and carry no content: read it with GET /threads/{id} or GET /threads/{id}/messages/{messageId}.
The stream starts with retry: 3000, then a ready event whose data is { cursor, resumed }. Pass the id of the last event you handled as the Last-Event-ID header (or the lastEventId query parameter) and the events after it are replayed first, for as long as it is at most 10 minutes and 1000 events back. When it is older, or unknown, a reset event comes first, with { reason, cursor } (expired or unknown): list again what you keep in sync, then carry on from the stream. A comment line keeps the connection open every 25 seconds, and carries an id when events you filtered out moved the cursor on. The server ends every stream after 30 minutes, and when the credential stops being valid, with an end event whose reason is lifetime, credential or unavailable: open it again with Last-Event-ID, as the SDKs do by themselves.
A key, an app or a session holds at most 5 open streams and a workspace at most 50. A key or an app limited to particular addresses gets only the events of the addresses it reaches, checked on the server for every event, and an address it does not reach delivers nothing rather than failing. The credential is checked again at most once a minute while events flow, so a revoked key stops receiving within a minute.
Requires the threads:read scope.
Query parameters
typesstringOnly these kinds of event, separated by commas:
message.received,message.sent,thread.changed,thread.deleted,message.status_changed. Left out, all of them.ready,resetandendalways come.Up to 200 charactersaddressstringOnly the events of this address. One the key does not reach delivers nothing rather than failing.
3 to 320 characterslastEventIdstringResume after this event id, for clients such as a browser
EventSourcethat cannot set theLast-Event-IDheader on the first request. The header wins when both are sent.Up to 32 characters
Headers
Last-Event-IDstringResume after this event id: the
idof the last event you handled.Up to 32 characters
Returns
The open stream, as server-sent events. Each data line is a LiveEvent, or the payload of a ready, reset or end event.
Errors
- 429
too_many_streams: this credential already holds 5 open streams, or the workspace 50.rate_limited: the key or app made more than 600 requests in 60 seconds. Wait for the seconds inRetry-After.- 503
live_events_unavailable: the stream could not be opened just now. Try again shortly.
The errors every operation can return400401403404422500Error catalog
Also available in
Objects
LiveEventStreamstring
A text/event-stream body. Events whose event is one of the LiveEvent types carry a LiveEvent as JSON in data; ready carries LiveStreamReady, reset carries LiveStreamReset and end carries LiveStreamEnd. Lines starting with : are keepalive comments.
Google Workspace