Skip to main content

Thread gates

Thread gates set who can reply to a post.

The available rules are:

  • app.bsky.feed.threadgate#mentionRule: Allow replies from actors mentioned in your post.
  • app.bsky.feed.threadgate#followingRule: Allow replies from actors you follow.
  • app.bsky.feed.threadgate#listRule: Allow replies from actors on a list.

A thread gate may have up to 5 rules.

Setting a thread gate

You set a thread gate by creating a app.bsky.feed.threadgate record with the same rkey as the post you're gating.

const {rkey} = new AtUri(postUri)

await agent.com.atproto.repo.createRecord({
repo: agent.session.did,
collection: 'app.bsky.feed.threadgate',
rkey,
record: {
$type: 'app.bsky.feed.threadgate',
post: postUri,
allow: [
// allow mentioned users
{$type: 'app.bsky.feed.threadgate#mentionRule'},
// allow followed users
{$type: 'app.bsky.feed.threadgate#followingRule'},
// allow list members
{$type: 'app.bsky.feed.threadgate#listRule', list: listUri},
],
createdAt: new Date().toISOString()
}
})

If a thread gate record is present but empty, then nobody can reply.

await agent.com.atproto.repo.createRecord({
repo: agent.session.did,
collection: 'app.bsky.feed.threadgate',
rkey,
record: {
$type: 'app.bsky.feed.threadgate',
post: postUri,
// empty allow-list, nobody can reply
allow: [],
createdAt: new Date().toISOString()
}
})

If a thread gate record is not present, then anybody can reply.