digital-identity-platform-docs
digital-identity-platform-docs / supabase/functions/accept-invitation
supabase/functions/accept-invitation
Fileoverview
Accept Invitation Edge Function
Handles the acceptance of team invitations, creating the necessary client and site memberships for the authenticated user.
Cloudflare Architecture Context
| Attribute | Value |
|---|---|
| Classification | 🔵 BACKEND-ONLY |
| Position | App Backend (team management) |
| Receives Public Traffic | No (authenticated users only) |
| Latency Sensitive | No |
| Safe to Retry | No (creates memberships) |
| Failure Behavior | Fail-closed (returns error) |
Endpoint
POST /accept-invitation
Auth
Required - JWT in Authorization header
Remarks
- Validates invitation token, status (must be 'pending'), and expiration
- Checks email restriction if invitation was sent to specific email
- Prevents duplicate memberships for the same client
- Creates client_memberships record with invited role
- Creates site_memberships for all sites under the client
- Updates invitation status to 'accepted' with timestamp
Example
json
{ "token": "abc123-invitation-token" }