Appearance
Calls
1:1 and group (up to 32) audio/video calls over Agora RTC. The API owns call state; Agora carries media only. All routes are under /v1 and need a signed-in user on a registered device (CALL_DEVICE_REQUIRED otherwise, for start/accept/join).
Media is encrypted with Agora's built-in aes_256_gcm2 using a per-call secret and salt, returned only to participants in rtc.encryption.
Shapes
- CallView:
id, kind (direct|group), media (audio|video), status, conversationId, linkId, initiatorUserId, maxParticipants, ringingAt, acceptedAt, endedAt, endReason, durationSeconds, participants[]. - Participant:
userId, role (initiator|participant), state (invited|ringing|joined|left|declined|missed), rtcUid, screenRtcUid, isMuted, isCameraOn, isHandRaised, isScreenSharing, isOnHold, isReconnecting, leaveReason, invitedAt, ringingAt, joinedAt, leftAt, declinedAt, missedAt. - CallSession:
{ call: CallView, rtc: RtcCredentials | null, skippedUserIds: string[] }.skippedUserIdsare callees left out for a block, theirwho_can_callsetting, or being on another call (group calls only; a 1:1 refusal is an error). - RtcCredentials:
{ appId, channel, media: {uid, token, expiresAt}, screen: {uid, token, expiresAt} | null, encryption: {mode: "aes_256_gcm2", secret, salt} }. - Call statuses:
ringing → accepted ⇄ on_hold ⇄ reconnecting → ended | failed;ringing → declined | busy | missed | cancelled | failed.
HTTP
| Method | Path | Body | Response | Errors |
|---|---|---|---|---|
| POST | /calls | {media, calleeUserIds?, conversationId?, linkCode?} (callees/conversation, or a link code) | 201 CallSession | CALL_BUSY, CALL_BLOCKED, CALL_NOT_ALLOWED, CALL_PARTICIPANT_LIMIT, CALL_DEVICE_REQUIRED, RATE_LIMITED |
| GET | /calls/:id | CallSession (participants only) | CALL_NOT_FOUND | |
| POST | /calls/:id/accept | CallSession with rtc | CALL_NOT_PARTICIPANT, CALL_ALREADY_ENDED, CALL_BUSY, CALL_INVALID_TRANSITION (answered on another device) | |
| POST | /calls/:id/decline | CallView | CALL_INVALID_TRANSITION, CALL_ALREADY_ENDED | |
| POST | /calls/:id/end | CallView. Caller while ringing = cancelled; callee while ringing = declined | CALL_NOT_PARTICIPANT | |
| POST | /calls/:id/invite | {userIds} (1–31) | CallSession (rtc null) | CALL_NOT_ALLOWED, CALL_PARTICIPANT_LIMIT, CALL_ALREADY_ENDED |
| POST | /calls/:id/join | CallSession with rtc. Group call, by a chat member or anyone rung | CALL_NOT_PARTICIPANT, CALL_BUSY, CALL_PARTICIPANT_LIMIT | |
| POST | /calls/:id/token | RtcCredentials (renewed) | CALL_NOT_PARTICIPANT, CALL_ALREADY_ENDED | |
| GET | /calls/history?cursor&limit&filter=all|missed | page of CallLog | PAGINATION_CURSOR_INVALID | |
| GET | /calls/history/missed-count | {count} unseen missed incoming | ||
| POST | /calls/history/seen | {status:"ok"} | ||
| DELETE | /calls/history/:logId | 204 | NOT_FOUND | |
| POST | /call-links | {media, conversationId?, expiresInSeconds?} (1 h–90 d, default 90 d) | 201 CallLink | CALL_NOT_ALLOWED |
| GET | /call-links/:code | guest-safe | CallLinkPreview {code, joinUrl, deepLink, media, title, hostUserId, scheduledStartAt, scheduledEndAt, isActive, isCancelled, isLive, participantCount, requiresSignIn} | CALL_LINK_INVALID |
| GET | /call-links/:code/details | CallLink, with invitees (creator and invitees only) | CALL_LINK_INVALID | |
| POST | /call-links/:id/rotate | CallLink with a new code; the old code stops working immediately (creator only) | CALL_LINK_INVALID | |
| POST | /call-links/:id/reset | 201: a fresh CallLink with the same settings and invitees; the old link is revoked (creator only) | CALL_LINK_INVALID | |
| POST | /calls/:id/link | CallLink for the ongoing group call; returns the same link on a repeat request (moderators and up). The socket version is call:link-create {callId} | CALL_NOT_ALLOWED | |
| POST | /call-links/:code/join | sign-in required (a guest gets UNAUTHENTICATED with a sign_in action back to links.call) | CallSession with rtc: joins the call on the link or starts one | CALL_LINK_INVALID, CALL_LINK_EXPIRED, CALL_BLOCKED, CALL_BUSY |
| DELETE | /call-links/:id | 204 (creator only) | CALL_LINK_INVALID |
CallLog: id, callId, conversationId, direction (outgoing|incoming), outcome (completed|missed|declined|cancelled|busy|failed), media, isGroup, peerUserId, initiatorUserId, participantCount, startedAt, endedAt, durationSeconds, isSeen.
CallLink: id, code, url, media, conversationId, createdByUserId, expiresAt, isActive, activeCallId, createdAt.
Socket namespace /call
Acks use the shared {ok, data} / {ok:false, error:{code, message}} shape. On connect, the socket joins user:<id> and the room of every live call the user is in.
| Command | Payload | Ack data |
|---|---|---|
call:start | as POST /calls | CallSession |
call:ringing | {callId} (callee device is showing the ring) | CallView |
call:accept | {callId} | CallSession |
call:decline | {callId} | CallView |
call:end | {callId} | CallView |
call:invite | {callId, userIds} | CallSession |
call:join | {callId} | CallSession |
call:join-link | {code} | CallSession |
call:state | {callId, muted?, cameraOn?, handRaised?, onHold?, reconnecting?} | CallView |
call:upgrade-request | {callId} (audio→video; a group call switches at once) | CallView |
call:upgrade-respond | {callId, accept} | CallView |
call:screen-share | {callId, on} | {call, screen: {uid, token, expiresAt} | null} |
call:renew-token | {callId} | RtcCredentials |
call:heartbeat | {callId}, every 30 s while in a call; 90 s of silence = left | {status:"ok"} |
call:get | {callId} | CallSession |
| Emit | Rooms | Payload |
|---|---|---|
call:incoming | callee user: rooms | {call, callerUserId} |
call:updated | every participant's user: room | {call} |
call:participant-updated | call:<id> | {callId, participant} |
call:ended | every participant's user: room | {call} |
call:answered-elsewhere | answerer's user: room | {callId, deviceId}, other devices stop ringing |
call:upgrade-requested | call:<id> | {callId, byUserId} |
call:upgrade-responded | call:<id> | {callId, byUserId, accepted} |
call:busy | caller's user: room | {callId, userId} |
Push and timers
- Incoming:
call.incoming, prioritycritical(VoIP: PushKit / FCM high), collapse keycall-<id>, deep linkplemuz://call/<id>. No names or content. - Missed:
call.missed, priorityhigh, same collapse key, so it replaces the ring. - Each ring times out after
CALLS_RING_TIMEOUT_SECONDS(45 s) → that person is missed; a call nobody answered settles as missed, declined or busy. A minutely sweep backstops lost timers, silent clients, empty calls and calls over 12 h. - Every final call writes one history row per participant and a call-log item in the chat (direct calls, and group calls from a chat).
In-call controls, roles and scheduled calls
Toggles set a state rather than flipping it, so a retry changes nothing. Each change is broadcast to call:<id> as call:participant-updated, plus the specific event listed below. A participant also carries callRole, deviceId, cameraFacing, audioRoute, networkQuality (Agora's scale, 0–6) and handRaisedAt. A call carries maxDurationSeconds and endsAt.
Roles: owner (whoever started the call) > admin > moderator > participant. Moderators and up can lower hands, and can mute or remove people ranked below them. Owners and admins can also assign roles below their own and end the call for everyone. Only the owner can hand over ownership, and becomes an admin after doing so. When the owner leaves, ownership passes to the longest-serving admin, then moderator, then participant. A person who was removed can't rejoin unless invited again. The creator of a call link becomes an admin when joining.
| Command | Payload | Ack | Also emits |
|---|---|---|---|
call:session | {callId} | CallSnapshot = CallSession + recentMessages[50] + serverTime (full resync after a reconnect; rejoins the room) | – |
call:mute | {callId, muted} | CallView | – |
call:camera | {callId, on} | CallView | – |
call:camera-switch | {callId, facing: front|back} | CallView | – |
call:audio-route | {callId, route: earpiece|speaker|bluetooth|wired} | CallView | – |
call:hold | {callId, onHold} | CallView (a 1:1 call moves to on_hold) | call:updated |
call:network | {callId, quality: 0..6} (≤12 per minute) | CallView | – |
call:hand / call:hand-lower (moderator) | {callId, raised} / {callId, userId} | CallView | call:hand-changed {callId, userId, raised, byUserId} |
call:share-start / call:share-stop | {callId} | {call, screen} (the screen track gets its own uid and token; one sharer at a time) | call:share-changed {callId, userId, sharing, screenRtcUid} |
call:reaction | {callId, emoji} (never stored) | ok | call:reaction-sent {callId, userId, emoji, at} |
call:message | {callId, clientMessageId, body≤1000} (a repeated clientMessageId returns the first copy) | CallMessage | call:message-sent {message} |
call:messages | {callId, before?, limit} | CallMessage[] | – |
call:participant-add | {callId, userIds} | CallSession | as call:invite |
call:participant-remove (moderator) | {callId, userId} | CallView | call:participant-removed {callId, userId, byUserId} (also to that person's own room), then call:session-state |
call:participant-mute (moderator) | {callId, userId} | CallView | call:muted-by-moderator {callId, userId, byUserId} |
call:role (owner/admin) | {callId, userId, role} | CallView | call:session-state {call} |
call:end-all (owner/admin) | {callId} | CallView (reason ended_by_host) | call:ended |
call:time-limit-warning {callId, endsAt} is sent two minutes before CALLS_MAX_DURATION_SECONDS (default 4 h), counted from when the call was answered. At the limit the call ends with reason call_time_limit.
| Method | Path | Body | Response |
|---|---|---|---|
| GET | /calls/:id/session | – | CallSnapshot |
| GET / POST | /calls/:id/messages | ?before&limit / {clientMessageId, body} | CallMessage[] / CallMessage (201) |
| POST | /calls/:id/participants/:userId/remove | /mute | – | CallView (CALL_NOT_ALLOWED when outranked) |
| PUT | /calls/:id/participants/:userId/role | {role} | CallView |
| POST | /calls/:id/end-all | – | CallView |
| POST | /call-links | adds title?, description?, scheduledStartAt?, scheduledEndAt?, inviteeUserIds[]≤31 | CallLink (201). Invitees refused by who_can_call are skipped; the rest get a call.scheduled push |
| GET | /call-links/upcoming | ?limit | scheduled calls you made or were invited to, soonest first |
| POST | /call-links/:code/rsvp | {response: accepted|declined|tentative} | CallLink |
| POST | /call-links/:id/cancel | – | CallLink (creator only) |
A CallLink includes joinUrl (https://spread.plemuz.com/call/<code>, from DEEP_LINK_BASE_URL), deepLink (plemuz://call/<code>), title, description, scheduledStartAt, scheduledEndAt, isCancelled and invitees[{userId, response, respondedAt}].
- Joining early: a scheduled call opens
CALLS_EARLY_JOIN_SECONDS(15 min) before its start. Before that, joining returnsCALL_NOT_STARTED, except for the creator. - Reminders: a
call.starting_soonreminder goes to the creator and to every invitee who hasn't declined, 10 minutes before the start. - Link lifetime: the link stays valid for at least a day after the scheduled end.
Hot state: the public call snapshot is cached in Valkey (30 s) and dropped on every change. Postgres row locks stay the authority for every transition.
Call push for CallKit
The call.incoming VoIP push adds callId, media (audio|video), isGroup ("true"|"false"), callerUserId, and when known callerName and callerAvatarUrl (signed, short-lived), so iOS can report the call to CallKit with the caller shown before any request. call:start also takes calleeProfileIds (from a profile or search result) in place of calleeUserIds.
Adding people
GET /calls/:id/candidates?limit lists [{ userId, displayName, avatarUrl }]: the call's chat members, then mutual follows, without people already in it, people blocked either way or anyone whose call privacy refuses.
Add-people candidates
GET /calls/:id/candidates?limit returns [{ userId, displayName, avatarUrl }]: the call's chat members, then mutual follows, minus people in the call, blocks and who_can_call refusals.