Skip to content

Invites

Invites let space creators distribute membership tokens without knowing recipients’ DIDs in advance.

Only the space’s creator or an operator with superadmin can create invites.

const response = await fetch("https://happyview.example.com/xrpc/dev.happyview.space.createInvite", {
method: "POST",
headers: {
"X-Client-Key": CLIENT_KEY,
"Authorization": `DPoP ${ACCESS_TOKEN}`,
"DPoP": DPOP_PROOF,
"Content-Type": "application/json",
},
body: JSON.stringify({
space: "at://did:web:happyview.example.com/space/com.example.forum/main",
access: { read: true, write: true },
maxUses: 10,
expiresAt: "2026-06-01T00:00:00Z",
}),
});
interface CreateInviteResponse {
inviteId: string;
token: string;
access: { read: boolean; write: boolean };
maxUses: number;
expiresAt: string;
}
const data: CreateInviteResponse = await response.json();

Input:

FieldTypeRequiredDefaultDescription
spacestringYesThe space this invite is for
accessobjectNo{ "read": true, "write": false }Access granted on acceptance: read and write booleans, both required when access is given
maxUsesintegerNounlimitedMaximum number of times the invite can be redeemed
expiresAtstring (datetime)NoneverWhen the invite expires

Response (201):

{
"inviteId": "uuid",
"token": "a1b2c3d4e5f6...",
"access": { "read": true, "write": true },
"maxUses": 10,
"expiresAt": "2026-06-01T00:00:00Z"
}

Any authenticated user can accept an invite token to join the space.

const response = await fetch("https://happyview.example.com/xrpc/dev.happyview.space.acceptInvite", {
method: "POST",
headers: {
"X-Client-Key": CLIENT_KEY,
"Authorization": `DPoP ${ACCESS_TOKEN}`,
"DPoP": DPOP_PROOF,
"Content-Type": "application/json",
},
body: JSON.stringify({
token: "a1b2c3d4e5f6...",
}),
});
interface AcceptInviteResponse {
uri: string;
access: { read: boolean; write: boolean };
}
const data: AcceptInviteResponse = await response.json();

Response (201):

{
"uri": "at://did:web:happyview.example.com/space/com.example.forum/main",
"access": { "read": true, "write": true }
}

Acceptance fails if:

  • The token is invalid (no matching hash found)
  • The invite has been revoked
  • The invite has reached its maxUses
  • The invite has expired
  • The user is already a member of the space
const response = await fetch("https://happyview.example.com/xrpc/dev.happyview.space.revokeInvite", {
method: "POST",
headers: {
"X-Client-Key": CLIENT_KEY,
"Authorization": `DPoP ${ACCESS_TOKEN}`,
"DPoP": DPOP_PROOF,
"Content-Type": "application/json",
},
body: JSON.stringify({
space: "at://did:web:happyview.example.com/space/com.example.forum/main",
inviteId: "uuid",
}),
});

Revoking an invite prevents future redemptions but does not remove members who already redeemed it.

Only the space’s creator or an operator with superadmin can list invites.

const response = await fetch(
"https://happyview.example.com/xrpc/dev.happyview.space.listInvites?space=at://did:web:happyview.example.com/space/com.example.forum/main",
{
headers: {
"X-Client-Key": CLIENT_KEY,
"Authorization": `DPoP ${ACCESS_TOKEN}`,
"DPoP": DPOP_PROOF,
},
},
);
interface Invite {
id: string;
access: { read: boolean; write: boolean };
maxUses: number;
uses: number;
expiresAt: string;
revoked: boolean;
createdBy: string;
createdAt: string;
}
const data: { invites: Invite[] } = await response.json();

Parameters:

FieldTypeRequiredDescription
spacestringYesThe space to list invites for

Response:

{
"invites": [
{
"id": "uuid",
"access": { "read": true, "write": true },
"maxUses": 10,
"uses": 3,
"expiresAt": "2026-06-01T00:00:00Z",
"revoked": false,
"createdBy": "did:plc:abc123",
"createdAt": "2026-05-09T12:00:00Z"
}
]
}

The token itself is never returned in list responses — only the invite metadata.