DNS API
Manage DNS domains and records programmatically
Overview
The DNS API allows you to manage DNS domains and records. You can create domains, add/update/delete DNS records, validate domain names, and retrieve DNS region information.
GET List DNS Domains
Retrieve a list of DNS domains for the authenticated customer.
Request
GET /api/rest/v2.9/dns/domain
Response
{
"code": "OK",
"message": "Domains Retrieved Successfully",
"data": [
{
"id": 123,
"name": "example.com",
"customerId": 456,
"regionId": 1,
"regionName": "Global Default",
"records": [...]
}
],
"matches": 1
}
GET Get DNS Domain
Retrieve a single DNS domain by ID, including all its records.
Request
{
"cmd": "dns.domain.get",
"id": 123
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=dns.domain.get&id=123');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.get(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
params={'cmd': 'dns.domain.get', 'id': 123},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X GET "https://api.rackcorp.net/api/rest/v2.9/json.php?cmd=dns.domain.get&id=123" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
GET /api/rest/v2.9/dns/domain/123 Authorization: Bearer YOUR_JWT_TOKEN
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Yes | Domain ID (from path parameter) |
Response
{
"code": "OK",
"message": "Domain Retrieved Successfully",
"data": {
"id": 123,
"name": "example.com",
"customerId": 456,
"regionId": 1,
"regionName": "Global Default",
"records": [
{
"id": 789,
"name": "www",
"type": "A",
"data": "192.0.2.1",
"ttl": 3600
}
]
}
}
POST Create DNS Domain
Create a new DNS domain.
Request
{
"cmd": "dns.domain.create",
"name": "example.com",
"customerId": 456,
"regionId": 1
}
<?php
$ch = curl_init('https://api.rackcorp.net/api/rest/v2.9/json.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'cmd' => 'dns.domain.create',
'name' => 'example.com',
'customerId' => 456,
'regionId' => 1
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_JWT_TOKEN',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
curl_close($ch);
?>
import requests
response = requests.post(
'https://api.rackcorp.net/api/rest/v2.9/json.php',
json={
'cmd': 'dns.domain.create',
'name': 'example.com',
'customerId': 456,
'regionId': 1
},
headers={'Authorization': 'Bearer YOUR_JWT_TOKEN'}
)
data = response.json()
curl -X POST "https://api.rackcorp.net/api/rest/v2.9/json.php" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cmd": "dns.domain.create",
"name": "example.com",
"customerId": 456,
"regionId": 1
}'
POST /api/rest/v2.9/dns/domain
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json
{
"name": "example.com",
"customerId": 456,
"regionId": 1
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Domain name (e.g., "example.com") |
customerId |
integer | Yes | Customer ID that owns the domain |
regionId |
integer | No | DNS region ID (default: 0 for Global Default) |
Response
{
"code": "OK",
"message": "Domain Created Successfully",
"id": 123
}
PUT Update DNS Domain
Update an existing DNS domain.
Request
PUT /api/rest/v2.9/dns/domain/123
Content-Type: application/json
{
"id": 123,
"name": "updated.example.com",
"regionId": 2
}
Response
{
"code": "OK",
"message": "Domain Updated Successfully"
}
GET Get DNS Record
Retrieve a single DNS record by ID.
Request
GET /api/rest/v2.9/dns/records/789
Response
{
"code": "OK",
"message": "Record Retrieved Successfully",
"record": {
"id": 789,
"name": "www",
"type": "A",
"data": "192.0.2.1",
"ttl": 3600,
"domainId": 123,
"regionId": 1,
"customerId": 456
}
}
POST Create DNS Record
Create a new DNS record.
Request
POST /api/rest/v2.9/dns/records
Content-Type: application/json
{
"name": "www",
"type": "A",
"data": "192.0.2.1",
"ttl": 3600,
"domainId": 123,
"regionId": 1,
"customerId": 456
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Record name (hostname, e.g., "www", "@", "mail") |
type |
string | Yes | Record type (A, AAAA, CNAME, MX, TXT, NS, etc.) |
data |
string | Yes | Record data (IP address, hostname, text, etc.) |
ttl |
integer | No | Time to live in seconds (default: 3600) |
domainId |
integer | Yes | Domain ID this record belongs to |
regionId |
integer | No | DNS region ID (default: 0) |
customerId |
integer | Yes | Customer ID that owns the record |
Response
{
"code": "OK",
"message": "Record Created Successfully",
"data": {
"id": 789,
"name": "www",
"type": "A",
"data": "192.0.2.1",
"ttl": 3600
}
}
PUT Update DNS Record
Update an existing DNS record.
Request
PUT /api/rest/v2.9/dns/records/789
Content-Type: application/json
{
"id": 789,
"data": "192.0.2.2",
"ttl": 7200
}
Response
{
"code": "OK",
"message": "Record Updated Successfully",
"data": {
"id": 789,
"name": "www",
"type": "A",
"data": "192.0.2.2",
"ttl": 7200
}
}
DELETE Delete DNS Record
Delete a DNS record.
Request
DELETE /api/rest/v2.9/dns/records/789
Response
{
"code": "OK",
"message": "Record Deleted Successfully"
}
GET Get DNS Regions
Retrieve all available DNS regions.
Request
GET /api/rest/v2.9/dns/regions
Response
{
"code": "OK",
"message": "Regions Retrieved Successfully",
"regions": [
{
"id": 0,
"name": "Global Default",
"code": "GLOBAL",
"parentId": null
},
{
"id": 1,
"name": "Australia",
"code": "AU",
"parentId": 0
}
]
}
GET Validate Domain Name
Validate if a domain name is in a valid format.
Request
GET /api/rest/v2.9/dns/validatedomainname?name=example.com
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Domain name to validate |
Response
{
"code": "OK",
"valid": true,
"message": "Valid Domain Name"
}
DNS Record Types
Supported DNS record types:
- A - IPv4 address record
- AAAA - IPv6 address record
- CNAME - Canonical name record
- MX - Mail exchange record
- TXT - Text record
- NS - Name server record
- SRV - Service record
- PTR - Pointer record
Error Responses
If an error occurs, the API will return a response with code: "FAULT":
{
"code": "FAULT",
"message": "Error message"
}