Skip to main content
The co-mind.ai API supports two authentication methods. Both use the Authorization: Bearer <token> header.

JWT Authentication Flow

Login

POST /v1/auth/login
Response:
LDAP/AD routing: If the user’s email domain matches an IdP configuration, the login request is automatically routed to the configured LDAP/AD directory for authentication. No client-side changes are needed.

SSO Login (Microsoft Entra ID)

POST /v1/auth/sso

Refresh Token

POST /v1/auth/refresh
The refresh endpoint validates the user’s current status — suspended or disabled users are blocked from refreshing tokens.

Logout

POST /v1/auth/logout

Get Current User

GET /v1/auth/me
Returns user info including privileges, group memberships, current tenant scope, and user version. Accepts either a JWT or a PAT. Response (multi-tenant user):
  • currentTenantId — the tenant this session (or PAT) is currently scoped to.
  • groupMemberships[] — every tenant the user belongs to. Read directly from the database, so a PAT (which is bound to one tenant) still returns the full list.

Multi-tenant Sessions

A user may belong to more than one tenant (workspace). An interactive JWT session can be switched between the user’s tenants; each switch mints a fresh token pair scoped to the target tenant.
PATs cannot be switched — a PAT is bound to a single tenant at issuance. To operate against another tenant, mint a new PAT under that tenant. See API Tokens → Tenant scope.

Switch Tenant

POST /v1/auth/switch-tenant
Response (new token pair, scoped to the target tenant):
The prior access token is blacklisted immediately on switch and will return 401 on the next call. Clients must replace their cached access_token and refresh_token with the pair returned above.
  • tenant_id may be a sub-organization id; the server normalizes it to the tenant root for isolation. Sub-organizations remain addressable by their own id on endpoints that take one.
  • Membership is verified — the caller must be a member of the target tenant. System administrators may switch into any tenant (recorded as an override in the audit log).
  • Rate-limited per user; do not switch in tight loops.

Full flow — list tenants, then switch

1

Log in

2

List memberships and see the active tenant

If currentTenantId is null, the session has not yet picked an active tenant — pick one in the next step.
3

Switch to a chosen tenant

4

Confirm the switch landed

Registration & Password Reset

Registration Flow

1

Check Registration

2

Register

3

Confirm Email

Password Reset Flow

1

Request Reset

2

Execute Reset

Authentication Endpoints Reference

Security Best Practices

PATs are long-lived and scoped — much better than JWTs for automated workflows. Reserve JWTs for interactive sessions.
Never send tokens over HTTP. All production deployments should enforce TLS.
Use environment variables or secret managers (AWS Secrets Manager, HashiCorp Vault) — never commit tokens to source control.
Only request the permissions you need. A read-only integration should not have write scopes.
Use the POST /v1/api-tokens/{id}/rotate endpoint for seamless rotation without downtime.
Delete tokens that are no longer needed using DELETE /v1/api-tokens/{id}.
Use .env files, CI/CD secrets, or secret managers instead.