Registering a domain

The first two parameters of the function are the usual ones in the DNSimple library: The client struct contains all the authentication and configuration information, and the account_id is your account ID. The third one is domain_name, which is the name of the domain that you want to register. There is one other argument that I want to bring to your attention: attributes.

The attributes parameter corresponds to any extended attributes required by the registry when registering a domain. Some country code TLDs, or ccTLDs—like .es, .us, .uk, etc… require extra information when purchasing a domain. For example, to buy a Spanish domain, such as dnsimple.es, you will have to provide some sort of identification number, like your passport. You can use our TLD API to find out what extended attributes are required by each ccTLD.

Looking at the endpoint input documentation we can see that we can provide up to 5 attributes. However only one of them is mandatory: the registrant_id. (Note that extended_attributes and premium_price are also flagged as such but they are mandatory only under specific circumstances).

The registrant contact

The registrant_id of the contact in your DNSimple account that is used to register the domain. The contact information will show up in the WHOIS details of the domain (unless you have the WHOIS privacy service enabled). A registrant is required by ICANN policy and it is not possible for you to buy a domain without providing the corresponding contact information.

You can use the Contacts.list_contacts/3 function to list the contacts in your account and their corresponding IDs (be sure to replace TOKEN with your access token, and ACCOUNT_ID with your account id when you run this):

What you get back is a DomainRegistration struct. It takes some time for the domain registration to complete, so we create one and return it immediately. Once it finishes you will receive an invoice for the domain registration and a notification in your DNSimple account's email address. And, of course, you will also get a webhook notification!

If any error occurs while starting the registration it will be returned as part of the response:

That's all you have to do to register a domain with DNSimple using Elixir. Once you know what contact to use, registering a domain gets as simple as a function call.

There are more complex scenarios when registering ccTLD domains that require you to provide extended attributes or if the domain is considered premium by the registry. If you have any issues with those cases just drop us a line, support@dnsimple.com and we will be happy to help.