Back to docsRecipe

Team invite flow

A three-step pattern for inviting teammates, handling expired tokens, and surfacing clear error states — without a single modal.


Step 1 — Send

Owner enters an email. The server creates a time-limited invite record, stores a hashed token, and sends a magic link. The UI shows a pending row immediately — optimistic, no spinner.

POST /api/teams/:id/invites { email, role }

Step 2 — Accept

Recipient clicks the link. The page reads the token from the URL, validates it server-side, and either joins them to the team or surfaces a reason it failed.

GET /join?token=... → 200 or 410

Step 3 — Errors

Expired, already-used, and invalid tokens each get a dedicated inline message. No redirects — the page stays put so the user can copy the link or request a new one.

  • Expired — “This invite link has expired. Ask the team owner to send a new one.”
  • Already used — “This invite was already accepted. You’re all set.”
  • Invalid — “We couldn’t find that invite. Double-check the link.”

Need the full API reference? Teams API →