folkwaysDocs
Console

Topic rules

Every setting of a topic rule in the Console, from patterns and event types to access, presence and limits.

Topic rules decide which topics exist in a segment and what they carry. Manage them on the segment's Topic rules tab; owners and admins edit them. Rules are checked from the top, and the first match wins. A segment with no rules denies every topic. Topics explains the model.

Rule settings

SettingDefaultMeaning
PatternrequiredTopic names it covers: * matches one level, a trailing > one or more. E.g. chat/*, rides/*/location
Who may use itAnyone the token allowsAnyone the token allows makes matching topics public: the token decides. Members only makes them private: your backend keeps a member list
Event typesrequiredWhich of Stream, KV and Signal the topics carry
Event namesnoneFix each event name to one type. With none, an event may have any name and any allowed type
OperationsallThe most any token may do on these topics: subscribe, publish, set, signal, history, presence
PresenceoffSubscribers show up in presence
Max payloadthe segment'sA lower payload limit for these topics
Retention5 MiBStream history kept per topic, in bytes
TTL0 for KV, 5 s for signalsDefault lifetime of values; 0 keeps a KV value until it is replaced
Max keys10,000KV values and signals kept per topic, together

Event names

Listing event names is the safest setup: each name is held to its type, and a name you didn't list is refused. For each event you can set:

OptionForMeaning
TypeallStream, KV or Signal
TTLKV, SignalThis event's default lifetime, overriding the rule's
Nobody can write another member's entryKVOnly the publisher (or your backend) may write or delete its own key, e.g. a read receipt

Examples

PatternTypesEventsAccessFor
rooms/*Stream, KV, Signalmessage stream, read KV (own entry only), typing signalAnyone the token allowsChat rooms
dm/*Stream, KV, Signalas aboveMembers onlyDirect messages
rides/*/locationKVlocation KV, TTL 30 sAnyone the token allowsLive map
docs/*KV, Signaltitle KV, cursor signalAnyone the token allowsCollaborative editing
ai/*Streamtoken, doneAnyone the token allowsStreaming AI output

Paste rules as JSON

Paste JSON takes rules in the same shape the Realtime API uses, which is also what the JavaScript SDK's defineTopic(…).rule() produces:

JSON
[
  {
    "pattern": "rooms/*",
    "types": ["stream", "kv", "signal"],
    "events": {
      "message": { "delivery": "stream" },
      "read": { "delivery": "kv", "key_is_publisher": true },
      "typing": { "delivery": "signal", "ttl_ms": 3000 }
    },
    "strict_events": true,
    "access": "token",
    "presence": true
  }
]

See Define topics and export rules.

Changing rules

Changes reach the Realtime API within seconds. Rules are matched in order, so put specific patterns, such as rooms/announcements, above general ones like rooms/*.

On this page