folkwaysDocs
Realtime API

POST /v1/members/*

Keep the member list of a private topic, deciding who may use it and with which operations.

A private topic, one whose rule is Members only, has a member list your backend keeps. A user may do there only what their token ∩ the rule's operations ∩ their member entry allow. So tokens don't list rooms, and a token refresh can't undo a removal. JSON, not frames; service tokens only.

HTTP
POST https://realtime.folkways.net/v1/members/add
Authorization: Bearer <service token with publish on the topic>
Content-Type: application/json

{ "topic": "dm/7f3a9c", "identities": ["user:1", "user:2"], "ops": ["subscribe", "publish", "set", "signal"] }

Endpoints

EndpointBodyDoesResponse
POST /v1/members/add{ topic, identities, ops }Each identity gets exactly ops, whether or not it was a member204
POST /v1/members/set{ topic, identity, ops }The same, for one identity. Narrow to ["subscribe"] to let someone read but not write204
POST /v1/members/remove{ topic, identities }The identities lose every right in the topic. Not being a member isn't an error204
POST /v1/members/clear{ topic }Everyone loses access: the room is closed204
POST /v1/members/list{ topic }Lists the members200 { "topic", "members": [{ "identity", "ops" }] }
FieldMeaning
topicA topic name (not a pattern, not a $ topic) matched by a members-only rule
identities, identityToken subs, each one topic level, not anonymous. 1 to 1,000 per request
opsAt least one of subscribe, publish, set, signal, history, presence. To take every right away, remove the member

add and set replace a member's ops; they don't merge. A topic holds at most 10,000 members. The service token needs publish on the topic.

When a change applies

The response comes once the change is stored. Removals apply first and at once:

  • a removed member's subscriptions to the topic end with SubEnded { Forbidden }, normally within milliseconds;
  • a long-poll they have waiting there returns at once with Forbidden;
  • their next publish, subscribe or poll there gets Forbidden, whatever token they hold.

A member narrowed to ["subscribe"] keeps their subscription and can no longer write. Grants apply once the change is stored.

If the request fails with Unavailable, sending it again is safe. What it took away already applies; what it granted doesn't.

Errors

StatuserrorWhen
401AuthRequired, AuthInvalid, AuthExpired, AuthRevokedNo token, or a bad one
403ForbiddenNot a service token; no rule for the topic; no publish on it
403SuspendedThe segment is suspended
400InvalidArgumentMalformed body, or the topic's rule isn't members-only
429QuotaExceededThe topic would have more than 10,000 members; nothing changed
429RateLimitedThe segment's backend request budget is used up. Wait retry_after_ms
503UnavailableTry again

No CORS: browsers never hold service tokens.

On this page