Docs/SSE Events

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/events

Open 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

EventDescription
connectedConnection established, session ID confirmed
image:readyA new image has been uploaded and is ready for processing
image:deliveredAn image has been delivered to a destination
image:failedAn image delivery attempt has failed
session:completedThe 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.

SSE Events | Documentation de l'API | Apertur