Skip to content
Dashboard

Domains and DNS

View as Markdown

Domains

List the domains a key can reach, register a new Enterprise domain, confirm its setup, copy settings from another domain and delete it.

newNSlive

A domain is where everything else in the API starts: its public_id is part of the path of every DNS and CDN call. This page covers the whole life of a domain, from registering it to deleting it.

The examples on this page use these shell variables:

export DIAMWALL_API_KEY="your key"
export API="https://api.diamwall.com/public-api"
Action What the key needs
List Any active key. A restricted key only sees its own domains.
Register A partner account with Enterprise capacity, and a key with domain creation enabled.
Complete setup A key with domain creation enabled, on an account that owns the domain.
Copy settings A key with domain creation enabled. Both domains are Enterprise, have the same owner and are assigned to the key.
Delete A key with domain deletion enabled, with the domain assigned to that key, on the account that owns it.

A key that lacks the permission answers 403. See API keys and IP and domain restrictions.

Register and complete setup both answer with the domain’s public_id and its status, as a number:

status Meaning
1 Active
2 Config
3 Moved
4 Suspended
5 Terminated
6 Blocked
7 Setup: registered, waiting for its name servers to be confirmed

A new domain starts at 7 and becomes 1 when its setup is complete.

curl "$API/domains/" \
-H "Authorization: Api-Key $DIAMWALL_API_KEY"

The answer is a paginated list, sorted by name. Each entry has the name and the public_id of a domain. Add ?name=example.com to find one domain, and ?page=2 for the next page.

Send the name in domain, at most 100 characters:

curl -X POST "$API/domains/" \
-H "Authorization: Api-Key $DIAMWALL_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "domain": "example.com" }'

A new domain answers 201:

{ "public_id": "acb66b15-da87-422a-8774-825ae2a8cb8c", "status": 7 }

The domain belongs to your account and is assigned to the key that created it. Keep the public_id: every other call for this domain needs it.

A registered domain waits in status 7 until both of its name servers are confirmed. Once the domain is delegated to them, ask for the check:

curl -X POST "$API/domains/acb66b15-da87-422a-8774-825ae2a8cb8c/complete-setup/" \
-H "Authorization: Api-Key $DIAMWALL_API_KEY"

The request needs no body. An empty JSON object, {}, is also accepted. When both name servers are confirmed the answer is 200 with "status": 1, and the domain is active.

Repeating the request runs the check again, so it is safe to retry while the delegation spreads.

To set up a new domain like one you already have, copy the settings and rules across. The domain in the path receives them. The domain in source_domain_public_id is read and never changed.

curl -X POST "$API/domains/acb66b15-da87-422a-8774-825ae2a8cb8c/copy-settings/" \
-H "Authorization: Api-Key $DIAMWALL_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "source_domain_public_id": "684393bc-679d-4779-a802-12cab3769191" }'
Copied Not copied
Network, compression, cache and TLS settings Origins
Cache rules, redirect rules, request transforms and response transforms DNS
Firewall rules and firewall access rules Certificates and mTLS
WAF rule exceptions Credentials

The copy runs group by group, in this order: network, compression, cache, tls, cache-rules, redirect-rules, request-transforms, response-transforms, firewall-rules, firewall-access-rules, waf-rule-exceptions. A complete copy answers 200 with one entry for each group, applied when something changed and unchanged when the target already matched:

{
"groups": [
{ "group": "network", "status": "applied" },
{ "group": "compression", "status": "unchanged" }
]
}

Repeating the request is safe. It creates no duplicates and deletes nothing: rules the target already has are reused, and they keep their order.

A copy that could not finish answers COPY_INCOMPLETE, with the status of the failure that stopped it: 400, 409, 412, 429 with a Retry-After header, 502 or 503. The body says how far it got:

{
"message": "COPY_INCOMPLETE",
"groups": [
{ "group": "network", "status": "applied" },
{ "group": "compression", "status": "unchanged" },
{ "group": "cache", "status": "unchanged" },
{ "group": "tls", "status": "failed", "code": "COPY_TLS_PROFILE_UNSUPPORTED" }
],
"not_run": ["cache-rules", "redirect-rules", "request-transforms", "response-transforms", "firewall-rules", "firewall-access-rules", "waf-rule-exceptions"]
}
  • groups lists what ran. A failed group has a code.
  • not_run lists the groups that were not reached. Fix the cause and send the same request again: the groups already applied come back as unchanged.
  • A rule that cannot be copied is listed in omitted of its group, with a reference (the public id of the rule, or its position in the source list, counting from 0) and a code. The other rules of that group are still copied, and later groups still run.
omitted code Meaning
COPY_RULE_CITES_SOURCE The rule refers to the source domain itself.
COPY_RULE_NOT_PORTABLE The rule cannot be moved to another domain.
COPY_WAF_RULE_UNKNOWN The exception is for a WAF rule the target does not have.

A delete needs the X-Confirm-Domain header with the name of the domain, exactly as it is stored, upper and lower case included:

curl -X DELETE "$API/domains/acb66b15-da87-422a-8774-825ae2a8cb8c/" \
-H "Authorization: Api-Key $DIAMWALL_API_KEY" \
-H "X-Confirm-Domain: example.com"

A deleted domain answers 204 with no body.

The code is in the message field of the answer.

Status Code Where What happened
400 DOMAIN_INVALID_FORMAT, DOMAIN_INVALID_CHARACTERS, DOMAIN_TOO_SHORT Register The name is not a valid domain name.
400 DOMAIN_INVALID_OR_UNSUPPORTED_TLD Register The ending of the name is not valid or not supported.
400 DOMAIN_SUBDOMAIN_NOT_ALLOWED, DOMAIN_USE_ROOT Register A subdomain was sent. Register the root domain.
400 DOMAIN_CONFIRMATION_REQUIRED Delete X-Confirm-Domain is missing or does not match the stored name.
403 API_KEY_ENDPOINT_FORBIDDEN All The key is not allowed to call this operation.
403 API_KEY_ACCESS_DENIED Setup, delete The key cannot act on this domain.
404 DOMAIN_NOT_FOUND Setup, delete No domain has that public id.
409 DOMAIN_ALREADY_REGISTERED, DOMAIN_ALREADY_ACTIVE Register The domain already exists.
409 DOMAIN_PARENT_ALREADY_ACTIVE, DOMAIN_DESCENDANT_ALREADY_ACTIVE Register, delete A domain above or below this one is already active.
409 PARTNER_ENTERPRISE_QUOTA_EXCEEDED Register The account has no Enterprise capacity left.
409 DOMAIN_SETUP_NOT_ALLOWED Register, setup The setup cannot be confirmed for this domain in its current state.
409 DOMAIN_SETUP_REQUIRED Delete The setup is still pending. Complete it first.
409 DOMAIN_HAS_SUBSCRIPTIONS Delete The domain has a subscription.
409 COPY_SOURCE_IS_TARGET Copy settings The source and the target are the same domain.
any COPY_INCOMPLETE Copy settings The copy stopped part of the way. The body says which groups ran.
409 DOMAIN_BUSY All writes Another operation is running on the domain. Try again shortly.
502 DOMAIN_CREATION_UNCONFIRMED, DOMAIN_SETUP_UNCONFIRMED Register, setup The result could not be confirmed. Repeat the same request.
502 DOMAIN_TERMINATION_UNCONFIRMED Delete The delete could not be confirmed. List your domains to see whether it is gone.

The errors that come from the key itself, such as API_KEY_IP_NOT_ALLOWED, are on the Errors page.

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

Loading the endpoints...