Skip to main content

vaults.inviteMember

Invite a user to an enterprise vault by email.
Requires owner or admin role in the vault

Request

vaultId
string
required
UUID of the enterprise vault
email
string
required
Email address of the user to invite. Must be a valid email format.
role
enum
default:"member"
Role to assign. One of: admin, member
const invitation = await trpc.vaults.inviteMember.mutate({
  vaultId: "a1b2c3d4-...",
  email: "[email protected]",
  role: "admin"
});

Response

id
string
required
UUID of the invitation
vaultId
string
required
UUID of the vault
vaultSlug
string
required
Slug of the vault
vaultName
string
required
Display name of the vault
vaultType
enum
required
Vault type (always enterprise for this endpoint)
vaultColor
string | null
required
Vault color
role
enum
required
Role the invitee will receive. One of: admin, member
status
enum
required
Invitation status. One of: pending, accepted, declined, revoked, expired
invitedByUserId
string | null
required
User ID of the person who created the invitation
expiresAt
Date | null
required
When the invitation expires (14 days from creation)
createdAt
Date
required
When the invitation was created
updatedAt
Date
required
When the invitation was last updated

Example

const invitation = await trpc.vaults.inviteMember.mutate({
  vaultId: "a1b2c3d4-...",
  email: "[email protected]",
  role: "member"
});
// {
//   id: "inv123-...",
//   vaultId: "a1b2c3d4-...",
//   vaultSlug: "engineering",
//   vaultName: "Engineering Team",
//   vaultType: "enterprise",
//   vaultColor: "#3b82f6",
//   role: "member",
//   status: "pending",
//   invitedByUserId: "user456",
//   expiresAt: new Date("2024-03-29T10:00:00Z"),
//   createdAt: new Date("2024-03-15T10:00:00Z"),
//   updatedAt: new Date("2024-03-15T10:00:00Z")
// }

Validation

  • Email addresses are normalized (trimmed, lowercased)
  • Cannot invite your own email address (throws BAD_REQUEST)
  • Vault must be of type enterprise (throws NOT_FOUND)
  • If a pending invitation already exists, it will be updated with the new role and expiry
  • Invitations expire after 14 days

vaults.invitations.listPending

List all pending vault invitations for the authenticated user.

Request

No input parameters. Uses authenticated session context.
const invitations = await trpc.vaults.invitations.listPending.query();

Response

Returns an array of pending invitation objects (same structure as vaults.inviteMember response).

Example

const invitations = await trpc.vaults.invitations.listPending.query();
// [
//   {
//     id: "inv123-...",
//     vaultId: "a1b2c3d4-...",
//     vaultSlug: "engineering",
//     vaultName: "Engineering Team",
//     vaultType: "enterprise",
//     vaultColor: "#3b82f6",
//     role: "member",
//     status: "pending",
//     invitedByUserId: "user456",
//     expiresAt: new Date("2024-03-29T10:00:00Z"),
//     createdAt: new Date("2024-03-15T10:00:00Z"),
//     updatedAt: new Date("2024-03-15T10:00:00Z")
//   }
// ]

vaults.invitations.acceptInvitation

Accept a pending vault invitation.

Request

invitationId
string
required
UUID of the invitation to accept
const result = await trpc.vaults.invitations.acceptInvitation.mutate({
  invitationId: "inv123-..."
});

Response

success
literal
required
Always true on success
invitationId
string
required
UUID of the invitation
vaultId
string
required
UUID of the vault
role
enum
required
Role assigned. One of: owner, admin, member
status
literal
required
Always "accepted"

Example

const result = await trpc.vaults.invitations.acceptInvitation.mutate({
  invitationId: "inv123-..."
});
// {
//   success: true,
//   invitationId: "inv123-...",
//   vaultId: "a1b2c3d4-...",
//   role: "member",
//   status: "accepted"
// }

Validation

  • Invitation must exist (throws NOT_FOUND)
  • Invitation status must be pending (throws BAD_REQUEST)
  • Invitation email must match authenticated user’s email (throws FORBIDDEN)
  • Expired invitations are automatically marked as expired and rejected (throws BAD_REQUEST)
  • Creates or updates vault membership with the invitation’s role

vaults.invitations.declineInvitation

Decline a pending vault invitation.

Request

invitationId
string
required
UUID of the invitation to decline
const result = await trpc.vaults.invitations.declineInvitation.mutate({
  invitationId: "inv123-..."
});

Response

success
literal
required
Always true on success
invitationId
string
required
UUID of the invitation
vaultId
string
required
UUID of the vault
role
enum
required
Role that was offered. One of: owner, admin, member
status
literal
required
Always "declined"

Example

const result = await trpc.vaults.invitations.declineInvitation.mutate({
  invitationId: "inv123-..."
});
// {
//   success: true,
//   invitationId: "inv123-...",
//   vaultId: "a1b2c3d4-...",
//   role: "member",
//   status: "declined"
// }

Validation

  • Invitation must exist (throws NOT_FOUND)
  • Invitation status must be pending (throws BAD_REQUEST)
  • Invitation email must match authenticated user’s email (throws FORBIDDEN)
  • Expired invitations are automatically marked as expired and cannot be declined (throws BAD_REQUEST)
  • Does not create a vault membership

Invitation Status Transitions

Invitations follow this lifecycle:
[created] → pending

           ├─→ accepted (membership created)
           ├─→ declined (no membership)
           ├─→ revoked (admin action - not yet implemented)
           └─→ expired (14 days passed)

Status Details

  • pending: Invitation is active and can be accepted or declined
  • accepted: User accepted and membership was created/updated
  • declined: User declined the invitation
  • revoked: Admin cancelled the invitation before acceptance
  • expired: Invitation exceeded the 14-day expiry period

Expiration

  • Invitations expire 14 days after creation
  • Expired invitations are auto-detected when users try to accept/decline
  • Status is updated to expired when expiry is detected

Build docs developers (and LLMs) love