# Errors and limits

## The error body

Every error, on every route, is JSON with one field, `error`, and an HTTP
status that says what kind of error it is:

```
HTTP/1.1 400 Bad Request
Content-Type: application/json
X-Request-Id: Rz8vKm3pWq6tXc1nLb9sHd4fJg7yAe2M

{"error": "minimum payment in USDT_TRC20 is $6.44 right now (network fees)"}
```

Branch on the **status**, and log the **message**. Messages are written for
developers, in English, and may be reworded over time: do not match on their
exact text, and do not show them to your customers.

Every response, error or not, carries an `X-Request-Id` header. Quote it when
you write to payitgo's support: it finds the request in the logs.

## Status codes

| Status | Meaning | Typical causes | Retry? |
|---|---|---|---|
| `200 OK` | Done | A read, an update, or `POST /v1/payments` returning the order's open payment | |
| `201 Created` | Created | A new payment, key, user, store, payout, mass payout batch or withdrawal | |
| `202 Accepted` | Queued | A webhook test or a redelivery: it is sent within seconds | |
| `400 Bad Request` | The request is invalid | A missing or malformed field, an unsupported token, an amount under the minimum, a webhook URL that is not `https://` | No: fix the request |
| `401 Unauthorized` | Not authenticated | `missing api key`, `invalid api key` (unknown or revoked) | No: fix the key |
| `403 Forbidden` | Authenticated, but not allowed | Any key before the account's email is confirmed (`this account's email is not confirmed yet`), a live key while live mode is off, a suspended account, a storefront key changing the account's webhook, a read-only key creating or changing something, a key without payouts making a payout, a key used from an address not in its allowed IPs, a payment for a customer you blocked | No |
| `404 Not Found` | No such thing | An unknown id, a payment of the other mode, an order with no open payment, an unknown route (`Not Found`) | No |
| `409 Conflict` | It clashes with the current state | Changing the coin of a payment once something arrived, simulating a test payment while its simulation runs, cancelling a payout that is no longer `requested`, changing or submitting a mass payout batch that was submitted already | No |
| `413 Request Entity Too Large` | The body is over 1 MiB | | No |
| `429 Too Many Requests` | Too many requests in a short time | See below | Yes, after a short wait |
| `500 Internal Server Error` | Something failed on payitgo's side | The message is generic (`payment creation failed`, `could not set the webhook`…); the details are in payitgo's logs | Yes, with backoff |
| `503 Service Unavailable` | Something payitgo needs is unavailable for a moment | `exchange rate unavailable for currency: try again shortly`, `the email could not be sent: try again in a few minutes` | Yes, after a short wait |

The message for each error of each endpoint is listed on its page:
[Payments](https://payitgo.co/docs/payments.md#errors), [Checkout](https://payitgo.co/docs/checkout.md),
[Webhooks](https://payitgo.co/docs/webhooks.md#the-webhook-api),
[Authentication](https://payitgo.co/docs/authentication.md#api-key-errors),
[Mass payouts](https://payitgo.co/docs/payouts.md).

## Rate limits

Every route is rate limited, per API key or per visitor, so one runaway
client never slows anyone else down. The limits sit well above what any
integration needs. Go past one and you get:

```
HTTP/1.1 429 Too Many Requests

{"error": "rate limit exceeded"}
```

Wait a moment and retry, backing off a little more each time (the official
libraries do it for you). Webhooks make polling unnecessary for almost every
integration: if you meet a limit, you are probably polling payments you
could be told about.

## Retrying safely

Networks fail. These requests can be sent again without doing anything twice:

| Request | Why it is safe |
|---|---|
| `POST /v1/payments` with the same `order_id` | While the order has an open payment you get that payment back (`200`), not a second one |
| `POST /v1/payouts` (a payout request) with the same `reference` | You get the payment that has it back (`200`), not a second one ([Payout requests](https://payitgo.co/docs/payouts.md#payout-requests)) |
| `PUT /v1/webhook` | Setting the URL it already has changes nothing |
| `DELETE /v1/webhook` | Removing a URL that is already removed changes nothing |
| `GET` anything | Reads change nothing |

`POST /v1/webhook/test` is harmless to repeat, but each call sends one more
`ping`.

On a `5xx` or a network error, retry with exponential backoff (for example
1 s, 2 s, 4 s, up to a minute). On a `4xx` other than `429`, retrying the same
request gets the same answer.

## Conventions

- **Requests** are JSON with `Content-Type: application/json`. Without that
  header the body is not read as JSON: the request is refused (usually
  `400 invalid request body`) or answered as if its fields were missing.
- **Amounts** are decimal strings in responses (`"49.9"`, `"0.00117"`). Requests
  accept a JSON number or a decimal string. Parse responses with a decimal type,
  not a float.
- **Times** are RFC 3339 in UTC (`2026-10-10T09:00:00.112Z`). The number of
  fractional digits varies: use a real RFC 3339 parser.
- **Optional fields** are left out of a response when they have no value. Code
  that reads them must handle their absence.
- **New fields** may appear in responses at any time, and unknown fields in
  requests are ignored: parse leniently.
- **Lists** take `limit` (1 to 200, default 50) and `offset`, and return
  `total`, except two that page with a cursor: `GET /v1/events`
  ([Replay missed events](https://payitgo.co/docs/webhooks.md#replay-missed-events)) and
  `GET /v1/payouts` ([List payments](https://payitgo.co/docs/payouts.md#list-payments)).
- **Ids** are opaque strings: store and compare them whole, and never read
  meaning into their shape. An id is 24 lowercase hex characters
  (`6710c3a1f2b4e5d6a7b8c9d0`), whatever it is: a payment, a settlement, an
  event, an API key. API keys and webhook signing secrets are 64 hex
  characters; they do not say their mode either (a key's `livemode` does).

## Service status

How every part of payitgo is doing is public, at
[payitgo.co/status](https://payitgo.co/status) and as JSON, with no
credentials. Each part is monitored around the clock: the API, the
dashboard, the hosted checkout, webhooks, payment detection on each network,
payouts to merchants' wallets and mass payouts.

`GET /status` · no authentication

```bash
curl https://api.payitgo.co/status
```

```json
{
  "status": "operational",
  "updated_at": "2026-10-24T20:31:00Z",
  "groups": [
    {
      "id": "networks",
      "name": "Payment networks",
      "components": [
        {
          "id": "bitcoin",
          "name": "Bitcoin",
          "description": "Payment detection and confirmations",
          "status": "operational",
          "since": "2026-10-24T08:02:00Z"
        }
      ]
    }
  ],
  "events": []
}
```

- `status` is `operational`, `degraded` (working, more slowly) or `outage`,
  for the whole platform (its worst part) and for each component.
- `events` are the times a part was not operational over the last 30 days,
  newest first: `component`, `name`, `status` (the worst it got to),
  `started_at`, and `ended_at` (`null` while it goes on). Component `all` is
  the whole platform being unreachable.

`GET /status/history` · no authentication

```json
{
  "days": ["2026-07-27", "…", "2026-10-24"],
  "components": {
    "bitcoin": { "uptime": "99.98", "minutes": [[1440, 0, 0], "…", [1230, 12, 0]] }
  }
}
```

The last 90 days (UTC), oldest first: for each component, its minutes
operational, degraded and in an outage on each day (`[0, 0, 0]` before it
was recorded), and `uptime`, the share of the recorded minutes it was
working, as a percentage rounded down (`""` with no record). Both answer from
memory: poll them as often as once a minute. During a delay on a network,
payments sent meanwhile are detected as soon as it catches up.
