API: Auth
Registration, login, token refresh/logout, invite acceptance. Public (no JWT).
На этой странице
- POST /auth/bootstrap
- POST /auth/invite/accept
- POST /auth/login
- POST /auth/logout
- GET /auth/oidc/callback
- POST /auth/oidc/start
- POST /auth/password/forgot
- POST /auth/password/reset
- POST /auth/refresh
- POST /auth/register
- POST /auth/register/domain-review
- POST /auth/register/request-invite
- POST /auth/register/resend
- POST /auth/register/verify
Раздел собран из спецификации OpenAPI продукта: 14 метод(ов). Поверхность — query-api (основной API, база /api/v1). Все методы этого раздела доступны без токена доступа.
Методы раздела
- POST
/auth/bootstrap - POST
/auth/invite/accept - POST
/auth/login - POST
/auth/logout - GET
/auth/oidc/callback - POST
/auth/oidc/start - POST
/auth/password/forgot - POST
/auth/password/reset - POST
/auth/refresh - POST
/auth/register - POST
/auth/register/domain-review - POST
/auth/register/request-invite - POST
/auth/register/resend - POST
/auth/register/verify
/auth/bootstrap Rotate the customer refresh cookie and return the initial application shell
Reads only the `pp_rt` httpOnly cookie, rotates it exactly like `/auth/refresh`, and returns the token response together with the currently available shell data. An optional `org_id` switches the organization after the server re-checks active membership. Cloud responses may include `billing` and `usage`; on-prem responses may include `license`. Shell sections are optional so a temporarily unavailable section does not invalidate an otherwise valid session. The response is never cacheable.
Тело запроса application/json , необязательно
| Поле | Тип | Описание |
|---|---|---|
org_id необязательно | integer (int64) | Organization to select; active membership is re-checked by the server. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 200 | Rotated customer session and the available application shell Заголовки: Cache-Control, Set-Cookie.
| CustomerBootstrapResponse |
| 401 | Missing or invalid credentials (code=unauthorized) | Error |
| 403 | Authenticated but not permitted (code=forbidden) | Error |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/invite/accept Accept an org invite (creates or verifies the user)
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
token обязательно | string | |
password необязательно | string | Required for a brand-new user (min 8 chars) |
name необязательно | string | |
mfa_code необязательно | string | Required when the existing invited account has MFA enabled; accepts TOTP or a recovery code. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 200 | Membership added; access token in the body, refresh token in the cookie Заголовки: Set-Cookie.
| oneOf<TokenResponse | MFARequiredResponse> |
| 401 | Missing or invalid credentials (code=unauthorized) | Error |
| 404 | Resource not found (code=not_found) | Error |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/login Log in with email/password (optionally selecting an org)
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email обязательно | string (email) | |
password обязательно | string | |
org_id необязательно | integer (int64) | Optional org to log into |
mfa_code необязательно | string | Current six-digit TOTP or one unused recovery code when MFA is enabled. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 200 | Access token in the body, refresh token in the cookie Заголовки: Set-Cookie.
| oneOf<TokenResponse | MFARequiredResponse> |
| 401 | Missing or invalid credentials (code=unauthorized) | Error |
| 403 | Authenticated but not permitted (code=forbidden) | Error |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/logout No request body: the refresh token is read from the `pp_rt` httpOnly cookie. Always clears the cookie; a missing/unknown token still yields 204. A present `Origin` header must be in the allowlist, otherwise 403.
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 204 | Logged out; refresh cookie cleared (Max-Age=0) Заголовки: Set-Cookie.
| пусто |
| 403 | Authenticated but not permitted (code=forbidden) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/oidc/callback Consume the OIDC authorization response
Atomically consumes state, exchanges the code with its encrypted PKCE verifier, and validates issuer, audience, signature, expiry, nonce, verified email, exact domain policy and controlled membership/JIT policy. Success sets only the httpOnly refresh cookie and redirects to the SPA; no token is placed in the URL.
Параметры
| Имя | Где | Тип | Описание |
|---|---|---|---|
state обязателен | Query | string | |
code обязателен | Query | string | |
error необязателен | Query | string |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 303 | OIDC session established; continue at the SPA callback Заголовки: Set-Cookie, Location.
| пусто |
| 401 | Missing or invalid credentials (code=unauthorized) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/oidc/start Start a server-bound OIDC authorization flow
Resolves exactly one enabled organization from an exact email domain (or an explicit org_id), then creates a short-lived one-time state, nonce and S256 PKCE verifier. The verifier is encrypted at rest. No credential is returned to the SPA; authorization_url points to the IdP.
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email необязательно | string (email) | |
org_id необязательно | integer (int64) |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 200 | Authorization URL valid for ten minutes | OIDCStartResponse |
| 404 | Resource not found (code=not_found) | Error |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/password/forgot Request a password reset email
Always returns 204 regardless of whether the account exists (prevents user enumeration). If the account exists, an email with a one-hour reset link is sent; requesting a new token invalidates previous unused ones.
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email обязательно | string (email) |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 204 | Accepted (email sent if the account exists) | пусто |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/password/reset Set a new password using a token from the reset email
Consumes the one-time token: on success all refresh tokens of the user are revoked (every session is logged out). An unknown, used or expired token yields 422 with message "invalid or expired token".
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
token обязательно | string | |
password обязательно | string |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 204 | Password updated; all sessions revoked | пусто |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/refresh Rotate the refresh cookie and mint a new access token, optionally for another org
The refresh token is read EXCLUSIVELY from the `pp_rt` httpOnly cookie (send with `credentials: include`). An optional `org_id` selects a new organization context; the server derives the user from the refresh token and re-checks an active membership before minting the new org claim. Omitting the body preserves the refresh token's current org and remains backwards-compatible. On success the cookie is rotated (new Set-Cookie); on an invalid/reused token the cookie is cleared and 401 is returned (reuse also revokes all of the user's sessions). A present `Origin` header must be in the allowlist (CORS_ORIGINS + APP_BASE_URL), otherwise 403.
Тело запроса application/json , необязательно
| Поле | Тип | Описание |
|---|---|---|
org_id необязательно | integer (int64) | Organization to select; active membership is re-checked by the server. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 200 | New access token; rotated refresh cookie Заголовки: Set-Cookie.
| TokenResponse |
| 401 | Missing or invalid credentials (code=unauthorized) | Error |
| 403 | Authenticated but not permitted (code=forbidden) | Error |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/register Register a new user and create their organization
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email обязательно | string (email) | |
password обязательно | string | |
name необязательно | string | |
org_name необязательно | string | |
device_fp необязательно | string | Optional best-effort client-side device fingerprint hash (see frontend/src/lib/deviceFingerprint.ts). Used only in trial-first catalog mode as an additional anti-fraud signal (signup_signals.device_fp_hash, salted server-side — the raw value is never stored). Malformed or oversized values are silently dropped rather than rejected, and the field is entirely ignored outside trial-first mode. |
utm необязательно | object | Optional first-touch UTM parameters captured client-side (utm_source/utm_medium/utm_campaign/utm_term/utm_content; see frontend/src/lib/signupUtm.ts). Used only in trial-first catalog mode; stored as-is in signup_signals.utm (not PII). Values longer than 200 characters are truncated server-side; entries beyond 10 keys and any non-string-map shape are silently dropped rather than rejected. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 201 | Created; access token in the body, refresh token in the cookie Заголовки: Set-Cookie.
| TokenResponse |
| 202 | Trial-first catalog mode: no account is created yet. A six-digit confirmation code and a link token have been sent to the email address (valid for 24 hours); registration completes via `/auth/register/verify`. | SignupVerificationRequired |
| 422 | Request failed validation (code=validation_failed), or — in trial-first catalog mode only — the email domain (including any subdomain of a listed domain) belongs to a known disposable email provider (code=disposable_email, details.field=email): such addresses cannot start a trial signup; a work email is required. | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/register/domain-review Register a separate company on an already-taken corporate domain (manual review)
Continuation of the 409 domain_has_org answer of `/auth/register/verify` («Это другая компания»). Accepts the same email+code or link token plus an optional company_note, consumes the verification and registers the user and organization through the ordinary path — but with a pending_review subscription instead of a trial: event ingestion is blocked immediately and the cabinet is read-only (403 trial_pending_review) until a manual review activates the account (email promise: within one business day). The applicant is logged in right away (201 token response). Code defects — and calling this endpoint without an actual domain conflict — yield the same uniform 422 as `/auth/register/verify` (the verification is left untouched in the no-conflict case).
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email необязательно | string (email) | Required together with code. |
code необязательно | string | Six-digit code from the confirmation email. |
token необязательно | string | Link token from the emailed URL; replaces email+code. |
company_note необязательно | string | Free-form note for the review queue (why this is a different company). Up to 1000 characters. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 201 | Registered pending review; access token in the body, refresh token in the cookie, org.trial_state=pending_review. The subscription status is pending_review — mutations answer 403 trial_pending_review until activation. Заголовки: Set-Cookie.
| TokenResponse |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/register/request-invite Ask the owner of the existing same-domain organization for an invite
Continuation of the 409 domain_has_org answer of `/auth/register/verify`. Accepts the same email+code or link token, consumes the verification and emails the owner of the most recent organization on the domain a request to invite the applicant (Settings → Team link included). No user or organization is created — membership only appears through the ordinary invite flow. Every code defect — and calling this endpoint when the domain rule would not fire — yields the same uniform 422 as `/auth/register/verify`; in the no-conflict case the verification is left untouched so a normal verify still works.
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email необязательно | string (email) | Required together with code. |
code необязательно | string | Six-digit code from the confirmation email. |
token необязательно | string | Link token from the emailed URL; replaces email+code. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 202 | Invite request accepted; the owner has been notified | object |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/register/resend Re-send the signup confirmation email
Always answers 202 whether or not a pending verification exists (anti-enumeration). When one exists, a fresh code and link token are issued and the previous ones stop working. Rate limited to 1 request per minute per email on top of the shared per-IP limit.
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email обязательно | string (email) |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 202 | Accepted (no indication whether a pending signup exists) | SignupVerificationRequired |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
/auth/register/verify Complete a verify-first signup with the emailed code or link token
Trial-first companion of `/auth/register`. Accepts either the email plus the six-digit code from the confirmation email, or the opaque link token from the emailed URL. Every defect — unknown email, expired or already used verification, more than 10 wrong code attempts, wrong code — yields the same 422 so pending signups cannot be enumerated. Success creates the user, the organization and (per catalog policy) its trialing subscription in one transaction, and returns the same body a legacy 201 registration would, plus org.trial_state. Rule-based risk checks (a signal matching an organization whose trial started less than 90 days ago; a free email provider plus any signal match; two or more signups from the same IP within 24 hours) do NOT reject the signup silently: the organization is still created and the user logged in (201), but with a pending_review subscription instead of a trial (org.trial_state=sms_required) — event ingestion stays blocked until the account is activated via SMS phone confirmation or by the manual review queue (email promise: within one business day).
Тело запроса application/json , обязательно
| Поле | Тип | Описание |
|---|---|---|
email необязательно | string (email) | Required together with code. |
code необязательно | string | Six-digit code from the confirmation email. |
token необязательно | string | Link token from the emailed URL; replaces email+code. |
Ответы
| Код | Что означает | Тело |
|---|---|---|
| 201 | Registration completed; access token in the body, refresh token in the cookie Заголовки: Set-Cookie.
| TokenResponse |
| 409 | Team-already-here rule (code=domain_has_org): the email belongs to a corporate domain (not a known free email provider) and an existing cloud organization already has a member on that domain. No account is created and the verification stays alive, so the same code/token can continue via `/auth/register/request-invite` («Запросить инвайт») or `/auth/register/domain-review` («Это другая компания»). details.org_name_masked and details.owner_email_masked identify the existing organization without disclosing it (first letter plus asterisks, e.g. «A*** C***» and «a***@domain»). | Error |
| 422 | Request failed validation (code=validation_failed) | Error |
| 429 | Rate limit (code=rate_limited) or plan quota exceeded (code=quota_exceeded). On ingest operations a live trial that exhausted its total event cap answers code=trial_quota_exceeded instead of quota_exceeded. Заголовки: Retry-After.
| Error |
Источник раздела — docs/api/openapi.yaml репозитория продукта,
версия API 1.0.0, OpenAPI 3.0.3,
снимок 095579325c2d.
Расхождение снимка со спецификацией роняет сборку документации.