16 API Domains
Lukas Metzger edited this page 2018-04-09 16:13:49 +02:00

Domains

Get list of domains

GET /domains?page=5&pagesize=10&query=foo&sort=id-asc,name-desc,type-asc,records-asc&type=MASTER

parameter explanation
page The page of the results to return, if omitted returns page 1
pagesize How many items should be on each page, if omitted page size is infinite therefore all results are returned
query A search query
sort A comma separated list of field names to sort (in this order) combined with the sort order (see example)
type Filter for specific type, if omitted return all types

Response

code result
200 Everything was successful
{
  "paging": {
    "page": 5,
    "total": 20,
    "pagesize": 10
  },
  "results": [
    {
      "id": 1,
      "name": "example.com",
      "type": "MASTER",
      "records": 21
    },
    {
      "id": 2,
      "name": "example.com",
      "type": "SLAVE",
      "master": "12.34.56.78",
      "records": 10
    }
  ]
}

Create new domain

POST /domains

Note this won't create a SOA record for the domain, so it stays invalid until the SOA is set using the API below.

Can currently only be called by an admin user.

Body

{
  "name": "example.com",
  "type": "MASTER"
}

Or for a slave zone:

{
  "name": "example.com",
  "type": "SLAVE",
  "master": "12.34.56.78"
}

Response

code result
201 Everything was successful, domain has been created
400 Type is invalid
409 A domain with that name already exists
422 One of the required fields is missing
{
  "id": 21,
  "name": "example.com",
  "type": "MASTER"
}

Or for a slave zone:

{
  "id": 21,
  "name": "example.com",
  "type": "SLAVE",
  "master": "12.34.56.78"
}

Delete domain

DELETE /domains/{id}

Can currently only be called by an admin user.

Response

code result
204 Everything was successful, the answer body is therefore empty
404 The given domain id does not exist

Get single domain

GET /domains/{id}

Response

code result
200 Call was successful
404 The given domain id does not exist
{
  "id": 1,
  "name": "example.com",
  "type": "MASTER",
  "records": 21
}

Or for a slave zone:

{
  "id": 1,
  "name": "example.com",
  "type": "SLAVE",
  "master": "12.34.56.78",
  "records": 10
}

Update domain

PUT /domains/{id}

This is only valid for slave zones to update the master. All other fields will be ignored.

User needs permission for the given domain.

Body

{
  "master": "1.2.3.4"
}

Response

code result
204 Everything was successful, the answer body is therefore empty
404 The given domain id does not exist
405 The given domain is not a slave zone
422 One of the required fields is missing

Get SOA information

GET /domains/{id}/soa

Does not work for slave zones.

Response

code result
200 Call was successful
404 The given domain id does not exist or has no SOA record
{
  "primary": "ns1.example.com",
  "email": "hostmaster@example.com",
  "refresh": 3600,
  "retry": 900,
  "expire": 604800,
  "ttl": 86400,
  "serial": 2017121801
}

Update SOA information

PUT /domains/{id}/soa

Does not work for slave zones.

Body

{
  "primary": "ns1.example.com",
  "email": "hostmaster@example.com",
  "refresh": 3600,
  "retry": 900,
  "expire": 604800,
  "ttl": 86400
}

Response

code result
204 Everything was successful, the answer body is therefore empty
404 The given domain id does not exist
405 The given domain was not a master or a native zone
422 One of the required fields is missing