Guides

Sessions & Notifications

Your own sessions, sign-out of one device, push devices, the inbox and notification preferences.

The /api/v1/console/me/** routes belong to the person who is signed in. They are self-service, so no capability is needed, and they are open on every plan.

  • Console JWT only. An API key or OAuth token is refused with 403, because a machine credential has no sessions or devices.
  • Your own data only. Another person's id reads 404.
  • Open during maintenance. They keep working during a read-only maintenance window.

Sessions

Every sign-in is one session. The sign-in and refresh result carries sessionId, and your access token names the same session.

RouteWhat it does
GET /api/v1/console/me/sessionsYour live sessions: the current one first, then by last activity, at most 50
DELETE /api/v1/console/me/sessions/{id}End another session. Its access token stops working on its next request. 409 for the session you are using: sign out instead
POST /api/v1/console/me/sessions/revoke-othersEnd every session except this one: { "revoked": n }. 409 if your token is older than session ids: refresh, then retry

Each session carries id, current, label (for example "Galaxy Tab A7 · Panoptes Staff"), deviceId, deviceName, client, platform, appVersion, ip, userAgent, signedInAt, lastActiveAt and expiresAt. Send an optional deviceName with deviceId when you sign in, so the list is readable.

Signing out with POST /api/v1/console/auth/logout:

You sendWhat ends
Bearer + { "refreshToken": "…" } in the bodyThis device's session only
Bearer + { "everywhere": true }Every session
Bearer and no bodyEvery session, as before
Only a refresh token, in the body or the cookieThat one session

Push devices

Register the device's Firebase Cloud Messaging token after every sign-in, whenever the token refreshes, and at least once a day:

curl -X POST https://staging-api.panoptesos.com/api/v1/console/me/push-devices \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{ "deviceId": "6f1c2a4e-5b7d-4c1a-9e2f-0a1b2c3d4e5f", "token": "<fcm token>",
        "platform": "android", "appVersion": "1.3.0+21", "locale": "ar",
        "deviceName": "Galaxy Tab A7" }'
  • The fields. platform is android, ios or web; windows is refused, because Windows apps use the inbox only. locale is ar or en, and pushes arrive in that language. deviceId must be the one the session signed in with.
  • Other routes. GET lists your devices. DELETE /me/push-devices/{deviceId} stops pushes; it is idempotent. POST /me/push-devices/{deviceId}/test sends a test notification, at most once a minute per device, and answers 429 with Retry-After beyond that.
  • When a registration retires itself. Signing out, ending a session or changing your password retires the matching registrations. You do not need to clean them up.
  • When pushes are off. If push is not enabled on the server, transportEnabled is false. The inbox still works.

Each push's data carries v (the payload version, "1"), notificationId, category, event, severity, route, createdAt and, when relevant, entityType, entityId and branchId. Open route when the user taps the push; treat an unknown route as /notifications.

Inbox

Every notification is kept in your inbox, whether or not its push arrived.

RouteWhat it does
GET /api/v1/console/me/notificationsNewest first: page, per_page (at most 100), unread=true, category. No sort
GET /api/v1/console/me/notifications/unread-count{ "unread": n }
POST /api/v1/console/me/notifications/{id}/readMark one read; idempotent
POST /api/v1/console/me/notifications/read-allMark all read, optionally one category's: { "category": "hr" } → { "updated": n }

Each item carries id, category, event, severity, titleAr, titleEn, bodyAr, bodyEn, entityType, entityId, branchId, route, createdAt, readAt and pushState.

Preferences

GET /api/v1/console/me/notification-preferences lists every category, with:

  • push: on or off;
  • optional: whether it can be switched off;
  • relevant: whether your role in the active branch receives it;
  • quietHours: drop or defer.

It also returns the quiet-hours window (Baghdad time) and transportEnabled.

CategoryCan be mutedDuring quiet hours
guest_paymentsyesdropped
integrityyesdelivered after
hryesdelivered after
announcementsyesdelivered after
systemnodelivered after

PATCH merges, so anything you leave out is unchanged:

{
  "categories": [{ "category": "hr", "push": false }],
  "quietHours": { "enabled": true, "start": "22:30", "end": "07:00" }
}

The PATCH answers 422 for:

  • an unknown category;
  • switching system off;
  • a time that is not HH:mm;
  • enabled quiet hours whose start equals their end.

Muting stops the push only. The inbox still records the notification.