API
Most of what the dashboard does goes through an API you can use too. Agents are paired, renamed, unpaired and rebuilt there but not disabled; users, their sessions, forward-auth access and DNS provider credentials are all managed through it.
GraphQL
Section titled “GraphQL”/api/graphql serves every resource: proxy hosts, L4 hosts, certificates, access lists, users,
groups, agents, settings, the audit log, and a Caddy apply.
curl -sX POST https://cpm.example.com/api/graphql \ -H "Authorization: Bearer $CPM_TOKEN" \ -H 'content-type: application/json' \ -d '{"query":"{ proxyHosts { id name domains enabled } }"}'The schema is introspectable by any authenticated GraphQL client, so your tooling can discover it rather than being told about it.
What is a field, and what is JSON
Section titled “What is a field, and what is JSON”Stable, queryable things are fields: ids, names, domains, timestamps, foreign keys. Configuration
that the model layer owns (load balancing, WAF and geoblock overrides, location rules, mTLS)
travels as a JSON scalar: readable through config on a host, and passed back as input on a
mutation.
That split is deliberate. Those settings change with the product and are already validated by code that exists; restating them in the schema would be thousands of lines that can drift out of step with the validator while looking authoritative.
Changing many hosts
Section titled “Changing many hosts”bulkProxyHosts and bulkL4ProxyHosts take { action, ids } and return how many hosts changed.
Proxy hosts accept enable, disable, delete, maintenanceOn, maintenanceOff,
setCertificate (with certificateId, null for automatic), setAccessList (with
accessListId, null for none) and addTag (with tag); L4 hosts enable, disable, delete
and addTag. Up to 500 ids per call.
mutation { bulkProxyHosts(input: { action: "disable", ids: [4, 7, 9] })}A batch is all or nothing: an unknown id, or a change one host cannot take, fails the call and
writes nothing. Each host is audited on its own, and Caddy is applied once, or not at all for
addTag. The REST equivalents are POST /api/v1/proxy-hosts/bulk and
POST /api/v1/l4-proxy-hosts/bulk.
Both host types carry tags as a field, and take them as tags in a create or update input,
where they are normalised the way the editor stores them.
Previewing a change
Section titled “Previewing a change”previewProxyHost and previewL4ProxyHost take the input createProxyHost or updateProxyHost
would (no id for a create) and run every check the save runs, then answer what the save would
do without storing, auditing or applying anything: each changed field with its before and after
(nested settings as one line per changed path, secret-looking values as [masked]), the agents
that would be sent a new config, whether the host is pinned, the names Caddy would request a
certificate for, and warnings as codes with values, such as domainInUse or
protectionRemoved. revert names fields to leave as stored, the way the editor’s Undo does.
mutation { previewProxyHost(id: 4, input: { domains: ["app.example.com", "www.example.com"] }) { changes { field before after } impact { reload agents { name connected } certificates warnings } }}A refusal is the same error the save would return. The REST routes beside the host routes do the
same: POST /api/v1/proxy-hosts/preview and POST /api/v1/proxy-hosts/{id}/preview, and the
l4-proxy-hosts pair, with ?revert=<field> repeatable.
Audit integrity and portable configuration
Section titled “Audit integrity and portable configuration”auditLog events carry changes, each field’s before and after with secrets masked, and
verifyAuditChain recomputes the audit log’s hash chain,
answering ok, how many events it checked and the firstBroken link.
exportConfig(passphrase, sections) returns the portable configuration
as base64 of its JSON file. previewConfigImport(file, passphrase) answers what importing it
would create, update or skip, writing nothing; applyConfigImport takes the same arguments and
plans again before it writes. All three are admin only, audited and need a token with the full
scope; from a dashboard session, the export and the import need a sign-in from the last 10
minutes. Each preview item carries changes, its fields before and after with secrets masked,
and kept, the fields an import never changes, such as a client certificate’s revocation.
mutation { verifyAuditChain { ok checked firstBroken { reason seq eventId } }}Upstream health
Section titled “Upstream health”proxyHostUpstreamHealth(id) asks Caddy on every agent serving the host for its upstreams’ state,
as the host editor shows it. Each upstream has a merged state (healthy, failing,
unchecked, unreported or unknown), its failure count, whether it is outOfRotation, and the
same per agent; an agent that did not answer is unknown and reachable: false.
query { proxyHostUpstreamHealth(id: 4) { healthChecks agents { name reachable } upstreams { upstream state fails outOfRotation } }}There is no REST route for it: new queries and mutations are added to GraphQL only.
Agents
Section titled “Agents”mintAgentPairingCode answers the live six-letter code that pairs a new agent, minting one when
none is live; with agentId it answers a code that re-pairs that one agent only, or writes the
bundled agent’s bootstrap token and answers bootstrap: true. The code is readable in that answer
alone. renameAgent, unpairAgent and rebuildAgentCaddy do what their buttons on the Agents
page and Settings → Agent do, with the same effects: an unpaired agent stops its Caddy, and a
rebuild is refused while no agent is connected. All four need agents:write.
Analytics
Section titled “Analytics”analyticsReport(query) answers what the analytics page shows for one state:
totals against the previous period, the timeline, the chart’s groups, ten rows of each top list and
the latest requests. query takes the page’s own fields: range (or from and to), compare,
group, filters and mitigatedOnly. It is sanitised the way a hand-edited link is.
analyticsTopList returns one list at up to 100 rows, and trafficSignals the 5xx bursts,
mitigation spikes and blocked-traffic concentrations of the last 24 hours, with budgetMs capping
how long it waits.
query { analyticsReport( query: { range: "7d", filters: [{ field: "outcome", op: "not", value: "served" }] } ) { totals { requests mitigated serverErrors } topLists { dimension rows { key label requests } } } trafficSignals { available skipped signals { kind severity host ongoing } }}Saved views are analyticsViews, createAnalyticsView, updateAnalyticsView and
deleteAnalyticsView; a view’s query is the page’s address after the ?.
proxyHostTraffic(id) is one host’s last 24 hours, as its page shows them: totals, half-hour
buckets of served and 5xx responses, top paths and status codes. It is null with analytics off.
Needs attention
Section titled “Needs attention”attention is the overview’s Needs attention list, worst first; proxyHostId
narrows it to one host. Each item has an English title and detail, and the code and values
the dashboard renders them from in the reader’s language. skipped names the checks that ran out
of their four seconds, whose items are missing.
query { attention { items { severity title detail href } skipped truncated } setupChecklist { hidden steps { step detected markedDone } }}setSetupStepDone(step, done) and setSetupChecklistHidden(hidden) change the checklist.
Security
Section titled “Security”securityReport is the security events page for the same query input as
analyticsReport, plus a page for its WAF event list. Each event carries a key, which
wafEvent takes to answer the event in full: the rules it matched with their points, the score
against the threshold, the narrowest exclusion for it and the request as a curl command.
mutation { createWafExclusion(input: { ruleId: 942100, proxyHostId: 3, path: "/upload", target: "ARGS:content", reason: "Rich text" }) { id path } createBlockedSource(input: { kind: "cidr", value: "203.0.113.0/24", expiresAt: "2026-12-01T00:00:00Z" }) { id }}wafExclusions, updateWafExclusion and deleteWafExclusion manage exclusions; a refused one
answers with Coraza’s reason. reviewWafEvent(key, verdict) marks an event intended or
false_positive, and null clears it. blockedSources and deleteBlockedSource manage the
deny list.
wafPresets, createWafPreset, updateWafPreset and deleteWafPreset manage the WAF presets
hosts select; a preset is compiled by Coraza on an agent before it is stored, and one still
selected cannot be deleted. crsPlugins lists the installed CRS plugins and crsPluginRegistry
what the configured registries offer, with the registry settings. createCrsPlugin(input: { name, registry? }) installs one, updateCrsPlugin(id, input: { config }) replaces its -config file
(null runs the upstream one again), updateCrsPluginFromRegistry(id) moves it to the latest
release and deleteCrsPlugin uninstalls it. checkCrsPluginRegistry re-reads every registry now,
and setCrsPluginRegistrySettings takes registries, refreshIntervalHours and a write-only
githubToken.
mutation { createWafPreset(input: { name: "Nextcloud", directives: "SecRule ARGS \"@rx x\" \"id:9700,phase:1,pass,nolog,ctl:ruleRemoveById=942100\"" }) { id } createCrsPlugin(input: { name: "wordpress-rule-exclusions" }) { id version }}Access lists
Section titled “Access lists”An AccessList carries its rules in order (each with one of cidr, hostname, country,
continent or asn, plus note and expiresAt), ipDefault, satisfy, failClosed and
denyResponse. setAccessListRules(id, rules) replaces the rules as a whole, as the REST
ip-rules route does, and updateAccessList takes denyResponse (null for the plain 403) and
failClosed. accessListStats(id) answers the hosts using a list and, with analytics on, what it
stopped and the failed sign-ins over the last 24 hours.
mutation { setAccessListRules(id: 2, rules: [ { action: "deny", cidr: "192.0.2.7" }, { action: "allow", country: "PT", note: "Offsite", expiresAt: "2026-12-31T18:00:00Z" } ]) { rules { action cidr country expiresAt } }}Global rate-limit zones and the never-limited list are the rate-limit settings group:
{ enabled, zones, allowlist }.
Sign-in providers and Caddy modules
Section titled “Sign-in providers and Caddy modules”oauthProviders lists the OIDC providers as the Settings page shows them: clientId keeps its
last four characters, hasClientSecret says whether one is stored, and callbackUrl is the
redirect URI to register at the IdP. The secret itself has no field. createOAuthProvider takes
the REST body (name, clientId, clientSecret, then issuer, the endpoint URLs, scopes,
autoLink and the group-to-role mapping); updateOAuthProvider keeps the stored secret when the
body leaves it blank, and a provider the environment configures takes enabled alone.
deleteOAuthProvider refuses that provider.
caddyModules answers which modules the running binary holds, and setCaddyModules(input: { modules, customModules }) stores the selection as PUT /api/v1/caddy/modules does: refused
while a module in use would be disabled, and otherwise the start of a rebuild on every agent that
builds its own image.
Authentication
Section titled “Authentication”Requests authenticate with a Bearer token, created from Profile → API tokens in an authenticated dashboard session. That restriction is deliberate: an existing token cannot mint replacement credentials, so a leaked one cannot extend its own life. An account holds at most ten, and each expires in 30 days, 90 days (the default), a year, on a date you pick, or never. A token stops working while its owner is overdue for two-factor setup.
A token carries its owner’s role, custom or built-in: each
field and endpoint needs a permission the role holds outright. Hosts and agents a role reaches only
through a group grant don’t count, so an operator’s token gets nothing a
user’s doesn’t: grants delegate the dashboard, not the API. Managing your own tokens is the
exception, and open to every signed-in role. A refusal answers 403 with
This account's role does not allow this request.
Scopes
Section titled “Scopes”Each token also has a scope, which can only narrow what the role allows:
| Scope | What it may do |
|---|---|
Same as my role (full) |
Everything the owner’s role can do through the API. Tokens made before scopes existed have this one |
Read only (read) |
Queries and GET requests. Every mutation is refused, the audit log check and the host previews included |
Chosen permissions (custom) |
Only the areas listed, each read or write (write includes read) |
The areas are overview, hosts (proxy and L4 hosts), accessLists, certificates (with CAs,
client certificates and mTLS roles), security (WAF, CRS plugins and blocked sources),
analytics, agents, users (users, groups and sessions), settings (settings, providers and
Caddy), audit and tokens. A permission is written area:access, such as hosts:write.
Backups (/api/v1/backup, download and restore) and the portable config (exportConfig,
previewConfigImport, applyConfigImport) need a Same as my role token. They carry every
private key and write users, groups and grants, which no single area covers.
What a request gets is the role and the scope together. A user’s token scoped to users:write
still cannot manage users, because the role cannot; an admin’s read-only token cannot delete a host,
because the scope cannot. A refused request answers 403 over REST and as a GraphQL error naming the
scope. A query or route added in a later release stays closed to a narrowed token until it is given
an area.
mutation { createApiToken(input: { name: "Monitoring", expiresAt: "2027-01-01T00:00:00Z", scope: "custom", permissions: ["hosts:read", "analytics:read"] }) { secret token { id scope permissions } }}Over REST, POST /api/v1/tokens takes the same scope and permissions beside name and
expires_at. Creating and deleting a token is in the audit log.
The REST API is deprecated
Section titled “The REST API is deprecated”/api/v1/ still works exactly as it did, with the same Bearer tokens and interactive OpenAPI 3.1.0
documentation at /api-docs. It is no longer the documented path and will be removed in a later
release.
Nothing in the field breaks in the meantime: both APIs call the same model functions, so they cannot disagree about what a write does.
Health
Section titled “Health”/api/health is public and unauthenticated; the container health check probes it. It also
answers the dashboard host reachability probe when asked with a nonce. Its
boot field is a random id that changes each time the process starts, which is how setup tells a
restart that finished between two checks from one that never happened.