Sessions
Session lifecycle — start, end, heartbeat.
Session rows feed the /admin/sessions analytics endpoints. All mutations are scoped by app_user_id so a session id leaked via logs can't be ended or bumped by another user.
Source: apps/api/src/routes/client/sessions.ts.
Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /client/sessions/start | Open a session row. |
| POST | /client/sessions/end | Close a session with duration_seconds. |
| POST | /client/sessions/heartbeat | Bump duration_seconds while the session is open. |
POST /client/sessions/start
Request (StartSessionInput)
| Field | Type | Required |
|---|---|---|
session_id | string | yes |
platform | string | no |
app_version | string | no |
device_model | string | no |
metadata | object | no |
Response 201
Errors
500 CREATE_FAILED.
Try it:
POST
client auth/client/sessions/startcurl -X POST 'https://api.amba.dev/client/sessions/start'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
POST /client/sessions/end
Request (EndSessionInput)
| Field | Type | Required |
|---|---|---|
session_id | string | yes |
Computes duration_seconds from the stored started_at and stamps ended_at = NOW().
Response 200
Errors
404 UPDATE_FAILED— session not found for this user.
Try it:
POST
client auth/client/sessions/endcurl -X POST 'https://api.amba.dev/client/sessions/end'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl:
POST /client/sessions/heartbeat
Request
| Field | Type | Required |
|---|---|---|
session_id | string | yes |
Updates duration_seconds to the delta since started_at. Does not close the session.
Response 200
Updated row.
Errors
404 UPDATE_FAILED.
Try it:
POST
client auth/client/sessions/heartbeatcurl -X POST 'https://api.amba.dev/client/sessions/heartbeat'Loading auth… Configure auth in the settings drawer (top-right) to run this request.
Curl: