API: authentication

The API works with API keys. A key belongs to a workspace, not to a person, and only works in that workspace.

New

Version 1 of the API has just opened up for your own scripts, with API keys per workspace. What is between [brackets] we have yet to fill in.

API keys

You create a key in the dashboard, under Developer, on the API keys tab. For that you need the Manage API keys permission; owners always have it. You give the key a name and choose what it may do and how long it is valid. You see the key itself once, straight after creating it: store it somewhere safe right away. We only keep a fingerprint of it and cannot show it to you again later.

Because the key belongs to the workspace, it keeps working when the person who created it leaves the workspace. A workspace has at most 25 keys at a time.

Sending a key

Send the key with every request in the Authorization header. A key always starts with srv_, so you recognise it when it turns up somewhere it does not belong. This is how you check that a new key works:

Terminal
curl https://api.servur.com/v1/workspace \
  -H "Authorization: Bearer srv_..."

Without a key, with a key that does not exist, or with a revoked or expired key, the API answers with 401.

What a key may do

Every key may read: the services, DNS zones, domain names, invoices and balance of its workspace. What it may change on top of that you choose when creating it, with the same permissions as members have:

  • Manage services: change DNS records, redirects, templates and DNSSEC, manage nameservers and DS records of domain names, mailboxes, webhosting and VoIP, claim domains, and cancel subscriptions or give them a different term.
  • Transfer services: request the transfer code of a domain name, and start, claim or withdraw a transfer to another workspace. Accepting and confirming is done by an owner in the dashboard.
  • Manage finances: pay orders, renewals and invoices, top up the balance, revoke direct debit mandates and request payment terms. Ordering, and changing a subscription's plan or quantity, needs this permission and Manage services together.
  • Manage details: change domain holders and billing details.
  • Invite people and Manage people: invite people, and remove members or change their permissions. A key never grants the Owner, Manage workspace or Manage API keys permissions, and leaves the owner alone.

If you ask for something the key may not do, the API answers with 403. See error messages.

Only from certain addresses

Give a key the addresses it may be used from: single addresses such as 203.0.113.7 or ranges such as 2001:db8::/48. A request from another address gets 403 with API_KEY_IP_NOT_ALLOWED, even if the key itself is right. That way a leaked key is worthless elsewhere. Without addresses the key works everywhere.

Expiring, renewing and revoking

A key never expires, or expires after 30 days, 90 days or a year. A week before the end, the people who manage the workspace's keys get an email. You can revoke a key at any time, under API keys in the dashboard: the next request with that key already gets a 401.

Renew gives a key a new value, with the same name, permissions and addresses. The old one then keeps working for an hour, a day or a week, or stops straight away, so you can switch your scripts over without them faltering.

What a key did

For every key the dashboard shows its requests from the last thirty days: when, from which address, which endpoint, and what the response was. Open a request for the headers and the body, both ways. Refused requests are in there too, as are requests with the key after it was revoked or expired, so you can see which script is still using it.

A key that still works never appears in full, only its first characters. Cookies, passwords and authorisation codes in a body show as [hidden].

In the activity

What a key changes appears in the workspace's activity and in the DNS zone's history, under the key's name. That way you always see which script did what.

Was this helpful?

Everything for your online success, all in one place

Create an account