Overview
TheInviteType and related types define the structure of invitation data stored in the database and used throughout the invite plugin.
InviteType
Core invitation data structure without the database ID.Fields
Unique invitation token used for activation. Generated based on
tokenType:"token": 24-character random string"code": 6-character alphanumeric code"custom": Generated byoptions.generateToken
ID of the user who created this invitation.
Timestamp when the invitation was created.
Timestamp when the invitation expires. Calculated as
createdAt + invitationTokenExpiresIn.Maximum number of times this invitation can be used.
- Default:
1for private invites (with email) - Default:
Infinityfor public invites (no email)
Optional URL to redirect users to after accepting the invitation (for logged-in users).
Can include
{token} placeholder which will be replaced with the actual token.Whether to share the inviter’s name with the invitee.
When
true, the invitee can see who invited them via the getInvite endpoint.Email address for private invitations. When present:
- Only the user with this email can accept/reject
- Creates a private invite
- Email notification is sent
- Creates a public invite (shareable link)
- Anyone with the token can accept
The role to assign to the user when they accept the invitation.
Only set for private invites. Indicates whether this invitation is for:
true: A new user who needs to create an accountfalse: An existing user who will get a role upgrade
Current status of the invitation. See InvitationStatus below.
InviteTypeWithId
Invitation type with database ID included.Fields
Includes all fields fromInviteType plus:
Unique database identifier for the invitation.
InvitationStatus
Enum-like type defining the possible states of an invitation.Status Values
Initial state. Invitation has been created but not yet accepted, rejected, or canceled.
The invitee has rejected the invitation (private invites only).Triggered by:
POST /invite/rejectThe invitation creator has canceled the invitation.Triggered by:
POST /invite/cancelThe invitation has been successfully activated.Triggered by:
POST /invite/activate (when user is authenticated)Status Flow
pending to any other status, it cannot be used or changed.
InviteUseType
Tracks individual uses of an invitation (for invitations withmaxUses > 1).
Fields
Reference to the invitation ID that was used.
ID of the user who used the invitation.
Timestamp when the invitation was used.
InviteUseTypeWithId
Invitation use record with database ID.Fields
Includes all fields fromInviteUseType plus:
Unique database identifier for this usage record.
Examples
Private Invite for New User
Private Invite for Role Upgrade
Public Invite (Shareable Link)
Used Invitation with ID
Invitation Use Record
Database Schema
These types correspond to the following database tables:invite Table
inviteUse Table
Type Guards
Useful type guards for working with invitations:Source Code Reference
Type definitions:src/types.ts:323-364
Database schema: src/schema.ts:3-40
Related
- InviteOptions - Plugin configuration
- Permissions Type - Permission configuration
- Create Invite - Creating invitations
- Activate Invite - Activating invitations