Rotate the token of the calling node (node side, `opdns-node rotate-token`).
const url = 'https://api.opdns.io/v1/nodes/self/token';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"reason":"manual"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.opdns.io/v1/nodes/self/token \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "reason": "manual" }'Issues a new node token. Only the current token of the node can rotate. The
previous token of a committed rotation, still valid for its grace period, gets
409 node_token_superseded. Both tokens work until the first request of the
node with the new token. That request commits the rotation, which the API
audits (node.token_rotated, meta reason, committed_by). The presented
token then keeps working for previous_valid_s seconds (600). A connected node
rotates over the link instead (RotateToken, same rules). Over the link,
rotation is automatic every link.token_rotation, 90 days by default. The API
shows the token once. The response is Cache-Control: no-store.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
Recorded in the audit row. Default manual.
Responses
Section titled “Responses”The new token.
object
The new node token (opdnsnode_...).
The seconds that the presented token keeps working after the commit.
Examplegenerated
{ "node_token": "example", "previous_valid_s": 1}Malformed request.
object
Stable machine code.
object
Seconds, the same value as the Retry-After header (rate limits, offline nodes).
The plan limit that a plan_limit problem reached.
object
The value of the limit in the plan.
Where to change to a larger plan.
The scope that the API token did not have (insufficient_scope).
Example
{ "type": "https://opdns.io/problems/bad_request", "title": "Bad Request", "status": 400, "code": "bad_request", "detail": "The JSON in the request is not valid (unexpected end of JSON input). Correct the JSON and try again.", "request_id": "5f2c9a0e7b1d4c38"}The node token is missing or unknown (unauthenticated), or the node is revoked (node_revoked).
object
Stable machine code.
object
Seconds, the same value as the Retry-After header (rate limits, offline nodes).
The plan limit that a plan_limit problem reached.
object
The value of the limit in the plan.
Where to change to a larger plan.
The scope that the API token did not have (insufficient_scope).
Example
{ "type": "https://opdns.io/problems/node_revoked", "title": "Unauthorized", "status": 401, "code": "node_revoked", "detail": "This node was removed from your account, so its token no longer works. Enroll the node again to reconnect it.", "request_id": "5f2c9a0e7b1d4c38"}node_token_superseded: the presented token is no longer the current token of the node.
object
Stable machine code.
object
Seconds, the same value as the Retry-After header (rate limits, offline nodes).
The plan limit that a plan_limit problem reached.
object
The value of the limit in the plan.
Where to change to a larger plan.
The scope that the API token did not have (insufficient_scope).
Example
{ "type": "https://opdns.io/problems/node_token_superseded", "title": "Conflict", "status": 409, "code": "node_token_superseded", "detail": "A newer node token already replaced this one. Rotate the token with the current token of the node.", "request_id": "5f2c9a0e7b1d4c38"}Field validation failed (validation_failed, unknown_list), or the plan of the organization does not allow the write (plan_limit, which names the limit in limit).
object
Stable machine code.
object
Seconds, the same value as the Retry-After header (rate limits, offline nodes).
The plan limit that a plan_limit problem reached.
object
The value of the limit in the plan.
Where to change to a larger plan.
The scope that the API token did not have (insufficient_scope).
Example
{ "type": "https://opdns.io/problems/validation_failed", "title": "Unprocessable Content", "status": 422, "code": "validation_failed", "detail": "Some values in the request are not valid. The list of errors tells you what to change.", "errors": [ { "field": "settings.block_mode", "message": "one of nxdomain, refused, null, block-page" } ], "request_id": "5f2c9a0e7b1d4c38"}Rate limited (rate_limited). For an API token, the organization used all of the rate of its plan until RateLimit-Reset.
object
Stable machine code.
object
Seconds, the same value as the Retry-After header (rate limits, offline nodes).
The plan limit that a plan_limit problem reached.
object
The value of the limit in the plan.
Where to change to a larger plan.
The scope that the API token did not have (insufficient_scope).
Example
{ "type": "https://opdns.io/problems/rate_limited", "title": "Too Many Requests", "status": 429, "code": "rate_limited", "detail": "You sent too many requests in a short time. Wait a moment, then try again.", "request_id": "5f2c9a0e7b1d4c38", "retry_after": 6}Headers
Section titled “Headers”On every response to an API token: the rate of the plan of the organization, in requests per one-minute window (api_requests_per_minute).
On every response to an API token: the requests left to the organization in the current window.
On every response to an API token: the seconds until the current window ends and the count resets.
On every response to an API token: the quota policy, <limit>;w=60.