# GDPR

Read the GDPR zone of a domain, switch it on at a location, move it or switch it off.

A domain can have a GDPR zone at one location that you choose. This page covers reading the zone, listing the locations it can be in, and switching it on, moving it or switching it off. The paths start with `/v2/cdn/gdpr/{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).

- [Locations](#list-the-locations): The locations the GDPR zone of the domain can be in.
- [Read the zone](#read-the-zone): Whether the domain has a GDPR zone, and where.
- [Change the zone](#change-the-zone): Switch it on at a location, move it or switch it off.

The examples on this page use these shell variables:

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

## The order of calls

| Step | Call | What you keep |
| --- | --- | --- |
| 1 | `GET .../references/gdpr-locations/` | The `id` of the location you want |
| 2 | `GET .../settings/gdpr/` | The `ETag` header of the answer |
| 3 | `PATCH .../settings/gdpr/` | The new `ETag`, for the next change |

Step 1 is only needed when you switch the zone on or move it. Step 2 is needed before every change.

## List the locations

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

```bash
curl "$GDPR/references/gdpr-locations/?limit=50" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY"
```

```json
{
  "revision": "sha256:a3cdbdbf2ff3...",
  "consistency": "verified",
  "data": {
    "state": "resolved",
    "items": [
      {
        "id": "HKG",
        "city": "Hong Kong",
        "country": "Hong Kong",
        "continent": "Asia",
        "name": "Hong Kong PoP"
      },
      { "id": "LIS", "city": "Lisbon", "country": "PT", "continent": "EU" }
    ],
    "page": { "limit": 50, "next_cursor": null, "total": 2 }
  }
}
```

- The `id` is what you send as `location_id` when you change the zone.
- `city`, `country` and `continent` are labels. `country` and `continent` are not ISO codes: show them as they are and do not compare them with a code. `name` is only there for some locations.
- `limit` goes from 1 to 100. Without it a page holds 50 locations.
- To read the next page, send `data.page.next_cursor` back as `cursor`, until it is `null`. `data.page.total` is the number of locations in all.
- If the list changes between two pages, the next page answers `409 CURSOR_STALE`. Start again from the first page.
- No other query parameter is accepted.
- The list is read-only. Its answer has no `ETag`.

> **Check data.state first**
> `data.items` and `data.page` are only there when `data.state` is `resolved`. With any other state the answer is still `200`, but the locations are unavailable, sometimes with a `data.reason`. Show them as unavailable and offer none to choose. It is not an empty list.

## Read the zone

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

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

**Zone on**

```json
{
  "revision": "sha256:9074f9827d70...",
  "consistency": "verified",
  "data": {
    "enabled": { "state": "resolved", "value": true },
    "location_id": { "state": "resolved", "value": "LIS" },
    "created_at": { "state": "resolved", "value": "2026-10-10T12:00:00.000Z" },
    "shared_address_tenant_count": { "state": "resolved", "value": 1 },
    "publication": { "state": "resolved", "value": "local_artifacts_verified" }
  }
}
```

**No zone**

```json
{
  "revision": "sha256:9074f9827d70...",
  "consistency": "verified",
  "data": {
    "enabled": { "state": "resolved", "value": false },
    "location_id": { "state": "resolved", "value": null },
    "publication": { "state": "resolved", "value": "not_configured" }
  }
}
```

**Could not be read**

```json
{
  "revision": null,
  "consistency": "degraded",
  "state": "unknown"
}
```

Each field comes back as an object with a `state`, and a `value` only when the `state` is `resolved`.

| Field | What it is |
| --- | --- |
| `enabled` | Whether the domain has a GDPR zone. |
| `location_id` | The `id` of the zone's location, from [the locations list](#list-the-locations). `null` when there is no zone. |
| `created_at` | When the zone was created. Absent when there is no zone. |
| `shared_address_tenant_count` | How many domains share the address of the zone. A count only, with no names. Absent when there is no zone. |
| `publication` | What the CDN holds of the zone on the node it read. See below. |

`publication` inside `data` has one of these forms:

| `state` | `value` | Meaning |
| --- | --- | --- |
| `resolved` | `not_configured` | There is no GDPR entry for the domain, and nothing left of one. |
| `resolved` | `local_artifacts_verified` | What the zone needs is coherent on the node that was read. This does not confirm every point of presence. |
| `unknown` | none | Some evidence could not be confirmed. A `reason` says which. This does not mean the zone is off. |

> **unknown is not off**
> - A field whose `state` is `unknown` is unavailable. Never treat it as `false`, `null` or `0`.
> - A field that is missing from `data` was not answered. Do not fill it in.
> - When the whole answer has `"state": "unknown"`, there is no `data`, the `revision` is `null` and there is no `ETag`. The zone could not be read. It is not a domain with no zone, and you cannot change the zone from this answer.

The `ETag` header of the answer is the revision of the settings. Keep it: a change needs it in `If-Match`.

## Change the zone

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

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

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

The body is exactly one of two forms. No other field is accepted.

| You want to | Body |
| --- | --- |
| Switch the zone on at a location | `{ "enabled": true, "location_id": "LIS" }` |
| Move a zone that is on to another location | `{ "enabled": true, "location_id": "HKG" }` |
| Switch the zone off | `{ "enabled": false }` |

**Switch on or move**

```bash
curl -X PATCH "$GDPR/settings/gdpr/" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "If-Match: $ETAG" \
  -d '{ "enabled": true, "location_id": "LIS" }'
```

**Switch off**

```bash
curl -X PATCH "$GDPR/settings/gdpr/" \
  -H "Authorization: Api-Key $DIAMWALL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "If-Match: $ETAG" \
  -d '{ "enabled": false }'
```

The answer is `200` with the settings as they are after the change, in the same form as [a read](#read-the-zone), and a new `ETag` header to use on your next change.

The body rules are strict, and nothing is converted or repaired:

- `enabled` is required and must be a JSON boolean. `"true"`, `1` and `null` are refused.
- `location_id` is required with `enabled: true` and refused with `enabled: false`. It is 1 to 128 letters, digits, `_` or `-`, sent as the locations list answered it.
- A request with no body is refused. It is never read as `enabled: false`.

Each of these answers `400 INVALID_REQUEST`, usually with the field named in `fields`.

> **Already in that state**
> Asking for the state the zone is already in (on at that same location, or off) answers `409 ALREADY_IN_STATE`. Nothing was written, and the same request answers the same. Read the zone to show what is published.

### When a change fails part way

The CDN changes a zone in several steps. Some `503` answers mean the change may have been made, or was made. For all of them the rule is the same: read the zone before you try anything else, and never repeat the request blindly.

| Code | What it tells you |
| --- | --- |
| `503 COMMITTED_CLEANUP_FAILED` | The change was made. A step after it failed. This is not a refusal. |
| `503 TRANSACTION_PREPARE_FAILED` | The CDN failed while it prepared the change, before it was committed. |
| `503 TRANSACTION_PREPARE_CLEANUP_FAILED` | The same, and the CDN could not clean up what it had prepared. |
| `503 TRANSACTION_RECOVERY_FAILED` | An earlier unfinished change could not be recovered. What is published is not known from the answer. |
| `502 FILE_SERVER_OUTCOME_UNKNOWN`, `500 UNEXPECTED_ERROR` | The change may have been made. |
| `FILE_SERVER_V2_ERROR`, under any status | What happened is not known, so neither is what was written. |

## Limits and permissions

- **Plan.** GDPR zones are Enterprise only. A domain on any other plan answers `403 FEATURE_NOT_AVAILABLE` on all three endpoints, with `details.feature` (`gdpr_zones`) and `details.plan`. This is true for the owner of the domain too.
- **Credits.** Each domain has a budget of 3000 credits a minute, shared by everyone who calls the API for that domain. Each call on this page costs 8 credits. A request that is refused for its query, body, headers, plan or permissions (`400`, `403`, `428`) spends none.
- **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.** Both reads need `ssl.view` on the domain. A change needs `ssl.edit`, plus `ssl.create` for `enabled: true` (switching on and moving both count) or `ssl.delete` for `enabled: false`. Someone with `ssl.edit` and neither of the two can read the zone but not change it: `403 PERMISSION_DENIED`.

## Errors you are likely to see

The code is in the `message` field of the answer.

| Status | Code | What happened |
| --- | --- | --- |
| `400` | `INVALID_REQUEST` | The body, `limit`, `cursor` or an unknown parameter or field is wrong. The answer names the field in `fields` when it can. |
| `400` | `INVALID_PRECONDITION` | `If-Match` is not one quoted `ETag` as it came from the read. |
| `403` | `FEATURE_NOT_AVAILABLE` | The domain is not on the Enterprise plan. |
| `403` | `PERMISSION_DENIED` | You may read the zone but lack `ssl.create` or `ssl.delete` for this change. |
| `404` | `REFERENCE_NOT_FOUND` | The list of locations is not available. It is not an empty list. |
| `404` | `SETTINGS_GROUP_NOT_FOUND` | The GDPR settings are not available for the domain. It is not a domain with no zone. Nothing was written. |
| `404` | `DOMAIN_NOT_FOUND` | The CDN does not have the domain. Nothing was read or written. |
| `409` | `CURSOR_STALE` | The locations changed while you were paging. Start from the first page. |
| `409` | `ALREADY_IN_STATE` | The zone is already as the body asks. Nothing was written. |
| `409` | `DOMAIN_WITHOUT_KEY`, `DOMAIN_REPLACEMENT_PENDING` | The domain is in a state that does not allow the call. |
| `412` | `REVISION_MISMATCH` | The settings changed since your read. `details.current_revision` has the current 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`. |
| `503` | `STATE_CHANGING`, `RUNTIME_UNAVAILABLE` | The state of the domain is changing or unavailable. Come back later. |
| `503` | `UNSAFE_PATH` | The locations could not be read safely. They are unavailable, not empty. |
| `503` | `COMMITTED_CLEANUP_FAILED`, `TRANSACTION_...` | See [When a change fails part way](#when-a-change-fails-part-way). |

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 GDPR 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/gdpr) for every endpoint, with parameters and responses.
