Appearance
Listen together
A host opens a session, shares its invite code, and everyone present hears the same queue at the same position. All routes need a signed-in user (Authorization: Bearer). Someone not present in a session gets TOGETHER_SESSION_NOT_FOUND for it, never a hint it exists.
Each participant's entitlement is checked when they join. previewOnly: true means that person's client plays 15 s previews only, whatever the session plays.
Sync model
The server stores positionMs measured at a server-time anchor, rate and isPlaying. Every change is a PlaybackSnapshot:
| Field | Type | Notes |
|---|---|---|
| sessionId | uuid | |
| serverTime / serverTimeMs | ISO string / int | When positionMs was measured |
| positionMs | int | |
| rate | number | 0.5–2 |
| isPlaying | boolean | |
| itemId | uuid | null | Queue item ID |
| contentType / contentId | recording|episode / uuid, or null | |
| version | int | Increases with every change; ignore older ones |
A client estimates offset with time:sync (serverTimeMs - (sentAt + receivedAt) / 2, best of several samples) and plays at positionMs + (Date.now() + offset - serverTimeMs) * rate while isPlaying. Snapshots are settled on read: finished items roll over to the next one even if the host's client never sent skip.
REST
| Method | Path | Body | Response | Errors |
|---|---|---|---|---|
| GET | /v1/me/together | – | { session: SessionView | null } | |
| POST | /v1/together/sessions | { title?, maxParticipants? (2–100, capped by config), listenersCanQueue? } | 201 SessionView | TOGETHER_ALREADY_HOSTING |
| POST | /v1/together/sessions/join | { inviteCode } (8 chars, case-insensitive) | SessionView | TOGETHER_INVITE_INVALID, TOGETHER_SESSION_ENDED, TOGETHER_SESSION_FULL |
| GET | /v1/together/sessions/:id | – | SessionView | TOGETHER_SESSION_NOT_FOUND |
| POST | /v1/together/sessions/:id/leave | – | { status: "ok" } | Host leaving hands over to the longest-present listener; last one out ends it |
| POST | /v1/together/sessions/:id/end | – | { status: "ok" } | TOGETHER_NOT_HOST, TOGETHER_SESSION_ENDED |
| GET | /v1/together/sessions/:id/participants | – | ParticipantView[] | |
| POST | /v1/together/sessions/:id/host | { userId } | SessionView | TOGETHER_NOT_HOST, TOGETHER_NOT_PARTICIPANT |
| POST | /v1/together/sessions/:id/invites | { userIds: uuid[1..20] } | 202 { invited } | Rate limited 30/h. Blocked people are skipped silently. DEPENDENCY_UNAVAILABLE without a notifier |
| GET | /v1/together/sessions/:id/playback | – | PlaybackSnapshot | |
| POST | /v1/together/sessions/:id/playback | PlaybackControl | PlaybackSnapshot | Host only. TOGETHER_NOT_HOST, TOGETHER_QUEUE_EMPTY, TOGETHER_QUEUE_ITEM_NOT_FOUND |
| GET | /v1/together/sessions/:id/queue | – | QueueItemView[] | |
| POST | /v1/together/sessions/:id/queue | { items: [{ type: "recording"|"episode", id }] (1–50) } | 201 QueueItemView[] | TOGETHER_NOT_HOST (when listeners can't queue), TOGETHER_TRACK_UNAVAILABLE, TOGETHER_QUEUE_FULL |
| PATCH | /v1/together/sessions/:id/queue/:itemId | { toIndex } | QueueItemView[] | Host only. TOGETHER_QUEUE_ITEM_NOT_FOUND |
| DELETE | /v1/together/sessions/:id/queue/:itemId | – | QueueItemView[] | Host, or whoever added it |
| GET | /v1/together/sessions/:id/messages | ?cursor&limit | page of MessageView, newest first | PAGINATION_CURSOR_INVALID |
| POST | /v1/together/sessions/:id/messages | { body (1–1000) } | 201 MessageView | Rate limited 30/min, TOGETHER_SESSION_ENDED |
PlaybackControl (action discriminates): play, pause, seek { positionMs }, skip { direction: "next" | "previous" } (previous restarts after 3 s), jump { itemId }, rate { rate }.
SessionView: id, hostUserId, title, inviteCode, status (active|ended), maxParticipants, listenersCanQueue, participantCount, everyoneEntitled, createdAt, endedAt, you { role, previewOnly } | null.
ParticipantView: userId, role (host|listener), previewOnly, joinedAt.
QueueItemView: id, type, contentId, title, durationMs, addedByUserId, index, isCurrent.
MessageView: id, sessionId, userId | null, body, createdAt.
Socket namespace /together
Room together:<sessionId>, joined only through session:join once membership holds. Acks use { ok, data | error }.
| Command | Payload | Ack |
|---|---|---|
session:join | { sessionId } (already present) or { inviteCode } | { session, playback } |
session:leave | { sessionId } | { status: "ok" } |
playback:control | { sessionId, control } | PlaybackSnapshot (host only) |
playback:state | { sessionId } | PlaybackSnapshot |
queue:add | { sessionId, items } | QueueItemView[] |
queue:reorder | { sessionId, itemId, toIndex } | QueueItemView[] |
queue:remove | { sessionId, itemId } | QueueItemView[] |
chat:send | { sessionId, body } | MessageView (5 per 10 s) |
time:sync | { clientTimeMs } | { clientTimeMs, serverTimeMs } (30 per 10 s) |
| Emit | Payload |
|---|---|
playback:synced | PlaybackSnapshot |
queue:updated | { sessionId, items } |
participant:joined | { sessionId, participant } |
participant:left | { sessionId, userId } |
host:changed | { sessionId, hostUserId } |
chat:sent | MessageView |
session:ended | { sessionId, endedAt, reason (host_ended|empty|idle|account_deleted) } |
session:opened | { sessionId, inviteCode, title, startsAt, openedAt }, to the room and to the host and invitees (user:<id>) |
session:cancelled | { sessionId, cancelledAt, reason }, to the host and invitees |
Sessions untouched for 6 hours are ended by the together.idle-sweep job, which also opens and reminds any listening party whose delayed job was lost.
Listening parties
A party is a session for a drop that waits as scheduled until startsAt, then opens by itself (scheduled → active); it can be cancelled before that. Status is one of scheduled | active | ended | cancelled, and SessionView carries startsAt and isPublic. Joining by code before the start gives TOGETHER_PARTY_NOT_STARTED; after a cancel, TOGETHER_PARTY_CANCELLED.
| Method | Path | Body | Response | Errors |
|---|---|---|---|---|
| POST | /v1/together/parties | { title (1–100), startsAt (ISO, 1 min–180 days ahead), queue: [{ type, id }] (1–200), inviteUserIds?: uuid[≤100], isPublic? } | 201 { sessionId, code, link } | TOGETHER_START_TIME_INVALID, TOGETHER_TRACK_UNAVAILABLE, TOGETHER_QUEUE_FULL. 20 per day |
| POST | /v1/together/parties/:id/cancel | { reason? (≤200) } | { status: "ok" } | Host only. TOGETHER_SESSION_NOT_FOUND, TOGETHER_PARTY_STARTED |
link is the spread link links.together({ code }). Other modules use TogetherApi.scheduleSession and cancelSession for the same thing.
Timing and notices, all on queue together:
| Job | When | Does |
|---|---|---|
together.party-open | delayed to startsAt | Opens the party, adds the host, emits session:opened |
together.party-remind | delayed to 10 min before | Sends together.party_starting |
together.party-fanout | on schedule, reminder, cancel | Sends together.party_scheduled / _starting / _cancelled to invitees, then to presavers of the queued items in batches of 500, skipping the host and invitees |
Each batch has its own dedupe key (<type>:<sessionId>:invitees or :presavers:<n>), so retries never notify twice.