How To Manage Domains Using The DNSimple API - Part 2

After the first part on managing domains using the DNSimple API, here is the follow-up where we will see how to do domain registration operations using the sandbox version of the API.

What do you need to get started?

At this point, here is what you need for using the sandbox API:

  • Create an account on the Sandbox environment: Go to the required page to register your account. It does not have to match your DNSimple production account. More info about the sandbox service is available here. When asked to choose a plan choose Skip this step and choose a plan later at the bottom.

  • To be able to do domain registration operations, a valid subscription is needed: After your login step, visit your account related URL, and there, proceed to select the "Personal" plan. It costs $5 monthly for service on up to 5 domains, and you have a 30 days trial, so the deal is good enough for having this sandbox environment. Once you are ready, complete the process for you plan to be activated.

  • Also, for domains registration, make sure you add a "contact" to your account: Go to the page corresponding to, click on "Add a contact" and fill the form with the details.

  • Almost there! Now, go get the token for the account, as we have previously seen for the production API, via the link "Access tokens" from the account page. Note that the URL should be of the type

Authentication with the Sandbox API

You can start by testing the authentication with the sandbox API, via the /whoami endpoint, using the token:

$ http Authorization:'Bearer YourOAuthToken'

HTTP/1.1 200 OK

    "data": {
        "account": {
            "created_at": "2017-10-30T14:12:06Z",
            "email": "",
            "id": 12345,
            "plan_identifier": "dnsimple-personal",
            "updated_at": "2017-11-11T10:03:51Z"
        "user": null

If all goes well, this request also allows you to confirm the account ID which will be needed for the operations commands. For the command examples I am showing here to be comprehensible, let's say the account ID is 12345.

Let's start doing the common operations

Check if a domain is available and register it

Let's say I am interested into the domain

Using the following GET request on the endpoint /12345/registrar/domains/ (12345 being our example of account ID), we can check if the domain called is available.

$ http Authorization:'Bearer YourOAuthToken'

HTTP/1.1 200 OK

    "data": {
        "available": true,
        "domain": "",
        "premium": false

Based on this result, the domain is available. So we can register it.

One thing to note is that we need the "registrant_id" for the domain registration command. That corresponds to a contact that we have added to the account. Remember I mentioned it at the beginning in the list of setup steps needed? We can fetch that information by using the /12345/contacts endpoint:

$ http Authorization:'Bearer YourOAuthToken'

If all goes well, you will get a 200 OK response, with a JSON data structure containing the contact information and the value of the "id" we are looking for to use in the next request command. Let's say the value is 1357.

The endpoint to use for the registration is /12345/registrar/domains/

$ http POST Authorization:'Bearer YourOAuthToken' registrant_id=1357

HTTP/1.1 201 Created

    "data": {
        "auto_renew": false,
        "created_at": "2017-11-11T10:03:50Z",
        "domain_id": 35709,
        "id": 25446,
        "period": 1,
        "premium_price": null,
        "registrant_id": 1357,
        "state": "new",
        "updated_at": "2017-11-11T10:03:50Z",
        "whois_privacy": false

Done! And when visiting the DNSimple dashboard, you should be able to see the domain.

Next, we will dive into creating a domain (once it is registered) and using DNS management services for it.

comments powered by Disqus

Need help for your project?

I can contribute to your project, working on a specific task, or doing all the coding based on your specifications using a web framework / CMS.