POST /v1/kick and /v1/revoke
Disconnect an identity, or revoke one token, before the token expires.
Your backend can cut a user off before their token expires. JSON, not frames; service tokens only.
| Endpoint | Body | Effect |
|---|---|---|
POST /v1/kick | { "identity": "user:42" } | Closes every WebSocket connection of that identity in the segment with Close { AuthRevoked }, within a second. Its tokens still work |
POST /v1/revoke | { "jti": "9b1d3c0e-…" } | Closes every connection holding the token with that jti, and refuses the token with AuthRevoked from then on, on every endpoint, until it would have expired |
POST https://realtime.folkways.net/v1/kick
Authorization: Bearer <service token with publish on $user/user:42>
Content-Type: application/json
{ "identity": "user:42" }| Endpoint | Field | Meaning | The service token needs |
|---|---|---|---|
/v1/kick | identity | The sub to disconnect; one topic level | publish on $user/{identity} |
/v1/revoke | jti | The token ID, 1 to 256 bytes | publish on $user/> |
Both answer 204 with no body, whether or not anyone was connected or the token was ever seen, so a request
reveals nothing about who exists.
Banning a user
A kick alone doesn't keep anyone out: the app can reconnect with a token it still holds. To ban a user, stop
issuing tokens for them and revoke the ones they hold, or kick them and let their tokens run out (at most 15
minutes). Only tokens with a jti can be revoked.
Revocations are kept in memory for the token's remaining lifetime, up to 10,000 per segment at a time, and don't yet survive a restart of the service. Keep tokens short-lived and stop issuing them, rather than relying on revocation alone.
Clients must not reconnect automatically after AuthRevoked: sign the user out, and reconnect only once your
backend issues a new token.
Errors
| Status | error | When |
|---|---|---|
401 | AuthRequired, AuthInvalid, AuthExpired, AuthRevoked | No token, or a bad one |
403 | Forbidden | Not a service token, or without the right above |
403 | Suspended | The segment is suspended |
400 | InvalidArgument | Malformed body |
429 | QuotaExceeded | /v1/revoke only: the segment already holds 10,000 revocations. Room comes back as they expire |
429 | RateLimited | The segment's backend request budget is used up. Wait retry_after_ms |
503 | Unavailable | Try again |
No CORS: browsers never hold service tokens.