SSE Endpoint
Connection details, headers, and error handling for the event stream.
Endpoint
GET https://tizemint.com/api/tip-events/stream
Authentication
One of the two is required. If both are provided, the query parameter takes precedence.
Response Headers
On a successful connection, the server responds with:
| Header | Value |
|---|---|
Content-Type | text/event-stream |
Cache-Control | no-cache, no-transform |
Connection | keep-alive |
X-Accel-Buffering | no |
Connection Lifecycle
- Client opens the SSE connection with a valid token.
- Server authenticates the token (prefix lookup + SHA-256 hash comparison).
- Server opens an upstream WebSocket to the overlay-sync worker for your profile.
- A
{"type":"connected"}event is sent to confirm the stream is live. - Tip events are forwarded as they arrive. Only events with a
tip:*type prefix pass through. - The stream ends when any of these occur:
- The Vercel function reaches its 300-second (5 minute) timeout.
- The client disconnects.
- The upstream WebSocket closes unexpectedly.
Error Responses
The endpoint returns standard HTTP errors before the stream opens:
| Code | Reason |
|---|---|
401 | Missing token, invalid token, token hash mismatch, or expired token. |
502 | The overlay-sync worker is unreachable or NEXT_PUBLIC_OVERLAY_SYNC_URL is not configured. |
Once the SSE stream is open, errors are not sent as HTTP status codes — the connection simply closes.
Client Examples
Using EventSource
The browser EventSource API handles SSE connections natively, including automatic reconnection:
const source = new EventSource(
"https://tizemint.com/api/tip-events/stream?token=YOUR_TOKEN"
);
source.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data.type, data);
};
source.onerror = () => {
// EventSource auto-reconnects with exponential backoff.
// No action needed unless you want to log or update UI.
};EventSource does not support custom headers. Use the ?token= query parameter for browser-based clients.Using fetch (Node.js / Deno)
For server-side consumers that need header-based auth:
const response = await fetch(
"https://tizemint.com/api/tip-events/stream",
{ headers: { Authorization: "Bearer YOUR_TOKEN" } }
);
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
for (const line of text.split("\n")) {
if (line.startsWith("data: ")) {
const data = JSON.parse(line.slice(6));
console.log(data.type, data);
}
}
}What Happens When the WebSocket Closes
The SSE endpoint bridges your client to an internal WebSocket. If the WebSocket drops (e.g., worker restart), the SSE stream closes cleanly. EventSource clients reconnect automatically; custom consumers should implement retry logic (see Rate Limits).