Skip to content

Mobile Sessions API

The Sessions API enables two devices to share observation state in real time — for example, pairing a phone running the PWA with a laptop controlling a rotor, or letting two observers collaborate on the same tracking session. Each session is identified by a unique token and expires after 24 hours.

Once a session is created and joined, the paired devices communicate over a WebSocket relay at /ws/session/{token} (documented in the Tracking API).

Creates a new pairing session and returns a unique token. The session expires 24 hours after creation.

POST /api/sessions

No request body is required.

{
"token": "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0u1V2",
"created_at": "2026-02-14T18:00:00Z",
"expires_at": "2026-02-15T18:00:00Z",
"is_paired": false
}
FieldTypeDescription
tokenstringURL-safe base64 token (43 characters) for identifying the session
created_atdatetimeWhen the session was created
expires_atdatetimeWhen the session will expire (24 hours from creation)
is_pairedbooleanWhether a second device has joined the session

Retrieves the current state of an existing session.

GET /api/sessions/{token}
ParameterTypeDescription
tokenstring (path)The session token
{
"token": "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0u1V2",
"created_at": "2026-02-14T18:00:00Z",
"expires_at": "2026-02-15T18:00:00Z",
"is_paired": true
}

Returns 404 if the session token does not exist. Returns 410 Gone if the session has expired.


Joins an existing session from a second device. This sets is_paired to true and optionally records the joining device’s information.

POST /api/sessions/{token}/join
ParameterTypeDescription
tokenstring (path)The session token to join
{
"device_info": "iPhone 15 Pro / Safari 19"
}
FieldTypeRequiredDescription
device_infostring or nullNoFree-form description of the joining device
{
"token": "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8s9T0u1V2",
"created_at": "2026-02-14T18:00:00Z",
"expires_at": "2026-02-15T18:00:00Z",
"is_paired": true
}

Returns 404 if the session token does not exist. Returns 410 Gone if the session has expired.


Ends a session immediately, removing it from the database. Any WebSocket connections on this session token will be closed by the relay.

DELETE /api/sessions/{token}
ParameterTypeDescription
tokenstring (path)The session token to delete

Returns 204 No Content on success. Returns 404 if the session token does not exist.


A typical pairing flow works as follows:

  1. Device A calls POST /api/sessions and receives a token.
  2. Device A displays the token (or a QR code encoding it) for the second device.
  3. Device B calls POST /api/sessions/{token}/join with optional device info.
  4. Both devices open a WebSocket connection to /ws/session/{token} and begin exchanging real-time state (target coordinates, rotor position, tracking mode).
  5. Either device can call DELETE /api/sessions/{token} to end the session, or it expires automatically after 24 hours.