Auth: All protected routes require a valid session cookie (web) or Bearer token (mobile). Unauthenticated requests return 401 Unauthorized. Public routes are marked public.

Auth

Identity + session management. One-time-code (OTP) flow over email or SMS; account/community creation. GAT-998 / GAT-1011.

POST/api/auth/signuppublic

Create a person + identity and send a one-time code to BOTH channels (email AND SMS). Does not create an account or community.

Parameters
firstNamebodyrequired1–80 chars
lastNamebodyrequired1–80 chars
emailAddressbodyrequiredValid email
phoneNumberbodyrequiredE.164 — both channels are always required (GAT-998 AC2)
refbodyoptionalOpaque affiliate-attribution token (GAT-769)
GAT-1011: phone lookup auto-links the new identity to an existing person when the phone matches one already on file; otherwise creates a new person. Response: 201 { data: { userId, emailMasked, phoneMasked, otpExpiresAt, status: 'otp_sent' } }. Existing-email branches: 'resume_otp' (200), 'needs_signin' (409), 'already_exists' (409).
POST/api/auth/signup/verifypublic

Verify BOTH one-time codes (email + SMS) to finalize signup, or complete a signin re-verification when a token is provided.

Parameters
userIdbodyrequiredUser id returned by /api/auth/signup (or 409 from /signin)
emailCodebodyrequired6-digit code from the email card
smsCodebodyrequired6-digit code from the SMS card
pendingVerificationTokenbodyoptionalCarried from a /signin 409 response — switches the response into signin re-verify mode (populates landingCommunityId via favorite → last-accessed → first-joined)
Response: 200 { data: { sessionToken, userId, landingCommunityId } }. landingCommunityId is null on first-time signup (client then calls /api/auth/organization). On a wrong, expired, or already-used code, 400 { error } names which channel(s) failed without revealing the correct code.
POST/api/auth/signup/resendpublic

Re-send the signup one-time code on a specific channel so the two cards can resend independently.

Parameters
userIdbodyrequiredUser id returned by /api/auth/signup
channelbodyrequired'email' | 'sms' — identifies which card is resending
Rate-limited (silent throttle per GAT-998 AC8). Response: 200 { data: { sent: true, channel } }.
POST/api/auth/signup/confirmation-email

Send the post-signup welcome email with the 'Set up my community' CTA.

Parameters
userIdbodyrequiredUser id
communityNamebodyrequiredCommunity name shown in the email body
firstNamebodyrequiredMember first name
POST/api/auth/signinpublic

Initiate sign-in with an email address or phone number. Sends a one-time code when the account is fully verified, or returns 409 when contacts still need to be verified.

Parameters
identifierbodyrequiredEmail address or E.164 phone number — server infers the channel
refbodyoptionalOpaque affiliate-attribution token
GAT-849 anti-enumeration: unknown identifiers return the same 200 shape and timing as known-and-verified ones. GAT-998 AC1: when the identifier belongs to an account whose contacts haven't been verified, response is 409 { error: 'signup_not_complete', message, userId, pendingVerificationToken, emailMasked, phoneMasked, status: 'needs_signup_verification' } — client passes the token to /signup/verify to complete re-verification. GAT-1011 AC5: when a phone resolves to a person with multiple identities, server auto-selects the identity whose last-accessed community is most recent. Success response: 200 { data: { signInId, status: 'needs_verification', channel } }.
POST/api/auth/signin/verifypublic

Verify the sign-in one-time code. Issues a session and returns the landing community.

Parameters
signInIdbodyrequiredId returned by /api/auth/signin
codebodyrequired6-digit code
refbodyoptionalOpaque affiliate-attribution token
Response: 200 { data: { sessionToken, userId, landingCommunityId } }. landingCommunityId is favorite → last-accessed → first-joined (GAT-1011 AC3/AC4); null when the member belongs to zero communities.
GET/api/auth/session

Return the current session's user, enrollment status, and account/community context.

Reads the __cc_session cookie; verifies the JWT with jose; checks the sessions table for revocation and expiry. Response includes { user, accounts[] } with per-account community previews (top 10 by last-accessed).
POST/api/auth/signout

Revoke the current session and clear the __cc_session cookie.

POST/api/auth/organization

Create a new account (billing/plan container) and the first community under it. Sends welcome + community-created emails and creates a HubSpot contact.

Parameters
namebodyrequiredAccount and first-community name
accountTypebodyoptionalAccount type override
billingCustomerIdbodyoptionalPre-provisioned billing id
providerIdbodyoptionalProvider override (ref takes precedence)
providerPlanIdbodyoptionalProvider plan override (ref takes precedence)
refbodyoptionalOpaque affiliate-attribution token
Only called when a signup is creating their own account. Invitees joining an existing account skip this endpoint. HubSpot write runs via Vercel after() so it survives post-response (GAT-578).
GET/api/auth/organizations

List the accounts the current session's user belongs to.

community-cloud-api · API Documentation