Connect
The API host depends on the data region of your project:The examples on this page use the EU host. If your project lives in another region, replace
https://api.gleap.io with your region’s host. API tokens are per project and only valid in the project’s region.authEndpoint (with your token as the Authorization header) and subscribe to channel. Include two custom auth params:
consumerIdnames the connecting instance ([A-Za-z0-9_-]{1,64}).typingEvents: trueopts this stream intoagent.typing.*(high volume; default off).
userAuthEndpoint (Pusher “signin”) — that is what allows the server to cleanly terminate a superseded connection during takeover.
Event data arrives as a JSON string of the same envelope webhooks receive — JSON.parse it (Pusher clients usually do this for you). Payloads larger than the socket limit arrive as a slim pointer (data.truncated: true with the conversation/message id) — fetch the full object over REST.
Exactly one consumer
Gleap holds one active consumer per project. When a connection authorizes with a newconsumerId, it takes over: the previous consumer’s connection is terminated and a s2s.takeover control event is published (disconnect yourself if you receive it and the consumerId isn’t yours). Rolling deployments therefore need no coordination — the new pod connects, the old one is dropped. During the handover both may briefly receive the same events: deduplicate by (conversation id, sequence).
Resync on every (re)connect — mandatory
A dropped connection loses the events published during the gap; there is no replay. After every connect — first connect, reconnect, and after a takeover — run per-conversation catch-up for anything you track:GET /v3/s2s/contacts/{userId}/conversationsfor contacts with open activity, and/orGET /v3/s2s/conversations/{id}/messages?after=<last message id you have>per conversation.