API Functions

The following operations can currently be performed with the API:

  • Add, change, and delete domains
  • Add and edit resource records: SRV, MX, CNAME, TXT, A, AAAA, NS, SPF (which is here for compatibility, but not recommended for use--see RFC 7208), and PTR; when a domain is added, SOA records are created automatically with MINIMUM and EXPIRE values set to 300 and 604800 respectively
  • Change the contact email address in SOA records
  • Add and edit reverse records for IP addresses
  • Tag domains

Getting Started

First, you’ll need to obtain a key here.

The actual API is located at https://api.selectel.ru/domains/v1/. Your key will have to be included in GET requests to this address. The X-Sid: <key> parameter will have to be added to POST, PUT, PATCH, and DELETE request headers, but there is one nuance: the key structure is <hash>_<user_id>, but the user_id should be removed when it is added to headers (the parameter will thus be: X-Sid: <has>); however, in query parameters, the key will have to be fully added: api_key=<key>.

API responses are given in JSON format. Requests to change, create, and update a domain return object models. For example:

{
 "user_id": 1,
 "name": "selectel.org",
  "tags": [],
  "change_date": null,
  "create_date": 1427473275,
  "id": 1
}

Requests to delete a domain return a 204 (No Content) code. If an error occurs while carrying out a request, a description will be returned in the following format:

{
 “error”: “error description”,
 “code”: 400-599,
 “field”: “field that the error occurred in”
}

Basic Operations

All request data is sent and returned in JSON format.

Domain Operations

 

Operation

Request

Description

List domains

GET /

Returns a list of domains

Add new domain

POST /

Adds a new domain; the request must include the name of the new domain and the contents of the BIND zone file (optional)

Get domain information

GET /{domain_id}

Returns information on the given domain (name, data created, date last modified, tags, user ID)

Update domain

PATCH / {domain_id}

‘Update domain’ means updating its tags. The domain identification number and identification number of the tags required to mark the domain must be included in the request.

Returns information on the updated domain (name, date created, date last modified, tags, user ID).

Delete domain

DELETE /{domain_id}

Deletes the given domain; if successful, returns code 204 (No Content).

Resource Record Operations

 

Operation

Request

Description

List resource records for specific domain

GET /{domain_id}/records

Returns information on resource records for the given domain (record identifier, name, type, lifespan, date created, date last modified).

Add new resource record

PUT /{domain_id}/records

Adds a new resource record. The record’s identification number, name, and type must be included in the request. Each record type also requires its own specific parameters (visit our test platform for more detailed information).

Update resource record

PUT /{domain_id}/records/{record_id}

‘Update record’ means changing its parameters. The domain’s identification number and record’s name, identification number, and type need to be included in the request. Each record type also requires its own specific parameters (visit our test platform for more detailed information).

Delete resource record

DELETE /{domain_id}/records/{record_id}

Deletes the given resource record; if successful, returns code 204 (No Content).

Reverse Record (PTR) Operations

 

Operation

Request

Description

List resource records for specific domain

GET /ptr/

Returns information on reverse records for the given domain (record identifier, name, type, lifespan, date created, date last modified).

Add new resource record

POST /ptr/

Returns information on all modified reverse records (record identifier, return address, domain name, user ID), including new ones.

View reverse record information

GET /ptr/{ptr_id}

Returns information on the given reverse record (record identification, return address, domain name, user ID)

Update reverse record

PUT /ptr/{ptr_id}

‘Update reverse record’ means changing its parameters. The domain’s identification number, IP address, and domain must be included in the request.

Delete reverse record

DELETE /ptr/{ptr_id}

Deletes the given reverse record; if successful, returns code 204 (No Content).

Tag Operations

To make managing multiple domains easier, our API supports tags. With tags, you can structure a list of existing domains by breaking it into groups. This lets you search domains faster and automate domain array operations.

 

Operation

Request

Description

List tags for specific domain

GET /tags/

Returns a list of name and identifier tags as well as a list of tagged domains.

List domains by tag

GET /tags/{tag_id}

Returns a list of domains marked by the given tag.

Add new tag

POST /tags/

Returns the created tag.

Update tag

PUT /tags/{tag_id}

‘Update tag’ means changing its name. The tag’s identification number and new name must be included in the request.

Delete tag

DELETE /tags/{tag_id}

Deletes the given tag; if successful, returns code 204 (No Content).

Script for Uploading BIND Zones

The script for automating migration can be downloaded here.

To upload a BIND zone, enter the command:

$ bind_upload.py [-h] --key <key> --name <name> --zone <zone>

For the --key parameter value, enter your API access key; for --name, enter the domain name to be added. For the --zone parameter, enter the path to the zone file.

The script returns information on the added domain in JSON format. If any errors occur while adding a resource record, information on the error will be included in the response.