Skip to content
Open console

Manage DNS with the API

Manage DNS records over the REST API. Every request uses the base URL https://api.zcp.zsoftly.ca/api and sends a Bearer token in the Authorization header. See Authentication to create a token.

curl -s "https://api.zcp.zsoftly.ca/api/dns/domains" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json" | jq '.data'

Response:

{
"status": "Success",
"message": "OK",
"total": 1,
"data": [{ "name": "example.com", "slug": "examplecom", "status": true }]
}

Pass the zone slug. The response lists every record, including the SOA and NS records ZCP adds for you.

curl -s "https://api.zcp.zsoftly.ca/api/dns/domains/examplecom" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json" | jq '.data.records'

The API groups records by name and type and returns the values under contents. A name and type hold several values, so contents carries one entry per value. See Several values per name and type.

{
"name": "www.example.com.",
"type": "A",
"ttl": 14400,
"contents": ["203.0.113.10"]
}

POST to the zone’s records path. The name field is relative to the zone. Send www, not www.example.com. Use @ for the zone root.

curl -s -X POST "https://api.zcp.zsoftly.ca/api/dns/domains/examplecom/records" \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{ "name": "www", "type": "A", "content": "203.0.113.10", "ttl": 14400 }'

Response:

{ "status": "Success", "message": "Domain record created successfully." }

There is no update endpoint. To change a record, delete it and create it again with the new value.

An MX record needs a priority field alongside content. Send the mail server in content and the preference number in priority.

curl -s -X POST "https://api.zcp.zsoftly.ca/api/dns/domains/examplecom/records" \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{ "name": "@", "type": "MX", "content": "mail.example.com.", "priority": 10, "ttl": 3600 }'

The record then resolves as 10 mail.example.com.. Omitting priority on an MX record fails.

DELETE the zone’s records path with name, type, and content query parameters. Here name is the fully qualified record name with a trailing dot. content must match one record value exactly and must be URL encoded.

Each request deletes one value, not the whole record set. Repeat the request for every value you want to remove. For MX, include the priority and target together in content, for example 0 mail.example.ca.. For TXT and CAA, include the DNS quotes in content, then URL encode the complete value. For example, use "v=spf1 -all" for TXT and 0 issue "letsencrypt.org" for CAA.

Use zcp dns record-delete when you want the CLI to read the existing values and issue one delete request for each one.

curl -s -X DELETE --get \
"https://api.zcp.zsoftly.ca/api/dns/domains/examplecom/records" \
--data-urlencode "name=www.example.com." \
--data-urlencode "type=A" \
--data-urlencode "content=203.0.113.10" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"

Response:

{ "status": "Success", "message": "Domain record deleted successfully." }

The complete interactive reference is the Swagger UI: Open the Cloud Platform API.

See also: DNS Overview, Domains, DNS Records, Worked examples, Manage DNS with the CLI, Troubleshooting, API Quickstart

Ask the ZCP docs

Type a question and pick an assistant. The assistant opens in a new tab and reads this page and the full ZCP documentation, so its answer comes from our docs.

Example questions

Ask with

Your question goes to the assistant you pick, under its own terms.