# Errors and rate limits

> The error format, the most common codes and what your software should do, then the rate limits.

## Error format

Always the same object, with the message in the language of the `Accept-Language` header:

```json
{ "error": { "code": "missing_fields", "message": "Required fields without a value: Total.", "details": { "fields": ["order.total"] } } }
```

Your software relies on `code`. The message is meant for a human.

## Common codes

| HTTP | `code` | What to do |
| --- | --- | --- |
| 400 | `invalid_body` | The body is not a readable JSON object. Check the JSON sent and the `Content-Type: application/json` header |
| 401 | `unauthenticated` | Key revoked, or session expired. Check the key or open a new session |
| 402 | `api_not_included` | The Solo plan has no API. Switch to Team |
| 402 | `embedded_editor_not_included` | The editor embedded in a software is reserved for the Enterprise plan. Switch to Enterprise |
| 402 | `card_required`, `subscription_required`, `trial_over` | The workspace's subscription needs to be sorted out |
| 403 | `preview_only` | Add `"format": "pdf"` |
| 403 | `forbidden`, `role_required` | The action exceeds the rights of the key or session |
| 403 | `key_scope` | A "PDF only" key cannot reach this route. Use a full access key. See [API keys](https://mizanpage.com/en/docs/api/cles.md) |
| 404 | `not_found` | The resource does not exist in this workspace |
| 409 | `not_published` | Publish the template before generating |
| 409 | `no_template`, `ambiguous_template` | No single template for this type. Name it with `template` or choose a default template |
| 409 | `no_catalog` | Send this type's catalog first |
| 409 | `template_archived` | The template has been archived |
| 413 | `payload_too_large` | Body larger than 20 MB |
| 422 | `invalid` | `details.field` says what to fix |
| 422 | `invalid_pdf` | A file sent to the [PDF tools](https://mizanpage.com/en/docs/api/outils-pdf.md) is not a readable PDF; `details.field` names it |
| 422 | `missing_fields` | With `strict: true`, a required field is empty. See `details.fields` |
| 422 | `idempotency_key_reused` | Same `Idempotency-Key` with other data. Use a new key |
| 429 | `rate_limited` | Too many requests. Try again later |
| 500 | `internal_error` | An error on our side, logged on our side. Try again later with the same `Idempotency-Key`. If it happens again, write to contact@mizanpage.com |
| 503 | `renderer_busy`, `renderer_unavailable` | Rendering is busy. Retry with the same `Idempotency-Key` |

A `404` never confirms that a resource exists in another workspace.

## Rate limits

Counted over a sliding window. Beyond them, the request is refused with `429 rate_limited` before any work. The response's `Retry-After` header gives the number of seconds to wait before trying again.

| Limit | Maximum |
| --- | --- |
| PDFs per workspace | 120 per minute, previews included |
| PDFs from a test key | 200 per hour |
| PDFs during the trial | 100 per day |
| Generations and sessions per partner installation | 600 per minute (adjustable) |
| Generations and sessions per partner organisation | 120 per minute (adjustable) |

When all rendering slots are taken for more than 15 seconds, the call answers `503 renderer_busy` without counting anything. Retry after the delay of the `Retry-After` header (5 seconds). Increase it with each new attempt.

---

Documentation Mizanpage · Developers › API
https://mizanpage.com/en/docs/api/erreurs-limites/
