Endpoint
Authentication
This endpoint requires authentication. User must be logged in with a valid session, and their email must match the invitation email.Request Body
The invitation token to reject.
Response
Success Response (200)
Always
true on success.Confirmation message:
"Invite rejected successfully"Examples
Reject Private Invitation
Request:cleanupInvitesOnDecision is enabled).
Reject with Cleanup Enabled
WhencleanupInvitesOnDecision: true is configured:
Request:
Error Responses
Invalid Token (400)
- Token doesn’t exist in the database
- Invitation has already been canceled, rejected, or used
- Invitation has expired
Cannot Reject Invite (400)
- The invitation is a public invite (no email)
- The logged-in user’s email doesn’t match the invitation email
- User doesn’t have permission based on
canRejectInviteoption
Behavior
Rejection Process
- Validates the invitation token exists
- Verifies this is a private invite (has an email)
- Checks the logged-in user’s email matches the invitation email
- Checks the invitation status is “pending”
- Checks
canRejectInvitepermissions - Triggers
beforeRejectInvitehook - Either deletes or updates the invitation based on
cleanupInvitesOnDecisionsetting:- If
cleanupInvitesOnDecision: true: Deletes invitation and all invite uses - If
cleanupInvitesOnDecision: false(default): Updates status to “rejected”
- If
- Triggers
afterRejectInvitehook - Returns success confirmation
Authorization Rules
Always enforced:- Only works for private invites (with email)
- User’s email must match the invitation email
canRejectInvite:
- Additional custom permission checks
- Role-based restrictions
Cleanup Behavior
With cleanupInvitesOnDecision: false (default)
With cleanupInvitesOnDecision: true
Hooks
The following hooks are triggered during this endpoint:-
beforeRejectInvite: Called before rejecting the invitation -
afterRejectInvite: Called after the invitation is rejected
Permissions
Permission is checked using thecanRejectInvite option:
canRejectInvite: true, the user’s email must match the invitation email.
Use Cases
Decline Unwanted Invitation
Reject and Notify
Handle Rejection in UI
Differences from Cancel
| Feature | Cancel | Reject |
|---|---|---|
| Who can do it | Invitation creator | Invitation recipient |
| Invite type | Both public and private | Private invites only |
| Authorization | canCancelInvite | canRejectInvite |
| Use case | Revoke invitation before acceptance | Decline invitation as recipient |
| Status | canceled | rejected |
Invitation Status Flow
Public vs. Private Invites
Private invites (with email):- Can be rejected by the invitee
- Requires email match for rejection
- Cannot be rejected (no specific recipient)
- Can only be canceled by creator
Source Code Reference
Implementation:src/routes/reject-invite.ts:9-135
Related
- Create Invite - Create a new invitation
- Cancel Invite - Cancel an invitation (by creator)
- Activate Invite - Accept an invitation
- InviteOptions - Plugin configuration options