Skip to content
Sign inDashboard

Authentication, tokens and scopes

The dashboard is the first client of the API, and it uses no private endpoints. So anything that the dashboard does, you can do. The base URL is https://api.opdns.io. The specification is at /v1/openapi.yaml.

Method How Scopes
Session the __Host-opdns_session cookie, set when you sign in with your op account (GET /v1/auth/oidc/start in a browser, which goes to opauth.net and back) all
API token Authorization: Bearer opdns_… the scopes chosen at creation

Browsers use sessions. Scripts and integrations use tokens. The API rejects a write that a cookie authenticates if the write comes from an origin other than the dashboard (csrf_rejected).

A session lasts at most 30 days from sign-in and ends after 7 days without use. The first request more than 24 hours after the session token was issued gets a new token in Set-Cookie. The previous token keeps working for a few seconds, so requests already in flight do not fail. After failed password sign-ins, the API slows down the next attempts. The delay starts at 100 ms and doubles up to 5 s, per address and per account. Passkey sign-in is not slowed down.

In the dashboard, go to Account → API tokens → New token. Name the token and tick the scopes that it needs. Each scope says what it allows. You can also choose an expiry date. The token stops working at the end of that day. The dashboard shows the secret one time only. Store it like a password. Only a signed-in session can create or revoke tokens. A token cannot create another token.

With the API (session only):

Terminal window
curl -X POST https://api.opdns.io/v1/tokens \
-H 'Content-Type: application/json' \
--cookie "__Host-opdns_session=…" \
-d '{"name":"home-assistant","scopes":["profiles:read","analytics:read"]}'

The response holds secret (opdns_ followed by 52 characters) one time only.

Give a token the fewest scopes that it needs. Each operation needs exactly one scope, or takes a session only. The session-only operations are signing out, the tokens themselves, data exports, checkout and the billing portal. The table below is generated from the specification. The security of every operation names its scope (bearer: [scope]), and the API enforces exactly that scope.

Scope Allows Operations
profiles:read Read profiles and what belongs to them (settings, rules, lists, linked IPs, devices, nodes, list reports, block page certificate) and the setup values. GET /v1/profiles/{id}/block-page/ca.crt, GET /v1/profiles/{id}/block-page/ca.mobileconfig, GET /v1/profiles/{id}/block-page/ca.pem, GET /v1/profiles/{id}/block-page/ca, GET /v1/profiles/{id}/devices/{deviceId}, GET /v1/profiles/{id}/devices, GET /v1/profiles/{id}/linked-ips, GET /v1/profiles/{id}/list-reports, GET /v1/profiles/{id}/lists, GET /v1/profiles/{id}/nodes, GET /v1/profiles/{id}/rules, GET /v1/profiles/{id}, GET /v1/profiles, GET /v1/setup/{platform}
profiles:write Create, change and delete profiles and what belongs to them (rules, lists, linked IPs and their DDNS tokens, devices, list reports, block page certificate). DELETE /v1/profiles/{id}/block-page/ca, DELETE /v1/profiles/{id}/devices/{deviceId}, DELETE /v1/profiles/{id}/linked-ips/{linkId}, DELETE /v1/profiles/{id}, GET /v1/profiles/{id}/linked-ips/{linkId}/ddns, PATCH /v1/profiles/{id}/devices/{deviceId}, PATCH /v1/profiles/{id}, POST /v1/profiles/{id}/block-page/ca, POST /v1/profiles/{id}/linked-ips/{linkId}/ddns/rotate, POST /v1/profiles/{id}/linked-ips, POST /v1/profiles/{id}/list-reports, POST /v1/profiles, PUT /v1/profiles/{id}/lists, PUT /v1/profiles/{id}/rules
nodes:write Create self-hosted nodes and their enrollment codes, revoke nodes, and decide about the local profile of a standalone node. DELETE /v1/profiles/{id}/nodes/{node}, POST /v1/profiles/{id}/nodes/{node}/adoption, POST /v1/profiles/{id}/nodes
account:read Read the account, its plan and usage, its audit log and its API tokens. Send dashboard error reports and feedback. GET /v1/account/plan, GET /v1/auth/audit, GET /v1/auth/me, GET /v1/tokens, POST /v1/client-errors, POST /v1/feedback
billing:read Read the billing state of the organization (the organization owner only). GET /v1/account/billing
logs:read Search and tail the query logs of every profile. GET /v1/profiles/{id}/logs/stream, GET /v1/profiles/{id}/logs
analytics:read Read the counts, timelines and top lists of every profile. GET /v1/profiles/{id}/analytics/{shape}

Reading a DDNS URL needs profiles:write, not profiles:read, because the URL lets its holder move a linked address.

Each operation in the reference states its scope. A token without that scope gets 403 insufficient_scope. The required_scope of the problem names the missing scope:

{
"type": "https://opdns.io/problems/insufficient_scope",
"title": "Forbidden",
"status": 403,
"code": "insufficient_scope",
"detail": "the token lacks the nodes:write scope",
"required_scope": "nodes:write"
}

An operation that takes a session only answers a token with 403 session_required. Tokens see only the profiles of their own organization. Other profiles answer 404, not 403.

In API 0.45.0, creating and revoking nodes moved from profiles:write to nodes:write. At that time, every token that had profiles:write received nodes:write, so no token lost access.

Terminal window
curl -H "Authorization: Bearer $OPDNS_TOKEN" https://api.opdns.io/v1/profiles

To revoke a token, use the same dashboard page, or send DELETE /v1/tokens/{id} with a session. The next request with the token gets 401. The dashboard shows when each token was last used (to the minute) and when it expires. An expired token gets 401, like a revoked one.

Requests with tokens count against the API rate of your plan. Every token of your organization shares this rate. See Rate limits.

Every response carries X-Request-Id, the X-Opdns-Api-Version header, and these security headers for browsers:

  • Content-Security-Policy (default-src 'none'; frame-ancestors 'none' and more).
  • X-Frame-Options: DENY.
  • Referrer-Policy: no-referrer.
  • X-Content-Type-Options: nosniff.
  • Strict-Transport-Security, wherever the session cookie is marked Secure (every deployment except development).

Self-hosted nodes use a separate credential, the node token (opdnsnode_…). A node gets it when it exchanges a one-time enrollment code at POST /v1/nodes/enrol. Only the node endpoints and the link accept it. See Enroll a node.