# DNSSEC

Switch DNSSEC on or off for a zone, read the DS record to publish at your registrar, check what public resolvers see and rotate the zone signing key.

These endpoints control the DNSSEC of one zone. The paths start with `/v2/cdn/dnssec/{domain_public_id}/`, where the id is the public id of the domain, taken from [the domains list](https://docs.diamwall.com/products/domains/#list-your-domains).

- [Settings](#settings): Read the DNSSEC state and the DS record, switch DNSSEC on or off.
- [Diagnostic](#diagnostic): See what public resolvers observe for the domain.
- [Rotate ZSK](#rotate-the-zone-signing-key): Replace the zone signing key. The DS record stays as it is.

The examples on this page use these shell variables:

```bash
export DIAMWALL_API_KEY="your key"
export DNSSEC="https://api.diamwall.com/v2/cdn/dnssec/your-domain-public-id"
```

## The order of calls

Switching DNSSEC on takes four steps, and the last one is not done through this API:

1. Read the settings and keep the `ETag` header of the answer.
2. Send `PATCH` with `{ "enabled": true }` and that `ETag` in `If-Match`.
3. Take the DS record from `data.ds` of the answer and publish it at your registrar. Neither the API nor the CDN publishes it for you.
4. Run the diagnostic until `data.status` is `active`.

## Settings

### Read the settings

[`GET /v2/cdn/dnssec/{domain_public_id}/settings/dnssec/` in the API reference](https://docs.diamwall.com/api/#tag/dnssec/GET/v2/cdn/dnssec/{domain_public_id}/settings/dnssec/)

```bash
curl -i "$DNSSEC/settings/dnssec/" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY"
```

```json
{
  "revision": "sha256:9cb0a61e89b3...",
  "consistency": "verified",
  "publication": { "status": "verified", "rollout": "unknown" },
  "data": {
    "enabled": { "state": "resolved", "value": true },
    "keyset_complete": { "state": "resolved", "value": true },
    "key_artifacts_present": { "state": "resolved", "value": true },
    "private_keys_valid": { "state": "resolved", "value": true },
    "ksk": {
      "state": "resolved",
      "value": { "ttl": 3600, "public_key": "EgoNVIUfWzWlGoSgI9Nc..." }
    },
    "ds": {
      "state": "resolved",
      "value": {
        "ttl": 3600,
        "key_tag": 33519,
        "algorithm": 13,
        "algorithm_name": "ECDSAP256SHA256",
        "digest_type": 2,
        "digest_type_name": "SHA256",
        "digest": "CD491DBDCC608D79ACD01FC094D0AFC219DEB760CB36736C8715759E0A4F7DAB"
      }
    }
  }
}
```

`data` holds six fields:

| Field | What it says |
| --- | --- |
| `enabled` | Whether DNSSEC is on for the zone. |
| `keyset_complete` | Whether the keyset of the zone is complete. |
| `key_artifacts_present` | Whether the key artifacts of the zone are present. |
| `private_keys_valid` | Whether the CDN validated the private keys. It is a boolean. No private key material is ever answered. |
| `ksk` | The public key signing key: `ttl` and `public_key`, in base64. |
| `ds` | The DS record of that key: `ttl`, `key_tag`, `algorithm`, `algorithm_name`, `digest_type`, `digest_type_name` and `digest`. |

Each field comes back with a `state`, a `reason` when the CDN gives one, and a `value` only when `state` is `resolved`.

> **unknown is not off**
> A field whose `state` is `unknown` is unavailable. Show it as unavailable, never as `false` and never as a default. One such field makes the `consistency` of the answer `degraded`.

Three more things to know about this answer:

- The `ETag` header is the revision of the settings. Keep it for the next change.
- When the settings could not be read at all, the answer has `"state": "unknown"`, a `revision` of `null`, no `data` and no `ETag`. There is nothing to send in `If-Match`, so do not write.
- `publication.rollout` is always `unknown`. The answer does not prove anything about every point of presence.

### Publish the DS record

There is no ready-made DS line in the answer. Compose it from `ttl`, `key_tag`, `algorithm`, `digest_type` and `digest`, in the form your registrar asks for. With the values above, a zone file line looks like this:

```txt
example.com. 3600 IN DS 33519 13 2 CD491DBDCC608D79ACD01FC094D0AFC219DEB760CB36736C8715759E0A4F7DAB
```

The DS record is answered whole or with no `value`. Publish only a `ds` whose `state` is `resolved` and that has its `value`. A DS record that is nearly right breaks the resolution of the whole zone.

### Switch DNSSEC on or off

[`PATCH /v2/cdn/dnssec/{domain_public_id}/settings/dnssec/` in the API reference](https://docs.diamwall.com/api/#tag/dnssec/PATCH/v2/cdn/dnssec/{domain_public_id}/settings/dnssec/)

Read the settings first to get the `ETag`, then send it in `If-Match` exactly as it came, quotes included:

```bash
ETAG=$(curl -s -o /dev/null -D - "$DNSSEC/settings/dnssec/" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY" \
  | tr -d '\r' | awk 'tolower($1) == "etag:" { print $2 }')

curl -i -X PATCH "$DNSSEC/settings/dnssec/" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "If-Match: $ETAG" \
  -d '{ "enabled": true }'
```

- The body is exactly `enabled`, a JSON boolean. `true` switches DNSSEC on, `false` switches it off.
- A string, a number or `null` in `enabled` answers `400 INVALID_REQUEST` with `enabled` in `fields`. So does a missing body or any other field.
- The answer has the same form as the read, with the settings as they are after the change, and a new `ETag` header for the next change.
- After switching on, the DS record to publish is `data.ds` of this answer, when it is `resolved` and has its `value`. If it is not, read the settings again.

> **The zone needs a valid keyset**
> A zone whose keyset is missing or invalid is refused with `409` or `503` and the code `INVALID_STATE`. Nothing was changed. Do not send the same request again: it answers the same until the keyset is repaired. Read the settings, and quote the `request_id` of the answer to support.

## Diagnostic

[`GET /v2/cdn/dnssec/{domain_public_id}/diagnostics/dnssec/` in the API reference](https://docs.diamwall.com/api/#tag/dnssec/GET/v2/cdn/dnssec/{domain_public_id}/diagnostics/dnssec/)

The settings tell you what is configured. The diagnostic tells you what the Google and Cloudflare public resolvers observe for the domain. It takes no query parameter and no body.

```bash
curl "$DNSSEC/diagnostics/dnssec/" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY"
```

```json
{
  "diagnostic": "dnssec",
  "data": {
    "status": "missing_ds",
    "reasons": ["parent_ds_absent"],
    "warnings": [],
    "coverage": "full",
    "checked_at": "2026-11-11T10:00:00.000Z",
    "cache": { "hit": false, "expires_at": "2026-11-11T10:00:30.000Z" },
    "validation_basis": "trusted_resolver_ad_and_cd",
    "local": {
      "enabled": true,
      "keyset_complete": true,
      "consistency": "enabled_with_complete_keyset",
      "ds": { "ttl": 3600, "key_tag": 12345, "algorithm": 13, "digest_type": 2, "digest": "0123456789ABCDEF..." }
    },
    "resolvers": [
      { "id": "google", "available": true, "status": "missing_ds", "reasons": ["parent_ds_absent"] },
      { "id": "cloudflare", "available": true, "status": "missing_ds", "reasons": ["parent_ds_absent"] }
    ]
  }
}
```

The example is shortened. Each available resolver also answers `parent_ds` and `zone`, with what it saw.

Use `data.status` as the global state. `data.local.enabled` is only the configuration switch.

| `data.status` | How to read it |
| --- | --- |
| `active` | DNSSEC works. This is the only value to show as active. |
| `missing_ds`, `ds_mismatch`, `disabled_with_ds`, `validation_failed` | A problem that both resolvers agree on. `reasons` holds the codes that say why. |
| `disabled` | DNSSEC is off. |
| `inconclusive` | The evidence is insufficient or inconsistent. Do not show the domain as broken. |
| `unrecognized` | A value this API does not know. It does not confirm that DNSSEC works. |

- `reasons` and `warnings` are machine codes, such as `parent_ds_absent` or `additional_ds_records`. They are not text to show as is.
- `coverage` is `full` or `partial`. `active` and `disabled` can come with partial coverage. The problem states need both resolvers.
- A resolver that could not be reached answers only `id`, `available` and `reason`.
- `checked_at` is the time of the observation and may be earlier than your request. Observations can be reused for up to 30 seconds, and public resolvers have their own caches, so a change at the registrar does not show at once.
- `data.local.ds` can be `null`.
- The answer has no `ETag`. Use the settings read for `If-Match`.

> **Do not act on a DS alone**
> - Do not publish the local DS only because another DS was observed.
> - Do not remove additional DS records automatically.
> - A `503` is not a DNSSEC state. `DNSSEC_UNAVAILABLE` means no resolver was available. It never means DNSSEC is off or a DS is absent.

## Rotate the zone signing key

[`POST /v2/cdn/dnssec/{domain_public_id}/actions/dnssec-rotate-zsk/` in the API reference](https://docs.diamwall.com/api/#tag/dnssec/POST/v2/cdn/dnssec/{domain_public_id}/actions/dnssec-rotate-zsk/)

This action replaces the zone signing key (ZSK). The key signing key stays, so the DS record at your registrar does not change. The CDN also raises the serial of the zone.

The body is exactly `{}`. A body with any field, or no body at all, answers `400 INVALID_REQUEST`.

```bash
curl -X POST "$DNSSEC/actions/dnssec-rotate-zsk/" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: zsk-rotate-2026-11-23-c4" \
  -d '{}'
```

The answer holds the settings as the action left them under `data`, in the same form as the read, and `idempotency_replayed`. It has no `ETag`, and nothing of the old or the new key. The new serial is not in it either: read it in `data.serial` of the [SOA settings](https://docs.diamwall.com/products/dns/#soa).

> **A rotated key does not come back**
> Do not send the request again to make sure. The answer says what happened. If you are not sure, read the settings.

### Idempotency-Key

The action takes no `If-Match`. It takes an `Idempotency-Key` that you make up: 16 to 128 characters, the first a letter or a digit, the others letters, digits, `.`, `_`, `:` or `-`. Use one key per intent.

| Situation | What happens |
| --- | --- |
| Same key, same body, within 24 hours of the first sending | The action does not run again. You get the first answer back with `idempotency_replayed: true`. Its `data` is the settings as they were then, not as they are now. |
| Same key after those 24 hours | No replay is promised. The key may be rotated a second time. Read the settings instead. |
| Same key, another body | `409 IDEMPOTENCY_CONFLICT`. The action does not run. |
| No key, or a key outside the form | `400 IDEMPOTENCY_KEY_REQUIRED` or `400 INVALID_IDEMPOTENCY_KEY`. |

When an answer is lost or unclear, the code tells you what to do:

| Code | The action | Do this |
| --- | --- | --- |
| `502 FILE_SERVER_OUTCOME_UNKNOWN` | May have run | Within the 24 hours, send the same request with the same key. After them, read the settings first. |
| `409 ACTION_OUTCOME_UNKNOWN` | May have run | Stop. Read the settings. Do not repeat the request and do not make a new key to get past it. |
| `429 ACTION_HISTORY_FULL` | Did not run | Do not send the request again. Waiting does not end it. |
| `409 DOMAIN_BUSY` | Did not run | Wait a few seconds and send the same request with the same key. |
| `503 PUBLICATION_FAILED` | Not known | Do not send the request again. Read the settings and compare them with what you meant. |

## After a rename

A domain that is given another name by support keeps its DNSSEC. Its DS record can change with the name. Read the settings again after a rename, and update the DS record at your registrar if it changed.

## Limits and permissions

- **Credits.** Each domain has a budget of 3000 credits a minute, shared by everyone who calls the API for that domain. Reading or changing the settings and rotating the ZSK cost 8 credits each. The diagnostic costs 25.
- **Free refusals.** A request refused with `400` or `428` before it reaches the CDN spends no credits.
- **Out of credits.** The call answers `429 TOO_MANY_REQUESTS`, with the wait in `details.retry_after_seconds` and in the `Retry-After` header.
- **Permissions.** The settings read and the diagnostic need `dns.view` on the domain. Switching DNSSEC on or off and rotating the ZSK need `dns.edit`.

## Errors you are likely to see

| Status | Code | What happened |
| --- | --- | --- |
| `400` | `INVALID_REQUEST` | The body is wrong or missing. For the switch, `fields` names `enabled`. |
| `400` | `INVALID_PRECONDITION` | `If-Match` is not one quoted `ETag`, sent as it came. |
| `400` | `IDEMPOTENCY_KEY_REQUIRED`, `INVALID_IDEMPOTENCY_KEY` | The `Idempotency-Key` of the action is missing or outside its form. |
| `404` | `DIAGNOSTIC_NOT_FOUND` | The diagnostic is not available. It is not an empty result. |
| `409` | `INVALID_STATE` | The keyset of the zone is missing or invalid. Also answered as `503`. |
| `409` | `DOMAIN_BUSY` | Something else is changing the domain. Wait a few seconds and send the same request. |
| `409` | `DOMAIN_WITHOUT_KEY`, `DOMAIN_REPLACEMENT_PENDING` | The domain is in a state that does not allow the call. |
| `409` | `IDEMPOTENCY_CONFLICT` | The same `Idempotency-Key` was sent with another body. |
| `409` | `ACTION_OUTCOME_UNKNOWN` | An earlier run with this key has an unknown outcome. Read the settings. |
| `412` | `REVISION_MISMATCH` | The settings changed since your read. `details.current_revision` has the new one. Read again and retry. |
| `415` | `UNSUPPORTED_MEDIA_TYPE` | The body is not JSON. |
| `428` | `PRECONDITION_REQUIRED` | The `If-Match` header is missing. |
| `429` | `TOO_MANY_REQUESTS`, `RATE_LIMIT_EXCEEDED` | Too many requests. Wait `details.retry_after_seconds`. |
| `429` | `ACTION_HISTORY_FULL` | No more runs of the rotation are kept for the domain. |
| `502` | `FILE_SERVER_OUTCOME_UNKNOWN` | The answer was lost and the write may have been made. |
| `503` | `PUBLICATION_FAILED` | The change could not be published and verified. Whether anything was written is not known. |
| `503` | `STATE_CHANGING`, `RUNTIME_UNAVAILABLE` | The state of the domain is changing or unavailable. Come back later. |
| `503` | `DNSSEC_UNAVAILABLE`, `DIAGNOSTIC_UNAVAILABLE`, `DIAGNOSTIC_FAILED` | The diagnostic could not be read: no resolver was available, or diagnostic capacity was exhausted. |

The errors that come from the key itself, such as `API_KEY_IP_NOT_ALLOWED`, are on the [Errors](https://docs.diamwall.com/reference/errors/) page.

## All DNSSEC endpoints

Each row opens the endpoint in the API reference, with every parameter, rule and response.

See the [API reference](https://docs.diamwall.com/api/#tag/dnssec) for every endpoint, with parameters and responses.
