# Errors

Handle the problem response contract and correlate requests.

Errors follow the RFC 9457 problem JSON contract, with media type `application/problem+json`.

```json
{
  "type": "https://www.ninjabuy.com/api/v1/problems/bad-body",
  "title": "Invalid request",
  "status": 400,
  "detail": "The request did not match the expected shape.",
  "request_id": "REQUEST_ID",
  "errors": [{"pointer": "/links", "detail": "Validation detail"}]
}
```

`type` is the stable problem identifier; `title` and `detail` describe it. `status` matches the HTTP status. Optional `errors` entries contain a JSON Pointer and validation detail; an empty pointer means the whole body. Quote `request_id` (also in `X-Request-Id`) when reporting a problem.

All types below start with `https://www.ninjabuy.com/api/v1/problems/`.

| Type suffix                   | HTTP | Meaning / action                                                                                                                                             |
| ----------------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `bad-json`                    | 400  | Body is not valid JSON. Fix its syntax.                                                                                                                      |
| `bad-body`                    | 400  | Body, query parameters or cursor fail validation. Read `errors`.                                                                                             |
| `bad-idempotency-key`         | 400  | Use 1 to 255 printable ASCII characters for `Idempotency-Key`.                                                                                               |
| `unauthorized`                | 401  | Supply a valid bearer token; `WWW-Authenticate` provides discovery.                                                                                          |
| `sandbox-key`                 | 401  | A [sandbox](/docs/partners-api/sandbox.mdx) key (`nb_test_…`) was sent to the live API. Send it to `sandbox.ninjabuy.com`, or use a live key.                |
| `not-found`                   | 404  | Resource is unavailable, unknown or not owned by this account.                                                                                               |
| `method-not-allowed`          | 405  | Use the method in `Allow`.                                                                                                                                   |
| `idempotency-key-in-progress` | 409  | The first request with this key is running. Wait for `Retry-After`.                                                                                          |
| `too-many-batch-jobs`         | 409  | Five [batch jobs](/docs/partners-api/batch-jobs.mdx) are unfinished already. Wait for one to finish, or cancel one.                                          |
| `upload-too-large`            | 413  | Uploaded bytes exceed the declared size or 20 MiB limit.                                                                                                     |
| `unsupported-media-type`      | 415  | Send `Content-Type: application/json`.                                                                                                                       |
| `idempotency-key-reused`      | 422  | This key was used with another request. Use a new key.                                                                                                       |
| `unsupported-endpoint`        | 422  | Only `POST /api/v1/links` can be [batched](/docs/partners-api/batch-jobs.mdx).                                                                               |
| `invalid-workbook`            | 422  | Upload is not a readable XLSX/CSV within the limits. Read `errors`.                                                                                          |
| `upload-expired`              | 422  | Upload reservation expired. Upload the file again.                                                                                                           |
| `rate-limited`                | 429  | Wait the `Retry-After` seconds before retrying.                                                                                                              |
| `search-rate-limited`         | 429  | The keyword-search window is full. Wait for `Retry-After`.                                                                                                   |
| `sandbox-quota`               | 429  | [Sandbox](/docs/partners-api/sandbox.mdx) only: the account's daily searches or the sandbox's daily marketplace lookups are used up. Wait for `Retry-After`. |
| `service-unavailable`         | 503  | Retry shortly; respect `Retry-After` when present.                                                                                                           |
| `internal-error`              | 500  | Retry later; retain the request id if it persists.                                                                                                           |

A successful request can still contain per-input failures. Handle [link statuses](/docs/partners-api/links.mdx) separately from HTTP errors. Use [Idempotency-Key](/docs/partners-api/links.mdx#idempotency-key) to replay a create request; without a key, retrying a batch submission creates another job.
