threads plus one thread_messages row per turn. The arena creates a thread on the first message of a new chat and passes its ID as threadId on every later call.
Lifecycle
1
Create
POST /api/threads with { title, mode }. The API first upserts the caller into public.users, then inserts the thread. Defaults: title New Chat, mode battle, visibility private.2
Append turns
Every
dualchat or chat call that carries threadId writes a thread_messages row with the prompt, model names, answers, timings and, for battles, the comparison_id. The streaming endpoint does not write messages.3
Read
GET /api/threads lists the caller’s threads (newest first, limit default 20). GET /api/threads/{id}/messages returns turns in position order, with voteChoice and hasVoted filled in for the caller.4
Rename, share or delete
Only the owner can
PATCH /api/threads/{id} (title), PATCH /api/threads/{id}/visibility or DELETE /api/threads/{id}. Callers without a valid token get 401 UNAUTHORIZED; signed-in users who don’t own the thread get 403 FORBIDDEN.Who can read a thread
GET /api/threads/{id} and GET /api/threads/{id}/messages accept requests with or without a token and apply the same rules:
Share links
The arena’s share dialog sets the visibility and copieshttps://arena.dualmindlab.tech/share/{threadId}. That URL is meant to serve share/index.html, which reads the ID from the path, loads the thread through the API and renders it read-only. On the repository’s main branch that rewrite isn’t reached (see Arena web app → The Worker), so check share links whenever the arena’s routing changes.
The public_sharing feature flag is a row in system_settings read by GET /api/settings/feature-flag/public_sharing. If the flag is off, shared links stop working for signed-out readers without anyone changing thread visibility.
Admin view
Admins can list, search and change any thread from Arena → Threads in the admin panel, or with the admin thread routes.PATCH /api/admin/threads/{id}/visibility is the quick way to unpublish a shared thread.