Get started
Errors
Every error has the same shape: an HTTP status, a fixed type, and a stable code your code can branch on.
The error shape
422 Unprocessable Entity
{
"error": {
"type": "invalid_request_error",
"code": "domain_unavailable",
"message": "demo-domain-2.com is not available.",
"param": "domains[1]",
"request_id": "8f2c1e9a-4b7d-4e2a-9c1d-2b5a7e9f0c3d",
"doc_url": "https://docs.scaledmail.com/v2/errors#domain_unavailable"
}
}| Field | Meaning |
|---|---|
type | One of the eight types below. Never changes for a given code. |
code | Stable snake_case code. Branch on this. |
message | For people. The wording may change, so don't parse it. |
param | Only when one field or header is at fault, e.g. domains[1] or Workspace. |
errors | Only with validation_ when several fields are wrong: every field problem at once, each with param, code, message. These inner codes come from our validator (e.g. invalid_, invalid_, too_) and may change. |
request_ | The id of this request, a UUID. Also sent as the Request-Id header on every answer. Quote it when you contact support. |
doc_ | A link to the code on this page. |
Several field problems
{
"error": {
"type": "invalid_request_error",
"code": "validation_failed",
"message": "2 fields are not valid.",
"errors": [
{ "param": "tag", "code": "too_big", "message": "Too big: expected string to have <=60 characters" },
{ "param": "interval_months", "code": "invalid_type", "message": "Invalid input: expected number, received string" }
],
"request_id": "8f2c1e9a-4b7d-4e2a-9c1d-2b5a7e9f0c3d",
"doc_url": "https://docs.scaledmail.com/v2/errors#validation_failed"
}
}Error types
| Type | Status | Meaning | What to do |
|---|---|---|---|
authentication_ | 401 | The token is missing, wrong, expired or revoked, or is a v1 token. | Fix the token. Don't retry. |
permission_ | 403 | The token is valid but can't do this: missing scope or workspace. | Change the token's scopes or workspaces. |
invalid_ | 400, 422 | The request is malformed (400) or valid but can't be done (422). | Fix the request. Retrying the same body fails again. |
not_ | 404 | The object doesn't exist in this workspace. | Check the id and the workspace. |
conflict_ | 409 | The object's state does not allow this right now. | Read the object again, then decide. |
payment_ | 402 | The charge failed. Nothing was bought. | Ask the account owner to update the card, then send the call again. |
rate_ | 429 | Too many calls, or too many calls with a wrong token. | Wait for Retry-After seconds, then retry. |
api_ | 500, 501, 503 | Something failed on our side, a provider we depend on is down, or the feature isn't available yet (501). | Retry with backoff. A purchase (POST /orders, POST /orders/:id/add-domains, POST /domain-purchases) only after checking it wasn't made; never after needs_, order_ or 501. |
Error codes
These are the codes the API sends today, grouped by area. New codes may be added within v2: handle a code you don't know by its type. A code can appear with more than one status (e.g. not_): the status and type tell them apart.
Tokens and access
| Code | Type | Status | Meaning |
|---|---|---|---|
missing_ | authentication_ | 401 | No Authorization: Bearer <token> header. |
invalid_ | authentication_ | 401 | The token doesn't exist. Check that you copied the whole token. |
token_ | authentication_ | 401 | The token has passed its expiry date. Create a new one. |
token_ | authentication_ | 401 | The token was revoked. Create a new one. |
wrong_ | authentication_ | 401 | An API v1 token was sent to v2. v2 needs a v2 token. |
missing_ | permission_ | 403 | The token lacks the scope named in param. |
workspace_ | invalid_ | 400 | The Workspace header is missing. It is required on every call that works on a workspace. |
workspace_ | permission_ | 403 | The token doesn't cover the workspace in Workspace. |
no_ | permission_ | 403 | The person who made the token is no longer an owner or admin of its workspace. |
role_ | permission_ | 403 | The person who made the token may not do this in this workspace (owners and admins only). |
not_ | permission_ | 403 | The person who made the token may not do this, e.g. rename the workspace or read its invoices. |
account_ | permission_ | 403 | The account is blocked. Contact support. |
test_ | permission_ | 403 | Test tokens aren't available. Use a live token. |
too_ | rate_ | 429 | Too many calls with a missing or wrong token from your address. Wait a minute. |
Request format
| Code | Type | Status | Meaning |
|---|---|---|---|
invalid_ | invalid_ | 400 | The body isn't valid JSON, is too large, or doesn't fit this endpoint. |
validation_ | invalid_ | 400 | A field is invalid (param names it). With several problems, errors lists them all. |
parameter_ | invalid_ | 400 | A required field is missing (param). |
parameter_ | invalid_ | 400 | A field can't be used here, e.g. with this product or domain source (param). |
invalid_ | invalid_ | 400 | A query value has the wrong type, format or enum value (param). |
invalid_ | invalid_ | 400 | The cursor is not one this list gave out. |
invalid_ | invalid_ | 400 | The status filter has a value that doesn't exist. |
route_ | not_ | 404 | No endpoint at this method and path. |
Payment
| Code | Type | Status | Meaning |
|---|---|---|---|
no_ | payment_ | 402 | The paying workspace has no saved card. |
card_ | payment_ | 402 | The card was declined. |
authentication_ | payment_ | 402 | The bank wants 3-D Secure. Pay once in the portal to confirm the card. |
payment_ | payment_ | 402 | The charge failed, or an earlier call with this token failed. Use a new token to try again. |
not_ | permission_ | 403 | This workspace is billed by invoice or buys only into its own subscription. Contact support. |
Workspaces and billing
| Code | Type | Status | Meaning |
|---|---|---|---|
name_ | invalid_ | 400 | The workspace name is empty or too long. |
cannot_ | permission_ | 403 | The token doesn't have Can create workspaces turned on. |
parent_ | permission_ | 403 | Only owners and admins of the main can add sub-workspaces. |
parent_ | not_ | 404 | parent_ isn't a workspace your token covers. |
parent_ | invalid_ | 422 | parent_ is a sub-workspace. Sub-workspaces can't have subs. |
main_ | invalid_ | 422 | The main in parent_ is billed outside Stripe (direct billing), so it can't have sub-workspaces. |
workspace_ | invalid_ | 422 | Only a main workspace can do this, e.g. list invoices with workspace=all. |
workspace_ | conflict_ | 409 | The owner already has the most workspaces allowed. |
sub_ | conflict_ | 409 | The main workspace already has 10 sub-workspaces. |
name_ | conflict_ | 409 | A workspace with this name already exists. |
Products, quotes and orders
| Code | Type | Status | Meaning |
|---|---|---|---|
split_ | invalid_ | 400 | The provider split doesn't add up to 100. |
billing_ | invalid_ | 400 | This billing period isn't offered for the product. |
interval_ | invalid_ | 400 | The product isn't sold with this billing interval. |
mailboxes_ | invalid_ | 400 | This number of mailboxes per domain isn't offered. |
quantity_ | invalid_ | 400 | The quantities don't match the domains in the order. |
mailbox_ | invalid_ | 400 | The mailboxes listed don't match the number ordered (with subdomains: per domain, all its subdomains together). |
invalid_ | invalid_ | 400 | subdomains isn't 2 to 5 labels, a label isn't valid, or one is listed twice; or a domain's own subdomains has another count than its provider's, or comes without the provider's subdomains. |
subdomains_ | invalid_ | 400 | Subdomains are only for build-your-own POST /orders (not with a package, pre-warmed orders or add-domains). |
duplicate_ | invalid_ | 400 | An add-on is listed twice. |
masking_ | invalid_ | 400 | A domain has a masking target but the order has no masking add-on. |
masking_ | invalid_ | 400 | The masking add-on needs a target for each domain. |
duplicate_ | invalid_ | 400 | A domain or inventory item is in the order twice. |
too_ | invalid_ | 400 | Too many domains in one call (an order takes up to 500). |
tag_ | invalid_ | 400 | tag is too long. |
invalid_ | invalid_ | 400 | A sender name isn't valid. |
invalid_ | invalid_ | 400 | A masking target isn't a valid domain. |
invalid_ | invalid_ | 400 | The order's domains and mailboxes don't form a valid order. |
coupon_ | invalid_ | 400 | No promotion code with this name, or it has expired. |
coupon_ | invalid_ | 400 | Promotion codes can't be used on this order: 3, 6 or 12-month billing, new domains, or your custom price. |
feedback_ | invalid_ | 400 | feedback is required for this cancel reason. |
product_ | invalid_ | 422 | The product can't be bought right now. |
inventory_ | invalid_ | 422 | A pre-warmed domain in the order is no longer available. |
order_ | invalid_ | 422 | This order is billed by invoice, so it can't be changed by API. Contact support. |
add_ | invalid_ | 422 | This order can't take these domains (provider or mailboxes per domain). Place a new order instead. |
domain_ | invalid_ | 422 | The domain isn't part of this order. |
nothing_ | invalid_ | 422 | This would remove every domain. Cancel the order instead. |
order_ | conflict_ | 409 | The order must be active for this. |
order_ | conflict_ | 409 | The order is still being set up. Try again when it is active. |
order_ | conflict_ | 409 | Another change to this order is still running. |
subdomain_ | conflict_ | 409 | The order's mailboxes are on subdomains: this change isn't supported in the API yet. Contact support. |
Domains, mailboxes and change requests
| Code | Type | Status | Meaning |
|---|---|---|---|
domain_ | invalid_ | 400 | Not a valid domain name, or a top-level domain we don't sell. |
duplicate_ | invalid_ | 400 | A domain name is in the list twice. |
invalid_ | invalid_ | 400 | A suggestion keyword is empty or uses characters that aren't allowed. |
invalid_ | invalid_ | 400 | A domain in the change request isn't valid. |
invalid_ | invalid_ | 400 | The redirect URL isn't valid. |
invalid_ | invalid_ | 400 | A mailbox alias uses characters that aren't allowed. |
invalid_ | invalid_ | 400 | The registrar login isn't valid. |
duplicate_ | invalid_ | 400 | A mailbox is listed twice. |
domain_ | invalid_ | 422 | The domain can't be bought: it is taken or reserved, or already used at ScaledMail. |
domain_ | invalid_ | 422 | The domain has a premium price. Premium names can't be bought through the API. |
domain_ | invalid_ | 422 | The domain is already used at ScaledMail, or is being placed in another order right now. |
domain_ | invalid_ | 422 | The new domain isn't one of your bought, unused domains. |
forwarding_ | invalid_ | 422 | redirect was sent for a masked domain, or masking for a domain without masking. |
mailbox_ | invalid_ | 422 | The mailbox doesn't belong to this domain. |
no_ | invalid_ | 422 | The change request asks for what is already set. |
alias_ | conflict_ | 409 | This mailbox address is already taken. |
change_ | conflict_ | 409 | This domain already has an open change request for one of these changes. |
change_ | conflict_ | 409 | Only a pending change request can be cancelled. |
Not found
| Code | Type | Status | Meaning |
|---|---|---|---|
workspace_ | not_ | 404 | No workspace with this id that your token covers. |
domain_ | not_ | 404 | No domain with this id or name in this workspace. |
mailbox_ | not_ | 404 | No mailbox with this id or address in this workspace. |
order_ | not_ | 404 | No order with this id in this workspace. |
change_ | not_ | 404 | No change request with this id in this workspace. |
report_ | not_ | 404 | No report with this id in this workspace. |
invoice_ | not_ | 404 | No invoice with this id in this workspace. |
Limits and our side
| Code | Type | Status | Meaning |
|---|---|---|---|
rate_ | rate_ | 429 | Over the rate limit. See Rate limits. |
server_ | api_ | 500 | Something failed on our side. Retry with backoff; for a purchase, check GET /orders first. |
needs_ | api_ | 500 | A payment went through or its outcome is unclear; our team was told and will finish or refund it. Don't send the purchase again. |
order_ | api_ | 500 | The order was paid and created, but its domains and mailboxes couldn't be saved. Our team was told. Don't order again. |
busy | api_ | 503 | We are briefly busy. Wait Retry-After seconds, then retry. |
not_ | api_ | 503 | Payments or domain search are switched off for a moment. Retry later. |
check_ | api_ | 503 | The registrar couldn't be reached to check a domain. Retry later. |
Handling errors well
- Branch on
code, fall back totype. Never onmessage. - Retry only
rate_andlimit_ error api_, with backoff. Each purchase call charges the card: after a timeout orerror server_, checkerror GET /orders(orGET /domains?status=unused) before sending it again. Never place a purchase again afterneeds_orteam order_: it was paid.form_ failed - Log
request_with every failed call.id
