2.6 REST API
Everything the web interface can do goes through the server's REST API. You can use it from scripts and monitoring tools as well. This page describes sign-in, conventions and the endpoint groups and shows a few calls with curl. The complete list of every endpoint is served by the server itself as an OpenAPI document.
Base and description
What | Where |
|---|---|
Base URL |
|
OpenAPI 3.1 (machine-readable) |
|
Readable list of all endpoints |
|
Authentication
Three ways:
Session:
POST /auth/loginwith user name and password sets the cookie__Host-pdc_sessionand returns acsrf_token. Every request exceptGET,HEADandOPTIONSmust send the token in the headerX-CSRF-Token. With TOTP, sign-in takes two steps (/auth/login, then/auth/login/totp). The session is valid forsession_hours(default 12).API token:
POST /auth/tokens(name, role, validity in days) returns a token of the formpdc_β¦once. It is sent asAuthorization: Bearer pdc_β¦; no CSRF header is needed. A token never has more rights than its owner; actions that require an interactive session (for example certificates or approvals) are refused withsession_required. With four-eyes approval, tokens never decide.OIDC:
GET /auth/oidc/startstarts sign-in through an identity provider (chapter 11 Users and Security).
Conventions
Topic | Rule |
|---|---|
Roles |
|
Lists |
|
Times | Unix seconds (UTC) |
Sizes | Bytes |
IDs | UUIDs for repositories, jobs, runs, agents; snapshot IDs are 64 hex characters, a unique prefix of at least 8 characters is enough |
Snapshot paths |
|
Errors | Non-2xx answers carry |
Important error codes: bad_request (400), unauthorized (401), forbidden and csrf (403), not_found (404), conflict (409), repository (502, storage or repository problem), internal (500), timeout (504, the agent did not answer), locked and too_many_requests (429), session_required (403), approval_required (202, a four-eyes request was created).
Endpoint groups
Group | Paths (examples) | Content |
|---|---|---|
Setup and session |
| First admin account, sign-in, password change |
Two-factor, tokens, OIDC |
| TOTP, API tokens, single sign-on |
Users |
| Accounts, roles, machine restriction |
Agents |
| Manage machines, settings, Wake-on-LAN, disks, enrollment tokens |
Repositories |
| Storage, statistics, isolation, hardening, forecast, rotated drives, quotas |
Jobs |
| Create, change and start jobs; schedules and exclude templates |
Plans and automation |
| Protection plans, system-wide rules, blackout windows |
Runs |
| Runs and logs, history, statistics, live events (Server-Sent Events) |
Snapshots |
| Browse restore points |
Restore |
| Restore, ZIP download, mounting, scan, instant recovery, recovery medium |
Deployment |
| Installation from the server, network discovery, agent packages, updates |
Monitoring |
| Dashboard, protection status, alerts, test results, retention holds |
Notifications and reports |
| Channels, rules, reports |
Security |
| Four-eyes approvals, audit log, metrics tokens |
System |
| Certificates, disaster recovery, configuration backup, API description |
The agent endpoint on port 8444 is not part of the REST API for the interface; it is described in section 2.3 Agent communication and PKI.
Example calls
Sign in and helper function
S=https://backup-pc:8443/api/v1
CSRF=$(curl -sk -c jar -H 'content-type: application/json' \
-d '{"username":"admin","password":"..."}' $S/auth/login | jq -r .csrf_token)
api() { curl -sk -b jar -H "x-csrf-token: $CSRF" -H 'content-type: application/json' "$@"; }
-k skips certificate verification because the server uses a certificate from its own CA. It is better to download the CA (/install/ca.crt on port 8444, or under Settings β Certificate) and verify with --cacert.
List agents and start a job
api $S/agents | jq '.items[] | {id, hostname}'
api -X POST $S/jobs/<job ID>/run
api $S/runs/<run ID>
Create a repository
api -X POST $S/repositories -d '{"name":"USB disk","kind":"local",
"location":"/mnt/usb/pdc","password":"a long passphrase"}'
api -X POST $S/repositories/test -d '{"kind":"local","location":"/mnt/usb/pdc"}'
POST /repositories/test checks a location before saving.
Backup job with schedule and retention
api -X POST $S/jobs -d '{"name":"Anna laptop","kind":"backup",
"agent_id":"<agent>","repository_id":"<repo>","workload":"files",
"spec":{"paths":["C:\\Users\\anna"],"exclude_templates":["windows-profiles-no-caches"]},
"schedule":{"type":"daily","time":"12:30","window":{"start":"08:00","end":"22:00"}},
"retention":{"keep_daily":7,"keep_weekly":4,"keep_monthly":12,"keep_yearly":3}}'
Token for monitoring without a session
api -X POST $S/auth/tokens -d '{"name":"zabbix","role":"readonly","expires_days":365}'
curl -sk -H 'Authorization: Bearer pdc_β¦' $S/dashboard
The token appears only in the answer of the first call. The fields of the job specifications (spec) and the options of each workload are in chapter 06 Jobs, schedule fields in chapter 07 Schedules and Plans, restore fields in chapter 09 Restore.