Bridge Reference
The bridge API is a set of XRPC methods under social.colibri.beta.bridge, served by the AppView. @colibri-social/bridge-core wraps all of them. This page is for anyone calling them directly.
Authentication
Section titled “Authentication”Methods a bridge calls take service auth. The token’s iss is the bridge’s DID, aud is the AppView’s DID, and lxm is the method being called. Every write names a community and a registration, and the AppView checks that the registration belongs to the calling bridge.
Methods an admin calls take the admin’s own session, proxied through their PDS. The admin needs the Manage Space permission in the Space.
The social.colibri.beta.permissionBridge permission set covers every method a bridge calls, plus the channel, thread and blob reads it needs.
Methods called by a bridge
Section titled “Methods called by a bridge”createPairing
Section titled “createPairing”Procedure. Starts a pairing and returns a code for an admin to redeem.
- Input:
platform,remoteSpace,remoteSpaceName - Output:
code,expiresAt
A code is eight characters long, works once, and expires after 10 minutes. A bridge can hold at most 10 unredeemed codes at a time.
getConfiguration
Section titled “getConfiguration”Query. Lists every registration the calling bridge holds, in every Space, with each one’s links and open channels. Call it at startup and whenever a bridgeEvent frame arrives.
- Output:
registrations, an array ofregistrationView
listChannels
Section titled “listChannels”Query. Lists the text channels of a Space that every member can read, so a bridge can offer them before an admin opens or links any. Channels restricted to some roles or members are left out.
- Input:
community,registration - Output:
channels, an array ofsocial.colibri.beta.community.defs#channelView
getMember
Section titled “getMember”Query. Describes an account’s standing in a Space, so a bridge can decide who may run its commands.
- Input:
community,registration,did,channel - Output:
did,member,owner,roles,permissions
member is false for accounts that aren’t members of the Space or are banned, and roles and permissions are then empty. roles lists each role’s rkey, name and position, highest first. permissions lists the account’s effective permissions in the Space. With a channel, linked or open to the registration, they include that channel’s overrides. An owner holds every permission.
putRemoteRooms
Section titled “putRemoteRooms”Procedure. Replaces the list of rooms admins can pick from when linking channels.
- Input:
community,registration,rooms, an array ofremoteRoom
uploadBlob
Section titled “uploadBlob”Procedure. Uploads a file to the Space’s repo, for an attachment or an avatar. Send the raw bytes as the body with a Content-Type header, and community and registration as query parameters.
- Output:
blob, a blob reference to use inpostMessage
replaceAvatar
Section titled “replaceAvatar”Procedure. Swaps the avatar on every message and thread attributed to one remote author of the registration. The previous avatar blob is then unreferenced.
- Input:
community,registration,remoteId,avatar - Output:
updated, the number of records changed
remoteId is the author’s id on the other service, as stored in the attribution. avatar is a blob from uploadBlob. Leave it out to remove the avatar.
postMessage
Section titled “postMessage”Procedure. Posts a message into a linked or open channel, written by the Space and attributed to someone on the other service.
- Input:
community,registration,channel,author(remoteAuthor),text,facets,parent,parentUri,attachments,forward,remoteMessage,createdAt - Output:
rkey
channel is a linked or open channel, or a thread beside one. parent is the did and rkey of the message being replied to. parentUri names the same message as a record URI in the channel, and the AppView prefers it over parent when it is valid. createdAt is when the message was sent on the other service, and defaults to now. forward has the shape of the forward field on social.colibri.beta.message. remoteMessage is the message’s id on the other service, stored in the attribution.
editMessage
Section titled “editMessage”Procedure. Replaces the text and facets of a message the bridge posted.
- Input:
community,registration,channel,rkey,text,facets
deleteMessage
Section titled “deleteMessage”Procedure. Deletes a message the bridge posted.
- Input:
community,registration,channel,rkey
addReaction
Section titled “addReaction”Procedure. Adds a reaction to a message in a linked or open channel, attributed to someone on the other service.
- Input:
community,registration,channel,author(remoteAuthor),target(didandrkeyof the message),uri,emoji - Output:
rkey
uri names the message as a record URI in the channel, and the AppView prefers it over target when it is valid. emoji is an emoji or a custom shortcode.
removeReaction
Section titled “removeReaction”Procedure. Removes a reaction the bridge added.
- Input:
community,registration,channel,rkey
createThread
Section titled “createThread”Procedure. Opens a thread beside a linked or open channel, written by the Space and attributed to someone on the other service.
- Input:
community,registration,channel,name,author(remoteAuthor),anchor,remoteThread,createdAt - Output:
thread, the thread’s space
anchor is the did and rkey of the message in channel the thread was opened from. Leave it out for a thread opened from scratch. remoteThread is the thread’s id on the other service. createdAt is when the thread was opened there, and defaults to now.
updateThread
Section titled “updateThread”Procedure. Renames a thread the bridge opened.
- Input:
community,registration,thread,name
deleteThread
Section titled “deleteThread”Procedure. Deletes a thread the bridge opened, along with its space.
- Input:
community,registration,thread
hideMessage
Section titled “hideMessage”Procedure. Hides a member’s message after a moderator removed its copy on the other service. The Space applies a hidden label to the message.
- Input:
community,registration,channel,subject(didandrkeyof the message),reason
It only works while the registration’s mirrorModeration is on, and only on messages the Space didn’t write. Delete the bridge’s own messages with deleteMessage.
importMessages
Section titled “importMessages”Procedure. Imports earlier messages into a linked channel, or a thread beside one, after an admin asked for a history import. The Space writes each message at its original time. The AppView streams them to open channels with imported set on the messageEvent, and sends no notifications for them.
- Input:
community,registration,channel,messages(up to 25, oldest first) - Output:
results, oneremoteMessageandrkeyper message
Each message has the postMessage fields author, text, facets, parent, attachments and forward, plus a required remoteMessage and createdAt. Every createdAt must lie between the link’s backfill.since and backfill.requestedAt. The record key comes from createdAt and remoteMessage, so importing the same message again overwrites it.
reportBackfill
Section titled “reportBackfill”Procedure. Reports a history import’s progress, which admins see in the channel’s backfillStatus.
- Input:
community,registration,channel,requestedAt,state(running,doneorfailed),imported,from,until,reached
requestedAt must match the link’s current backfill. reached is when the newest imported message in the channel was sent.
Procedure. Deletes one of the calling bridge’s registrations, for when admins on the other service disconnect it or remove the bridge. Messages it already relayed stay. A registration that was already revoked fails with RegistrationNotFound.
- Input:
community,registration
Methods called by an admin
Section titled “Methods called by an admin”getPairing
Section titled “getPairing”Query. Describes a pending code, so the admin can check which bridge they’re about to connect.
- Input:
code - Output:
pairing, apairingView
redeemPairing
Section titled “redeemPairing”Procedure. Redeems a code and writes a registration with no links.
- Input:
community,code - Output:
registration, aregistrationView
install
Section titled “install”Procedure. Connects a bridge to a Space by its handle or DID, with no pairing code. The registration starts with no links and no open channels. Its remoteSpace is the Space’s DID, its remoteSpaceName is the bridge’s handle, and its platform is external. The bridge receives a bridgeEvent and picks up the registration with getConfiguration.
- Input:
community,bridge(a handle or DID) - Output:
registration, aregistrationView - Errors:
Forbidden,CommunityNotFound,BridgeNotFound,AlreadyRegistered
The bridge’s DID document needs an atproto signing key. It needs no PDS service. A DID without a handle names the registration after the DID.
listRegistrations
Section titled “listRegistrations”Query. Lists the bridges connected to a Space.
- Input:
community - Output:
registrations
listRemoteRooms
Section titled “listRemoteRooms”Query. Lists the rooms a bridge last reported with putRemoteRooms.
- Input:
community,registration - Output:
rooms,updatedAt
update
Section titled “update”Procedure. Replaces a registration’s links or open channels, pauses and resumes it, or turns moderation mirroring on and off. Omitted fields keep their value.
- Input:
community,registration,links(array oflink),channels(array of space references),enabled,mirrorModeration - Output:
registration
To ask for a history import, set backfill on a link with a new requestedAt. Open channels have no history import.
revoke
Section titled “revoke”Procedure. Deletes a registration. The bridge’s next call fails, and messages it already relayed stay.
- Input:
community,registration
Events
Section titled “Events”A bridge subscribes to social.colibri.beta.sync.subscribeEvents with service auth, the same way a client does. It may only subscribe to channels linked to or open on one of its enabled registrations, and to threads beside them that every reader of the channel can see. The AppView drops the subscription when a channel is unlinked or closed, or a thread turns private.
The frames a bridge acts on are:
messageEvent, for messages created, edited and deleted in a linked or open channel or threadreactionEvent, for reactions added and removedthreadEvent, for threads opened, renamed and deleted beside a linked or open channellabelEvent, for labels applied to messages, such ashiddenbridgeEvent, when one of the bridge’s registrations changes
A bridge receives a Space’s threadEvent frames while it holds at least one of the Space’s channels. A new thread arrives with its threadView, and the bridge subscribes to the thread’s space to follow it.
A bridge must ignore message and reaction events carrying its own registration in bridged. Those are its own writes coming back. Each write a bridge makes produces one frame.
Besides the stream, a bridge can read its channels and threads with service auth:
social.colibri.beta.channel.listMessageslists the messages of a linked or open channel, or a thread beside one. It takescursorto page andaroundto center the page on one record key.social.colibri.beta.thread.listThreadslists the threads beside a channel the bridge holds. A bridge must passchannel. Threads limited to some roles or members are left out.social.colibri.beta.thread.getThreaddescribes one thread the bridge can read.
The AppView runs on several nodes. social.colibri.beta.server.listNodes lists the nodes that accept clients. Measure the round trip to each node’s probeUrl and open the event socket on the fastest node with the live role. XRPC calls go to the AppView host, which routes them to a nearby node.
Two frames tell a bridge how the node is doing:
drainNoticemeans the node goes offline atdeadline. Open a socket on another node, subscribe to the same channels, and close the old socket once the new one answers withsubscribed. Events can arrive on both sockets in between. The node closes any socket still open at the deadline.writeStatearrives on connect and whenever the node’s write mode changes. InreadOnlymode the node rejects writes with aReadOnlyerror, so hold writes until the mode changes again.queuedaccepts writes and applies them later.
@colibri-social/bridge-core does all of this for a bridge built on Bridge.
Records
Section titled “Records”bridged
Section titled “bridged”The social.colibri.beta.bridge.defs#attribution object, stored on bridged social.colibri.beta.message, social.colibri.beta.reaction and social.colibri.beta.thread records. On a thread, remoteMessage holds the thread’s id on the other service.
| Field | Type | Description |
|---|---|---|
registration |
TID | Record key of the registration the record was written for. |
platform |
string | The other service, as the bridge names it. |
remoteId |
string | The author’s id on the other service. |
name |
string | The author’s display name when the record was written. |
avatar |
blob | The author’s avatar, stored in the Space’s repo. Optional. |
remoteMessage |
string | The message’s id on the other service. Optional. |
imported |
boolean | Set on messages imported from earlier history. Optional. |
The AppView honours bridged only when the record’s author is the Space.
bridgedActor
Section titled “bridgedActor”The social.colibri.beta.bridge.defs#bridgedActor object. In views, a bridged author appears as a profileView whose bridge field holds one. The view’s did is the Space’s.
| Field | Type | Description |
|---|---|---|
registration |
TID | Record key of the registration the record was written for. |
platform |
string | The service the person is on. |
remoteId |
string | Their id on that service. |
bridgedReactor
Section titled “bridgedReactor”The social.colibri.beta.bridge.defs#bridgedReactor object, someone on another service who reacted through a bridge. A reaction summary lists them in bridgedReactors, next to the reactors array of Colibri users, and count includes both. A reactionEvent frame carries one in bridged, and its actor is then the Space that wrote the reaction.
| Field | Type | Description |
|---|---|---|
registration |
TID | Record key of the registration the reaction was written for. |
platform |
string | The service the person is on. |
remoteId |
string | Their id on that service. |
name |
string | Their display name on that service when they reacted. |
bridgedMention
Section titled “bridgedMention”The social.colibri.beta.richtext.facet#bridgedMention feature, a mention of someone on another service. It holds registration, platform and remoteId. The mentioned name is the text the facet covers.
Registration
Section titled “Registration”The social.colibri.beta.bridge.registration record, written by the Space in its configuration space. Every member can read it.
Besides links, a registration holds an optional channels array of space references. These are open channels: the bridge can read them, over REST and subscribeEvents, and write to them with postMessage and the other write methods, without a remote room behind them. An admin sets them with update.
registrationView
Section titled “registrationView”id, community, communityName, bridge, bridgeHandle, platform, remoteSpace, remoteSpaceName, links, channels, backfills (array of backfillStatus), enabled, mirrorModeration, createdBy, createdAt, updatedAt.
pairingView
Section titled “pairingView”bridge, bridgeHandle, platform, remoteSpace, remoteSpaceName, expiresAt.
channel (a space reference), remoteRoom, remoteName, backfill.
backfill asks for a history import. It holds requestedAt and an optional since. Leave out since to import the room’s whole history.
backfillStatus
Section titled “backfillStatus”channel, requestedAt, state, imported, from, until, reached, updatedAt. The share of the import done is how far reached has got from from to until.
remoteRoom
Section titled “remoteRoom”id, name, kind (text, voice, announcement, forum or other), parent (the category name).
remoteAuthor
Section titled “remoteAuthor”id, name, avatar (a blob from uploadBlob).
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Writes per registration | 5 per second, bursts up to 30 |
| Imported messages per registration | 20 per second, bursts up to 100 |
| Uploaded file size | 20 MB |
| Avatar size | 1 MB, PNG, JPEG, GIF or WebP |
| Pending pairing codes per bridge | 10 |
| Pairing code lifetime | 10 minutes |
A rate-limited request fails with HTTP 429 and a Retry-After header.
Errors
Section titled “Errors”| Error | Meaning |
|---|---|
AuthRequired |
The request has no valid service auth or session. |
Forbidden |
The caller doesn’t own the registration, or the admin lacks Manage Space. |
CommunityNotFound |
The Space doesn’t exist on this AppView. |
RegistrationNotFound |
The registration doesn’t exist in that Space. |
RegistrationDisabled |
An admin paused the registration. |
ChannelNotLinked |
The channel isn’t linked to or open on the registration, or the thread isn’t beside such a channel. |
ThreadNotFound |
The thread to change doesn’t exist. |
MessageNotFound |
The anchor message for a new thread isn’t in the channel. |
ModerationMirrorOff |
hideMessage was called while moderation mirroring is off. |
BackfillNotRequested |
No admin asked for a history import on the channel, or reportBackfill named an older request. |
OutsideBackfillRange |
An imported message was sent before since or after requestedAt. |
ChannelNotFound |
A link or open channel in update names a channel the Space doesn’t have. |
RecordNotFound |
The message or reaction to change doesn’t exist. |
NotBridged |
The record or thread wasn’t written for this registration, or hideMessage named a message the Space wrote. |
AlreadyReacted |
The same remote author already reacted with that emoji. |
AlreadyRegistered |
The bridge is already connected to this Space for that remote space. For install, the bridge is already installed in the Space. |
BridgeNotFound |
install named a handle or DID that doesn’t resolve to a bridge. |
PairingNotFound |
The code is wrong, used, or expired. |
BlobTooLarge |
The upload is over 20 MB. |
RateLimited |
The registration is over its write limit. |
CredentialsUnavailable |
The AppView can’t write as the Space right now. Retry later. |