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"
  }
}
FieldMeaning
typeOne of the eight types below. Never changes for a given code.
codeStable snake_case code. Branch on this.
messageFor people. The wording may change, so don't parse it.
paramOnly when one field or header is at fault, e.g. domains[1] or Workspace.
errorsOnly with validation_failed 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_type, invalid_value, too_big) and may change.
request_idThe id of this request, a UUID. Also sent as the Request-Id header on every answer. Quote it when you contact support.
doc_urlA 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

TypeStatusMeaningWhat to do
authentication_error401The token is missing, wrong, expired or revoked, or is a v1 token.Fix the token. Don't retry.
permission_error403The token is valid but can't do this: missing scope or workspace.Change the token's scopes or workspaces.
invalid_request_error400, 422The request is malformed (400) or valid but can't be done (422).Fix the request. Retrying the same body fails again.
not_found_error404The object doesn't exist in this workspace.Check the id and the workspace.
conflict_error409The object's state does not allow this right now.Read the object again, then decide.
payment_error402The charge failed. Nothing was bought.Ask the account owner to update the card, then send the call again.
rate_limit_error429Too many calls, or too many calls with a wrong token.Wait for Retry-After seconds, then retry.
api_error500, 501, 503Something 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_team, order_form_failed 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_available): the status and type tell them apart.

Tokens and access

CodeTypeStatusMeaning
missing_api_keyauthentication_error401No Authorization: Bearer <token> header.
invalid_tokenauthentication_error401The token doesn't exist. Check that you copied the whole token.
token_expiredauthentication_error401The token has passed its expiry date. Create a new one.
token_revokedauthentication_error401The token was revoked. Create a new one.
wrong_api_versionauthentication_error401An API v1 token was sent to v2. v2 needs a v2 token.
missing_scopepermission_error403The token lacks the scope named in param.
workspace_requiredinvalid_request_error400The Workspace header is missing. It is required on every call that works on a workspace.
workspace_not_allowedpermission_error403The token doesn't cover the workspace in Workspace.
no_accesspermission_error403The person who made the token is no longer an owner or admin of its workspace.
role_not_allowedpermission_error403The person who made the token may not do this in this workspace (owners and admins only).
not_allowedpermission_error403The person who made the token may not do this, e.g. rename the workspace or read its invoices.
account_blockedpermission_error403The account is blocked. Contact support.
test_mode_unavailablepermission_error403Test tokens aren't available. Use a live token.
too_many_failed_attemptsrate_limit_error429Too many calls with a missing or wrong token from your address. Wait a minute.

Request format

CodeTypeStatusMeaning
invalid_requestinvalid_request_error400The body isn't valid JSON, is too large, or doesn't fit this endpoint.
validation_failedinvalid_request_error400A field is invalid (param names it). With several problems, errors lists them all.
parameter_missinginvalid_request_error400A required field is missing (param).
parameter_not_allowedinvalid_request_error400A field can't be used here, e.g. with this product or domain source (param).
invalid_valueinvalid_request_error400A query value has the wrong type, format or enum value (param).
invalid_cursorinvalid_request_error400The cursor is not one this list gave out.
invalid_statusinvalid_request_error400The status filter has a value that doesn't exist.
route_not_foundnot_found_error404No endpoint at this method and path.

Payment

CodeTypeStatusMeaning
no_payment_methodpayment_error402The paying workspace has no saved card.
card_declinedpayment_error402The card was declined.
authentication_requiredpayment_error402The bank wants 3-D Secure. Pay once in the portal to confirm the card.
payment_failedpayment_error402The charge failed, or an earlier call with this token failed. Use a new token to try again.
not_available_for_accountpermission_error403This workspace is billed by invoice or buys only into its own subscription. Contact support.

Workspaces and billing

CodeTypeStatusMeaning
name_invalidinvalid_request_error400The workspace name is empty or too long.
cannot_create_workspacespermission_error403The token doesn't have Can create workspaces turned on.
parent_not_allowedpermission_error403Only owners and admins of the main can add sub-workspaces.
parent_not_foundnot_found_error404parent_id isn't a workspace your token covers.
parent_is_sub_workspaceinvalid_request_error422parent_id is a sub-workspace. Sub-workspaces can't have subs.
main_direct_billinginvalid_request_error422The main in parent_id is billed outside Stripe (direct billing), so it can't have sub-workspaces.
workspace_not_maininvalid_request_error422Only a main workspace can do this, e.g. list invoices with workspace=all.
workspace_limitconflict_error409The owner already has the most workspaces allowed.
sub_workspace_limitconflict_error409The main workspace already has 10 sub-workspaces.
name_takenconflict_error409A workspace with this name already exists.

Products, quotes and orders

CodeTypeStatusMeaning
split_not_100invalid_request_error400The provider split doesn't add up to 100.
billing_period_unavailableinvalid_request_error400This billing period isn't offered for the product.
interval_not_offeredinvalid_request_error400The product isn't sold with this billing interval.
mailboxes_per_domain_not_offeredinvalid_request_error400This number of mailboxes per domain isn't offered.
quantity_mismatchinvalid_request_error400The quantities don't match the domains in the order.
mailbox_count_mismatchinvalid_request_error400The mailboxes listed don't match the number ordered (with subdomains: per domain, all its subdomains together).
invalid_subdomainsinvalid_request_error400subdomains 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_not_supportedinvalid_request_error400Subdomains are only for build-your-own POST /orders (not with a package, pre-warmed orders or add-domains).
duplicate_add_onsinvalid_request_error400An add-on is listed twice.
masking_add_on_requiredinvalid_request_error400A domain has a masking target but the order has no masking add-on.
masking_target_requiredinvalid_request_error400The masking add-on needs a target for each domain.
duplicate_domainsinvalid_request_error400A domain or inventory item is in the order twice.
too_many_domainsinvalid_request_error400Too many domains in one call (an order takes up to 500).
tag_too_longinvalid_request_error400tag is too long.
invalid_nameinvalid_request_error400A sender name isn't valid.
invalid_mask_domaininvalid_request_error400A masking target isn't a valid domain.
invalid_orderinvalid_request_error400The order's domains and mailboxes don't form a valid order.
coupon_not_foundinvalid_request_error400No promotion code with this name, or it has expired.
coupon_not_allowedinvalid_request_error400Promotion codes can't be used on this order: 3, 6 or 12-month billing, new domains, or your custom price.
feedback_requiredinvalid_request_error400feedback is required for this cancel reason.
product_unavailableinvalid_request_error422The product can't be bought right now.
inventory_unavailableinvalid_request_error422A pre-warmed domain in the order is no longer available.
order_billed_manuallyinvalid_request_error422This order is billed by invoice, so it can't be changed by API. Contact support.
add_domains_not_offeredinvalid_request_error422This order can't take these domains (provider or mailboxes per domain). Place a new order instead.
domain_not_on_orderinvalid_request_error422The domain isn't part of this order.
nothing_leftinvalid_request_error422This would remove every domain. Cancel the order instead.
order_not_activeconflict_error409The order must be active for this.
order_in_progressconflict_error409The order is still being set up. Try again when it is active.
order_busyconflict_error409Another change to this order is still running.
subdomain_orderconflict_error409The order's mailboxes are on subdomains: this change isn't supported in the API yet. Contact support.

Domains, mailboxes and change requests

CodeTypeStatusMeaning
domain_invalidinvalid_request_error400Not a valid domain name, or a top-level domain we don't sell.
duplicate_domaininvalid_request_error400A domain name is in the list twice.
invalid_keywordinvalid_request_error400A suggestion keyword is empty or uses characters that aren't allowed.
invalid_domaininvalid_request_error400A domain in the change request isn't valid.
invalid_urlinvalid_request_error400The redirect URL isn't valid.
invalid_aliasinvalid_request_error400A mailbox alias uses characters that aren't allowed.
invalid_hostinginvalid_request_error400The registrar login isn't valid.
duplicate_mailboxinvalid_request_error400A mailbox is listed twice.
domain_unavailableinvalid_request_error422The domain can't be bought: it is taken or reserved, or already used at ScaledMail.
domain_premiuminvalid_request_error422The domain has a premium price. Premium names can't be bought through the API.
domain_in_useinvalid_request_error422The domain is already used at ScaledMail, or is being placed in another order right now.
domain_not_availableinvalid_request_error422The new domain isn't one of your bought, unused domains.
forwarding_type_mismatchinvalid_request_error422redirect was sent for a masked domain, or masking for a domain without masking.
mailbox_not_on_domaininvalid_request_error422The mailbox doesn't belong to this domain.
no_changeinvalid_request_error422The change request asks for what is already set.
alias_in_useconflict_error409This mailbox address is already taken.
change_request_openconflict_error409This domain already has an open change request for one of these changes.
change_request_not_pendingconflict_error409Only a pending change request can be cancelled.

Not found

CodeTypeStatusMeaning
workspace_not_foundnot_found_error404No workspace with this id that your token covers.
domain_not_foundnot_found_error404No domain with this id or name in this workspace.
mailbox_not_foundnot_found_error404No mailbox with this id or address in this workspace.
order_not_foundnot_found_error404No order with this id in this workspace.
change_request_not_foundnot_found_error404No change request with this id in this workspace.
report_not_foundnot_found_error404No report with this id in this workspace.
invoice_not_foundnot_found_error404No invoice with this id in this workspace.

Limits and our side

CodeTypeStatusMeaning
rate_limitedrate_limit_error429Over the rate limit. See Rate limits.
server_errorapi_error500Something failed on our side. Retry with backoff; for a purchase, check GET /orders first.
needs_teamapi_error500A 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_form_failedapi_error500The order was paid and created, but its domains and mailboxes couldn't be saved. Our team was told. Don't order again.
busyapi_error503We are briefly busy. Wait Retry-After seconds, then retry.
not_availableapi_error503Payments or domain search are switched off for a moment. Retry later.
check_failedapi_error503The registrar couldn't be reached to check a domain. Retry later.

Handling errors well

  • Branch on code, fall back to type. Never on message.
  • Retry only rate_limit_error and api_error, with backoff. Each purchase call charges the card: after a timeout or server_error, check GET /orders (or GET /domains?status=unused) before sending it again. Never place a purchase again after needs_team or order_form_failed: it was paid.
  • Log request_id with every failed call.