Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

refactor(contract): name the session path parameter sessionId everywhere

Yudhi Armyndharisfe1be667c62a
diff --git a/docs/05-database-design.md b/docs/05-database-design.md
index ade130779..adc829a3d 100644
--- a/docs/05-database-design.md
+++ b/docs/05-database-design.md
@@ -368,7 +368,7 @@ clears it, and so does a gateway restart.
| `autoRejectCalls` | `false` | Auto-reject an incoming call as soon as it rings |
Set them at creation with `POST /api/sessions`, or on an existing session with
-`PATCH /api/sessions/{id}/config` — no restart, and no re-scan of the QR. The patch merges, so a key
+`PATCH /api/sessions/{sessionId}/config` — no restart, and no re-scan of the QR. The patch merges, so a key
it does not mention keeps its stored value, and an explicit `null` clears a key back to the default
above (the only way back to unlimited reconnect attempts once a cap is set).
@@ -377,7 +377,7 @@ re-read from this row on every incoming call, so a patch applies to the next cal
keys are read once per `start()` into the in-memory reconnect state, so a patch applies on the next
start and leaves a reconnect sequence already in flight alone.
-`GET /api/sessions/{id}/config` reports the effective values. It reports only these three keys and
+`GET /api/sessions/{sessionId}/config` reports the effective values. It reports only these three keys and
never the raw column — `config` is stripped from `SessionResponseDto` alongside the
credential-bearing `proxyUrl`, and echoing an opaque blob back would defeat that.
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.md
index 3d26b9191..ccb1438ad 100644
--- a/docs/06-api-specification.md
+++ b/docs/06-api-specification.md
@@ -239,17 +239,17 @@ List all sessions, scoped to the API key's `allowedSessions`, ordered `createdAt
**Errors:** `401` missing/invalid `X-API-Key`
-#### GET /api/sessions/:id
+#### GET /api/sessions/:sessionId
Get a single session by ID.
-**Auth:** API key · **Scope:** session-scoped (key's `allowedSessions` enforced against `:id`)
+**Auth:** API key · **Scope:** session-scoped (key's `allowedSessions` enforced against `:sessionId`)
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | --------------------- |
-| `id` | string | WhatsApp session UUID |
+| Name | Type | Description |
+| ----------- | ------ | --------------------- |
+| `sessionId` | string | WhatsApp session UUID |
**Response** `200`
@@ -271,20 +271,20 @@ Get a single session by ID.
**Errors:** `401` missing/invalid key, or key not scoped to this session · `404` session not found
-#### GET /api/sessions/:id/config
+#### GET /api/sessions/:sessionId/config
Get the effective tunable configuration for a session. Only the three recognised keys are reported,
resolved through the same clamps the engine applies — the opaque stored `config` column is never
echoed back (it is stripped from `SessionResponseDto` alongside `proxyUrl`, and anything else placed
in it is stored but ignored).
-**Auth:** API key · **Scope:** session-scoped (key's `allowedSessions` enforced against `:id`)
+**Auth:** API key · **Scope:** session-scoped (key's `allowedSessions` enforced against `:sessionId`)
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Response** `200`
@@ -297,7 +297,7 @@ See §5 (Database Design) for what each key does and the moment it is read.
**Errors:** `401` · `403` key not scoped to this session · `404` session not found
-#### PATCH /api/sessions/:id/config
+#### PATCH /api/sessions/:sessionId/config
Merge a patch into the session's tunable configuration. No restart is required or performed:
omitted keys keep their stored value, and an explicit `null` clears a key back to its default (the
@@ -309,9 +309,9 @@ and therefore apply on the next start, leaving a reconnect sequence already in f
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `UpdateSessionConfigDto` (any subset; each key also accepts `null`)
@@ -329,7 +329,7 @@ and therefore apply on the next start, leaving a reconnect sequence already in f
**Errors:** `400` a supplied value is outside its accepted range · `401` · `403` key lacks OPERATOR role or is not scoped to this session · `404` session not found
-#### GET /api/sessions/:id/qr
+#### GET /api/sessions/:sessionId/qr
Get the QR code (PNG data URL) for session authentication.
@@ -337,9 +337,9 @@ Get the QR code (PNG data URL) for session authentication.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Response** `200` — `QRCodeResponseDto`
@@ -362,9 +362,9 @@ Get all groups the session is a member of (paginated).
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Query parameters**
@@ -383,7 +383,7 @@ Bare array mapped from the engine's group list then paginated. `linkedParentJID`
**Errors:** `400` session not started (engine not in memory) · `401` · `403` · `404` session not found
-#### GET /api/sessions/:id/chats
+#### GET /api/sessions/:sessionId/chats
Get active chats for a session, most-recent first (paginated).
@@ -391,9 +391,9 @@ Get active chats for a session, most-recent first (paginated).
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Query parameters**
@@ -482,7 +482,7 @@ network cannot reach WhatsApp directly. Set `proxyUrl`/`proxyType` on the same r
> ⚠ `proxyUrl` **must point at a real, reachable proxy server.** A placeholder or unreachable value
> (e.g. `http://proxy.example.com:8080`) launches the engine pinned to a dead proxy, so the WhatsApp
-> WebSocket never connects, **no QR code is ever delivered**, and `POST /api/sessions/:id/start`
+> WebSocket never connects, **no QR code is ever delivered**, and `POST /api/sessions/:sessionId/start`
> returns `504 Gateway Timeout` after ~30s. Leave `proxyUrl` unset unless you genuinely need a proxy.
**Response** `201`
@@ -507,7 +507,7 @@ Like every other session route, this returns the `SessionResponseDto` shape (via
**Errors:** `400` validation (bad `name`/`proxyUrl`/`proxyType`, or an extra non-whitelisted field) · `401` · `403` key lacks OPERATOR role · `409` session name already exists
-#### POST /api/sessions/:id/start
+#### POST /api/sessions/:sessionId/start
Start a session and initialize the WhatsApp connection.
@@ -515,9 +515,9 @@ Start a session and initialize the WhatsApp connection.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
No request body.
@@ -543,7 +543,7 @@ Returned via `transformSession`. Status typically transitions to `initializing`
**Errors:** `400` session already started / already starting · `401` · `403` · `404` not found · `409` credential teardown for the same session name still in flight (retryable; body carries `code: 'SESSION_NAME_TEARDOWN_PENDING'`; no destructive side effect runs before the refusal — a retry after cleanup settles proceeds)
-#### POST /api/sessions/:id/stop
+#### POST /api/sessions/:sessionId/stop
Stop a session and disconnect WhatsApp.
@@ -551,9 +551,9 @@ Stop a session and disconnect WhatsApp.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
No request body.
@@ -579,7 +579,7 @@ Returned via `transformSession`; status typically becomes `disconnected`.
**Errors:** `401` · `403` · `404` not found
-#### POST /api/sessions/:id/logout
+#### POST /api/sessions/:sessionId/logout
Attempt an engine-native unlink of this companion device, then tear the session down locally.
@@ -618,9 +618,9 @@ simply be left as-is.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
No request body.
@@ -648,7 +648,7 @@ distinguishing an intentional unlink from a plain stop.
**Errors:** `400` session is not started (no engine to send through; the row is left untouched) · `401` · `403` · `404` not found · `502` `SESSION_LOGOUT_INCOMPLETE` — session stopped locally but the logout operation did not complete (retryable; `phone` cleared, no success audit)
-#### POST /api/sessions/:id/force-kill
+#### POST /api/sessions/:sessionId/force-kill
Force-kill a stuck session (SIGKILL the wedged engine, then tear it down).
@@ -656,9 +656,9 @@ Force-kill a stuck session (SIGKILL the wedged engine, then tear it down).
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
No request body.
@@ -684,7 +684,7 @@ Returned via `transformSession`.
**Errors:** `400` session is not started (no live engine to kill) · `401` · `403` · `404` not found
-#### POST /api/sessions/:id/pairing-code
+#### POST /api/sessions/:sessionId/pairing-code
Request an 8-char pairing code to link via phone number (alternative to QR).
@@ -692,9 +692,9 @@ Request an 8-char pairing code to link via phone number (alternative to QR).
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `RequestPairingCodeDto`
@@ -716,7 +716,7 @@ Request an 8-char pairing code to link via phone number (alternative to QR).
**Errors:** `400` validation, or session not started, or already authenticated · `401` · `403` · `404` not found
-#### POST /api/sessions/:id/presence/subscribe
+#### POST /api/sessions/:sessionId/presence/subscribe
Ask WhatsApp to start reporting who is online or typing in a chat.
@@ -724,7 +724,7 @@ Ask WhatsApp to start reporting who is online or typing in a chat.
There is no synchronous answer: presence cannot be _fetched_ from either engine, only received.
Updates arrive as the `presence.update` webhook and socket event; the latest is readable at
-`GET /api/sessions/:id/presence/:chatId`.
+`GET /api/sessions/:sessionId/presence/:chatId`.
Two properties to design around:
@@ -737,9 +737,9 @@ Two properties to design around:
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `SubscribePresenceDto`
@@ -755,7 +755,7 @@ Two properties to design around:
**Errors:** `400` validation, or session not started · `401` · `403` · `404` session not found · `501` the active engine cannot observe presence (whatsapp-web.js exposes only `sendPresenceAvailable`/`sendPresenceUnavailable`, which publish the account's _own_ presence, and emits no presence event)
-#### GET /api/sessions/:id/presence/:chatId
+#### GET /api/sessions/:sessionId/presence/:chatId
The last presence reported for a chat.
@@ -787,7 +787,7 @@ restart would be worse than answering nothing.
**Errors:** `401` · `403` · `404` session not found
-#### PUT /api/sessions/:id/presence
+#### PUT /api/sessions/:sessionId/presence
Set the account's OWN global presence: appear online or offline. WhatsApp routes notifications away
from the phone while a linked device announces itself online, so a headless bot that never goes
@@ -818,7 +818,7 @@ leaving the account silently online.
**Errors:** `400` session not started / validation · `401` · `403` key lacks OPERATOR role · `404` session not found · `409` engine not ready
-#### POST /api/sessions/:id/chats/read
+#### POST /api/sessions/:sessionId/chats/read
Mark a chat as read/seen.
@@ -826,9 +826,9 @@ Mark a chat as read/seen.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `MarkChatReadDto`
@@ -850,7 +850,7 @@ Returns HTTP `200`, matching the OpenAPI contract.
**Errors:** `400` validation, or session not started · `401` · `403` · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied
-#### POST /api/sessions/:id/chats/unread
+#### POST /api/sessions/:sessionId/chats/unread
Mark a chat as unread.
@@ -858,9 +858,9 @@ Mark a chat as unread.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `MarkChatReadDto` (reused)
@@ -882,7 +882,7 @@ Returns HTTP `200`, matching the OpenAPI contract.
**Errors:** `400` validation, or session not started · `401` · `403` · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied
-#### DELETE /api/sessions/:id/chats/:chatId/messages
+#### DELETE /api/sessions/:sessionId/chats/:chatId/messages
Delete every message in a chat, keeping the chat itself in the list.
@@ -890,10 +890,10 @@ Delete every message in a chat, keeping the chat itself in the list.
**Path parameters**
-| Name | Type | Description |
-| -------- | ------ | ------------------------------------------------------------------------------------- |
-| `id` | string | Session UUID |
-| `chatId` | string | Engine-native JID, e.g. `[email protected]`. URL-encode it if your client does not. |
+| Name | Type | Description |
+| ----------- | ------ | ------------------------------------------------------------------------------------- |
+| `sessionId` | string | Session UUID |
+| `chatId` | string | Engine-native JID, e.g. `[email protected]`. URL-encode it if your client does not. |
**Response** `200`
@@ -907,7 +907,7 @@ Delete every message in a chat, keeping the chat itself in the list.
**Errors:** `400` session not ready · `401` missing/invalid API key · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied
-#### POST /api/sessions/:id/chats/archive
+#### POST /api/sessions/:sessionId/chats/archive
Archive or unarchive a chat.
@@ -915,9 +915,9 @@ Archive or unarchive a chat.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `ArchiveChatDto`
@@ -947,7 +947,7 @@ Archive or unarchive a chat.
**Errors:** `400` session not ready · `401` missing/invalid API key · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied
-#### POST /api/sessions/:id/chats/mute
+#### POST /api/sessions/:sessionId/chats/mute
Mute a chat's notifications until a given moment, or unmute it.
@@ -955,9 +955,9 @@ Mute a chat's notifications until a given moment, or unmute it.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `MuteChatDto`
@@ -999,7 +999,7 @@ Mute a chat's notifications until a given moment, or unmute it.
**Errors:** `400` session not ready, or invalid `chatId`/`muteUntil` · `401` missing/invalid API key ·
`404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied
-#### POST /api/sessions/:id/chats/pin
+#### POST /api/sessions/:sessionId/chats/pin
Pin a chat to the top of the chat list, or unpin it. Chat-level — distinct from
`messages/pin`, which pins a message inside a chat.
@@ -1008,9 +1008,9 @@ Pin a chat to the top of the chat list, or unpin it. Chat-level — distinct fro
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `PinChatDto`
@@ -1042,7 +1042,7 @@ Pin a chat to the top of the chat list, or unpin it. Chat-level — distinct fro
**Errors:** `400` session not ready · `401` missing/invalid API key · `404` session not found ·
`409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied
-#### POST /api/sessions/:id/chats/delete
+#### POST /api/sessions/:sessionId/chats/delete
Delete a chat from the chat list (e.g. a group you have left).
@@ -1050,9 +1050,9 @@ Delete a chat from the chat list (e.g. a group you have left).
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `DeleteChatDto`
@@ -1074,7 +1074,7 @@ Returns HTTP `200`, matching the OpenAPI contract.
**Errors:** `400` validation, or session not started · `401` · `403` · `404` session not found · `409` the session is not connected (engine exists but is not `ready`) · `503` WhatsApp did not answer within the request budget, or the engine’s browser page died — the change may or may not have been applied
-#### POST /api/sessions/:id/chats/typing
+#### POST /api/sessions/:sessionId/chats/typing
Send a typing/recording presence indicator to a chat (or clear it with `paused`).
@@ -1082,9 +1082,9 @@ Send a typing/recording presence indicator to a chat (or clear it with `paused`)
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Request body** — `SendChatStateDto`
@@ -1107,7 +1107,7 @@ Always returns `{ "success": true }` (the service returns void; the controller h
**Errors:** `400` validation, or session not started · `401` · `403` · `404` session not found
-#### DELETE /api/sessions/:id
+#### DELETE /api/sessions/:sessionId
Delete a session.
@@ -1115,9 +1115,9 @@ Delete a session.
**Path parameters**
-| Name | Type | Description |
-| ---- | ------ | ------------ |
-| `id` | string | Session UUID |
+| Name | Type | Description |
+| ----------- | ------ | ------------ |
+| `sessionId` | string | Session UUID |
**Response** `204` — empty body (`@HttpCode(204)`, returns void). A `findOne` lookup runs first, so a missing id yields `404`.
@@ -3843,7 +3843,7 @@ Every chat carrying a label.
**Auth:** API key · **Scope:** session-scoped · **Engines:** whatsapp-web.js only
-**Response** `200` — a bare array of `ChatSummary`, the same shape `GET /sessions/:id/chats` returns.
+**Response** `200` — a bare array of `ChatSummary`, the same shape `GET /sessions/:sessionId/chats` returns.
**Errors:** `400` session not started · `401` · `404` session not found · `501` Baileys, which has no label query
@@ -5526,7 +5526,7 @@ Replace all Data DB rows with the supplied export. **Destructive and transaction
**Orphan-engine pre-flight.** Before the transaction opens, any running engine whose session id is absent from `tables.sessions` is an orphan (the replace would delete its DB row, leaving an unstoppable engine writing into freshly restored tables). Default behaviour is to refuse with `409` listing those ids; `stopOrphans: true` stops them in-request and proceeds; `force: true` proceeds and leaves them running until restart.
-Because that pre-flight runs _before_ the transaction, its teardown is not covered by the rollback. A response with `imported:false` therefore still reports the engines it really stopped, and `restartRequired` on that path means only that a teardown **failed** — a cleanly stopped orphan leaves its session row intact (restart it with `POST /sessions/{id}/start`), and an engine `force` left running was never orphaned after all, since the data that would have orphaned it was not replaced.
+Because that pre-flight runs _before_ the transaction, its teardown is not covered by the rollback. A response with `imported:false` therefore still reports the engines it really stopped, and `restartRequired` on that path means only that a teardown **failed** — a cleanly stopped orphan leaves its session row intact (restart it with `POST /sessions/{sessionId}/start`), and an engine `force` left running was never orphaned after all, since the data that would have orphaned it was not replaced.
Inside the transaction every migration table is emptied. `webhooks` and `sessions` are DELETEd directly, so a missing table there fails the restore; 11 more go through a tolerant helper where a _genuinely missing_ table is skipped; and `automation_rules` is emptied by the `DELETE FROM sessions` cascade rather than by the helper. Any other DELETE failure propagates to the rollback. Rows are then re-inserted, sessions first. JSON object/array fields are auto-stringified before insert, and the Postgres-form `$N` placeholders are rewritten for SQLite. Two guards return `imported:false` after a rollback: any `warnings`, and a payload that restores **zero** rows in total (a wrong/empty backup would otherwise commit a silent wipe — the response then carries `Backup contained no rows to restore; refused to replace existing data. Check the file.`). On commit the lid→phone mirror is reloaded from the restored rows.
@@ -6731,7 +6731,7 @@ These are the events OpenWA actually emits. A webhook is registered with an `eve
| `message.revoked` | A message is deleted/recalled | `{ id, revokedId?, chatId, from, to, type: "revoked", body: "", timestamp }` — **reconcile on `revokedId`** (the original deleted message's id), falling back to `id`. On whatsapp-web.js `id` is the _revocation notification_ (a distinct message that won't match a stored id) and `revokedId` may be absent when the original isn't cached locally; on Baileys the two coincide |
| `message.reaction` | A reaction is added, changed, or removed | `{ messageId, chatId, reaction, senderId, reactions? }` — `reactions` is the post-apply `{ senderId: emoji }` snapshot, omitted when the gateway holds no stored copy of the message to compute it from (an ephemeral message, or one predating the session going live); treat it as unknown rather than empty and keep the map you already hold. `reaction` is empty when removed |
| `message.edited` | A message body or media caption is edited | `{ messageId, chatId, body, senderId, from, to, fromMe, isGroup, type, hasMedia, author?, mentionedIds?, timestamp }` — `messageId` is the original message id, `body` is the latest text/caption, and `timestamp` is the edit occurrence time in epoch **seconds** (not the original creation time) |
-| `session.qr` | A new pairing QR is generated | `{ sessionId, qr }` — `qr` is a **PNG data URL** (`data:image/png;base64,…`), the same rendered value `GET /api/sessions/{id}/qr` returns as `qrCode`, not the raw `2@…` linking ref. Render it directly in an `<img src>`; the raw ref never leaves the engine adapter |
+| `session.qr` | A new pairing QR is generated | `{ sessionId, qr }` — `qr` is a **PNG data URL** (`data:image/png;base64,…`), the same rendered value `GET /api/sessions/{sessionId}/qr` returns as `qrCode`, not the raw `2@…` linking ref. Render it directly in an `<img src>`; the raw ref never leaves the engine adapter |
| `session.authenticated` | The session pairs and becomes ready | `{ sessionId, phone, pushName }` |
| `session.disconnected` | The session disconnects on the engine or WhatsApp side (drop, conflict, or a phone-initiated unlink). Not fired for API-initiated stop/logout/delete — those are acknowledged by the API response and the `session.status` transition | `{ sessionId, reason }` |
| `session.reconnect_loop` | Every 5th consecutive reconnect attempt is scheduled (attempt 5, 10, 15, …) — the session is failing to come back up | `{ sessionId, attempts, nextDelayMs }` |
diff --git a/docs/07-api-collection.md b/docs/07-api-collection.md
index 5c47a1e4e..dde1c6de9 100644
--- a/docs/07-api-collection.md
+++ b/docs/07-api-collection.md
@@ -51,7 +51,7 @@ curl -X GET "$BASE/api/sessions?limit=100&offset=0" \
-H "X-API-Key: $API_KEY"
```
-#### GET /api/sessions/:id
+#### GET /api/sessions/:sessionId
Get a single session by ID.
@@ -60,7 +60,7 @@ curl -X GET "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a" \
-H "X-API-Key: $API_KEY"
```
-#### GET /api/sessions/:id/qr
+#### GET /api/sessions/:sessionId/qr
Get the QR code (PNG data URL) for authentication (OPERATOR).
@@ -78,7 +78,7 @@ curl -X GET "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/groups?limi
-H "X-API-Key: $API_KEY"
```
-#### GET /api/sessions/:id/chats
+#### GET /api/sessions/:sessionId/chats
List active chats, most-recent first (paginated).
@@ -109,7 +109,7 @@ curl -X POST "$BASE/api/sessions" \
With an optional per-session egress proxy — only if your network can't reach WhatsApp directly. The
proxy **must be a real, reachable host**; an unreachable value silently blocks the WhatsApp WebSocket
-(no QR is ever delivered) and `POST /api/sessions/:id/start` returns `504` after ~30s:
+(no QR is ever delivered) and `POST /api/sessions/:sessionId/start` returns `504` after ~30s:
```bash
curl -X POST "$BASE/api/sessions" \
@@ -118,7 +118,7 @@ curl -X POST "$BASE/api/sessions" \
-d '{ "name": "my-bot", "proxyUrl": "http://user:[email protected]:8080", "proxyType": "http" }'
```
-#### POST /api/sessions/:id/start
+#### POST /api/sessions/:sessionId/start
Start a session and initialize the connection (OPERATOR).
@@ -127,7 +127,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/start" \
-H "X-API-Key: $API_KEY"
```
-#### POST /api/sessions/:id/stop
+#### POST /api/sessions/:sessionId/stop
Stop a session and disconnect (OPERATOR).
@@ -136,7 +136,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/stop" \
-H "X-API-Key: $API_KEY"
```
-#### POST /api/sessions/:id/logout
+#### POST /api/sessions/:sessionId/logout
Attempt an engine-native unlink of this device, then stop the session (OPERATOR). Requires a running
session. A `200` means the unlink operation AND the required local cleanup completed — it is not an
@@ -151,7 +151,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/logout" \
-H "X-API-Key: $API_KEY"
```
-#### POST /api/sessions/:id/force-kill
+#### POST /api/sessions/:sessionId/force-kill
Force-kill a stuck session (OPERATOR). Returns `400` when the session is not started (there is no live engine to kill).
@@ -160,7 +160,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/force-kill
-H "X-API-Key: $API_KEY"
```
-#### POST /api/sessions/:id/pairing-code
+#### POST /api/sessions/:sessionId/pairing-code
Request an 8-char pairing code via phone number (OPERATOR).
@@ -171,7 +171,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/pairing-co
-d '{ "phoneNumber": "628123456789" }'
```
-#### POST /api/sessions/:id/presence/subscribe
+#### POST /api/sessions/:sessionId/presence/subscribe
Subscribe to presence updates (online/typing) for a chat (OPERATOR). Baileys only — whatsapp-web.js
answers `501`. The subscription belongs to the connection: re-issue it after a restart or reconnect.
@@ -184,7 +184,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/presence/s
-d '{ "chatId": "[email protected]" }'
```
-#### GET /api/sessions/:id/presence/:chatId
+#### GET /api/sessions/:sessionId/presence/:chatId
Read the last presence report received for a chat (any role). Returns `200` with a `null` body when
nothing has been reported yet — presence is held in memory, never persisted.
@@ -194,7 +194,7 @@ curl "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/presence/123456789
-H "X-API-Key: $API_KEY"
```
-#### PUT /api/sessions/:id/presence
+#### PUT /api/sessions/:sessionId/presence
Set the account's OWN global presence — appear online or offline (OPERATOR, both engines). The
setting does not survive a restart or reconnect; re-issue it after `session.status` reports one.
@@ -206,7 +206,7 @@ curl -X PUT "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/presence" \
-d '{ "available": false }'
```
-#### POST /api/sessions/:id/chats/read
+#### POST /api/sessions/:sessionId/chats/read
Mark a chat as read/seen (OPERATOR).
@@ -217,7 +217,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/read
-d '{ "chatId": "[email protected]" }'
```
-#### POST /api/sessions/:id/chats/unread
+#### POST /api/sessions/:sessionId/chats/unread
Mark a chat as unread (OPERATOR).
@@ -228,7 +228,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/unre
-d '{ "chatId": "[email protected]" }'
```
-#### DELETE /api/sessions/:id/chats/:chatId/messages
+#### DELETE /api/sessions/:sessionId/chats/:chatId/messages
Delete every message in a chat, keeping the chat.
@@ -237,7 +237,7 @@ curl -X DELETE "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/12
-H "X-API-Key: $API_KEY"
```
-#### POST /api/sessions/:id/chats/archive
+#### POST /api/sessions/:sessionId/chats/archive
Archive or unarchive a chat.
@@ -247,7 +247,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/arch
-d '{"chatId":"[email protected]","archive":true}'
```
-#### POST /api/sessions/:id/chats/mute
+#### POST /api/sessions/:sessionId/chats/mute
Mute a chat until an epoch-**milliseconds** timestamp, or send `"muteUntil":null` to unmute (OPERATOR).
@@ -257,7 +257,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/mute
-d '{"chatId":"[email protected]","muteUntil":1800000000000}'
```
-#### POST /api/sessions/:id/chats/pin
+#### POST /api/sessions/:sessionId/chats/pin
Pin a chat to the top of the list, or unpin it (OPERATOR). WhatsApp allows at most three pinned chats.
@@ -267,7 +267,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/pin"
-d '{"chatId":"[email protected]","pin":true}'
```
-#### POST /api/sessions/:id/chats/delete
+#### POST /api/sessions/:sessionId/chats/delete
Delete a chat from the chat list (OPERATOR).
@@ -278,7 +278,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/dele
-d '{ "chatId": "[email protected]" }'
```
-#### POST /api/sessions/:id/chats/typing
+#### POST /api/sessions/:sessionId/chats/typing
Send a typing/recording presence indicator (or clear it with `paused`) (OPERATOR).
@@ -289,7 +289,7 @@ curl -X POST "$BASE/api/sessions/8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a/chats/typi
-d '{ "chatId": "[email protected]", "state": "typing" }'
```
-#### DELETE /api/sessions/:id
+#### DELETE /api/sessions/:sessionId
Delete a session (OPERATOR). Returns `204` with no body.
diff --git a/docs/12-troubleshooting-faq.md b/docs/12-troubleshooting-faq.md
index 9a02ca581..fafc82968 100644
--- a/docs/12-troubleshooting-faq.md
+++ b/docs/12-troubleshooting-faq.md
@@ -250,13 +250,13 @@ Proxy egress (if WhatsApp is blocked on your network) is configured **per sessio
unreachable proxy silently blocks the WhatsApp WebSocket (see the _No QR code appears, or `/start`
returns `504`_ entry below).
-### Issue: No QR code appears, or `POST /api/sessions/:id/start` returns `504`
+### Issue: No QR code appears, or `POST /api/sessions/:sessionId/start` returns `504`
**Symptoms:**
-- `POST /api/sessions/:id/start` returns `504 Gateway Timeout`
+- `POST /api/sessions/:sessionId/start` returns `504 Gateway Timeout`
(`WhatsApp Web authentication timed out...`)
-- No QR code is ever produced — `GET /api/sessions/:id/qr` never has one
+- No QR code is ever produced — `GET /api/sessions/:sessionId/qr` never has one
- Engine log shows `Session engine failed: auth timeout` after ~30s
**Cause:** The session was created with a `proxyUrl` that doesn't resolve to a real, reachable proxy
@@ -281,7 +281,7 @@ curl -X POST "$BASE/api/sessions" -H "X-API-Key: $API_KEY" -H "Content-Type: app
> **Engine:** This issue applies to the `whatsapp-web.js` engine only. If you are using `ENGINE_TYPE=baileys`, skip this section.
**Symptoms:** After scanning the QR the phone links the device, but the session stays at
-`authenticating` indefinitely and never becomes `ready`. `GET /sessions/:id/qr` returns 400 while
+`authenticating` indefinitely and never becomes `ready`. `GET /sessions/:sessionId/qr` returns 400 while
stuck. Often seen on ARM64 (e.g. Raspberry Pi) after upgrading to v0.2.x.
**Cause:** whatsapp-web.js auto-selects a WhatsApp Web client version, and an incompatible version
@@ -528,8 +528,8 @@ onboarding_dialog_unrecognized`) carrying the dialog's heading and button labels
> that warning, the page is gone and the stop → start below is required rather than optional.
**Fix:** acknowledge the modal once (open WhatsApp Web in the account holder's own browser and click
-through the "What's new" screen), **then restart the session** (`POST /sessions/:id/stop` →
-`POST /sessions/:id/start`). Acknowledging alone does not return the session to `ready` — the status
+through the "What's new" screen), **then restart the session** (`POST /sessions/:sessionId/stop` →
+`POST /sessions/:sessionId/start`). Acknowledging alone does not return the session to `ready` — the status
is deliberately sticky — but the restart re-drives the engine from the stored credentials, so no new
QR scan is needed. If the modal never actually appeared (a false trip is possible but rare), the
same stop → start clears it.
diff --git a/docs/14-migration-guide.md b/docs/14-migration-guide.md
index 22d387e0b..1ba2b750a 100644
--- a/docs/14-migration-guide.md
+++ b/docs/14-migration-guide.md
@@ -568,9 +568,9 @@ Baileys — BAILEYS_AUTH_DIR, default ./data/baileys
> [!IMPORTANT]
> **Directories are keyed by session NAME, not by the REST id.** The API addresses a session by its
-> UUID (`/api/sessions/{id}`), but the engine receives `session.name` as its client id, so the on-disk
+> UUID (`/api/sessions/{sessionId}`), but the engine receives `session.name` as its client id, so the on-disk
> profile is `session-<name>` (whatsapp-web.js) or `<name>` (Baileys). Resolve the name via
-> `GET /api/sessions/{id}` before copying anything.
+> `GET /api/sessions/{sessionId}` before copying anything.
### Transfer Methods
@@ -585,7 +585,7 @@ Under the shipped compose the data directory lives in a named Docker volume
(`openwa-data:/app/data`), not a host bind mount, so the profile is copied through the container
with `docker compose cp` rather than straight off the host filesystem. `APP_DIR` is the directory
holding `docker-compose.yml` on each server; `SESSION_NAME` is the session `name` (resolve it via
-`GET /api/sessions/{id}` — the on-disk directory is keyed by name, not by the REST id).
+`GET /api/sessions/{sessionId}` — the on-disk directory is keyed by name, not by the REST id).
```bash
APP_DIR=/srv/openwa # docker compose project directory on both hosts
diff --git a/docs/17-dashboard-design.md b/docs/17-dashboard-design.md
index 141dd1a54..4e112bdda 100644
--- a/docs/17-dashboard-design.md
+++ b/docs/17-dashboard-design.md
@@ -199,12 +199,13 @@ a non-admin hitting the path falls through to the `*` redirect.
│ └─────────────────────────────────────────────────────────────┘ │
│ │
│ Unlink Device attempts an engine-native unlink of this companion │
-│ device (POST /sessions/:id/logout), then stops the session. A 200 │
-│ means the unlink + local cleanup completed (not an independent │
-│ Linked-Devices observation) — reconnecting then requires a fresh │
-│ QR scan or pairing code. A 502 (SESSION_LOGOUT_INCOMPLETE) stops │
-│ locally but leaves the operation incomplete; retry after starting. │
-│ Delete only clears the local data; it does NOT unlink. │
+│ device (POST /sessions/:sessionId/logout), then stops the │
+│ session. A 200 means the unlink + local cleanup completed (not an │
+│ independent Linked-Devices observation) — reconnecting then │
+│ requires a fresh QR scan or pairing code. A 502 │
+│ (SESSION_LOGOUT_INCOMPLETE) stops locally but leaves the │
+│ operation incomplete; retry after starting. Delete only clears │
+│ the local data; it does NOT unlink. │
│ │
│ ┌─────────────────────┬─────────────────────┐ │
│ │ 📊 Statistics │ ⚙️ Configuration │ │
diff --git a/openapi.json b/openapi.json
index 864efd1ac..1a4953605 100644
--- a/openapi.json
+++ b/openapi.json
@@ -416,12 +416,12 @@
]
}
},
- "/api/sessions/{id}": {
+ "/api/sessions/{sessionId}": {
"get": {
"operationId": "SessionController_findOne",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -454,7 +454,7 @@
"operationId": "SessionController_delete",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -480,12 +480,12 @@
]
}
},
- "/api/sessions/{id}/config": {
+ "/api/sessions/{sessionId}/config": {
"get": {
"operationId": "SessionController_getConfig",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -519,7 +519,7 @@
"operationId": "SessionController_updateConfig",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -562,12 +562,12 @@
]
}
},
- "/api/sessions/{id}/start": {
+ "/api/sessions/{sessionId}/start": {
"post": {
"operationId": "SessionController_start",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -603,12 +603,12 @@
]
}
},
- "/api/sessions/{id}/stop": {
+ "/api/sessions/{sessionId}/stop": {
"post": {
"operationId": "SessionController_stop",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -641,13 +641,13 @@
]
}
},
- "/api/sessions/{id}/logout": {
+ "/api/sessions/{sessionId}/logout": {
"post": {
"description": "Attempts an engine-native unlink of this companion device, then tears the session down locally. `200` means the engine-native unlink operation completed AND the required local credential cleanup completed — for Baileys a valid companion identity, an acknowledged `remove-companion-device` IQ response, and removal of the on-disk auth dir; for whatsapp-web.js the native `Client.logout()` promise settled. `200` is NOT an independent observation that the handset UI no longer shows the linked device. Because a completed unlink wipes the stored credentials, reconnecting after a `200` always requires a fresh QR scan or pairing code.",
"operationId": "SessionController_logout",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -697,12 +697,12 @@
]
}
},
- "/api/sessions/{id}/force-kill": {
+ "/api/sessions/{sessionId}/force-kill": {
"post": {
"operationId": "SessionController_forceKill",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -735,12 +735,12 @@
]
}
},
- "/api/sessions/{id}/qr": {
+ "/api/sessions/{sessionId}/qr": {
"get": {
"operationId": "SessionController_getQRCode",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -776,12 +776,12 @@
]
}
},
- "/api/sessions/{id}/pairing-code": {
+ "/api/sessions/{sessionId}/pairing-code": {
"post": {
"operationId": "SessionController_requestPairingCode",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -944,12 +944,12 @@
]
}
},
- "/api/sessions/{id}/chats": {
+ "/api/sessions/{sessionId}/chats": {
"get": {
"operationId": "SessionController_getChats",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1009,12 +1009,12 @@
]
}
},
- "/api/sessions/{id}/chats/read": {
+ "/api/sessions/{sessionId}/chats/read": {
"post": {
"operationId": "SessionController_markChatRead",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1063,13 +1063,13 @@
]
}
},
- "/api/sessions/{id}/presence/subscribe": {
+ "/api/sessions/{sessionId}/presence/subscribe": {
"post": {
"description": "Asks WhatsApp to start reporting who is online or typing in this chat. Updates arrive as the `presence.update` webhook and socket event — there is no synchronous answer, because presence cannot be queried from either engine, only received.\n\nThe subscription belongs to the connection: it does **not** survive a restart or an automatic reconnect, and must be re-issued. Subscribe per chat rather than to everything — WhatsApp emits an update on every transition, so a broad subscription is a firehose.\n\nwhatsapp-web.js cannot do this at all (it exposes no presence subscribe and emits no presence event) and answers `501`.",
"operationId": "SessionController_subscribeToPresence",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1118,13 +1118,13 @@
]
}
},
- "/api/sessions/{id}/presence": {
+ "/api/sessions/{sessionId}/presence": {
"put": {
"description": "Publishes whether this account appears online. WhatsApp routes notifications away from the phone while a linked device announces itself online, so a headless bot that never goes offline suppresses the phone's own alerts — set `available: false` to hand them back.\n\nThe setting belongs to the connection: it does not survive a restart or reconnect and must be re-issued after `session.status` reports one (on Baileys the socket re-announces itself per its connect-time behaviour). Supported on both engines.",
"operationId": "SessionController_setOnlinePresence",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1170,13 +1170,13 @@
]
}
},
- "/api/sessions/{id}/presence/{chatId}": {
+ "/api/sessions/{sessionId}/presence/{chatId}": {
"get": {
"description": "Serves the most recent report received since the chat was subscribed. Returns `null` when nothing has been reported — either the chat was never subscribed, or nothing has changed since. That is a normal state, not a missing resource, so it is `200` with a null body rather than a `404`.\n\nHeld in memory and never persisted: presence is short-lived, and answering \"typing\" from before a restart would be worse than answering nothing.",
"operationId": "SessionController_getPresence",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1215,12 +1215,12 @@
]
}
},
- "/api/sessions/{id}/chats/unread": {
+ "/api/sessions/{sessionId}/chats/unread": {
"post": {
"operationId": "SessionController_markChatUnread",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1269,12 +1269,12 @@
]
}
},
- "/api/sessions/{id}/chats/{chatId}/messages": {
+ "/api/sessions/{sessionId}/chats/{chatId}/messages": {
"delete": {
"operationId": "SessionController_clearChatMessages",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1322,12 +1322,12 @@
]
}
},
- "/api/sessions/{id}/chats/archive": {
+ "/api/sessions/{sessionId}/chats/archive": {
"post": {
"operationId": "SessionController_archiveChat",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1376,12 +1376,12 @@
]
}
},
- "/api/sessions/{id}/chats/mute": {
+ "/api/sessions/{sessionId}/chats/mute": {
"post": {
"operationId": "SessionController_muteChat",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1430,12 +1430,12 @@
]
}
},
- "/api/sessions/{id}/chats/pin": {
+ "/api/sessions/{sessionId}/chats/pin": {
"post": {
"operationId": "SessionController_pinChat",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1484,12 +1484,12 @@
]
}
},
- "/api/sessions/{id}/chats/delete": {
+ "/api/sessions/{sessionId}/chats/delete": {
"post": {
"operationId": "SessionController_deleteChat",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -1538,12 +1538,12 @@
]
}
},
- "/api/sessions/{id}/chats/typing": {
+ "/api/sessions/{sessionId}/chats/typing": {
"post": {
"operationId": "SessionController_sendChatState",
"parameters": [
{
- "name": "id",
+ "name": "sessionId",
"required": true,
"in": "path",
"description": "Session ID",
@@ -9915,7 +9915,7 @@
},
"config": {
"type": "object",
- "description": "Session configuration. Only three keys are read: autoRejectCalls (boolean, default false) rejects incoming calls as soon as they ring — the call.received event is still emitted first; maxReconnectAttempts (0-20, default unlimited) caps consecutive reconnects; and reconnectBaseDelay (1000-300000 ms, default 5000) sets the backoff base. Anything else is stored but ignored. All three can be changed later with PATCH /api/sessions/{id}/config, without restarting the session.",
+ "description": "Session configuration. Only three keys are read: autoRejectCalls (boolean, default false) rejects incoming calls as soon as they ring — the call.received event is still emitted first; maxReconnectAttempts (0-20, default unlimited) caps consecutive reconnects; and reconnectBaseDelay (1000-300000 ms, default 5000) sets the backoff base. Anything else is stored but ignored. All three can be changed later with PATCH /api/sessions/{sessionId}/config, without restarting the session.",
"example": {
"autoRejectCalls": false,
"maxReconnectAttempts": 5,
@@ -10048,7 +10048,7 @@
},
"engineLoaded": {
"type": "boolean",
- "description": "Whether the gateway currently holds a live engine for this session. This is the precondition the lifecycle routes actually enforce, and `status` alone does not imply it: a `disconnected` session keeps its engine for the duration of an automatic reconnect backoff, while a session stopped through `POST /sessions/:id/stop` carries the same status with no engine. When `true`, `stop`, `logout` and `force-kill` can act and `start` answers 400; when `false`, the reverse. Derived per request from live process state, so it is never persisted and never historical.",
+ "description": "Whether the gateway currently holds a live engine for this session. This is the precondition the lifecycle routes actually enforce, and `status` alone does not imply it: a `disconnected` session keeps its engine for the duration of an automatic reconnect backoff, while a session stopped through `POST /sessions/:sessionId/stop` carries the same status with no engine. When `true`, `stop`, `logout` and `force-kill` can act and `start` answers 400; when `false`, the reverse. Derived per request from live process state, so it is never persisted and never historical.",
"example": true
}
},
diff --git a/src/modules/group/group.controller.ts b/src/modules/group/group.controller.ts
index fd963f667..83aa31841 100644
--- a/src/modules/group/group.controller.ts
+++ b/src/modules/group/group.controller.ts
@@ -50,7 +50,7 @@ const PARTICIPANT_ID_400 =
'A participant does not name an individual. Pass a phone number, `<phone>@c.us` or `<lid>@lid`; ' +
'a group id or free text is rejected.';
-// NOTE: the session→groups LIST lives on the SessionController at GET /sessions/:id/groups (it
+// NOTE: the session→groups LIST lives on the SessionController at GET /sessions/:sessionId/groups (it
// registered first and owns the canonical narrow projection). A bare @Get() here would collide on
// the same path pattern (/sessions/{x}/groups) and be shadowed, so this controller owns only the
// group sub-resource routes (:groupId/...) under the same mount.
diff --git a/src/modules/session/dto/create-session.dto.ts b/src/modules/session/dto/create-session.dto.ts
index 8f17b0135..64d61d9d4 100644
--- a/src/modules/session/dto/create-session.dto.ts
+++ b/src/modules/session/dto/create-session.dto.ts
@@ -22,7 +22,7 @@ export class CreateSessionDto {
'rejects incoming calls as soon as they ring — the call.received event is still emitted ' +
'first; maxReconnectAttempts (0-20, default unlimited) caps consecutive reconnects; and ' +
'reconnectBaseDelay (1000-300000 ms, default 5000) sets the backoff base. Anything else is ' +
- 'stored but ignored. All three can be changed later with PATCH /api/sessions/{id}/config, ' +
+ 'stored but ignored. All three can be changed later with PATCH /api/sessions/{sessionId}/config, ' +
'without restarting the session.',
example: { autoRejectCalls: false, maxReconnectAttempts: 5, reconnectBaseDelay: 5000 },
})
diff --git a/src/modules/session/dto/session-response.dto.ts b/src/modules/session/dto/session-response.dto.ts
index eaaf401bd..83138fa39 100644
--- a/src/modules/session/dto/session-response.dto.ts
+++ b/src/modules/session/dto/session-response.dto.ts
@@ -87,7 +87,7 @@ export class SessionResponseDto {
'Whether the gateway currently holds a live engine for this session. This is the precondition ' +
'the lifecycle routes actually enforce, and `status` alone does not imply it: a `disconnected` ' +
'session keeps its engine for the duration of an automatic reconnect backoff, while a session ' +
- 'stopped through `POST /sessions/:id/stop` carries the same status with no engine. When `true`, ' +
+ 'stopped through `POST /sessions/:sessionId/stop` carries the same status with no engine. When `true`, ' +
'`stop`, `logout` and `force-kill` can act and `start` answers 400; when `false`, the reverse. ' +
'Derived per request from live process state, so it is never persisted and never historical.',
example: true,
diff --git a/src/modules/session/session.controller.spec.ts b/src/modules/session/session.controller.spec.ts
index c94e3d291..cf3f6a995 100644
--- a/src/modules/session/session.controller.spec.ts
+++ b/src/modules/session/session.controller.spec.ts
@@ -95,7 +95,7 @@ describe('SessionController — create() response contract', () => {
});
});
-// POST /sessions/:id/logout audits SESSION_LOGGED_OUT only after the service resolves — an
+// POST /sessions/:sessionId/logout audits SESSION_LOGGED_OUT only after the service resolves — an
// incomplete engine-backed attempt (502 SESSION_LOGOUT_INCOMPLETE) must NOT record a success
// audit row, and the service's structured rejection must be forwarded verbatim.
describe('SessionController — logout() audit + error forwarding contract', () => {
@@ -158,7 +158,7 @@ describe('SessionController — logout() audit + error forwarding contract', ()
});
});
-// POST /sessions/:id/start and /stop are thin, but they carry two contracts worth pinning: the
+// POST /sessions/:sessionId/start and /stop are thin, but they carry two contracts worth pinning: the
// success audit row is written ONLY after the service resolves (a refused lifecycle change — the
// engine-not-started 400, the foreign-node 409 — must leave no audit trace), and `engineLoaded`
// in the response comes from the live engine map, not from the row's status column.
diff --git a/src/modules/session/session.controller.ts b/src/modules/session/session.controller.ts
index 62a262dcf..4a9703144 100644
--- a/src/modules/session/session.controller.ts
+++ b/src/modules/session/session.controller.ts
@@ -46,7 +46,7 @@ import { ENGINE_NOT_READY_409 } from '../../common/openapi/engine-status-respons
@ApiTags('sessions')
@Controller('sessions')
-// The `:id` route param here is a WhatsApp session id, so the ApiKeyGuard enforces a key's
+// The `:sessionId` route param here is a WhatsApp session id, so the ApiKeyGuard enforces a key's
// allowedSessions scope against it (other controllers' `:id` is an unrelated resource id).
@SessionScoped()
export class SessionController {
@@ -106,34 +106,34 @@ export class SessionController {
return sessions.map(s => this.transformSession(s));
}
- @Get(':id')
+ @Get(':sessionId')
@ApiOperation({ summary: 'Get session by ID' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'Session details',
type: SessionResponseDto,
})
@ApiResponse({ status: 404, description: 'Session not found' })
- async findOne(@Param('id', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
+ async findOne(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
const session = await this.sessionService.findOne(id);
return this.transformSession(session);
}
- @Get(':id/config')
+ @Get(':sessionId/config')
@ApiOperation({ summary: 'Get the tunable configuration for a session' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'Effective session configuration',
type: SessionConfigResponseDto,
})
@ApiResponse({ status: 404, description: 'Session not found' })
- async getConfig(@Param('id', ParseUUIDPipe) id: string): Promise<SessionConfigResponseDto> {
+ async getConfig(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionConfigResponseDto> {
return this.sessionService.getConfig(id);
}
- @Patch(':id/config')
+ @Patch(':sessionId/config')
@RequireRole(ApiKeyRole.OPERATOR)
@ApiOperation({
summary: 'Update the tunable configuration for a session',
@@ -143,7 +143,7 @@ export class SessionController {
'`autoRejectCalls` is re-read on every incoming call, so it applies immediately; the two ' +
'reconnect settings are read once per start and therefore apply on the next start.',
})
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'Updated session configuration',
@@ -152,7 +152,7 @@ export class SessionController {
@ApiResponse({ status: 400, description: 'A supplied value is outside its accepted range' })
@ApiResponse({ status: 404, description: 'Session not found' })
async updateConfig(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: UpdateSessionConfigDto,
): Promise<SessionConfigResponseDto> {
const config = await this.sessionService.updateConfig(id, dto);
@@ -165,11 +165,11 @@ export class SessionController {
return config;
}
- @Delete(':id')
+ @Delete(':sessionId')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Delete a session' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 204, description: 'Session deleted' })
@ApiResponse({ status: 404, description: 'Session not found' })
@ApiResponse({
@@ -180,7 +180,7 @@ export class SessionController {
"another node currently holds this session's live engine and deleting it here would strip a " +
'session the owner is running. No destructive side effect runs before either refusal.',
})
- async delete(@Param('id', ParseUUIDPipe) id: string): Promise<void> {
+ async delete(@Param('sessionId', ParseUUIDPipe) id: string): Promise<void> {
const session = await this.sessionService.findOne(id);
await this.sessionService.delete(id);
await this.auditService.logInfo(AuditAction.SESSION_DELETED, {
@@ -189,13 +189,13 @@ export class SessionController {
});
}
- @Post(':id/start')
+ @Post(':sessionId/start')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({
summary: 'Start a session and initialize WhatsApp connection',
})
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'Session started',
@@ -213,7 +213,7 @@ export class SessionController {
"session's engine: only the owner may start it, and the claim is refused before any engine " +
'is launched, so no second connection to the account is opened.',
})
- async start(@Param('id', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
+ async start(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
const session = await this.sessionService.start(id);
await this.auditService.logInfo(AuditAction.SESSION_STARTED, {
sessionId: session.id,
@@ -222,11 +222,11 @@ export class SessionController {
return this.transformSession(session);
}
- @Post(':id/stop')
+ @Post(':sessionId/stop')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Stop a session and disconnect WhatsApp' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'Session stopped',
@@ -240,7 +240,7 @@ export class SessionController {
'it here would report the session down while the owner keeps running it, so the request is ' +
'refused. Retry against the owning node, or once its lease has lapsed.',
})
- async stop(@Param('id', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
+ async stop(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
const session = await this.sessionService.stop(id);
await this.auditService.logInfo(AuditAction.SESSION_STOPPED, {
sessionId: session.id,
@@ -249,7 +249,7 @@ export class SessionController {
return this.transformSession(session);
}
- @Post(':id/logout')
+ @Post(':sessionId/logout')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({
@@ -264,7 +264,7 @@ export class SessionController {
'unlink wipes the stored credentials, reconnecting after a `200` always requires a fresh QR ' +
'scan or pairing code.',
})
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description:
@@ -306,7 +306,7 @@ export class SessionController {
"body carries `code: 'SESSION_LOGOUT_INCOMPLETE'`; `phone` is cleared and no success audit " +
'is written. Start the session again and retry the logout.',
})
- async logout(@Param('id', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
+ async logout(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
const session = await this.sessionService.logout(id);
await this.auditService.logInfo(AuditAction.SESSION_LOGGED_OUT, {
sessionId: session.id,
@@ -315,11 +315,11 @@ export class SessionController {
return this.transformSession(session);
}
- @Post(':id/force-kill')
+ @Post(':sessionId/force-kill')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Force-kill a stuck session (SIGKILL its wedged engine, then tear it down)' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'Session force-killed',
@@ -327,7 +327,7 @@ export class SessionController {
})
@ApiResponse({ status: 400, description: 'Session is not started' })
@ApiResponse({ status: 404, description: 'Session not found' })
- async forceKill(@Param('id', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
+ async forceKill(@Param('sessionId', ParseUUIDPipe) id: string): Promise<SessionResponseDto> {
const session = await this.sessionService.forceKill(id);
await this.auditService.logInfo(AuditAction.SESSION_FORCE_KILLED, {
sessionId: session.id,
@@ -336,10 +336,10 @@ export class SessionController {
return this.transformSession(session);
}
- @Get(':id/qr')
+ @Get(':sessionId/qr')
@RequireRole(ApiKeyRole.OPERATOR)
@ApiOperation({ summary: 'Get QR code for session authentication' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'QR code data',
@@ -351,7 +351,7 @@ export class SessionController {
})
@ApiResponse({ status: 404, description: 'Session not found' })
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- async getQRCode(@Param('id', ParseUUIDPipe) id: string): Promise<QRCodeResponseDto> {
+ async getQRCode(@Param('sessionId', ParseUUIDPipe) id: string): Promise<QRCodeResponseDto> {
const qrCode = await this.sessionService.getQRCode(id);
await this.auditService.logInfo(AuditAction.SESSION_QR_GENERATED, {
sessionId: id,
@@ -359,23 +359,23 @@ export class SessionController {
return qrCode;
}
- @Post(':id/pairing-code')
+ @Post(':sessionId/pairing-code')
@RequireRole(ApiKeyRole.OPERATOR)
@ApiOperation({ summary: 'Request an 8-char pairing code to link via phone number (alternative to QR)' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 201, description: 'Pairing code generated', type: PairingCodeResponseDto })
@ApiResponse({ status: 400, description: 'Session not started or already authenticated' })
@ApiResponse({ status: 404, description: 'Session not found' })
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async requestPairingCode(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: RequestPairingCodeDto,
): Promise<PairingCodeResponseDto> {
return this.sessionService.requestPairingCode(id, dto.phoneNumber);
}
- // `:sessionId`, not `:id`, so this shares a Path Item with GroupController's POST on the same
- // route. Two names for one positional segment split it into two contract entries.
+ // Shares a Path Item with GroupController's POST on the same route — one parameter name for the
+ // one positional segment, or the contract splits it into two entries.
@Get(':sessionId/groups')
@ApiOperation({ summary: 'Get all groups for a session' })
@ApiParam({ name: 'sessionId', description: 'Session ID' })
@@ -407,9 +407,9 @@ export class SessionController {
});
}
- @Get(':id/chats')
+ @Get(':sessionId/chats')
@ApiOperation({ summary: 'Get active chats for a session' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 200, description: 'List of active chats (most recent first)', type: [ChatSummaryDto] })
@ApiResponse({ status: 400, description: 'Session not ready' })
@ApiResponse({ status: 404, description: 'Session not found' })
@@ -423,7 +423,7 @@ export class SessionController {
@ApiQuery({ name: 'limit', required: false, description: 'Max chats to return (1–1000, default 1000)' })
@ApiQuery({ name: 'offset', required: false, description: 'Number of chats to skip (for paging)' })
async getChats(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Query('limit') limit?: string,
@Query('offset') offset?: string,
): Promise<ChatSummary[]> {
@@ -433,11 +433,11 @@ export class SessionController {
});
}
- @Post(':id/chats/read')
+ @Post(':sessionId/chats/read')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Mark a chat as read/seen' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 200, description: 'Chat marked as read successfully', type: SessionActionResponseDto })
@ApiResponse({ status: 400, description: 'Session not ready' })
@ApiResponse({ status: 404, description: 'Session not found' })
@@ -449,14 +449,14 @@ export class SessionController {
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async markChatRead(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: MarkChatReadDto,
): Promise<{ success: boolean }> {
const success = await this.sessionService.sendSeen(id, dto.chatId);
return { success };
}
- @Post(':id/presence/subscribe')
+ @Post(':sessionId/presence/subscribe')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({
@@ -471,7 +471,7 @@ export class SessionController {
'whatsapp-web.js cannot do this at all (it exposes no presence subscribe and emits no presence ' +
'event) and answers `501`.',
})
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description: 'Subscribed; updates now arrive as presence.update events',
@@ -482,14 +482,14 @@ export class SessionController {
@ApiResponse({ status: 501, description: 'The active engine cannot observe presence (whatsapp-web.js)' })
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async subscribeToPresence(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: SubscribePresenceDto,
): Promise<{ success: boolean }> {
await this.sessionService.subscribeToPresence(id, dto.chatId);
return { success: true };
}
- @Put(':id/presence')
+ @Put(':sessionId/presence')
@RequireRole(ApiKeyRole.OPERATOR)
@ApiOperation({
summary: "Set the account's own global presence (appear online or offline)",
@@ -501,20 +501,20 @@ export class SessionController {
'be re-issued after `session.status` reports one (on Baileys the socket re-announces itself ' +
'per its connect-time behaviour). Supported on both engines.',
})
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 200, description: 'Presence published', type: SessionActionResponseDto })
@ApiResponse({ status: 400, description: 'Session not started, or validation failed' })
@ApiResponse({ status: 404, description: 'Session not found' })
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async setOnlinePresence(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: SetOwnPresenceDto,
): Promise<{ success: boolean }> {
await this.sessionService.setOnlinePresence(id, dto.available);
return { success: true };
}
- @Get(':id/presence/:chatId')
+ @Get(':sessionId/presence/:chatId')
@RequireRole(ApiKeyRole.VIEWER)
@ApiOperation({
summary: "Read a chat's last reported presence",
@@ -526,23 +526,23 @@ export class SessionController {
'Held in memory and never persisted: presence is short-lived, and answering "typing" from ' +
'before a restart would be worse than answering nothing.',
})
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiParam({ name: 'chatId', description: 'Chat ID as subscribed' })
@ApiResponse({ status: 200, description: 'Last reported presence, or null', type: ChatPresenceResponseDto })
@ApiResponse({ status: 404, description: 'Session not found' })
async getPresence(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Param('chatId') chatId: string,
): Promise<ChatPresenceResponseDto | null> {
const presence = await this.sessionService.getPresence(id, chatId);
return presence ? { ...presence, observedAt: new Date(presence.observedAt) } : null;
}
- @Post(':id/chats/unread')
+ @Post(':sessionId/chats/unread')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Mark a chat as unread' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 200, description: 'Chat marked as unread successfully', type: SessionActionResponseDto })
@ApiResponse({ status: 400, description: 'Session not ready' })
@ApiResponse({ status: 404, description: 'Session not found' })
@@ -554,18 +554,18 @@ export class SessionController {
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async markChatUnread(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: MarkChatReadDto,
): Promise<{ success: boolean }> {
const success = await this.sessionService.markUnread(id, dto.chatId);
return { success };
}
- @Delete(':id/chats/:chatId/messages')
+ @Delete(':sessionId/chats/:chatId/messages')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Delete every message in a chat, keeping the chat itself' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiParam({ name: 'chatId', description: "Chat JID, e.g. [email protected] (URL-encode the '@')" })
@ApiResponse({
status: 200,
@@ -584,18 +584,18 @@ export class SessionController {
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async clearChatMessages(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Param('chatId') chatId: string,
): Promise<{ success: boolean }> {
const success = await this.sessionService.clearChatMessages(id, chatId);
return { success };
}
- @Post(':id/chats/archive')
+ @Post(':sessionId/chats/archive')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Archive or unarchive a chat' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description:
@@ -613,18 +613,18 @@ export class SessionController {
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async archiveChat(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: ArchiveChatDto,
): Promise<{ success: boolean }> {
const success = await this.sessionService.archiveChat(id, dto.chatId, dto.archive);
return { success };
}
- @Post(':id/chats/mute')
+ @Post(':sessionId/chats/mute')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Mute or unmute a chat' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description:
@@ -642,16 +642,19 @@ export class SessionController {
'the gateway stopped waiting for a confirmation that never came.',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- async muteChat(@Param('id', ParseUUIDPipe) id: string, @Body() dto: MuteChatDto): Promise<{ success: boolean }> {
+ async muteChat(
+ @Param('sessionId', ParseUUIDPipe) id: string,
+ @Body() dto: MuteChatDto,
+ ): Promise<{ success: boolean }> {
await this.sessionService.muteChat(id, dto.chatId, dto.muteUntil);
return { success: true };
}
- @Post(':id/chats/pin')
+ @Post(':sessionId/chats/pin')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Pin or unpin a chat at the top of the chat list' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({
status: 200,
description:
@@ -676,16 +679,16 @@ export class SessionController {
'the gateway stopped waiting for a confirmation that never came.',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- async pinChat(@Param('id', ParseUUIDPipe) id: string, @Body() dto: PinChatDto): Promise<{ success: boolean }> {
+ async pinChat(@Param('sessionId', ParseUUIDPipe) id: string, @Body() dto: PinChatDto): Promise<{ success: boolean }> {
const success = await this.sessionService.pinChat(id, dto.chatId, dto.pin);
return { success };
}
- @Post(':id/chats/delete')
+ @Post(':sessionId/chats/delete')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: 'Delete a chat from the chat list (e.g. a group you have left)' })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 200, description: 'Chat deleted successfully', type: SessionActionResponseDto })
@ApiResponse({ status: 400, description: 'Session not ready' })
@ApiResponse({ status: 404, description: 'Session not found' })
@@ -696,21 +699,24 @@ export class SessionController {
'the gateway stopped waiting for a confirmation that never came.',
})
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
- async deleteChat(@Param('id', ParseUUIDPipe) id: string, @Body() dto: DeleteChatDto): Promise<{ success: boolean }> {
+ async deleteChat(
+ @Param('sessionId', ParseUUIDPipe) id: string,
+ @Body() dto: DeleteChatDto,
+ ): Promise<{ success: boolean }> {
const success = await this.sessionService.deleteChat(id, dto.chatId);
return { success };
}
- @Post(':id/chats/typing')
+ @Post(':sessionId/chats/typing')
@RequireRole(ApiKeyRole.OPERATOR)
@HttpCode(HttpStatus.OK)
@ApiOperation({ summary: "Send a typing/recording presence indicator to a chat (or clear it with 'paused')" })
- @ApiParam({ name: 'id', description: 'Session ID' })
+ @ApiParam({ name: 'sessionId', description: 'Session ID' })
@ApiResponse({ status: 200, description: 'Presence sent', type: SessionActionResponseDto })
@ApiResponse({ status: 404, description: 'Session not found' })
@ApiResponse({ status: 409, description: ENGINE_NOT_READY_409 })
async sendChatState(
- @Param('id', ParseUUIDPipe) id: string,
+ @Param('sessionId', ParseUUIDPipe) id: string,
@Body() dto: SendChatStateDto,
): Promise<{ success: boolean }> {
await this.sessionService.sendChatState(id, dto.chatId, dto.state);
@@ -735,7 +741,7 @@ export class SessionController {
memoryUsage: { heapUsed: number; heapTotal: number; rss: number };
}> {
// Scope aggregate stats to the key's allowedSessions so a session-restricted key cannot enumerate
- // global session counts/status (the route carries no :id for the guard to scope against).
+ // global session counts/status (the route carries no :sessionId for the guard to scope against).
return this.sessionService.getStats(apiKey?.allowedSessions);
}
}
diff --git a/test/session-teardown-pending-http.e2e-spec.ts b/test/session-teardown-pending-http.e2e-spec.ts
index f220212c8..04e2a344a 100644
--- a/test/session-teardown-pending-http.e2e-spec.ts
+++ b/test/session-teardown-pending-http.e2e-spec.ts
@@ -78,7 +78,7 @@ describe('Session name-scoped teardown fence: 409 code survives HTTP serializati
}
});
- it('DELETE /api/sessions/:id serializes the teardown-pending 409 with the code field in the body', async () => {
+ it('DELETE /api/sessions/:sessionId serializes the teardown-pending 409 with the code field in the body', async () => {
const res = await request(app.getHttpServer()).delete(`/api/sessions/${sessionId}`).set('X-API-Key', adminKey);
expect(res.status).toBe(409);
@@ -93,7 +93,7 @@ describe('Session name-scoped teardown fence: 409 code survives HTTP serializati
expect((res.body as { message: unknown }).message).toEqual(expect.stringContaining('still in flight'));
});
- it('POST /api/sessions/:id/start serializes the teardown-pending 409 with the code field in the body', async () => {
+ it('POST /api/sessions/:sessionId/start serializes the teardown-pending 409 with the code field in the body', async () => {
const res = await request(app.getHttpServer()).post(`/api/sessions/${sessionId}/start`).set('X-API-Key', adminKey);
expect(res.status).toBe(409);