# Errors

> The one shape every error takes, how to branch on it, and every error code the API can answer with what to do about each.

Source: https://docs.clouduxe.com/api/errors/

Every failed request answers with the same shape, whatever went wrong. Your code
branches on `code`, which never changes for a condition; `message` is for a
person to read and can be reworded.

## The error object

```json
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "A field has the wrong type or is out of range.",
    "param": "items[0].hostname",
    "requestId": "8f14e45f-ceea-467a-9f2b-1c3d5e7a9b0c",
    "docUrl": "https://docs.clouduxe.com/api/errors#parameter_invalid"
  }
}
```

| Field | What it is |
| --- | --- |
| `type` | The group the code belongs to. The SDKs raise one error class per type. |
| `code` | The stable, machine-readable reason. Branch on this. |
| `message` | A fixed sentence for a person. It never repeats your request back. |
| `param` | The field the error is about, as a path into your request, or `null`. |
| `requestId` | The same value as the `X-Request-Id` header, which every response carries. Quote it to support. |
| `docUrl` | A link to this code's entry below. |

## Types and statuses

| Type | Status |
| --- | --- |
| `authentication_error` | 401 |
| `permission_error` | 403 |
| `invalid_request_error` | 400, 405, 413, 415 and 422 |
| `not_found_error` | 404 |
| `conflict_error` | 409, 410 and 423 |
| `payment_error` | 402 |
| `idempotency_error` | the status its code lists below |
| `rate_limit_error` | 429 |
| `api_error` | 500 and 503 |

An object outside your token's account answers exactly as an unknown id does,
`404` [`not_found`](#not_found), so ids from other accounts cannot be probed.

A response you should retry carries `Retry-After`, in seconds. A `429` also
carries the `RateLimit-*` headers; see [Rate limits](https://docs.clouduxe.com/api/rate-limits/).

## Every error code

The full catalogue, generated from the API contract. Each code links here from
the `docUrl` of its error.

| Code | Status | Type | Meaning | What to do |
| --- | --- | --- | --- | --- |
| `account_closed` | 409 | conflict_error | This account is closed. | No action is possible on a closed account. |
| `action_limit_reached` | 429 | rate_limit_error | This service has reached its limit for this action. | Retry after Retry-After seconds. |
| `actions_unavailable` | 503 | api_error | Server actions are paused for a moment. | Retry after Retry-After seconds. |
| `api_access_disabled` | 403 | permission_error | API access is paused for this account. | Contact support. |
| `api_ordering_disabled` | 403 | permission_error | Ordering through the API is switched off for this account. | The account owner can switch it on in the panel, under API settings. |
| `attachment_unavailable` | 422 | invalid_request_error | An attachment is not uploaded, not yours, or already used. | Upload the file again and pass the new attachmentId. |
| `billing_currency_unknown` | 422 | invalid_request_error | The account has no billing currency yet. | Add a billing address in the panel. |
| `cancellation_final` | 409 | conflict_error | The paid period has ended, so the cancellation can no longer be undone. | Order a new service if you need one. |
| `confirmation_mismatch` | 422 | invalid_request_error | confirm must equal the service's id. | Send the service's own id in confirm. |
| `coupon_exhausted` | 409 | conflict_error | This coupon has no uses left. | Order again without couponCode. |
| `coupon_invalid` | 422 | invalid_request_error | This coupon does not exist or does not apply to this order. | Remove or change couponCode. |
| `credit_currency_mismatch` | 402 | payment_error | The wallet holds no credit in this order's currency. Credit is never converted. | Add credit in the order's currency in the panel. |
| `currency_not_offered` | 409 | conflict_error | The target plan is not offered in this service's currency. | Open a support ticket. |
| `cursor_invalid` | 400 | invalid_request_error | The cursor is malformed, has expired, or belongs to a list with other filters. | Start the list again without a cursor. |
| `cycle_unavailable` | 422 | invalid_request_error | This plan has no orderable price for that billing cycle. | Pick one of the plan's cycles. |
| `department_unavailable` | 422 | invalid_request_error | This support department is not available. | Use a department from GET /v1/support/departments. |
| `files_unavailable` | 503 | api_error | File storage could not be reached. | Retry shortly. |
| `firewall_not_available` | 409 | conflict_error | Protection is not set up for this server yet. | Retry later, or contact support. |
| `firewall_preset_covered` | 409 | conflict_error | Every rule of this preset is already covered. | No action is needed. |
| `firewall_preset_unavailable` | 422 | invalid_request_error | No such firewall preset is available. | Use a preset from GET /v1/firewall-presets. |
| `firewall_resetting` | 423 | conflict_error | This address recently changed hands, and its firewall is being reset. | Retry in a few minutes. |
| `firewall_rule_exists` | 409 | conflict_error | A rule with this protocol and first port already exists. | Edit it instead. |
| `firewall_rule_limit` | 422 | invalid_request_error | This server already has 15 firewall rules. | Remove or merge rules first. |
| `firewall_rule_overlap` | 409 | conflict_error | The rule's ports overlap another rule of the same protocol. | Edit the existing rule instead. |
| `firewall_value_refused` | 422 | invalid_request_error | The protection service refused one of the rule's values. | Check the rule's limits in the reference. |
| `firewall_would_block_all` | 409 | conflict_error | This change would leave no enabled rule while the default policy denies, which blocks every port. | Enable another rule first, or set the default policy to allow. |
| `forbidden` | 403 | permission_error | Your role on this service does not allow this action. | Ask the account owner for access, or use the owner's token. |
| `hostname_invalid` | 422 | invalid_request_error | The hostname must be a valid DNS name of at most 253 characters. | Send DNS labels of letters, digits and hyphens joined by dots. |
| `idempotency_in_progress` | 409 | idempotency_error | A request with this Idempotency-Key is still running. | Retry after Retry-After seconds with the same key. |
| `idempotency_key_invalid` | 400 | idempotency_error | Idempotency-Key must be 1 to 128 characters of letters, digits, underscore, dot, colon or hyphen. | Use a UUID. |
| `idempotency_key_required` | 400 | idempotency_error | This request needs an Idempotency-Key header. | Send a new unique key, such as a UUID, for each logical request. |
| `idempotency_mismatch` | 422 | idempotency_error | This Idempotency-Key was already used with a different request. | Use a new key for a new request. |
| `image_unavailable` | 422 | invalid_request_error | This OS image is not offered here. | Use an image from the plan's orderForm, or from GET /v1/services/{serviceId}/images. |
| `insufficient_credit` | 402 | payment_error | Wallet credit in the order's currency does not cover the total. Nothing was ordered. | Add credit in the panel, then try again. |
| `internal_error` | 500 | api_error | An unexpected error occurred. It has been logged with this request id. | Retry once. If it repeats, contact support with the requestId. |
| `invalid_json` | 400 | invalid_request_error | The request body is not valid JSON. | Send a JSON body. |
| `ip_address_invalid` | 422 | invalid_request_error | Send one IPv4 address. | Send a single dotted IPv4 address. |
| `ip_already_listed` | 409 | conflict_error | That address is already on this list. | No action is needed, or remove it first to change it. |
| `ip_is_infrastructure` | 422 | invalid_request_error | That address serves this server's protection and cannot be blocked or removed. | No action is possible for this address. |
| `ip_is_own_address` | 422 | invalid_request_error | That is this server's own address. | Do not block your own server. |
| `ip_not_allowed` | 403 | permission_error | This request came from an address outside the token's IP allowlist. | Call from an allowed address, or change the allowlist in the panel. |
| `ip_range_unsupported` | 422 | invalid_request_error | Address ranges are not supported here. Send one IPv4 address. | Send single addresses. |
| `limits_unavailable` | 503 | api_error | Rate limits could not be checked, so the change was refused. | Retry shortly. |
| `maintenance` | 503 | api_error | This kind of change is paused for maintenance. Reads still work. | Retry after Retry-After seconds. |
| `metadata_invalid` | 400 | invalid_request_error | metadata takes at most 20 keys of up to 40 characters, each with a string value of up to 500 characters. | Fix the keys or values. |
| `method_not_allowed` | 405 | invalid_request_error | This path does not take this HTTP method. | Check the method in the reference. |
| `not_found` | 404 | not_found_error | No such object, or it is not visible to this token. | Check the id, and that the token belongs to the right account. |
| `option_invalid` | 422 | invalid_request_error | An option is missing, unknown, or not offered on this plan. | Use the option groups in the plan's orderForm. |
| `order_limit_reached` | 429 | rate_limit_error | This account has ordered its hourly maximum of services. | Retry after Retry-After seconds, or ask support to raise the limit. |
| `orders_unavailable` | 503 | api_error | Ordering is paused for a moment. Nothing was ordered. | Retry after Retry-After seconds. |
| `origin_invalid` | 422 | invalid_request_error | The proxy origin must be one of this account's own servers. | Send a service id, or an IPv4 address of one of your servers. |
| `out_of_stock` | 409 | conflict_error | This plan is sold out. | Pick another plan or region, or try again later. |
| `outcome_unknown` | 503 | api_error | The request may or may not have taken effect. | Retry with the same Idempotency-Key: the retry answers what happened, or does it once. |
| `parameter_invalid` | 400 | invalid_request_error | A field has the wrong type or is out of range. | Fix the field named in param. The reference gives each field's rules. |
| `parameter_missing` | 400 | invalid_request_error | A required field is missing. | Send the field named in param. |
| `parameter_unknown` | 400 | invalid_request_error | The request has a field this operation does not take. | Remove the field named in param. |
| `plan_change_not_allowed` | 422 | invalid_request_error | This plan is not an allowed change for this service. | Pick a plan from GET /v1/services/{serviceId}/plan-options. |
| `plan_change_open` | 409 | conflict_error | A plan change for this service is already paid and waiting to be applied. | Wait for its plan_change action to finish. |
| `plan_change_too_soon` | 409 | conflict_error | This service had a plan change request in the last 10 minutes. | Retry after Retry-After seconds. |
| `plan_change_unavailable` | 503 | api_error | Plan changes for this service are paused for a moment. Nothing was changed. | Retry after Retry-After seconds. |
| `plan_unavailable` | 422 | invalid_request_error | This plan cannot be ordered. | Pick a plan from GET /v1/plans. |
| `platform_unavailable` | 503 | api_error | The server platform could not be reached. Nothing was changed. | Retry shortly. |
| `previous_change_pending` | 409 | conflict_error | An earlier plan change is waiting for the server's next power cycle. | Restart the server, wait for the change to apply, then try again. |
| `protection_not_available` | 409 | conflict_error | This service has no protection data to show: it is not a protected server, or protection is not set up yet. | For a protected proxy, ask support. Otherwise retry once the service is active. |
| `quote_incomplete` | 422 | invalid_request_error | The price cannot be fixed until the account's billing details are complete. | Complete the billing address (for an Indian account, its GST state) in the panel. |
| `rate_limited` | 429 | rate_limit_error | Too many requests. | Retry after Retry-After seconds. The RateLimit headers show the window. |
| `reinstall_in_doubt` | 409 | conflict_error | A recent reinstall's outcome is unknown, so another is refused for up to 15 minutes. | Check the server, then retry after Retry-After seconds. |
| `renewal_in_progress` | 409 | conflict_error | A renewal for the next period is already paid, so the plan cannot change through the API. | Open a support ticket. |
| `request_too_large` | 413 | invalid_request_error | The request body is larger than 1 MiB. | Send a smaller body. Upload files through createAttachment. |
| `scope_missing` | 403 | permission_error | This API token does not have the scope this operation needs. | Make a token with the scope named in the reference for this operation. |
| `secret_unavailable` | 410 | conflict_error | This action's secret was deleted, has expired, was read 5 times, or never existed. | This is final: do not retry. Reset the password again with delivery api and retrieve it within 60 minutes. |
| `service_building` | 409 | conflict_error | A build or reinstall is running on this server. | Wait for its action to finish. |
| `service_ended` | 409 | conflict_error | This service has ended, so its cancellation cannot change. | No action is possible on an ended service. |
| `service_locked` | 423 | conflict_error | This service is suspended, cancelled or terminated. | Pay any overdue invoice, or contact support. |
| `service_not_ready` | 409 | conflict_error | This service is still being set up. | Wait for the service.provisioned event, then retry. |
| `service_unconfirmed` | 423 | conflict_error | Actions on this server are paused while its ownership is re-checked. | Retry later, or contact support. |
| `ssh_key_invalid` | 422 | invalid_request_error | The public key is not one accepted OpenSSH public key line. | Send ssh-ed25519, ecdsa-sha2-nistp256, -nistp384 or -nistp521, or ssh-rsa of at least 2048 bits. |
| `ssh_key_unknown` | 422 | invalid_request_error | An SSH key id is not in this account's key library. | Use ids from GET /v1/ssh-keys. |
| `ssh_keys_not_allowed` | 403 | permission_error | Only the account owner can pass SSH keys to a reinstall. | Reinstall without sshKeyIds, or use the owner's token. |
| `termination_pending` | 409 | conflict_error | This service is already being terminated. | No action is needed. |
| `terms_outdated` | 409 | conflict_error | Updated terms of service must be accepted before ordering. | The account owner accepts them in the panel. |
| `ticket_closed` | 409 | conflict_error | This ticket is closed. | Open a new ticket. |
| `token_expired` | 401 | authentication_error | The API token has expired. | Make a new token in the panel. |
| `token_invalid` | 401 | authentication_error | The API token is not valid. | Check the token, or make a new one in the panel. |
| `token_missing` | 401 | authentication_error | No API token was sent. Send it as Authorization: Bearer <token>. | Send your token in the Authorization header. |
| `token_revoked` | 401 | authentication_error | The API token was revoked. | Make a new token. If you did not revoke it, review your account's security log. |
| `too_many_ssh_keys` | 422 | invalid_request_error | Too many SSH keys for one request. | Send at most 10 key ids. |
| `unavailable` | 503 | api_error | The API is briefly unavailable. | Retry after Retry-After seconds. |
| `unsupported_media_type` | 415 | invalid_request_error | The request body must be application/json. | Send Content-Type: application/json. |
| `version_invalid` | 400 | invalid_request_error | Clouduxe-Version does not name an API version. | Send a version listed in the changelog, or omit the header to use your token's version. |
| `webhook_endpoint_limit` | 409 | conflict_error | This account already has 10 webhook endpoints. | Delete an endpoint you no longer use. |
| `webhook_url_refused` | 422 | invalid_request_error | The webhook URL must be https on port 443 or 8443, with a public DNS name that is not a Clouduxe host. | Use a public https URL on your own domain. |
