invitations
The methods of pd.invitations. Inputs and outputs are described in Conventions; every method can also fail as described in Errors.
Methods
pd.invitations.list(input, init?)
List a workspace's pending invitations
GET /api/workspaces/{workspaceId}/invitations
Needs members.read. Neither accepted nor revoked, newest first. Expired invitations stay listed so they can be resent. The link itself is never returned: it exists only in the email.
Input
| Name | In | Type | Required | Description |
|---|---|---|---|---|
workspaceId |
path | string (uuid) |
yes | Id of the workspace the request works in. The caller must be a member of it, or hold an API key issued by it. For anyone else, an unknown id and an id they do not belong to both answer 404 RESOURCE_NOT_FOUND, so membership cannot be probed. |
init |
init | { signal?: AbortSignal; timeoutMs?: number } |
no | The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout. |
Returns 200 OK
| Field | Type | Required | Description |
|---|---|---|---|
invitations |
object[] |
yes | Invitations neither accepted nor revoked, expired ones included, newest first. |
invitations[].id |
string (uuid) |
yes | Id of the invitation, used to resend or revoke it. |
invitations[].email |
string |
yes | The invited address, lowercased. The invitation can only be accepted by it. |
invitations[].roleIds |
string (uuid)[] |
yes | The roles the invitee receives on accepting; any that no longer exist by then are skipped, and when none is left the workspace's default roles apply. |
invitations[].invitedBy |
object | null |
yes | The inviter; null when it was an API key without a creator, or the user is gone. |
invitations[].invitedBy.id |
string |
yes | Id of the inviting user. |
invitations[].invitedBy.name |
string |
yes | Display name of the inviting user. |
invitations[].expiresAt |
string (date-time) |
yes | When the emailed link stops working, as an ISO 8601 timestamp: seven days after the last send. Past it the invitation is expired but stays listed, so it can be resent. |
invitations[].createdAt |
string (date-time) |
yes | When the invitation was first created, as an ISO 8601 timestamp. |
invitations[].lastSentAt |
string (date-time) |
yes | When the link was last emailed, as an ISO 8601 timestamp; resending is refused for a minute after. |
Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.
Example
import { PrismDraft } from "@prism-draft/sdk";
const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });
const result = await pd.invitations.list({
workspaceId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);
pd.invitations.revoke(input, init?)
Revoke an invitation
DELETE /api/workspaces/{workspaceId}/invitations/{invitationId}
Needs members.invite. The emailed link stops working at once, the seat it held is freed, and the address can be invited again. 404 RESOURCE_NOT_FOUND when the invitation is unknown or was already accepted or revoked. Records a members.invitation_revoked audit entry.
Input
| Name | In | Type | Required | Description |
|---|---|---|---|---|
workspaceId |
path | string (uuid) |
yes | Id of the workspace the request works in. The caller must be a member of it, or hold an API key issued by it. For anyone else, an unknown id and an id they do not belong to both answer 404 RESOURCE_NOT_FOUND, so membership cannot be probed. |
invitationId |
path | string (uuid) |
yes | Id of an invitation of this workspace, as id in GET .../invitations. One that is unknown, belongs to another workspace, or was already accepted or revoked answers 404 RESOURCE_NOT_FOUND. |
init |
init | { signal?: AbortSignal; timeoutMs?: number } |
no | The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout. |
Returns 200 OK
| Field | Type | Required | Description |
|---|---|---|---|
ok |
true |
yes | Always true: the change was made. A failure answers an error. |
Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.
Example
import { PrismDraft } from "@prism-draft/sdk";
const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });
const result = await pd.invitations.revoke({
workspaceId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
invitationId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);
pd.invitations.resend(input, init?)
Send an invitation again
POST /api/workspaces/{workspaceId}/invitations/{invitationId}/resend
Needs members.invite. Issues a new link valid for seven days and emails it; the previous link stops working. 403 FORBIDDEN when a role the invitation carries (the default role when it carries none) holds a permission the caller lacks, as when inviting; revoking has no such limit. Answers 429 RATE_LIMITED (with Retry-After) within a minute of the last send. Resending an expired invitation takes a seat again and can answer 429 QUOTA_EXCEEDED; one still open already holds its seat. 404 RESOURCE_NOT_FOUND when the invitation is unknown or was already accepted or revoked. The body is optional. The email is queued with the change and sent in the background. Records a members.invited audit entry.
Input
| Name | In | Type | Required | Description |
|---|---|---|---|---|
workspaceId |
path | string (uuid) |
yes | Id of the workspace the request works in. The caller must be a member of it, or hold an API key issued by it. For anyone else, an unknown id and an id they do not belong to both answer 404 RESOURCE_NOT_FOUND, so membership cannot be probed. |
invitationId |
path | string (uuid) |
yes | Id of an invitation of this workspace, as id in GET .../invitations. One that is unknown, belongs to another workspace, or was already accepted or revoked answers 404 RESOURCE_NOT_FOUND. |
body |
body | object | null |
no | |
body.locale |
body | "en" | "fr" |
no | Language of the email that carries the new link, en or fr. Omitted: the first language of the request's Accept-Language header when it is French or English, else en. |
init |
init | { signal?: AbortSignal; timeoutMs?: number } |
no | The second argument: signal aborts the call, timeoutMs overrides the client's per-attempt timeout. |
Returns 200 OK
| Field | Type | Required | Description |
|---|---|---|---|
invitation |
object |
yes | The invitation with its new expiresAt and lastSentAt. |
invitation.id |
string (uuid) |
yes | Id of the invitation, used to resend or revoke it. |
invitation.email |
string |
yes | The invited address, lowercased. The invitation can only be accepted by it. |
invitation.roleIds |
string (uuid)[] |
yes | The roles the invitee receives on accepting; any that no longer exist by then are skipped, and when none is left the workspace's default roles apply. |
invitation.invitedBy |
object | null |
yes | The inviter; null when it was an API key without a creator, or the user is gone. |
invitation.invitedBy.id |
string |
yes | Id of the inviting user. |
invitation.invitedBy.name |
string |
yes | Display name of the inviting user. |
invitation.expiresAt |
string (date-time) |
yes | When the emailed link stops working, as an ISO 8601 timestamp: seven days after the last send. Past it the invitation is expired but stays listed, so it can be resent. |
invitation.createdAt |
string (date-time) |
yes | When the invitation was first created, as an ISO 8601 timestamp. |
invitation.lastSentAt |
string (date-time) |
yes | When the link was last emailed, as an ISO 8601 timestamp; resending is refused for a minute after. |
Errors 400 invalid input, 401 missing or invalid key, 403 the key's roles lack the permission, 404 not found, 429 rate limited or out of quota. See Errors.
Example
import { PrismDraft } from "@prism-draft/sdk";
const pd = new PrismDraft({ apiKey: process.env.PRISMDRAFT_API_KEY! });
const result = await pd.invitations.resend({
workspaceId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
invitationId: "3f0c5a1e-8b2d-4c6e-9a7f-1d2e3f4a5b6c",
});
console.log(result);