Skip to main content

Blocking users

Blocking a user prevents interaction and hides the user from the client experience. Blocked accounts will not be able to like, reply, mention, or follow you. Their posts, replies, and profile in search will also be hidden from you. Blocks are public.

Blocking users is as simple as muting, but requires creating a record directly.

agent.app.bsky.graph.block.create
const { uri } = await agent.app.bsky.graph.block.create(
{ repo: agent.session.did },
{
subject: blockingUserDid,
createdAt: new Date().toISOString()
},
)

The agent.app.bsky.graph.block.create method takes two position parameters. First, the repo:

ParameterTypeDescriptionRequired
repostringThe DID of the authenticated userYes

And the block record itself:

ParameterTypeDescriptionRequired
subjectstringThe DID of the user to blockYes
createdAtstringThe current timestampYes

Unblocking a user

Similar to likes and follows, unblocking a user is as simple as deleting the record.

agent.app.bsky.graph.block.delete
import { AtUri } from '@atproto/api'

const { rkey } = new AtUri(uri)

await agent.app.bsky.graph.block.delete(
{
repo: agent.session.did,
rkey,
},
)
ParameterTypeDescriptionRequired
repostringThe DID of the authenticated userYes
rkeystringThe record key (rkey) of the block recordYes