Docs menu

HTTP API

All endpoints except /healthz require a bearer token that satisfies the token contract. Request and response bodies are JSON with camelCase field names. Room ids are UUIDs.

Endpoints

Method and pathWho can call itRate bucketNode role
GET /healthzAnyoneUnauthenticatedAll roles
POST /rooms/{roomId}/messagesRoom memberssendAll, Api
GET /rooms/{roomId}/messagesRoom membersreadAll, Api
GET /rooms/{roomId}/participantsRoom membersreadAll, Api
GET /rooms/{roomId}/eventsRoom membersreadAll, Gateway
/admin/...adminadminAll, Api
/audit/...auditorreadAll, Api

"Room members" means the role cross-check passes and the caller is in room_members for that room. A room id that isn't a UUID returns 404 on member routes and 400 on admin routes.

Errors

Typed errors have this body:

{ "error": "<code>", "reason": "<optional text>" }
StatuserrorMeaning
400invalid_contentContent is empty or longer than Dotwire:MaxContentBytes UTF-8 bytes, including after a presend rewrite.
400invalid_user_idA user or sender id is empty, longer than 256 characters, or contains control characters.
400invalid_requestA request field is out of range. reason says which.
409self_role_changeAn admin tried to change or delete their own role.
409last_adminThe call would demote, delete or erase the last remaining admin.
409legal_holdA legal hold covers the room or the message's sender.
409minimum_keepThe message is younger than Dotwire:Compliance:MinimumKeepDays, or a retention value is below it.
409changes_not_allowedDotwire:Compliance:AllowChanges is false.
409erasure_openThe user has an open erasure, so roles, memberships and injected messages for them are refused.
409erasure_mode_conflictAn erasure for this user is already open with a different mode.
409self_erasureAn admin tried to erase their own user id.
409already_releasedThe legal hold was already released.
422presend_rejectedThe presend webhook rejected the message. reason is the webhook's reason.
429rate_limitedA rate bucket is empty, or an SSE connect would exceed Dotwire:MaxConnectionsPerUser. The Retry-After header gives the wait in seconds.
503presend_unavailableThe presend webhook failed and its fail policy is Closed.
503stream_unavailableJetStream didn't accept the message.
503audit_unavailabledotwire couldn't write the audit event for this call.
503access_log_unavailableThe access log is on and couldn't record this read or stream, so it wasn't served.
503notice_unavailableThe redaction succeeded, but its erasure notice couldn't be queued. Retry: redaction is idempotent and queues the notice again.

401, 403, and 404 responses have no body. Some admin validation failures return a bare 400. A request body larger than Dotwire:MaxRequestBodyBytes (256 KiB by default) gets a bare 413 before it's parsed.

Requests without a valid token are limited per client IP by the Unauthenticated bucket instead, and don't spend the bucket of the route they call.

Messages

Send a message

POST /rooms/{roomId}/messages

{ "content": "<message text>" }

Returns 202 Accepted once JetStream has stored the message:

{ "seq": 42, "time": "2026-11-06T12:00:00.123456+00:00" }

The sender is the token's sub. If a presend webhook is configured, it runs first. See Write path.

To make retries safe, send an Idempotency-Key header of 1 to 128 printable characters. A retry with the same key from the same sender in the same room, within JetStream's duplicate window, returns the original seq instead of storing a second message, and doesn't trigger postsend again.

Errors: invalid_content, invalid_user_id, invalid_request (malformed Idempotency-Key), presend_rejected, presend_unavailable, stream_unavailable, rate_limited.

With Dotwire:HubSend:Enabled, this endpoint and the hub Send method share one per-user send bucket. Over the limit it still answers 429 with Retry-After.

Read history

GET /rooms/{roomId}/messages

Query parameterDescription
afterSeqReturn messages with seq greater than this, oldest first. Use it for gap-fill.
beforeSeqReturn the page of messages just before this seq. Use it to page backwards.
limitPage size, 1 to 100. Default 50.

Without afterSeq or beforeSeq, you get the newest page. Messages in every page are in ascending seq order.

{
  "roomId": "a0000000-0000-0000-0000-000000000001",
  "messages": [
    { "seq": 41, "time": "2026-11-06T12:00:00.000000+00:00", "senderId": "alice", "content": "<message text>" }
  ],
  "hasMore": true
}

hasMore is true when another page exists in the direction you're reading. Redacted messages never appear. Erased messages appear with senderId dotwire:erased (anonymize mode) or not at all (delete mode).

With the access log on, each page is recorded before it's sent, and a page that can't be recorded is refused with 503 access_log_unavailable.

List participants

GET /rooms/{roomId}/participants

Returns a JSON array of member user ids, sorted:

["alice", "bob"]

It contains no profile data and isn't a presence snapshot. See Participants and presence.

Stream room events

GET /rooms/{roomId}/events streams text/event-stream. You can pass the token as an access_token query parameter instead of the Authorization header.

To resume, send the Last-Event-ID header, or pass afterSeq as a query parameter. dotwire replays history after that seq in pages of Dotwire:Sse:ReplayPageSize, then switches to live delivery without gaps or duplicates. Without either, the stream starts with live events only.

Events:

event:id:data:
messageThe message seq{ roomId, seq, senderId, time, content, replayed }. replayed is true for history replay.
typing—{ roomId, userId, isTyping }
presence—{ roomId, joined, left }
retracted—{ roomId, seq } for a redacted message
erased—{ roomId, mode, seqs } for messages an account erasure anonymized (mode anonymize) or deleted (delete)
revoked—{ roomId }. Your membership was revoked and the stream ends.

dotwire also sends a : ping comment every Dotwire:Sse:KeepAliveSeconds seconds (15 by default). The stream ends when the token expires, when your membership is revoked, when you fall more than Dotwire:Sse:BufferSize events behind, or after a resume has replayed Dotwire:Sse:MaxReplayRows messages (1,000 by default). Reconnect with Last-Event-ID to resume.

With the access log on, the stream is recorded as a live window when it opens, and each replay page as a history read. If the open can't be recorded, the request fails with 503 access_log_unavailable. If a replay page can't be recorded, the stream ends, and the client can reconnect.

If Dotwire:Sse:Enabled is false, this endpoint returns 404.

Admin

Every /admin route needs a token whose dw:role is admin and a matching row in user_roles. Every mutation writes an audit event and returns 503 audit_unavailable if it can't.

Roles

RequestBodyResponse
PUT /admin/users/{userId}/role{ "role": "member" }, with member, auditor, or admin200 { userId, role }. A bare 400 for any other role. 409 self_role_change on your own user id, 409 last_admin when it would demote the last admin.
GET /admin/users/{userId}/role—200 { userId, role }, or 404 if the user has no role
DELETE /admin/users/{userId}/role—204. Also removes every room membership the user has and revokes their live connections. 409 self_role_change on your own user id, 409 last_admin for the last admin.
GET /admin/users/{userId}/rooms—200 { userId, roomIds }

Membership

RequestBodyResponse
POST /admin/rooms/{roomId}/members{ "userIds": ["alice"], "ensureMemberRole": false }200 { roomId, members }, listing the ids you sent. A bare 400 if userIds is empty.
DELETE /admin/rooms/{roomId}/members/{userId}—204. Revokes the user's live connections to the room.
GET /admin/rooms/{roomId}/members—200 { roomId, members }, sorted

ensureMemberRole is optional and defaults to false. When true, users without a role get member; existing roles are left alone.

Inject a message

POST /admin/rooms/{roomId}/messages

{ "content": "<message text>", "senderId": "system" }

senderId is optional and defaults to system. Returns 202 with { seq, time }, or 409 erasure_open if senderId has an open erasure. The admin doesn't need to be a room member. Presend and postsend run only when their IncludeAdminSends setting is on.

dotwire writes the audit event after JetStream accepts the message and before live fanout. If the audit event can't be written, dotwire erases the message from JetStream and Postgres and returns 503 audit_unavailable. No client receives the message, so retrying doesn't create a duplicate.

Redact a message

DELETE /admin/rooms/{roomId}/messages/{seq}

{ "roomId": "a0000000-0000-0000-0000-000000000001", "seq": 42, "removedFromHistory": true, "removedFromStream": true }

Returns 404 if seq belongs to a different room, and 503 if JetStream can't be reached. Redaction is idempotent: retrying after success returns 200 with both flags false. See Redaction.

It answers 409 legal_hold, 409 minimum_keep or 409 changes_not_allowed when a hold or compliance setting protects the message. A refusal changes nothing and writes no audit event. When the erasure webhook is set, a successful redaction queues an erasure notice, and 503 notice_unavailable means the message is gone but the notice wasn't queued.

Emergency deletion

POST /admin/rooms/{roomId}/messages/{seq}/emergency-delete

{ "reason": "illegal_content" }

reason is illegal_content or court_order; anything else is 400 invalid_request. It works like redaction and returns the same body, but ignores legal holds, MinimumKeepDays and AllowChanges. The audit event is message.redacted.emergency, with the reason code as its value. Use it only with a documented basis.

RequestBodyResponse
POST /admin/holds{ "roomId": "<uuid>", "matterRef": "case-2026-114" } or { "userId": "dave", "matterRef": "..." }, exactly one of roomId and userId201 with the hold. 400 invalid_request for both or neither target, or a matterRef that's empty, over 256 characters or has control characters.
DELETE /admin/holds/{id}—204. 404 for an unknown id, 409 already_released for a released hold.
GET /admin/holds?active=true—200 with an array of holds, oldest first. active=false lists released holds.
{
  "id": 7,
  "scope": "room",
  "roomId": "a0000000-0000-0000-0000-000000000001",
  "userId": null,
  "matterRef": "case-2026-114",
  "placedBy": "host-admin",
  "placedAt": "2026-11-27T10:00:00+00:00",
  "releasedAt": null,
  "releasedBy": null
}

Placing a hold pauses retention, then waits up to Dotwire:Compliance:HoldRetentionWaitSeconds for a retention job that was already running. Chunks that job dropped before the hold can't be restored. Releasing a hold wakes the erasure worker. The audit events (hold.placed, hold.released) carry the hold id, never matterRef.

Account erasure

RequestBodyResponse
POST /admin/users/{userId}/eraseOptional { "mode": "delete" }, anonymize or delete. Defaults to Dotwire:Compliance:Erasure:Mode.202 with the erasure status. Repeating the call while it's open returns the same erasure. 409 self_erasure, 409 last_admin, or 409 erasure_mode_conflict when one is open with the other mode.
GET /admin/erasures/{id}—200 with the status, or 404.
GET /admin/users/{userId}/erasures—200 with every erasure for the user, oldest first.
{
  "id": 3,
  "userId": "dave",
  "mode": "anonymize",
  "requestedAt": "2026-11-27T10:00:00+00:00",
  "status": "waiting",
  "remaining": 12,
  "blockedBy": ["legal_hold"],
  "completedAt": null
}

The request revokes the user's memberships and role at once, like DELETE /admin/users/{userId}/role. status is in_progress while the worker can still act, waiting when every remaining message is blocked (blockedBy lists legal_hold, changes_not_allowed and minimum_keep as they apply), and completed once no message from the user is left. See Legal holds and erasure.

Compliance settings

GET /admin/compliance returns the config-only compliance settings and the current hold state:

{
  "allowChanges": true,
  "minimumKeepDays": 0,
  "erasureMode": "anonymize",
  "activeHolds": 1,
  "retentionPaused": true,
  "accessLogEnabled": false,
  "accessLogRetentionDays": 0
}

Retention

RequestBodyResponse
GET /admin/retention—200 { "messagesDays": 90, "paused": false }. 0 means indefinite. paused is true while a legal hold is active.
PUT /admin/retention{ "messagesDays": 90 }, from 0 to 36,500200 { messagesDays, paused }. 400 invalid_request if out of range, 409 minimum_keep for a value between 0 and MinimumKeepDays.

Export a user's data

GET /admin/users/{userId}/export streams one JSON document:

{
  "userId": "dave",
  "exportedAt": "2026-11-06T12:00:00+00:00",
  "role": "member",
  "roomIds": ["a0000000-0000-0000-0000-000000000001"],
  "messages": [
    { "roomId": "a0000000-0000-0000-0000-000000000001", "seq": 42, "time": "2026-11-06T11:59:00+00:00", "content": "<message text>" }
  ],
  "auditEvents": [
    { "id": 17, "eventType": "member.added", "roomId": "a0000000-0000-0000-0000-000000000001", "messageSeq": null, "actorId": "host-admin", "subjectId": "dave", "value": null, "time": "2026-11-06T11:00:00+00:00" }
  ],
  "accessLog": [
    { "time": "2026-11-06T11:30:00+00:00", "event": "history.read", "roomId": "a0000000-0000-0000-0000-000000000001", "userId": "dave", "actorId": null, "role": "member", "via": "rest", "windowId": null, "expiresAt": null, "reason": null, "fromSeq": 1, "toSeq": 42, "count": 42 }
  ]
}

messages holds every message the user sent, decrypted. A message that can't be decrypted has "content": null and "undecryptable": true. role is null if the user has none. accessLog holds the raw access-log rows where the user is the subject or the dw:actor, and is empty while the access log is off.

Audit

Every /audit route needs a token whose dw:role is auditor and a matching row in user_roles. admin is not enough. Every call writes an audit.read event, or access_log.read for /audit/access.

Read the log

GET /audit?afterId=0&limit=100

afterId defaults to 0. limit is 1 to 500, default 100.

{
  "events": [
    {
      "id": 1,
      "eventType": "role.set.member",
      "roomId": null,
      "messageSeq": null,
      "actorId": "host-admin",
      "subjectId": "user-42",
      "value": null,
      "time": "2026-11-06T12:00:00.000000+00:00",
      "hash": "<lowercase-hex-sha256>"
    }
  ],
  "hasMore": false
}

Read the access log

GET /audit/access?from=2026-11-27T00:00:00Z&to=2026-11-28T00:00:00Z&roomId=<uuid>&userId=dave&limit=100&cursor=<next>

from is required, ISO 8601. to defaults to now. roomId and userId are optional filters, limit is 1 to 500 (default 100), and cursor is the next value of the previous page. Each call writes an access_log.read audit event with the filters as its room and subject. The response has Cache-Control: no-store.

{
  "entries": [
    {
      "kind": "live",
      "roomId": "a0000000-0000-0000-0000-000000000001",
      "userId": "dave",
      "actorId": null,
      "role": "member",
      "via": "hub",
      "start": "2026-11-27T09:58:00+00:00",
      "windowId": "8f6c1e0a-6d0e-4b8e-9d36-1f3c0c2b7a11",
      "end": "2026-11-27T10:20:00+00:00",
      "endReason": "left",
      "expiresAt": "2026-11-27T10:58:00+00:00",
      "fromSeq": null,
      "toSeq": null,
      "count": null
    },
    {
      "kind": "history",
      "roomId": "a0000000-0000-0000-0000-000000000001",
      "userId": "dave",
      "actorId": "host-admin",
      "role": "member",
      "via": "rest",
      "start": "2026-11-27T10:05:00+00:00",
      "windowId": null,
      "end": null,
      "endReason": null,
      "expiresAt": null,
      "fromSeq": 1,
      "toSeq": 42,
      "count": 42
    }
  ],
  "next": null
}

A live entry is one hub subscribe or SSE stream that overlaps the range, including one opened before from. endReason is left, disconnected, revoked or error. When end is null, the window is still open or its close was lost, and expiresAt (the token's exp) is the latest it can have ended. A history entry is one page served by REST history or SSE replay. Entries are ordered by start. See Access log.

Verify the chain

GET /audit/verify?full=false

Returns { ok, fromId, toId, checked, firstInvalidId, anchor }. See Read and verify.

List checkpoints

GET /audit/checkpoints?limit=30

limit is 1 to 365, default 30. Newest first.

{
  "checkpoints": [
    { "day": "2026-11-05", "lastId": 1200, "hash": "<lowercase-hex-sha256>", "createdAt": "2026-11-06T00:00:01+00:00" }
  ]
}