Stream

Events pushed over a WebSocket, with replay.

Open the event stream

GET/v1/ws

Access key: an API key, or a correctly scoped app token where delegated access is allowed; console sessions are refused.

A WebSocket that pushes events as they happen, the same payload as a webhook plus delivered_at and attempt. Authenticate with the Authorization header, or ?token=dm_... for clients that cannot set headers; an app access token needs events:read and mail:read, and sessions are not accepted. Then send JSON frames (see StreamClientFrame): subscribe, with optional inbox_ids, event_types and last_event_id to replay up to 100 missed events; unsubscribe; ping. Limits: 10 connections per account (the next is closed with 4008), 30 frames per 10 seconds per connection (4029); a revoked key, a deleted inbox, or an app access token that ran out or was revoked closes its connections with 4001. A failed push is not retried over the socket: reconnect with last_event_id to catch up, with a renewed token when it was an app's.

OAuth: allowed with all of events:read, mail:read. App permissions apply in addition to account and resource checks.

Also available as client.stream in TypeScript and doorman events tail on the command line.

Parameters
  • tokenstring, in queryoptional

    The API key, for clients that cannot set the Authorization header. Example: dm_....

  • Upgrade"websocket", in headerrequired

    websocket.

Answers 101: Switching protocols: the stream is open.

Frames the client sends: StreamClientFrame

One of:

StreamSubscribe

Start receiving events, for everything the key can see or a narrower set. Subscriptions accumulate.

  • type"subscribe"required

  • inbox_idsstring[]optional

    Up to 32 inbox ids, all of them the key's.

  • event_types("message.received" | "message.sent" | "thread.updated" | "inbox.created" | "inbox.deleted" | "delivery.failed" | "message.held" | "send.held" | "send.discarded" | "sign_in.requested" | "sign_in.completed")[]optional

    Only these event types; absent or empty means all.

  • last_event_idstringoptional

    Replay every event after this one (up to 100, filtered by the subscription) before live events. Example: evt_01jc5e5f6g7h8j9k0m1n2p3q4r

StreamUnsubscribe

Stop receiving events: everything, or specific inboxes.

  • type"unsubscribe"required

  • inbox_idsstring[]optional

    The inboxes to stop receiving for; absent or empty stops everything.

StreamPing

A keepalive the edge answers with pong without waking the stream; send one every 30 to 60 seconds through idle proxies.

  • type"ping"required

Frames the server sends: StreamServerFrame

One of:

StreamSubscribed

The subscription in force after a subscribe frame; empty arrays mean all.

  • type"subscribed"required

  • inbox_idsstring[]required

  • event_typesstring[]required

StreamUnsubscribed

The answer to an unsubscribe frame, echoing the inboxes it named.

  • type"unsubscribed"required

  • inbox_idsstring[]required

StreamPong

The answer to a ping.

  • type"pong"required

StreamError

A frame that could not be honoured; the connection stays open.

  • type"error"required

  • messagestringrequired

StreamEvent

An event as the stream frames it: the webhook payload plus when it was pushed. attempt is always 1; a missed frame is recovered with last_event_id, not retried.

No fields.

Close codes
Close codeReason
4001unauthorized
4008connectionLimit
4029rateLimit
Errors
StatusErrorMeaning
401unauthorizedThe credential was missing, malformed, revoked or belongs to an inactive account.
403insufficient_scopeThe app's token lacks a required scope, or the operation cannot be delegated.
426upgrade_requiredThe stream needs a WebSocket upgrade.
500internal_errorSomething went wrong on the server.
import WebSocket from "ws";

const socket = new WebSocket("wss://api.doorman.fyi/v1/ws", { headers: { authorization: `Bearer ${process.env.DOORMAN_API_KEY}` } });
// A client that cannot set headers (a browser) passes the key as ?token=dm_... instead.
socket.addEventListener("open", () => socket.send(JSON.stringify({"type":"subscribe","inbox_ids":["inb_01jc4q7w9k2m5n8p3r6t1v4x7z"]})));
socket.addEventListener("message", (message) => {
  const frame = JSON.parse(String(message.data));
  if (frame.type === "subscribed") console.log("subscribed", frame.inbox_ids);
  if (frame.event === "message.received") console.log(frame.event_id, frame.message.subject);
});

Up Down to move, Enter to open, Esc to close