The key feature of Exoscale DNS resides in its simple JSON API, which allows you to program hosted zones and records.

We assume for this guide that you have already chosen a zone bundle. If you have not chosen a zone bundle yet, refer to the quickstart to select one.

An X-DNS-Token is used for authentication. The X-DNS-Token header follows this layout: API_KEY:API_SECRET.

In the following examples, should be replaced by your API_KEY:API_SECRET.

Configuring a zone with the API

Create the example.com zone:

curl -H 'X-DNS-Token: <token>' \
     -H 'Accept: application/json' \
     -H 'Content-Type: application/json' \
     -d '{"domain":{"name":"example.com"}}' \
     -X POST \
     https://api.exoscale.com/dns/v1/domains

View the zone:

curl -H 'X-DNS-Token: <token>' \
     -H 'Accept: application/json' \
     https://api.exoscale.com/dns/v1/domains

Configuring a machine record

To configure a record, we need to pass some JSON to our curl request.

We want to create an A record named ‘web’ pointing to the IP 1.2.3.4:

{
  "record":
  {
    "name": "web",
    "record_type": "A",
    "content": "1.2.3.4",
    "ttl": 3600
  }
}

The request will be:

curl  -H 'X-DNS-Token: <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X POST \
      -d '{"record":{"name": "web","record_type": "A","content": "1.2.3.4","ttl": 3600}}' \
      https://api.exoscale.com/dns/v1/domains/example.com/records

Configuring an alias record

We want to create a CNAME record named ‘www’ pointing to ‘web.example.com’:

{
  "record":
  {
    "name": "www",
    "record_type": "CNAME",
    "content": "web.example.com",
    "ttl": 3600
  }
}

The request will be:

curl  -H 'X-DNS-Token: <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X POST \
      -d '{"record":{"name": "www","record_type": "CNAME","content": "web.example.com","ttl": 3600}}' \
      https://api.exoscale.com/dns/v1/domains/example.com/records

Configuring a Mail Exchange record

We want to create an MX record pointing to ‘mail.example.com’:

{
  "record":
  {
    "name": "",
    "record_type": "MX",
    "content": "mail.example.com",
    "ttl": 3600,
    "prio": 10
  }
}

The request will be:

curl  -H 'X-DNS-Token: <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X POST \
      -d '{"record":{"name": "","record_type": "MX","content": "mail.example.com","ttl": 3600,"prio":10}}' \
      https://api.exoscale.com/dns/v1/domains/example.com/records

Configure my domain to point to an IP

We want the domain ‘example.com’ to point to ‘1.2.3.4’:

{
  "record":
  {
    "name": "",
    "record_type": "A",
    "content": "1.2.3.4",
    "ttl": 3600
  }
}

The request will be:

curl  -H 'X-DNS-Token: <token>' \
      -H 'Accept: application/json' \
      -H 'Content-Type: application/json' \
      -X POST \
      -d '{"record":{"name": "","record_type": "A","content": "1.2.3.4","ttl": 3600}}' \
      https://api.exoscale.com/dns/v1/domains/example.com/records