Authentication
AIUS uses two user credentials:- a short-lived HS256 session token, normally held in the
__Host-aius_sessioncookie; and - a durable
aius_…terminal/API credential bound to an organization and a user principal.
Examples target
https://dev.aius.co/api. For dev, use
https://dev.aius.co/api and Accept-Encoding: identity.1. Register
POST /v1/register creates an email/password account and its default
organization. The account must verify its email before normal use.
2. Log in and complete 2FA
POST /v1/login accepts email/password. Without 2FA it returns
{user, message, session_token}. With 2FA it returns
{requires_2fa: true, challenge_token, email, message}.
POST /v1/2fa/login:
3. Recommended terminal device flow
The CLI performs the following exchange:Request a code
POST /v1/auth/device/code returns a device code, short user code,
verification URL, expiry, and polling interval.Approve in the portal
The user opens
/account/device, signs in, and approves the code. If they
have multiple live organization memberships, they choose one. The portal
calls POST /v1/auth/device/authorize with
{user_code, client_id?} and its session cookie.client_id must be an exact org_… id in the signed-in user’s live
memberships. If omitted, AIUS resolves the default organization. Selecting an
inaccessible organization returns 403; failure to establish memberships
returns 503.
Each organization/principal pair has its own active credential. A new device
login rotates only that user’s previous credential in that organization, so
teammates do not sign each other out.
4. Direct credential mint
POST /v1/tokens is the session-authenticated programmatic mint used by the
same credential layer. It is not a portal key-management feature.
token_name is optional and defaults to API key. client_id is optional;
when present it must be an organization the session user currently owns or has
membership in. The response returns the plaintext token once:
5. Use the bearer credential
{"type":"auth","token":"aius_…"}.
An unknown, revoked, or removed-member credential is rejected. For a
user-associated organization credential, AIUS revalidates live membership
before run/chat and protected account operations:
- 403 means the user no longer belongs to the organization;
- 503 means the membership authority could not be established, and the request fails closed rather than running unbilled.
org_id query parameter matching the
resource scope, for example:
Team membership endpoints
These routes use a browser session or an authorized bearer identity:| Endpoint | Method | Access |
|---|---|---|
/v1/clients/{client_id}/members | GET | Any live member |
/v1/clients/{client_id}/members | POST | Owner; body {"email":"exact@example.com"} |
/v1/clients/{client_id}/members/{user_id} | DELETE | Owner; cannot remove owner |
Manage TOTP
Authenticated TOTP endpoints:| Endpoint | Method | Purpose |
|---|---|---|
/v1/2fa/status | GET | Read enabled state |
/v1/2fa/setup | POST | Return secret and otpauth_uri |
/v1/2fa/enable | POST | Confirm code and return recovery codes |
/v1/2fa/disable | POST | Disable with TOTP or recovery code |
Password reset
| Endpoint | Method | Purpose |
|---|---|---|
/v1/password/reset/request | POST | Send reset email; does not reveal whether an address exists |
/v1/password/reset/confirm | POST | Set a new password from the reset token |