Skip to main content

API Reference

The interactive API is rooted at /api. Most endpoints accept either a user JWT or an API key; Agent protocol endpoints use a node-specific token. Public probes and one-time installers are listed separately.

Authentication

User JWT

Obtain a JWT through POST /api/auth/login and send it as a Bearer token:

curl -H "Authorization: Bearer $BACKUPX_TOKEN" \
https://backup.example.com/api/backup/tasks

The login flow may require OTP, TOTP, recovery code, a trusted-device token, or WebAuthn depending on account and system settings.

API key

An administrator creates API keys in the console or through POST /api/api-keys. The plaintext bax_... value is returned only once.

curl -H "X-Api-Key: $BACKUPX_API_KEY" \
https://backup.example.com/api/dashboard/stats

Authorization: Bearer bax_... is also accepted. API keys carry an admin, operator, or viewer role and can be disabled or given an expiry.

Agent token

Agent protocol handlers authenticate the node token supplied in X-Agent-Token. This token is not a user credential and must not be used with the interactive resource API.

Access labels

The tables use these labels:

LabelRequired access
PublicNo JWT or API key; an install route still requires its one-time token
AuthAny authenticated viewer, operator, or admin
Operatoroperator or admin
Adminadmin only
AgentValid node-specific Agent token

Viewers can use read endpoints except node filesystem browsing. Operators can run and mutate backup resources. Administrators additionally manage users, API keys, settings, nodes, install tokens, and node-token rotation. A rejected role returns HTTP 403.

Authentication and account security

MethodEndpointAccessDescription
GET/api/auth/setup/statusPublicCheck whether first-admin setup is required
POST/api/auth/setupPublicCreate the first administrator when no user exists
POST/api/auth/loginPublicComplete password or MFA login and obtain a JWT
POST/api/auth/otp/sendPublicSend a configured login OTP
POST/api/auth/webauthn/login/optionsPublicBegin passkey login
POST/api/auth/logoutAuthAcknowledge logout; the client must discard its stateless JWT
GET/api/auth/profileAuthRead the current account
PUT/api/auth/passwordAuthChange the current account password
POST/api/auth/2fa/setupAuthPrepare TOTP enrollment
POST/api/auth/2fa/enableAuthEnable TOTP after verification
POST/api/auth/2fa/recovery-codesAuthRegenerate recovery codes
DELETE/api/auth/2faAuthDisable TOTP
PUT/api/auth/otp/configAuthUpdate OTP login configuration
POST/api/auth/webauthn/register/optionsAuthBegin passkey registration
POST/api/auth/webauthn/register/finishAuthFinish passkey registration
GET/api/auth/webauthn/credentialsAuthList passkeys
DELETE/api/auth/webauthn/credentials/:idAuthDelete a passkey
GET/api/auth/trusted-devicesAuthList trusted devices
DELETE/api/auth/trusted-devices/:idAuthRevoke a trusted device

Use an interactive JWT, not an automation API key, for account-security endpoints.

System and storage targets

MethodEndpointAccessDescription
GET/api/system/infoAuthVersion and system information
GET/api/system/update-checkAuthCheck available releases
GET/api/storage-targetsAuthList storage targets
POST/api/storage-targetsOperatorCreate a target
POST/api/storage-targets/testOperatorTest an unsaved configuration
GET/api/storage-targets/rclone/backendsAuthList available rclone backends
POST/api/storage-targets/google-drive/auth-urlOperatorStart Google Drive authorization
POST/api/storage-targets/google-drive/completeOperatorComplete Google Drive authorization
GET/api/storage-targets/google-drive/callbackAuthHandle the OAuth callback
GET/api/storage-targets/:idAuthRead a target
PUT/api/storage-targets/:idOperatorUpdate a target
DELETE/api/storage-targets/:idOperatorDelete a target
PUT/api/storage-targets/:id/starOperatorToggle favorite state
POST/api/storage-targets/:id/testOperatorTest a saved target
GET/api/storage-targets/:id/usageAuthRead recorded usage
GET/api/storage-targets/:id/google-drive/profileAuthRead the connected Google Drive profile

Backup tasks

MethodEndpointAccessDescription
GET/api/backup/tasksAuthList tasks
GET/api/backup/tasks/tagsAuthList task tags
GET/api/backup/tasks/exportAuthDownload all task definitions, or select them with ?ids=1,2
POST/api/backup/tasks/importOperatorImport task definitions, up to 1 MiB
POST/api/backup/tasks/batch/toggleOperatorEnable or disable tasks in bulk
POST/api/backup/tasks/batch/deleteOperatorDelete tasks in bulk
POST/api/backup/tasks/batch/runOperatorRun tasks in bulk
GET/api/backup/tasks/:idAuthRead a task
POST/api/backup/tasksOperatorCreate a task
PUT/api/backup/tasks/:idOperatorUpdate a task
DELETE/api/backup/tasks/:idOperatorDelete a task
PUT/api/backup/tasks/:id/toggleOperatorEnable or disable a task
POST/api/backup/tasks/:id/runOperatorTrigger a backup
POST/api/backup/tasks/:id/verifyOperatorTrigger verification from a task

Task export intentionally excludes database passwords and storage credentials. It is useful for migration and review, not a complete control-plane backup.

Backup and restore records

MethodEndpointAccessDescription
GET/api/backup/recordsAuthList and filter backup records
POST/api/backup/records/batch-deleteOperatorDelete records in bulk
GET/api/backup/records/:idAuthRead a backup record
GET/api/backup/records/:id/logs/streamAuthStream logs with server-sent events
GET/api/backup/records/:id/downloadAuthDownload an artifact
GET/api/backup/records/:id/contentsAuthBrowse artifact contents where supported
POST/api/backup/records/:id/restoreOperatorStart a restore
POST/api/backup/records/:id/replicateOperatorReplicate an existing artifact
POST/api/backup/records/:id/verifyOperatorVerify an existing artifact
PUT/api/backup/records/:id/lockOperatorSet retention lock state
DELETE/api/backup/records/:idOperatorDelete a record and its managed artifact
GET/api/restore/recordsAuthList restore records
GET/api/restore/records/:idAuthRead a restore record
GET/api/restore/records/:id/logs/streamAuthStream restore logs
GET/api/replication/recordsAuthList replication records
GET/api/replication/records/:idAuthRead a replication record
GET/api/verify/recordsAuthList verification records
GET/api/verify/records/:idAuthRead a verification record
GET/api/verify/records/:id/logs/streamAuthStream verification logs

Templates, reports, and dashboard

MethodEndpointAccessDescription
GET/api/task-templatesAuthList task templates
GET/api/task-templates/:idAuthRead a task template
POST/api/task-templatesOperatorCreate a template
PUT/api/task-templates/:idOperatorUpdate a template
DELETE/api/task-templates/:idOperatorDelete a template
POST/api/task-templates/:id/applyOperatorCreate tasks from a template
GET/api/reports/complianceAuthRead compliance evidence
GET/api/reports/compliance/exportAuthExport compliance evidence as CSV
GET/api/dashboard/statsAuthSummary statistics
GET/api/dashboard/timelineAuthRecent activity
GET/api/dashboard/slaAuthRPO and SLA status
GET/api/dashboard/clusterAuthCluster summary
GET/api/dashboard/breakdownAuthTask and record breakdown
GET/api/dashboard/node-performanceAuthPer-node performance

Notifications, settings, and administration

MethodEndpointAccessDescription
GET/api/notificationsAuthList notification channels
GET/api/notifications/:idAuthRead a channel
POST/api/notificationsOperatorCreate a channel
PUT/api/notifications/:idOperatorUpdate a channel
DELETE/api/notifications/:idOperatorDelete a channel
POST/api/notifications/testOperatorTest an unsaved configuration
POST/api/notifications/:id/testOperatorTest a saved channel
GET/api/settingsAuthRead system settings
PUT/api/settingsAdminUpdate system settings
GET/api/usersAdminList users
POST/api/usersAdminCreate a user
PUT/api/users/:idAdminUpdate a user
POST/api/users/:id/2fa/resetAdminReset a user's second factor
DELETE/api/users/:idAdminDelete a user
GET/api/api-keysAdminList API keys without plaintext values
POST/api/api-keysAdminCreate an API key and return its plaintext once
PUT/api/api-keys/:id/toggleAdminEnable or disable an API key
DELETE/api/api-keys/:idAdminRevoke an API key

Audit, events, search, and discovery

MethodEndpointAccessDescription
GET/api/audit-logsAuthList and filter audit records
GET/api/audit-logs/exportAuthExport audit records
GET/api/events/streamAuthStream real-time application events with SSE
GET/api/searchAuthSearch supported resources
POST/api/database/discoverAuthDiscover databases from supplied connection details

Nodes

MethodEndpointAccessDescription
GET/api/nodesAuthList nodes
GET/api/nodes/:idAuthRead a node
GET/api/nodes/:id/fs/listOperatorBrowse the selected node filesystem
POST/api/nodesAdminCreate a node
POST/api/nodes/batchAdminCreate up to 50 nodes
PUT/api/nodes/:idAdminUpdate a node
DELETE/api/nodes/:idAdminDelete an unreferenced node
POST/api/nodes/:id/install-tokensAdminCreate a one-time installer
GET/api/nodes/:id/install-script-previewAdminPreview generated install material
POST/api/nodes/:id/rotate-tokenAdminRotate the long-lived node token

Agent protocol

These routes are for the backupx agent process and authenticate inside the handler with the node token.

MethodEndpointAccessDescription
POST/api/agent/heartbeatAgentReport liveness and node state
POST/api/agent/commands/pollAgentClaim a pending command
POST/api/agent/commands/:id/resultAgentReport a command result
GET/api/agent/tasks/:idAgentFetch a runnable task specification
POST/api/agent/records/:idAgentAppend logs or update backup state
PUT/api/agent/records/:id/artifacts/:targetIdAgentStream a relayed artifact to the Master
GET/api/agent/restores/:id/specAgentFetch restore instructions
GET/api/agent/restores/:id/artifactAgentStream a restore artifact
POST/api/agent/restores/:idAgentUpdate restore state
GET/api/v1/agent/selfAgentValidate node identity during installation

Public operational and install routes

MethodEndpointAccessDescription
GET/healthPublicLiveness
GET/api/healthPublicAPI-prefixed liveness alias
GET/readyPublicSQLite readiness
GET/api/readyPublicAPI-prefixed readiness alias
GET/metricsPublicPrometheus metrics
GET/install/:tokenPublicConsume a one-time Agent installer token
GET/api/install/:tokenPublicAPI-prefixed installer route
GET/install/:token/compose.ymlPublicRender a Docker Agent Compose file
GET/api/install/:token/compose.ymlPublicAPI-prefixed Docker Compose route

Restrict probes and metrics to monitoring networks. Install tokens are single-use, time-limited secrets and must not be written to public logs.

Response formats

Most JSON successes use:

{
"code": "OK",
"message": "success",
"data": {}
}

Errors use an HTTP 4xx or 5xx status plus a stable application code:

{
"code": "BACKUP_TASK_NOT_FOUND",
"message": "备份任务不存在"
}

Clients should branch on the HTTP status and code, not the localized message.

Artifact downloads, task JSON export, audit or compliance exports, installer responses, and /metrics return their native content types instead of the JSON envelope. Log and event streams use text/event-stream; reverse proxies must keep response buffering disabled.