> Index of every page: https://docs.merchantservicedepot.com/llms.txt

# Errors

> One error shape, a short list of codes, and which ones are safe to retry.

Every `/v1` error has the same shape and one of nine codes. The code tells you whether to fix the request, ask Myela, or try again.

## The error shape

An error is an `error` object with a `code` and a `message`. Some errors add a `capability`, the operation that was refused, or a `details` object with a finer `code` of its own.

**403**

```js title="response.json"
{
  "error": {
    "code": "capability_not_enabled",
    "message": "…",
    "capability": "payments.refund"
  }
}
```

**422**

```js title="response.json"
{
  "error": {
    "code": "invalid_request",
    "message": "…",
    "details": { "code": "BREAKDOWN_MISMATCH" }
  }
}
```

`details` carries only `code`. Nothing else is passed through. A `429` from the per-IP limiter also carries a legacy `type: "RATE_LIMITED"` field; read `code` instead.

## Error codes

The top-level `code` is always one of these nine. Only `rate_limited` and `api_error` are worth retrying. The rest fail the same way however many times you send them.

| code | HTTP | Means | Retry? |
| --- | --- | --- | --- |
| `authentication_failed` | 401 | The key is missing, malformed, or revoked, or a live key sent no signature. | No. Fix the credential. |
| `capability_not_enabled` | 403 | The key is valid, but this operation isn't enabled for it. Carries capability. | No. Ask Myela. |
| `permission_denied` | 403 | The key is valid, but the request was refused for another reason. | No. |
| `not_found` | 404 | No such object on your account. | No. |
| `conflict` | 409 | The request conflicts with the object's current state. | Not the same request. |
| `invalid_request` | 422 | Something in the request is wrong and needs correcting. | No. Fix the request. |
| `rate_limited` | 429 | Too many requests, from your source or upstream. | Yes, after backing off. |
| `api_error` | 500 | A temporary problem on Myela's side. | Yes. |
| `capability_not_supported` | 501 | Permanently unavailable on this account. Carries capability when known. | Never. |

An object that belongs to another merchant answers `404 not_found`, never `403`, so you can't tell it apart from an id that doesn't exist. A path that isn't a `/v1` route is also `404 not_found`, with the message "No such endpoint."

## Detail codes

`details.code` names the exact rule a request broke. It sits under a top-level code, and the HTTP status still decides whether a retry can help: a `422` means fix the request, a `409` means the object's state refuses it. New detail codes get added over time, so handle one you don't recognize by its top-level code. These are the ones you're most likely to meet:

| details.code | HTTP | Means |
| --- | --- | --- |
| `UNKNOWN_FIELD` | 422 | A body field isn't accepted. Often a snake_case spelling of a camelCase field. |
| `BREAKDOWN_MISMATCH` | 422 | amountBase + amountSurcharge + amountTax + amountTip doesn't equal amount. |
| `PAYMENT_TOKEN_UNUSABLE` | 422 | The payment token is spent, expired, or not yours. |
| `UNKNOWN_CURSOR` | 422 | startingAfter names no row in this list. |
| `CONCURRENT_MODIFICATION` | 409 | The object changed while your request was in flight. Read it again. |
| `PROCESSOR_NOT_CONFIGURED` | 403 | Payment processing isn't set up for the account yet. |
| `SANDBOX_ONLY` | 403 | The operation runs only in the sandbox. |

The `409` codes for repeated and in-flight requests are covered in [Idempotency and retries](https://docs.merchantservicedepot.com/docs/platform/idempotency/).

## Capability errors

Two codes carry a `capability` naming the operation, such as `payments.refund`. They mean different things:

- `403 capability_not_enabled`: the operation exists but your key isn't allowed to use it. Ask Myela to enable it.
- `501 capability_not_supported`: the operation isn't available on this account at all. Don't retry it. Build around it.

When an operation is both unsupported and not enabled, you get the `501`.

## Handling errors

Branch on `code` and `details.code`, never on `message`. Messages are written for people and can change. An `api_error` says "A temporary problem occurred. Safe to retry." and a `501` says "This operation is not supported on this account. Do not retry."

### In the Node SDK

The SDK throws a class per case. Every error also has `retryable`, true for `rate_limited`, a failed connection, a timeout, or a retryable status, and `permanent`, its opposite.

| Class | Thrown when |
| --- | --- |
| `MyelaCapabilityError` | code is capability_not_enabled or capability_not_supported |
| `MyelaValidationError` | 400 or 422 |
| `MyelaAuthenticationError` | 401 |
| `MyelaPermissionError` | 403 |
| `MyelaNotFoundError` | 404 |
| `MyelaConflictError` | 409 |
| `MyelaRateLimitError` | 429 |
| `MyelaApiError` | Anything else |

Source: https://docs.merchantservicedepot.com/docs/platform/errors/
