The short answer: when a new client arrives, your program can do through the API what you would otherwise do by hand in Meu MozOut: check that the name is free, register the domain from your account credit, connect it to one of your hosting plans, add the DNS records and create the mailboxes. This guide gives the right order, with the real requests, and the precautions that prevent double charges and refused requests. For an overview of what the API does for resellers, see the API for resellers and agencies.
Before you start: two keys, each with its own job
Keep purchases apart from everything else. That way, if your everyday key leaks, it cannot spend your credit.
| Key |
Permissions |
What for |
| Purchases |
domains:read, domains:write, billing:read, billing:purchase |
Checking names, seeing your credit, registering and renewing domains. With a spending limit that matches what you register. |
| Setup |
hosting:read, hosting:write, dns:read, dns:write, email:read, email:write |
Connecting the domain to a hosting plan, changing DNS, creating mailboxes and requesting SSL. No sensitive permissions. |
billing:purchase is a sensitive permission, off by default: switch it on only for the purchases key. Keys are created on the API page in Meu MozOut, and the step-by-step guide is in creating an API key. Start with sandbox_ keys: reads are real, while changes and purchases are simulated and nothing is charged.
From the client's name to their mailboxes, step by step
| 1 |
Check the name and the price. GET /v1/domains/availability?domain=... tells you whether the name is free (available), the one-year price in one_year_price and whether the name is handled in Meu MozOut (portal_only). If the status is unknown, it could not be confirmed right now and registration through the API will not go ahead.
|
|
| 2 |
Check your credit. Registration is paid only from your account credit, and GET /v1/billing/credit shows how much you have. If it is not enough, the purchase answers 402 and nothing is charged.
|
|
| 3 |
Register the domain with POST /v1/domains/register: domain, years and, if you like, nameservers. Always send the Idempotency-Key header, built from your client's order number: if the connection drops, you repeat with the same value and the domain is neither registered nor charged twice.
|
|
| 4 |
Wait for it to finish. The answer is 202 with an action_id, and GET /v1/actions/{id} says running while it runs, then done or failed. Some extensions, including .mz, are handled manually and take longer: your program checks again later, without repeating the purchase.
|
|
| 5 |
Connect the domain to the hosting plan where the site will live, with POST /v1/services/{id}/addon-domains and the domain (directory is optional). The id comes from GET /v1/services. The domain must be active in your account and point to our nameservers, and it counts towards the plan's site limit.
|
|
| 6 |
Add the DNS records with POST /v1/domains/{domain}/dns, for example an A record for the site or a verification TXT. To check without saving, first send the same body to POST /v1/domains/{domain}/dns/validate.
|
|
| 7 |
Create the mailboxes with POST /v1/services/{id}/email/mailboxes: address, password and quota_mb.
|
|
| 8 |
Request the free SSL certificate with POST /v1/services/{id}/ssl/autossl, which only works for domains already pointing at our servers, and check SPF, DKIM and DMARC with GET /v1/services/{id}/email/authentication.
|
|
The registration, with the purchases key:
curl https://api.mozout.co.mz/v1/domains/register -X POST \
-H "Authorization: Bearer $PURCHASE_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-domain" \
-d '{"domain": "asuaempresa.co.mz", "years": 1}'
The client's first mailbox, with the setup key (88 is the id of your hosting plan):
curl https://api.mozout.co.mz/v1/services/88/email/mailboxes -X POST \
-H "Authorization: Bearer $SETUP_KEY" \
-H "Content-Type: application/json" \
-d '{"address": "info@asuaempresa.co.mz", "password": "...", "quota_mb": 1024}'
|
Creating a mailbox is not safe to repeat. The API never stores the password, so on requests with a password the Idempotency-Key has no effect: repeating the request runs it again. If the connection drops halfway, list the mailboxes with GET /v1/services/{id}/email/mailboxes before trying again. The password must be 12 to 128 characters, with at least 3 kinds among lowercase, uppercase, digits and symbols, and the quota goes from 1 MB up to the plan's disk space.
|
DNS only counts if the domain uses our nameservers
GET /v1/domains/{domain}/nameservers returns the nameservers and uses_our_nameservers. If it is false, the zone you change with us is not the one answering: switch them with PUT /v1/domains/{domain}/nameservers to ours, dns1.mozout.co.mz dns2.mozout.co.mz dns3.mozout.co.mz dns4.mozout.co.mz. DNS management must also be on for the domain: in the list from GET /v1/domains/{domain}/dns, dns_enabled tells you. If it is off, switch it on in Meu MozOut. The details are in DNS through the API.
The answers you will meet, and what to do
| Answer |
When |
What to do |
| 402 insufficient_credit |
There is not enough credit for the registration. Nothing was charged. |
Top up your credit and ask again. |
| 403 spending_limit_exceeded |
The registration goes over the key's spending limit. Nothing was charged. |
Create a key with a higher limit. |
| 422 with portal_url |
The name is handled in Meu MozOut: for example .mz and .ao names of up to 3 characters, or extensions that need documents. |
Follow the link and register it in Meu MozOut. |
| 409 domain_not_owned |
When connecting to the hosting plan, the domain is not yet active in your account. |
Wait for the registration action to finish, then repeat. |
| 409 cname_conflict |
A CNAME with other records on the same name. |
Change or delete the other record. |
| 409 account_email_domain |
The request touches mail for the domain of your account's e-mail, or of one of its users. |
Make that change in Meu MozOut. |
| 429 rate_limited |
You went over a request limit. |
Wait the number of seconds in Retry-After and repeat. |
The limits that matter for a reseller
With many clients, the per-account limits matter more than the key's: buying domains and extras and paying invoices share 5 requests a minute; domain and DNS changes, 20 a minute; e-mail changes, 20 a minute per hosting plan, and passwords 10 a minute. Handle clients in a queue, one at a time, and answer a 429 by waiting for Retry-After. The current values can change: see the API request limits.
What the API does not do for you
| Case |
Where it is done |
| The accounts your clients have inside your reseller hosting |
In the reseller's WHM. See first steps as a reseller. |
| .mz and .ao names of up to 3 characters, .ac.mz, .gov.mz and .mil.mz, extensions that need extra holder details, transfers of .mz and .ao |
In Meu MozOut. |
| Changing a domain's contacts and holder |
Not in the API yet: it is done in Meu MozOut. |
| Adding to a hosting plan a domain registered elsewhere |
In the hosting plan's cPanel. |
|
After registration, renewal: PUT /v1/domains/{domain}/auto-renew turns the renewal invoices for each domain on or off, and POST /v1/domains/{domain}/renew renews whenever you choose. If you are still deciding how to organise your clients, see reseller hosting or one plan per client. The plans are on the reseller hosting page and the prices on domain pricing.
|
|
Want to automate new client set-up? The API page has the documentation and the button to create your first key.
See the API page
|