Authentication
The client API uses HTTP Bearer. Send Authorization: Bearer and either an API key or a portal session_token. The credential selects the tenant and the schema. Keys are issued out of band. Contact us to get one. Parameters and responses are in the API reference.
GET /v1/commercial/whoami echoes that principal: tenant_id, auth_method (api_key, magic_auth, or sso), scopes, plan, entitlements, schema, exclude_from_billing, and exclude_from_metrics. tenant_id is the value you send on later writes. A missing or invalid bearer is HTTP 401.
Portal login
Portal login is WorkOS Magic Auth. You never send a WorkOS access token to Cloudswift. The session bearer is separate.
POST /v1/auth/magic-auth takes email. On success the body is { "status": "sent" }. The one-time code is only in the email.
POST /v1/auth/magic-auth/verify takes email and code. code is six digits. The response is a session:
- session_token — bearer for later calls
- refresh_token — send only to refresh
- expires_in — session lifetime in seconds
- token_type — Bearer
- tenant_id, organization_id, email
- auth_method — magic_auth for this flow
- schema — the schema this organization maps to
POST /v1/auth/refresh takes a JSON body whose only field is refresh_token, plus Authorization: Bearer set to the session token, which may already be expired. The refresh token is not a bearer.
POST /v1/auth/sso/authorize builds a browser authorize URL. While only Magic Auth is enabled, that call responds 403. The browser later posts the returned code to POST /v1/auth/sso/callback.