> ## Documentation Index
> Fetch the complete documentation index at: https://docs.matambaintelligence.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors

> Every error code the API returns, and how to handle it.

Every error response has the same shape:

```json Example error theme={"dark"}
{
  "error": {
    "type": "order_error",
    "code": "order_rejected",
    "message": "The exchange rejected this order.",
    "reject_reason": "insufficient_funds",
    "doc_url": "https://docs.matambaintelligence.com/errors#order_rejected"
  }
}
```

Use `code` to handle errors in your integration. `message` is a description for people and can change, so don't match on it. When an error relates to a specific field, `param` names that field. When the broker or the exchange rejects an order, an application or an allocation, `reject_reason` gives the reason.

| Code                                                    | Status | Type                    |
| ------------------------------------------------------- | ------ | ----------------------- |
| [`invalid_request`](#invalid_request)                   | 400    | `invalid_request_error` |
| [`missing_required_field`](#missing_required_field)     | 400    | `invalid_request_error` |
| [`unknown_account`](#unknown_account)                   | 400    | `invalid_request_error` |
| [`unauthorized`](#unauthorized)                         | 401    | `authentication_error`  |
| [`allocation_not_found`](#allocation_not_found)         | 404    | `invalid_request_error` |
| [`application_not_found`](#application_not_found)       | 404    | `invalid_request_error` |
| [`not_found`](#not_found)                               | 404    | `invalid_request_error` |
| [`order_not_found`](#order_not_found)                   | 404    | `invalid_request_error` |
| [`method_not_allowed`](#method_not_allowed)             | 405    | `invalid_request_error` |
| [`account_not_at_broker`](#account_not_at_broker)       | 409    | `invalid_request_error` |
| [`duplicate_allocation`](#duplicate_allocation)         | 409    | `idempotency_error`     |
| [`duplicate_application`](#duplicate_application)       | 409    | `idempotency_error`     |
| [`duplicate_order`](#duplicate_order)                   | 409    | `idempotency_error`     |
| [`order_not_cancelable`](#order_not_cancelable)         | 409    | `order_error`           |
| [`similar_order_unresolved`](#similar_order_unresolved) | 409    | `order_error`           |
| [`request_too_large`](#request_too_large)               | 413    | `invalid_request_error` |
| [`unsupported_media_type`](#unsupported_media_type)     | 415    | `invalid_request_error` |
| [`allocation_rejected`](#allocation_rejected)           | 422    | `wallet_error`          |
| [`application_rejected`](#application_rejected)         | 422    | `application_error`     |
| [`limit_exceeded`](#limit_exceeded)                     | 422    | `limit_error`           |
| [`order_rejected`](#order_rejected)                     | 422    | `order_error`           |
| [`unknown_symbol`](#unknown_symbol)                     | 422    | `order_error`           |
| [`wallet_too_low`](#wallet_too_low)                     | 422    | `wallet_error`          |
| [`rate_limited`](#rate_limited)                         | 429    | `rate_limit_error`      |
| [`internal_error`](#internal_error)                     | 500    | `api_error`             |
| [`exchange_error`](#exchange_error)                     | 502    | `api_error`             |
| [`allocation_not_sent`](#allocation_not_sent)           | 503    | `api_error`             |
| [`application_not_sent`](#application_not_sent)         | 503    | `api_error`             |
| [`cancel_unconfirmed`](#cancel_unconfirmed)             | 503    | `api_error`             |
| [`exchange_unavailable`](#exchange_unavailable)         | 503    | `api_error`             |
| [`order_not_sent`](#order_not_sent)                     | 503    | `api_error`             |
| [`service_unavailable`](#service_unavailable)           | 503    | `api_error`             |
| [`settlement_lockout`](#settlement_lockout)             | 503    | `api_error`             |

<a id="invalid_request" />

## invalid\_request

`400` `invalid_request_error`

The request could not be read.

<a id="missing_required_field" />

## missing\_required\_field

`400` `invalid_request_error`

A required field is missing.

<a id="unknown_account" />

## unknown\_account

`400` `invalid_request_error`

That account is not one of yours.

<a id="unauthorized" />

## unauthorized

`401` `authentication_error`

Invalid credentials.

<a id="allocation_not_found" />

## allocation\_not\_found

`404` `invalid_request_error`

No such allocation.

<a id="application_not_found" />

## application\_not\_found

`404` `invalid_request_error`

No such application.

<a id="not_found" />

## not\_found

`404` `invalid_request_error`

No such path on this API. Check the path against the contract.

<a id="order_not_found" />

## order\_not\_found

`404` `invalid_request_error`

No such order.

<a id="method_not_allowed" />

## method\_not\_allowed

`405` `invalid_request_error`

That method is not allowed on this path.

<a id="account_not_at_broker" />

## account\_not\_at\_broker

`409` `invalid_request_error`

The broker does not recognise this account. Contact us: this is ours to fix.

<a id="duplicate_allocation" />

## duplicate\_allocation

`409` `idempotency_error`

This Idempotency-Key already belongs to a different allocation.

<a id="duplicate_application" />

## duplicate\_application

`409` `idempotency_error`

This Idempotency-Key already belongs to a different application.

<a id="duplicate_order" />

## duplicate\_order

`409` `idempotency_error`

This Idempotency-Key already belongs to a different order.

<a id="order_not_cancelable" />

## order\_not\_cancelable

`409` `order_error`

This order cannot be cancelled.

<a id="similar_order_unresolved" />

## similar\_order\_unresolved

`409` `order_error`

An identical order on this account is not yet resolved.

<a id="request_too_large" />

## request\_too\_large

`413` `invalid_request_error`

That body is larger than any request to this API can be.

<a id="unsupported_media_type" />

## unsupported\_media\_type

`415` `invalid_request_error`

Content-Type must be application/json.

<a id="allocation_rejected" />

## allocation\_rejected

`422` `wallet_error`

The broker rejected this allocation; its amount is back in the wallet.

<a id="application_rejected" />

## application\_rejected

`422` `application_error`

The broker rejected this application.

<a id="limit_exceeded" />

## limit\_exceeded

`422` `limit_error`

This would take today's total past your limit. Nothing was written and nothing was sent.

<a id="order_rejected" />

## order\_rejected

`422` `order_error`

The exchange rejected this order.

<a id="unknown_symbol" />

## unknown\_symbol

`422` `order_error`

The exchange does not list this symbol. Nothing was written and nothing was sent.

<a id="wallet_too_low" />

## wallet\_too\_low

`422` `wallet_error`

The wallet does not hold that much. Nothing was written and nothing was sent.

<a id="rate_limited" />

## rate\_limited

`429` `rate_limit_error`

Too many requests. Nothing was done. Send the same request again after the Retry-After seconds.

<a id="internal_error" />

## internal\_error

`500` `api_error`

Something went wrong on our side. Retry the same request exactly as you sent it.

<a id="exchange_error" />

## exchange\_error

`502` `api_error`

The exchange's answer could not be used. Nothing was changed. Asking again will not change it: contact us.

<a id="allocation_not_sent" />

## allocation\_not\_sent

`503` `api_error`

The allocation was written down but could not be sent, and never reached the broker.

<a id="application_not_sent" />

## application\_not\_sent

`503` `api_error`

The application was written down but could not be sent, and never reached the broker.

<a id="cancel_unconfirmed" />

## cancel\_unconfirmed

`503` `api_error`

The cancel may not have reached the exchange. Send it again: asking twice is harmless.

<a id="exchange_unavailable" />

## exchange\_unavailable

`503` `api_error`

The exchange cannot be reached right now. Nothing was written and nothing was sent. Retry with the same Idempotency-Key.

<a id="order_not_sent" />

## order\_not\_sent

`503` `api_error`

The order was written down but could not be sent, and never reached the exchange.

<a id="service_unavailable" />

## service\_unavailable

`503` `api_error`

The gateway cannot serve this request right now. Retry the same request; nothing here was changed.

<a id="settlement_lockout" />

## settlement\_lockout

`503` `api_error`

The exchange is settling the day's trades. Ask again after the Retry-After seconds.

## Reject reasons

When you receive `order_rejected`, or an order is in the `rejected` state, `reject_reason` has one of these values.

| `reject_reason`         | What to do                                                                                                              |
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `account_not_at_broker` | The broker does not recognise this account. Contact us: this is ours to fix.                                            |
| `insufficient_funds`    | The account does not have enough cash for this order. Fund the account, then send the order with a new Idempotency-Key. |
| `limit_orders_etf_only` | Limit orders are accepted for ETFs only. Send a market order, with a new Idempotency-Key.                               |
| `market_closed`         | The market is closed. Send the order with a new Idempotency-Key when it opens.                                          |
| `rejected_by_exchange`  | The exchange rejected this order.                                                                                       |
| `settlement_lockout`    | Trading is paused while the day's trades settle. Send the order with a new Idempotency-Key when it reopens.             |
| `symbol_not_tradable`   | This symbol cannot be traded here now.                                                                                  |
| `unknown_symbol`        | The exchange does not list this symbol.                                                                                 |
