Module supabase/functions/get-invitation-by-token

Fileoverview

Get Invitation by Token Edge Function

Retrieves invitation details by token for display on the accept invitation page. This is a public endpoint (no JWT required) to allow unauthenticated users to view invitation details before signing up or logging in.

Endpoint

POST /get-invitation-by-token

Auth

None - Public endpoint

Remarks

  • Uses service role to bypass RLS for reading invitations
  • Validates invitation status (must be 'pending')
  • Checks expiration and returns 410 Gone for expired invitations
  • Does NOT return the token in response for security
  • Includes client name via join for display purposes

Example: Request body

{ "token": "abc123-invitation-token" }

Returns

200 - Invitation details (id, client_id, email, role, status, expires_at, client name)

Returns

400 - Missing token in request

Returns

404 - Invitation not found

Returns

410 - Invitation expired or already used

Returns

500 - Internal server error