SSE Events
Subscribe to real-time upload events via Server-Sent Events. Receive instant notifications as images are uploaded and delivered.
Endpoint
GET
/api/v1/sessions/:sessionId/eventsOpen a persistent connection to the SSE endpoint. The server sends events as they occur. Pass your API key via the Authorization header or a token query parameter.
Event Types
| Event | Description |
|---|---|
| connected | Connection established, session ID confirmed |
| image:ready | A new image has been uploaded and is ready for processing |
| image:delivered | An image has been delivered to a destination |
| image:failed | An image delivery attempt has failed |
| session:completed | The session has been completed (all images delivered or session closed) |
Subscribing
Connect to the event stream using the Node.js SDK, a browser EventSource, or any HTTP client that supports streaming.
# Subscribe to SSE events for a session
curl -N -H "Authorization: Bearer aptr_live_xxxx" \
"https://api.apertur.ca/api/v1/sessions/sess_01HX.../events"
# Example stream output:
# event: connected
# data: {"sessionId":"sess_01HX..."}
#
# event: image:ready
# data: {"imageId":"img_01HX...","filename":"photo.jpg","sizeBytes":245000}
#
# event: image:delivered
# data: {"imageId":"img_01HX...","destinationId":"dest_..."}Reconnection
The SSE protocol supports automatic reconnection. If the connection drops, the client will reconnect and the server replays any events missed since the last received id.
Note
Events are retained for 5 minutes. If a client reconnects after this window, it may miss intermediate events.