Using the API
Manage your DNS records from your own scripts and servers. Everything you can do in the console's DNS pages, you can do here.
Signed in, you can download this guide as a Markdown file (apidns.md).
1. Getting started
- Make sure you have access to the DNS console (see Requesting access).
- In the console, go to API keys and make a key for the public IP address your script connects from (see API keys).
- Store the key safely, for example in an environment variable. Never put it in code that ends up in a repository.
- Base URL: https://api.centerdesk.nl. HTTPS only: a call over plain HTTP is refused, and the key you sent is then considered exposed. Revoke it and make a new one.
- Requests and responses are JSON. Send Accept: application/json, and for POST/PATCH Content-Type: application/json.
- Successful responses wrap their content in "data".
2. Authentication
Send the key in the Authorization header:
Authorization: Bearer cdk_xxxxxxxxxxxxxxxxxxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
- The key works only from the IP address it was made for. From anywhere else you get 403 ip_not_allowed.
- The key reaches only the domains set for you one by one (per domain, by your customer manager or Centerdesk), with the role set there, and follows it when it changes. Your default role in the console does not count for keys. The API keys page shows what your keys reach.
- A key unused for 60 days stops working for good (401 key_disabled). Make a new one in the console.
In the examples below:
export CDKEY='cdk_...' # your key export API=https://api.centerdesk.nl
3. Who am I: GET /v1/me
A quick check that your key works.
curl -s "$API/v1/me" -H "Authorization: Bearer $CDKEY" -H "Accept: application/json"
{
"data": {
"id": "6f1c0d8e-8a51-4c57-9b3e-2d1f0a7e5b11",
"name": "Acme BV",
"slug": "acme-x1y2",
"zones": 1
}
}
4. Your domains: GET /v1/zones
What you may change, and within which limits. Read this before you write; you never have to discover a limit by running into it.
curl -s "$API/v1/zones" -H "Authorization: Bearer $CDKEY" -H "Accept: application/json"
{
"data": [
{
"zone": "example.nl",
"covers": "*.shop.example.nl and shop.example.nl",
"scope": "subtree",
"label": "shop",
"types": ["A", "AAAA"],
"allowed_targets": ["217.154.204.53/32"],
"ttl": { "min": 300, "max": 86400 },
"records": { "used": 2, "limit": 25 },
"writable": true,
"expires_at": null,
"role": "full"
}
]
}
| covers | The names you may use: subtree = a name and everything under it, exact = only that one name, zone = every name in the domain. |
|---|---|
| allowed_targets | Addresses and ranges your records may point to. |
| writable | false: the domain is not yet hosted at the provider; writes are refused. |
| role | What this key may do here: read, create or full. With create, below holds the name it may add below (e.g. test.example.nl: adds a.test.example.nl), and it changes and deletes only its owner's records there. |
5. Listing records
GET /v1/zones/{zone}/records gives the records you made in that domain. GET /v1/zones/{zone}/records/{id} gives one.
curl -s "$API/v1/zones/example.nl/records" -H "Authorization: Bearer $CDKEY" -H "Accept: application/json"
{
"data": [
{
"id": "0b6a3a0e-8b35-4d6e-9d0f-2a4c5e6f7a8b",
"name": "app.shop.example.nl",
"type": "A",
"value": "217.154.204.53",
"ttl": 3600,
"status": "active",
"applied_at": "2026-09-30T10:12:44+00:00",
"created_at": "2026-09-30T10:12:43+00:00"
}
]
}
This lists only the records made through the console or the API.
Add ?all=1 to see every record within the names you were given, as the DNS provider serves them. That includes records Centerdesk made, and for a whole domain also the domain itself (MX, TXT and so on). Your own have an id and "editable": true. The others have "id": null, "editable": false and the reason in locked; they cannot be changed through the API. prio is set for MX and SRV records. If the provider cannot be reached, you get your own records with "complete": false.
curl -s "$API/v1/zones/example.nl/records?all=1" -H "Authorization: Bearer $CDKEY" -H "Accept: application/json"
6. Creating a record: POST /v1/zones/{zone}/records
| Field | Required | Meaning |
|---|---|---|
| name | yes | The name without the domain (app.shop), or in full (app.shop.example.nl). |
| type | no | A (default), AAAA, CNAME or TXT, as far as your types allow. |
| value | yes | A/AAAA: the IPv4 or IPv6 address. CNAME: a host name (shop.example.com). TXT: up to 255 printable characters on one line, without double quotes. |
| ttl | no | Seconds, default 3600, within the domain's TTL range. |
curl -s -X POST "$API/v1/zones/example.nl/records" \
-H "Authorization: Bearer $CDKEY" -H "Accept: application/json" -H "Content-Type: application/json" \
-d '{"name": "app.shop", "type": "A", "value": "217.154.204.53", "ttl": 3600}'
Answer: 201 with the new record, including its id. Keep that id to change or delete the record later.
7. Changing a record: PATCH /v1/zones/{zone}/records/{id}
Send only what changes: value and/or ttl. The name and type of a record never change; for that, delete it and make a new one.
curl -s -X PATCH "$API/v1/zones/example.nl/records/0b6a3a0e-8b35-4d6e-9d0f-2a4c5e6f7a8b" \
-H "Authorization: Bearer $CDKEY" -H "Accept: application/json" -H "Content-Type: application/json" \
-d '{"value": "217.154.204.54", "ttl": 600}'
Answer: 200 with the changed record.
8. Deleting a record: DELETE /v1/zones/{zone}/records/{id}
curl -s -X DELETE "$API/v1/zones/example.nl/records/0b6a3a0e-8b35-4d6e-9d0f-2a4c5e6f7a8b" \ -H "Authorization: Bearer $CDKEY" -H "Accept: application/json"
{ "data": { "id": "0b6a3a0e-8b35-4d6e-9d0f-2a4c5e6f7a8b", "status": "deleted" } }
9. History: GET /v1/changes
The latest changes for your organisation, newest first. Optional ?limit= from 1 to 200 (default 50).
curl -s "$API/v1/changes?limit=20" -H "Authorization: Bearer $CDKEY" -H "Accept: application/json"
{
"data": [
{
"id": "…",
"zone": "example.nl",
"action": "update",
"name": "app.shop.example.nl",
"type": "A",
"from": { "value": "217.154.204.53", "ttl": 3600 },
"to": { "value": "217.154.204.54", "ttl": 600 },
"status": "applied",
"error": null,
"applied_at": "2026-09-30T10:20:01+00:00",
"created_at": "2026-09-30T10:20:00+00:00"
}
]
}
10. Rules
Every write is checked against these rules, in the API itself. The console applies exactly the same ones.
- Only names within your covers, and only the types in types (A, AAAA, CNAME, TXT; which ones is up to Centerdesk).
- A/AAAA: only addresses within allowed_targets. Private, local and reserved addresses are always refused.
- CNAME: a host name, not an address and not the name itself. A CNAME stands alone: not where anything else exists, and nothing next to it.
- TXT: next to your own records at a name is fine, one TXT of yours per name.
- Never the domain itself, never names starting with an underscore, never wildcards (*).
- Never reserved names such as www, mail, smtp, autodiscover, api, admin, vpn and ftp.
- Not a name where someone else has a record, and only records you made yourself can be changed or deleted.
- TTL within the range in ttl; values outside it are refused, not rounded.
- No more records than records.limit per assigned name.
11. Errors
An error has this shape, with a sentence you can show to a person:
{ "error": "outside_grant", "message": "www.example.nl is outside your names. You hold: *.shop.example.nl and shop.example.nl." }
Field errors (422) come as {"message": …, "errors": {"field": ["…"]}}.
| Status | error | Meaning and what to do |
|---|---|---|
| 401 | unauthenticated | Key missing, wrong, or revoked. |
| 401 | key_disabled | The key was revoked or not used for 60 days. Make a new one. |
| 403 | ip_not_allowed | Called from another IP address than the key's. |
| 403 | https_required | Called over plain HTTP. Replace the key: it crossed the network unencrypted. |
| 403 | role_forbids | Your role in this domain does not allow this (for example read-only). |
| 403 | outside_grant | The name is outside the names assigned to you. |
| 404 | – | Unknown domain or record, or a domain you have no access to. |
| 409 | name_in_use | Something is already published at that name. |
| 409 | record_limit_reached | You have the maximum number of records for that name. |
| 409 | zone_drifted | The record was changed outside the API. Contact Centerdesk. |
| 409 | zone_not_managed | The domain is not yet hosted at the provider (writable: false). |
| 409 | zone_busy | Another change to the domain is in progress. Try again in a few seconds. |
| 422 | reserved_name | A reserved name, or one starting with an underscore. |
| 422 | apex_not_writable | The domain itself cannot be changed. |
| 422 | type_not_allowed | A record type other than those in types. |
| 422 | target_not_allowed | The address is outside allowed_targets. |
| 422 | ttl_out_of_range | TTL outside the allowed range. |
| 429 | – | Too many requests. Wait the number of seconds in the Retry-After header. |
| 502 | – | The DNS provider did not respond or refused. Check the record list before trying again. |
12. Limits
- Reading: 120 requests per minute for your organisation.
- Writing: 10 changes per minute for your organisation, per domain.
- One active key per IP address per person; keys unused for 60 days stop working.
- Every request made with a key is logged, including refused ones.
13. Example: keep a record up to date
A small shell script that points app.shop.example.nl at an address, and only changes it when needed. It uses curl and jq.
#!/bin/sh
set -eu
API=https://api.centerdesk.nl
ZONE=example.nl
FQDN=app.shop.example.nl
WANT=217.154.204.54
AUTH="Authorization: Bearer $CDKEY"
record=$(curl -sf "$API/v1/zones/$ZONE/records" -H "$AUTH" -H "Accept: application/json" \
| jq -c --arg n "$FQDN" '.data[] | select(.name == $n and .type == "A")')
if [ -z "$record" ]; then
curl -sf -X POST "$API/v1/zones/$ZONE/records" -H "$AUTH" -H "Accept: application/json" \
-H "Content-Type: application/json" -d "{\"name\": \"$FQDN\", \"value\": \"$WANT\"}"
elif [ "$(echo "$record" | jq -r .value)" != "$WANT" ]; then
id=$(echo "$record" | jq -r .id)
curl -sf -X PATCH "$API/v1/zones/$ZONE/records/$id" -H "$AUTH" -H "Accept: application/json" \
-H "Content-Type: application/json" -d "{\"value\": \"$WANT\"}"
fi
Questions about the API? Contact Centerdesk.