REST API
Dopbase exposes the versioned REST API used by the CLI and embedded Admin UI. Fresh startup enters automatic setup; complete it before using authenticated endpoints. Enable API documentation with dopbase server start --docs. The generated OpenAPI 3 specification is then available from the running server:
OpenAPI JSON: http://localhost:8840/api/v1/openapi.json
Swagger UI: http://localhost:8840/api/docsUse the documentation on your running server to explore the API available in your installed version.
Resource areas
Consult Swagger for request bodies, parameters, authentication schemes, and the responses supported by each operation.
Response format
A successful request uses a typed envelope:
{
"success": true,
"message": "PROJECT_CREATED",
"data": {
"id": "prj_01...",
"name": "payment-service"
}
}Errors map stable codes to safe messages:
{
"success": false,
"error": {
"EMAIL_INVALID": "Please use proper email"
}
}Validation may report more than one code in the error object. Clients must branch on the code rather than the English message or object ordering. Request correlation is returned in the X-Request-Id header. Errors never include request bodies, plaintext secrets, tokens, key material, SQL, or filesystem details.
Optional features
GET /api/v1/auth/session returns features, the features the server has on: sso, rbac, rbac.roles, secret_references and secret_editor. Its capabilities leave out any capability a disabled feature takes away, for root too: sso.manage without sso, groups.manage, grants.manage and roles.manage without rbac, and roles.manage without rbac.roles.
A request for a feature that's off is refused with 403 FEATURE_DISABLED. The message names the setting that turns it on.
secret_references refuses nothing. While it is on, the runtime routes fill in ${KEY} references, and so do POST /api/v1/environments/{id}/secrets/export?references=resolve and POST /api/v1/environments/{id}/secrets/{key}/reveal?references=resolve. A filled-in reveal is logged as secret.revealed with "references": "resolve". Without references=resolve, export and reveal return values as stored, and so do the version routes. See secret references.
secret_editor refuses nothing either. It tells the web app to offer the Editor view on an environment's secrets. The import and layout routes that view uses also serve the CLI, so they answer the same with it on or off.
Import authentication
POST /api/v1/environments/{id}/secrets/import requires a human project account. Browser sessions must include X-Dopbase-CSRF. When the server sets reauth_interval_minutes, they must also have confirmed their password within that many minutes. This applies to merge and replace, for both previews (dryRun: true) and actual imports.
An expired password confirmation returns 403 with RECENT_AUTHENTICATION_REQUIRED before any stored values are compared. Confirm the password through /api/v1/auth/reauthenticate, then retry the same request. Existing CLI authentication behavior is unchanged.
Successful previews record secret.import_previewed with the actor, project/environment, mode, and submitted entry count. They do not change secrets, versions, or layout. If the audit event cannot be saved, the server returns an error without the comparison results.
Creating a protected environment
POST /api/v1/projects/{ref}/environments with { "name": "production", "protected": true } creates the environment already protected, in one request, so grants on the whole project below project manager never reach it. Without protected, or with false, it is created unprotected. The environment.created audit event records protected.
Copying keys between environments
POST /api/v1/environments/{id}/copy-secrets with { "from": "env_918201", "keys": ["API_KEY", "DATABASE_URL"], "values": false } creates those keys in this environment from another one in the same project, in one transaction. Without values, or with false, each key starts with an empty value and Names only on the source is enough. With values: true each key gets the source's current value, copied on the server and never returned, which needs Read on the source. Writing needs Write here. Keys this environment already has are skipped, never overwritten. The response lists copiedKeys and skippedKeys.
It is refused, without writing anything, with:
Environment responses include secretCount, the number of secrets the environment holds.
Creating a key only when it is missing
PUT /api/v1/environments/{id}/secrets/{key} with { "value": "...", "createOnly": true } only creates the key. If the key exists by the time the write runs, the request is refused with 409SECRET_VERSION_CONFLICT and nothing changes, so a value someone else just set is kept. The Compare tab sends it when you type a value for a missing key. Without createOnly, PUT creates the key or stores a new version as before.
File secrets
A secret's value is always text. A value can carry a file tag that says which file it came from.
PUT /api/v1/environments/{id}/secrets/{key} takes an optional file: { "name": "release.jks", "encoding": "base64" }. encoding is text when the value is the file's text, or base64 when the value is the file's bytes in standard base64. The server keeps only the file's own name, in lower case with anything but letters, digits, . and _ turned into -, works out its size, and answers 422 SECRET_FILE_INVALID for an empty file, a name it cannot use, or base64 that does not decode. A PUT without file stores a plain value and removes the tag from a secret that had one.
Wherever a secret or a version is returned, a file adds file: { "name", "encoding", "size" }: the list, a single secret, both reveal routes, the versions list and the answer to PUT. size is the file's size in bytes before any base64. A plain secret has no file field. Copying a secret to another environment and rolling back to a file version carry the tag along.
The export answer adds files, a map from key to file tag for the entries that are files. POST …/secrets/export?files=exclude leaves file secrets out of entries, without decrypting them, so the rest can be edited as .env text.
The import request takes two optional fields:
The import answer adds fileKeys: the updated or deleted keys that held a file before the import. Both runtime routes add the same files map as the export, so a client can tell which values to decode.
Older clients can ignore every added field.
Secret versions
GET /api/v1/environments/{id}/secrets/{key}/versions lists a secret's versions newest first, with the same access as listing secrets. Each item has version, changeType (created, updated, imported, rolled_back, or legacy), sourceVersion for rollbacks, actorType, actorLabel, createdAt, current, and restorable, which is false once retention has removed the value. Pass limit (1 to 200, default 50) and before to page; the response carries nextBefore for the next page and retainedVersions, the server's retention count. Items never contain values.
POST /api/v1/environments/{id}/secrets/{key}/versions/{version}/reveal returns one version's value, and POST /api/v1/environments/{id}/secrets/{key}/rollback with { "version": 3, "expectedVersion": 5 } saves the value of v3 as a new version. Both need a project manager, the CSRF header and recent password confirmation for browser sessions, and are audited. Runner tokens and AI agent tokens are refused with 403.
A rollback answers with the new version, sourceVersion, and previousVersion. It is refused, without writing anything, with:
Secret editor snapshots
POST /api/v1/environments/{id}/secrets/export returns entries, revision, and nullable envLayout from one snapshot. Export retains its existing human access requirements and audit event. Layout contains comments and empty key slots; comments are unencrypted metadata.
Pass expectedRevision to the import endpoint for both the dry run and apply. A stale revision returns 409 with IMPORT_PREVIEW_STALE, including during a dry run. Replace apply requires a revision. Invalid layout slots, including slots containing values, return 422 with ENV_LAYOUT_INVALID.
Existing export clients can ignore the added fields. env edit requires a server that supplies the snapshot revision and fails safely when it is missing.
Audit chain verification
GET /api/v1/audit-events/verify walks the audit log in sequence order, recomputes every record's hash from its stored contents, and reports the first inconsistency. It needs audit.verify, which Admin and Auditor hold, from a session or an audit token; runner tokens and other personal tokens are refused with 403.
The response carries ok, the number of records checked before the first break, headSeq and headHash for external anchoring, legacy for records written before the chain existed (not a failure), unsequenced for records inserted outside the chain after it existed (a failure), prunedSeq when retention removed records (the chain continues after it), and broken with the sequence number, record ID, and reason when something does not match.
Pass anchorSeq and anchorHash, saved from an earlier headSeq and headHash, to compare the log with that outside copy. The response then carries anchor with seq and a status of matched, mismatch, missing, or pruned; mismatch and missing set ok to false. Passing only one of the two returns 400.
The chain columns are additive: the audit list keeps its shape and filters, and every item now carries ipAddress, seq, prevHash, and recordHash, so an exported record can serve as an anchor. Recomputing hashes from an export is not supported yet: the list returns metadata re-serialized, so it does not match the stored bytes the hash covers. Verification reads no secret values. dopbase audit verify runs the same check from the terminal, and dopbase audit export streams the filtered list as JSON lines.
People, groups, and agent tokens
User responses include status (active or disabled), lastSignInAt (the last interactive sign-in, or null), and groups, each with id and name. countsTowardLimit is true for the accounts the user limit counts, which are active people other than root. AI agents never count. GET /api/v1/users/{id} returns one account. GET /api/v1/users/identities returns only each account's id and email, ordered by email, for screens that just need to name people. It needs the same users.view capability and browser session as the full list.
POST /api/v1/users/{id}/disable signs the account out everywhere and stops its tokens without deleting anything. POST /api/v1/users/{id}/enable lets it sign in again, and its unexpired tokens work again. Both answer with the account, need users.manage, the CSRF header, and recent password confirmation, and change nothing when the account already has that status. They are audited as user.disabled and user.enabled. They are refused with:
GET /api/v1/groups lists each group with members (id and email) and grants. Groups carry createdBy, and each member in GET /api/v1/groups/{id} carries addedAt and addedBy. createdBy and addedBy are { "id", "email" }, or null when that account is gone.
POST /api/v1/users/{id}/tokens takes "replaceExisting": true for an AI agent: the new token is created and the agent's other live tokens are revoked in the same step, so it holds one token at a time. For anyone else's agent this also needs tokens.revoke_others. On an account that isn't an AI agent it is refused with 422 TOKEN_REPLACE_INVALID.
Authentication
- Browser sessions use an HttpOnly, SameSite Strict cookie and require the server-issued
X-Dopbase-CSRFheader for mutations. Sign-in returns the token, andGET /api/v1/auth/sessionreturnscsrfTokentoo, so a tab opened later can get one. That token is derived from the session's own, and both stay valid. - CLI sessions, runner tokens, and personal tokens use
Authorization: Bearer <token>. POST /api/v1/auth/loginanswers a wrong email or password with401AUTHENTICATION_INVALID, worded the same either way. When 1 to 3 tries are left before a pause, the message says so, for exampleEmail or password is wrong. 2 more tries, then a 5-minute pause.During the pause it answers429RATE_LIMITEDwith how many minutes to wait, and aRetry-Afterheader with the same wait in seconds. Tries are counted per email and client address, so the pause holds for the address that made them. See Failed attempt limits.- A personal token acts for its account within its own scope and level. It never holds the account's capabilities, so it can't manage people, grants, projects, or tokens.
- Projects, environments, and secrets the caller can't reach answer
404; those it can see but not change answer403. Project and environment responses include the caller'slevel. - A runner token can retrieve runtime secrets and export the snapshot of its assigned environment. It cannot list secret metadata, mutate secrets, reveal individual values, or access another environment. Export retains the existing
entries,revision, andenvLayoutresponse fields and records the runner token ID in the audit log. Browser exports still require recent password authentication and a valid CSRF header. GET /api/v1/environments/{id}/secrets/runtimeasks a browser session for the same recent password confirmation as reveal and export, and answers403RECENT_AUTHENTICATION_REQUIREDwithout it. CLI sessions, personal tokens and runner tokens are not asked, sodopbase runworks as before.
Runner exports require server support for runner access to the export endpoint. Update the server before or alongside the CLI; older servers reject the request.
The OpenAPI document declares the cookieAuth, bearerAuth, and csrfHeader security schemes.
Account and agent-token administration requires a root/admin browser session; CLI bearer sessions cannot administer accounts. AI bearer tokens may only read metadata and instance status. See identity and tokens for the complete role matrix.
Runtime secrets for runner tokens
GET /api/v1/runtime/secrets returns the secrets of the runner token's environment. The token decides the environment, so an SDK or script needs only the server URL and the token:
curl -H "Authorization: Bearer $DOPBASE_TOKEN" \
https://dopbase.example.com/api/v1/runtime/secretsdata holds projectId, project, environment, environmentId, revision, and entries. The revision changes when a secret or the .env layout changes, and it matches the revision from export. A session or personal token gets 403 RUNNER_TOKEN_REQUIRED.
Send the ETag header back as If-None-Match to check for changes: while nothing has changed, the server answers 304 Not Modified with an empty body. The ETag follows the revision and also changes when the project or environment is renamed, so poll with it rather than with revision. A 304 reads no ciphertext, decrypts nothing and writes no audit event, so a client can poll every few seconds. A 200 writes one secret.runtime_accessed event with the revision.
Add ?reference= with an environment ID or PROJECT_REF/ENVIRONMENT_NAME to make sure the token is for that environment. Any other reference gets 403TOKEN_SCOPE_INVALID, and the server reads no value.
A runner token's lastUsedAt is updated at most once a minute.
Instance status and health checks
GET /api/v1/status returns the version, uptime, platform (os and arch), and resource counts to any signed-in account or personal token. A count is null when its query failed, so one broken query never fails the whole response.
Accounts holding instance.view also get:
checks: every health check, most severe first. Each has anidsuch asbackup.age, astatusofcrit,warn,tip, orok, atitle, adetail, an optional shortvalue, afixPath(an Admin UI path or a documentation URL), andlastRunAt. A check that fails to run comes back as awarntitled "Couldn't check ...", and the server log has the error. The public URL and HTTPS checks pass while the public URL points at this machine. On a network address, HTTP iscritand a missing public URL iswarn.summary: how many checks are critical, warnings, tips, and passed.health: the readings behind the Database, Master key, Disk, and Audit log cards.masterKey.filecompares the key file on disk with the key the server loaded at startup (matches,changed,missing, orunreadable).disk.usedBytesis the size of the data directory, plus the database when it lives elsewhere.diskisnullwhen the data directory can't be read.activity: the last 24 hours in hourly buckets: secret reads (with how many runner tokens, people and AI agents read), failed sign-ins, requests refused by the sign-in rate limits, and live browser and CLI sessions. The rate-limit count lives in memory and starts again when the server restarts.
With the opt-in update_check setting on (DOPBASE_UPDATE_CHECK=true), the server asks GitHub for the latest release and adds a version.latest check and a latestRelease object (version, updateAvailable, url, checkedAt). Reading the status starts the lookup when none has run in the last day, without waiting for it, so the answer shows up on a later read. A failed lookup keeps the last answer and is retried an hour later. A server nobody reads the status of never calls GitHub.
The emails and addresses behind failed sign-ins need audit.read. Names of expiring tokens need tokens.revoke_others. fixPath is always returned; the Admin UI hides fixes the viewer can't use.
Walking the audit hash chain reads every record, so it runs every 10 minutes in the background and the response carries the last result. POST /api/v1/status/checks/run walks it again right away and returns the same body. It needs instance.view and, from the Admin UI, the CSRF header. It answers 429 RATE_LIMITED when checks ran less than 10 seconds before.
Browser CLI login
The CLI signs in through the Admin UI with a device flow:
POST /api/v1/auth/cli/devicestarts a request and returns a secretdeviceCode, auserCodesuch asWDJB-MJHT, the approval link, the expiry, and the pollinginterval. It needs no authentication.POST /api/v1/auth/cli/tokenpolls with thedeviceCode. The status ispending,slowDownwhen polled faster than the interval, orapprovedwith the new CLI session. A denied request fails withDEVICE_ACCESS_DENIED, an expired one withDEVICE_CODE_EXPIRED, and a used or cancelled one withDEVICE_CODE_INVALID.POST /api/v1/auth/cli/cancelwithdraws a waiting request.POST /api/v1/auth/cli/inspect,/approve, and/denytake theuserCodefrom a browser session with the CSRF header. Approving also needs a recent confirmation.
GET /api/v1/auth/methods is public and reports whether the server accepts passwords, shows the password form, and offers single sign-on.
POST /api/v1/auth/cli/device takes an optional client, such as dopbase 0.2.0 on macOS, next to hostname. The server keeps printable text only, up to 80 characters. POST /api/v1/auth/cli/inspect returns it as client (or null), with sessionDays, the most days the approved CLI session lasts, and reauthIntervalMinutes, how long a confirmation lasts (0 when the server doesn't ask for one).
Single sign-on
Root manages the provider under /api/v1/sso/provider (GET, PUT, DELETE) and turns it on, requires it, or hides the password form with PUT on /enabled, /required, and /password-form. All of these need a root browser session; changes also need the CSRF header and a recent confirmation. GET also returns presets, the providers the settings page lists, and PUT refuses a preset that is not one of them with SSO_PRESET_INVALID.
The browser signs in with GET /api/v1/auth/sso/start, which redirects to the provider. The provider returns to GET /api/v1/auth/sso/callback, which sends the browser to the Admin UI with a one-time code in the URL fragment, and POST /api/v1/auth/sso/exchange trades that code for a session. Signed-in users link with POST /api/v1/auth/sso/link, read or remove their identity with GET or DELETE /api/v1/auth/sso/identity, and confirm sensitive actions with POST /api/v1/auth/sso/reauth. Administrators remove another user's link with DELETE /api/v1/users/{id}/sso.
Compatibility
GET /api/v1/health identifies the product, binary version, and API version. dopbase client connect validates this response before changing local client configuration.
Every API response also carries X-Dopbase-Version with the server's version. The CLI sends User-Agent: dopbase/<version> and warns once per command when the server is a minor or major release ahead. Set DOPBASE_VERSION_WARNING=false to hide the warning.
A request whose User-Agent names a Dopbase CLI older than 0.2.0, such as dopbase/0.1.9, gets 400 CLI_UPGRADE_REQUIRED with the command to update, before authentication runs. The check reads only a User-Agent of the form dopbase/X.Y.Z, so browsers, scripts, and 0.1.x CLIs (which send no User-Agent) are never refused, and GET /api/v1/health answers every client. Anyone can set a User-Agent, so this is not an access control.
Version 0.2.3 does not promise compatibility with future major API versions or implement idempotency keys.