Registrar API
How a billing system (a platform that sells domain names) uses Salt to find
out what a name costs, register it, renew it and manage it. Salt holds the
registrar account and its credentials; the billing system never sees them. It
sees a token, references it chooses, and money as whole numbers. The OpenAPI
document (/api/v1/openapi.json) has every field. The module and how it works
inside are in registrar.md.
The registrar API exists only while SALT_DNS_REGISTRAR=on; otherwise every
route below answers 404.
1. The token and its level
A token's access to the registrar is its own setting, the registrar level, and zone grants do not count:
| Level | May do |
|---|---|
none (the default) | nothing: every registrar call is 403 |
read | account, check, prices, list and read domains, read operations |
purchase | everything, including the calls that spend money |
An owner or admin sets the level when they create a token in the console (Credentials for an ordinary token, Provisioning for a provisioning token) and can change it there later. From the command line, a provisioning token with a level:
bin/salt_dns eval 'IO.puts(SaltDns.Release.create_provisioning_token(1, "me@example.org", "domains", registrar: :purchase))'
Use a separate token for the registrar, so that the token that creates zones cannot buy names.
An ordinary token acts in its own organisation. A provisioning token
names the customer in the X-Salt-Organisation header, as on the provisioning
routes. It must send the header on every call tied to a customer or a domain.
It may leave it out on the three platform calls (account, check, prices) and
then acts for its provider organisation.
2. Which registrar account
The calls use the active provider of the token's own organisation (the oldest that is not turned off). A provisioning token's customers are served by the provider of the provisioning token's own organisation.
A shared provider (one that belongs to no organisation, made by the
operator) is used only by the organisations the operator has allowed
(SaltDns.Release.registrar_allow/2, from the command line; no console page
and no API call can do it). An organisation that is not on the list has no
provider through the shared one at any level, reading the account included:
every route answers 503 registrar_unavailable with "cause": "no_provider".
An allowed organisation's provisioning token serves that organisation's
customers too. Giving a token a registrar level on the console is only offered
to an organisation that has a provider it may use.
With no provider the answer is 503 registrar_unavailable. Providers are set
up in the console (Registrar) or by the operator.
Authentication comes first, as on every route, and may answer before the switch
and the level are looked at: a request without a valid token is a 401, and a
provisioning token without X-Salt-Organisation on a route that requires it
gets 400 organisation_required (or 404 for an organisation that is not its
child). A request that passes authentication, with the module switched off, gets
404 not_found (the same as /proxy with routing off), before the level of
the token is looked at; so "a valid token gets 404 while the module is off" holds
for a request that passes authentication.
Calls through a domain follow the same rule as spending. A route that makes
a call to the registrar through a domain, or hands out something secret (reading
a pending domain from the registrar, the owner contact's verification state, the
authorisation code, renewing, restoring, abandoning an operation, contact
changes), needs the caller's own registrar account to be the one the domain is
held at: the active provider of the token's own organisation, as described
above. A customer organisation with an ordinary token of its own, with or without
an account of its own, is not served by its parent's account: it may read the
stored record of its domain (GET /registrar/domains, /domains/{fqdn} with
verification null, /operations/{reference}) and nothing more. It gets the
authorisation code only through the provider's own token; anything else is 503
registrar_unavailable with the cause no_provider, and no call is made.
A body that is not a JSON object (an array, a number, a string, null) is a
422 invalid with the error invalid_body.
Every spending call, contact change, authorisation-code read and abandon keeps the id of the token that asked (never the token itself) and the acting organisation on the operation and on its events. The console's operations list shows the token's name.
3. Which calls spend money
Only register, transfer, renew and restore spend money: PUT /registrar/domains/{fqdn} (with kind register or transfer), POST /registrar/domains/{fqdn}/renew and POST /registrar/domains/{fqdn}/restore.
Everything else is free: account, check, prices, contacts, the verification
e-mail, reading a domain, the list, the operations and the authorisation code.
(Contacts, the verification call and the authorisation code need the
purchase level all the same.)
| Call | Level | Header | Answer |
|---|---|---|---|
GET /registrar/account | read | optional | balance and reserved (money), currency, mode, provider name |
POST /registrar/check | read | optional | per name: status, costs, promotion, periods |
GET /registrar/prices?extension=com&period=2 | read | optional | the price block of one extension for a period |
PUT /registrar/contacts/{ref} | purchase | required | ref, version, state |
POST /registrar/contacts/{ref}/verification | purchase | required | sends the e-mail again, returns the state |
PUT /registrar/domains/{fqdn} | purchase | required | the operation: 200 done, 202 pending |
PUT /registrar/domains/{fqdn}/name-servers | purchase | required | the domain, with its name servers and their glue |
GET /registrar/domains | read | required | the organisation's domains |
GET /registrar/domains/{fqdn} | read | required | state, dates, lock, name servers, verification |
POST /registrar/domains/{fqdn}/renew, /restore | purchase | required | the operation |
POST /registrar/domains/{fqdn}/auth-code | purchase | required | the code, once |
GET /registrar/operations/{reference} | read | required | the ledger row |
POST /registrar/operations/{reference}/abandon | purchase | required | gives up a stuck operation, after a lookup |
4. Money
Money has one shape everywhere in the answers: {"minor": 1117, "currency": "USD"}, whole numbers in minor units (cents), never a float. Requests send the
price ceiling as cost_ceiling_minor with currency (or as a cost_ceiling
object of the same shape). Salt returns cost prices; any fee is yours to add.
The currency is the registrar account's. GET /registrar/account says
which it is. A request in another currency is refused as invalid with the
field currency named; Salt never converts and never ignores it. On a
registration or transfer the currency is required; on a renewal or restore it
may be left out and is then the account's.
Nothing is bought on credit and there is no overall spending cap. The only limit is the ceiling of each call; the registrar account's balance is the rest.
An operation shows three amounts:
cost_ceiling: the most you accepted;cost_quoted: the price Salt read from the registrar immediately before it ordered, written on the row before the order goes;cost_charged: the same price once the order call itself succeeded.cost_confirmedsays whether it is set. An operation completed from a lookup after a lost answer has a quote and no charge (cost_chargednull,cost_confirmedfalse): Salt cannot say what was charged.
5. Checking and prices
POST /registrar/check takes at most 15 names, as {"name": "example", "extension": "org"} or plain "example.org", "fresh": true to skip the
price cache (a few minutes) and "period" (years, default 1, for all names).
GET /registrar/prices?extension=com&period=2 gives the same block for one
extension. For that period, each answer has:
costs.create,costs.renew,costs.transfer: totals for the period, read from the registrar with the period and never multiplied (a promotion often covers the first year only, so two years can cost far more than twice one).costs.restoreis one restore.costs.renew_yearly: the price of renewing for one year, what a customer pays each year afterwards.promotion: null, or{"ends_on": "2026-12-31", "non_promotion": {money}}, wherenon_promotionis the price for the same period without the promotion.min_period,max_period,privacy_allowed,quarantine_days,soft_quarantine_days,fetched_at. For a name, alsostatus(free,taken,premium,unavailable).
quarantine_days and soft_quarantine_days are two different facts, both in
days, passed through as the registrar reports them for the extension. Either
may be null or 0. soft_quarantine_days is the period after expiry in which
the name can still be renewed or restored before it is deleted, as the registrar
defines it. Salt does not interpret either. Live values: .com has
quarantine_days 0 and soft_quarantine_days 40; .nl has quarantine_days 38
and soft_quarantine_days 0.
Reads are kept from becoming calls to the registrar at the caller's pace:
whether a name is free is kept for 2 minutes per name ("fresh": true asks
again), the price lists for a few minutes per extension and period, a pending
domain is read from the registrar at most once a minute, and the verification
state of the owner contact is kept for a minute.
A period outside min_period and max_period is 422 invalid with the field
period. An extension the registrar does not sell is 422
unsupported_extension. The cache is per extension and period. For a period
longer than one year costs.create is the price of the extension, not of the
name; a premium name is priced when it is ordered, against your ceiling.
6. Contacts
PUT /registrar/contacts/{ref} with the registrant's data (name with
first_name and last_name, company_name, email, phone, address,
locale) and a version. Salt sends the data to the registrar and keeps only
your reference, the version and the registrar's handle. The same version again
sends nothing; a higher one updates the contact at the registrar; an older one
is refused. A refusal by the registrar is 422 invalid_contact with the
fields in errors. The body is never written to a log. Admin, tech and billing
contacts of every name are the provider's company contact; you send only the
owner.
7. Registering, transferring, renewing, restoring
A registration is told from a transfer by the kind field of PUT /registrar/domains/{fqdn}: "register" or "transfer". auth_code is sent
only with a transfer (and required there). Neither needs a zone for the name
in Salt first: the registrar module only sets the name servers on the name at
the registrar. Zones are created by the caller through the existing zone
routes.
PUT /api/v1/registrar/domains/example.org
{"reference": "order-17", "kind": "register", "years": 1, "contact_ref": "owner-9",
"privacy": true, "cost_ceiling_minor": 1500, "currency": "USD"}referenceis yours and unique per organisation. The same reference with the same request returns the stored result and buys nothing, also while the first call is still running. The same reference with another request is409reference_reuse. After an error withfinal: false, call again with the same reference: Salt first looks the name up at the registrar before it orders anything (see section 9).cost_ceiling_minor(withcurrency) is the most you accept to pay for the whole period. Salt reads the price again immediately before it orders and refuses with409price_above_ceiling(withcurrent_cost) if it is higher or in another currency.- A premium name is refused (
422invalid) unless"allow_premium": true. kind: "transfer"needsauth_code(sent to the registrar, never stored or logged) and is usually202pending. Renew and restore takereference,years(renew),cost_ceiling_minorand optionallycurrency(the currency of the registrar account when left out).- Salt sets its own name servers on a new name and turns the registrar's
automatic renewal off. It does not create a DNS zone. Send
name_serversto use others: a list of host names or objects withnameand the optionalipv4andipv6. A name server that is the domain itself or under it needs an address (glue), or the request is422invalid; an address on one outside the domain is422too (a registry ignores or refuses it, and Salt does not drop it silently). Left out, Salt's own name servers are used. 200meansdone(dates and the amounts of section 4 in the answer);202meanspending(the registrar has not finished) orstarted(a repeat while the first call is still running): readGET /registrar/operations/{reference}or the domain until it is done. A background job also resolves pending operations and finishes operations that were cut short; it never places an order itself.
Name servers and glue
PUT /registrar/domains/{fqdn}/name-servers replaces them without spending
money:
{"name_servers": [
{"name": "ns1.trouweherverdeling.nl", "ipv4": "65.109.158.98"},
{"name": "ns2.trouweherverdeling.nl", "ipv4": "65.108.4.21", "ipv6": "2a01:7c8::21"}
]}The answer is the domain, with name_servers (the host names) and
name_server_addresses (the glue, keyed by name server; only the families
present). sync_domain (the daily read, and a read of a pending domain) keeps
the addresses the registrar reports, so a later change that names the same
server without an address keeps its stored glue.
8. Errors
Problem documents, type urn:salt-dns:problem:<code>. Every error body of
the registrar routes carries "final": true|false, and a 503 or 429 says why in
"cause" when it can be told:
| Code | Status | final | Meaning |
|---|---|---|---|
insufficient_funds | 402 | true | The registrar account cannot pay; nothing was bought. |
name_unavailable | 409 | true | The name cannot be registered, or is held or being ordered. |
price_above_ceiling | 409 | true | Has current_cost and cost_ceiling (money). |
reference_reuse | 409 | true | The reference belongs to another request. |
locked | 409 | true | The name is locked, or in a state that forbids it. |
invalid, invalid_contact | 422 | true | The request is wrong; errors lists the fields. |
unsupported_extension | 422 | true | The registrar does not sell that extension. |
rate_limited | 429 | false | Retry-After and retry_after say how long to wait. cause: rate_limited. |
registrar_unavailable | 503 | false | cause: registrar_login (Salt's own login at the registrar fails; its text is not shown), network, registrar_error (a server error), no_provider (no registrar account is configured). |
not_found | 404 | true | No such domain, contact or operation. |
provider | 502 | false | Any other registrar problem. |
operation_not_abandonable | 409 | true | The operation is done or failed. |
operation_in_progress | 409 | false | A call may still be running; try again later. |
too_early | 409 | false | Abandon found nothing at the registrar, but the last attempt is too young to conclude that nothing was ordered (a timed-out order may still complete). Nothing changed; Retry-After and retry_after say how many seconds to wait. |
forbidden | 403 | true | The token's registrar level is too low. |
organisation_required | 400 | true | A provisioning token must name the customer in X-Salt-Organisation. |
For an error on a route with no reference, final is whether repeating the
identical call can succeed.
9. Retrying and references
- After an error with
final: false(rate_limited,registrar_unavailable,provider), repeat the call with the same reference. Salt looks the name up at the registrar first and completes the operation from what it finds; it orders only if the name is not there. - After an error with
final: true, the reference is burned: the same reference gets the same answer for ever. Make a new reference for the next attempt (with a new quote if the price moved). - A good form is
<order id>-<attempt>:order-17-1, thenorder-17-2. - If an operation is stuck for good (it stays
startedafter the retries),POST /registrar/operations/{reference}/abandonlooks the name up and tells you plainly what it found:
{"outcome": "nothing_ordered", "operation": {"state": "failed", "...": "..."}} nothing_ordered: the registrar shows no such name in the account; the
operation is failed and final, and it is safe to refund. registered: the name
is at the registrar; the operation was completed instead, so do not
refund. If the lookup itself fails the answer is 503 (final: false) and
nothing changes. It is 409 for an operation that is done or failed, that
may still be running, or (too_early) whose last attempt is younger than the
stale time while the lookup finds nothing: wait the retry_after seconds.