Authentication¶
The b'nerd API supports two authentication methods: Bearer tokens (for CLI and scripted access) and session cookies (for browser / dashboard clients). Both grant access to the same API surface.
JWT bearer tokens (interactive sessions)¶
JWT tokens are short-lived and tied to a specific user account. Use them for interactive sessions in the CLI, or scripts that can refresh tokens.
Obtain a token¶
# 1. Create an account (first-time only) — see "Legal consent" and
# "Creating an organization" below for the full set of required fields.
curl -X POST https://api.bnerd.cloud/create-account \
-H "Content-Type: application/json" \
-d '{
"login": "you@example.com",
"name": "Your Name",
"password": "...",
"password-confirm": "...",
"organization_name": "ACME Corp",
"legal_name": "ACME Corp GmbH",
"country": "DE",
"b2b_declaration": "true",
"legal_agb_version": 1,
"legal_agb_hash": "...",
"legal_nutzungsbedingungen_version": 1,
"legal_nutzungsbedingungen_hash": "...",
"legal_datenschutz_version": 1,
"legal_datenschutz_hash": "..."
}'
# => {"success":"An email has been sent to you with a link to verify your account"}
# 2. Verify your email, then log in
curl -X POST https://api.bnerd.cloud/login \
-H "Content-Type: application/json" \
-d '{"login": "you@example.com", "password": "..."}' -i
# => Authorization: eyJhbGciOiJIUzI1NiJ9...
Legal consent¶
legal_agb_version/legal_agb_hash (and the matching pair for nutzungsbedingungen and datenschutz) pin the exact document version the account holder is consenting to. All three pairs are required — a signup without them is rejected and no account is created. Fetch the current version and hash for each doc type right before signing up:
curl https://api.bnerd.cloud/legal/agb
# => {"data": {"doc_type": "agb", "version": 1, "content_hash": "...", ...}}
A stale version, a missing pair, or a hash that does not match the current document is rejected with 422 ("terms were updated — please reload" or "consent payload invalid — please reload") — reload the current version and resubmit; the account is never created on a failed check. All three doc types pin German-language documents only in this version of the API.
Creating an organization¶
A signup with no token/invitation_token and no pending invitation for that email address creates a new organization, so it must additionally declare who is contracting.
If the email address has a pending invitation, a signup without the token is refused with 422 and "error_code": "invitation_pending" (no account is created). Sign up with the link from the invitation mail instead: it carries the token as invitation_token, and the new account joins the invitation's organization once the email address is verified. Such a signup sends none of the company fields below. Sign-up refusals use Rodauth's own body, so the reason is in error_code (not the errors[0].code of the other endpoints):
The fields for a signup that creates an organization:
| Field | Required | Notes |
|---|---|---|
legal_name | Yes | The org's legal name, single line, ≤ 200 characters. |
country | Yes | ISO 3166-1 alpha-2 (e.g. DE). |
b2b_declaration | Yes | Must be the string "true" — the § S.1(2) B2B declaration. |
vat_id | No | Upper-cased with separators stripped, then shape-checked (two letters + 2–14 letters/digits). For an EU country it must also carry that country's VAT prefix (Greece uses EL, not GR); outside the EU only the shape is checked. Validity is not verified at signup. |
organization_name | No | The organization's display name; falls back to legal_name. |
AVV pin — only once an AVV is published
When b'nerd has published a data processing agreement (avv) document, a signup that creates an organization must also pin it, like the other legal documents above: send legal_avv_version and legal_avv_hash, fetched from GET /legal/avv. Without them the signup is refused with 422 ("consent required"; a stale version or hash gets the same two reload messages as above) and no account is created. Until an AVV is published the fields are not needed. Signing up by accepting an invitation never needs them — the organization concludes its own AVV afterwards.
Any missing or invalid field is rejected with 422 before the account is created — see Concepts: Organization standing for what happens next. Signing up by accepting an invitation to an existing organization does not use any of these fields — see Joining an additional organization below.
The Authorization response header contains your JWT; the JSON response body also carries it as access_token. Use it in subsequent requests:
Browser / dashboard clients¶
When you log in via the dashboard, the API also sets two cookies:
_hq_session— anHttpOnly; Securecookie carrying the session JWT, inaccessible to JavaScript (XSS-safe)._hq_csrf— a readableSecurecookie with a random CSRF token for double-submit protection.
The dashboard reads _hq_csrf and sends it as X-CSRF-Token on every mutating request (POST, PUT, PATCH, DELETE). You do not need to manage these cookies manually — the browser and dashboard handle them automatically.
Via the CLI¶
When prompted, enter https://api.bnerd.cloud (the prompt's default http://localhost:3000 is for local development only). The interactive prompt then asks for your Bearer token (hidden input) and organization ID, and writes ~/.bnerd.yaml (mode 0600). Verify it works:
Static API tokens (machine-to-machine)¶
Static tokens are long-lived, org-scoped tokens intended for CI/CD pipelines and automated scripts. They do not expire on their own and are created and revoked through the dashboard or API.
Static tokens carry the same Bearer prefix:
Creating a token¶
- Go to Account (top-right menu) → Settings → API Tokens (
/account/tokens). - Enter a Token name and the Scopes your automation needs, comma-separated (e.g.
dns:read, rgw_users:*). At least one scope is required. - Click Create token.
- Copy the token value from the dialog — it is shown only once and cannot be retrieved after you close the dialog.
Alternatively, create a token via the API (requires an active JWT/cookie session):
curl -X POST https://api.bnerd.cloud/tokens \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{"token": {"name": "ci-deploy", "scopes": ["dns:read", "projects:read"]}}'
# 201 → data.token contains the raw value (shown once only)
List existing tokens¶
Returns metadata for all tokens (names, last-4 chars, scopes, expiry). The raw token values are never returned.
Revoking a token¶
In the dashboard, go to Account → Settings → API Tokens, find the token by name and last-4 characters, and click Revoke.
Via the API:
curl -X DELETE https://api.bnerd.cloud/tokens/$TOKEN_ID \
-H "Authorization: Bearer $JWT"
# 204 No Content
Scoping¶
Static tokens are scoped to an organization. Requests made with a static token operate as if the token owner's permissions apply within that organization. Fine-grained write operations (e.g. quota and lock changes on RGW users) still require admin-level permissions on the organization — a static token issued for a member-role account cannot escalate privileges.
Which token to use¶
| Situation | Auth method | CSRF required |
|---|---|---|
| Dashboard (browser) | Session cookie (automatic) | Yes — handled by dashboard |
b'nerd CLI (bnerd) | Static API token (stored via bnerd login) | No |
| CI/CD pipelines | Static API token | No |
| Scripted automation | Static API token | No |
Bearer-authenticated requests (CLI, provider, static tokens) are never subject to CSRF checks. Only cookie-authenticated mutations require X-CSRF-Token.
For the full technical contract — token claims, CSRF rules, error codes — see API: Authentication & Tokens.
Multi-organization accounts¶
An account can belong to more than one organization. If you have been invited into a second (or third) organization and accepted the invitation, you need to tell the API which organization each request targets:
# List projects in a specific organization
curl "https://api.bnerd.cloud/projects?organization_id=$ORG_ID" \
-H "Authorization: Bearer $TOKEN"
The ?organization_id query parameter is mandatory for any account that holds more than one membership. Requests without it are rejected with 403 Forbidden — the server never silently picks one for you. Accounts with a single membership can omit the parameter.
Switching active organization¶
Use GET /accounts/me to see all your memberships and determine the current context:
The response includes memberships[] (all organizations you belong to) and current_organization_id (the org resolved for this request). Switch by supplying a different ?organization_id on the next request.
The dashboard org-switcher and bnerd org switch (CLI) persist your active organization choice client-side and inject the parameter automatically on every request.
Joining an additional organization¶
An organization admin sends an invitation to your email address. The link in the mail carries the invitation token ($INVITE_TOKEN below). Inspect the invitation, then log in with the account it is addressed to and accept it ($JWT is your login token):
# 1. Inspect the invitation (public, no login)
curl "https://api.bnerd.cloud/invitations/details?token=$INVITE_TOKEN"
# 2. Accept — your account gains a new membership immediately
curl -X PATCH "https://api.bnerd.cloud/invite/$INVITE_TOKEN/accept" \
-H "Authorization: Bearer $JWT"
Declining works the same way with PATCH /invite/{token}/decline. Accept and decline return 401 without a login and 404 for an unknown, expired, accepted or declined invitation. Accept and decline return 403 in two cases, as an error envelope (errors[0].code):
forbidden: the invitation is addressed to another account.account_unverified: your email address is not verified yet. Verify it, then accept again.
If you signed up from the invitation link itself, you do not need to accept: you join the organization when your email address is verified. That holds only for the link you signed up with; after the invitation was re-sent, use the new link.
After accepting, GET /accounts/me returns the new membership in memberships[].
If you have no account yet, sign up with the link from the invitation mail — see Creating an organization for invitation_pending.
Unauthenticated endpoints¶
A few endpoints are public (no token required): the invitation details lookup, sign-up and login, the published legal documents, and alert acknowledgement links from email. The full list is in Unauthenticated endpoints. The other endpoints need a valid token and return 401 Unauthorized without one.