# Lỗi

> **Tóm tắt** — Rẽ nhánh theo `error.code`, không theo thông điệp. Chỉ thử lại các mã ghi Có, và lỗi mạng, với cùng `Idempotency-Key`.

Lỗi là JSON: `{"error": {"code": "...", "message": "..."}}`. Rẽ nhánh theo `code`; thông điệp dành cho người đọc và có thể đổi. Mọi phản hồi có header `X-Request-Id`: gửi nó khi liên hệ hỗ trợ.

Chỉ thử lại các mã ghi **Có** dưới đây và lỗi mạng, với cùng `Idempotency-Key`. Chờ `Retry-After` nếu phản hồi có, không thì lùi dần kèm jitter. Đừng thử lại các mã khác: cùng request sẽ lỗi y như cũ.

| HTTP | `code` | Thử lại? | Việc cần làm |
|---|---|---|---|
| 400 | `invalid_request` | Không | The body or a parameter is wrong; the message says which. |
| 400 | `idempotency_key_required` | Không | Send an Idempotency-Key header (max 255 chars) on every submit. |
| 400 | `end_user_id_required` | Không | end_user_id is required: the id of the person in your app this run is for. |
| 401 | `invalid_api_key` | Không | Missing, unknown or revoked API key. |
| 401 | `api_key_expired` | Không | This API key has expired. Create or rotate a key. |
| 402 | `wallet_empty` | Không | The product wallet and the org pool cannot cover this run. Add money, then retry. |
| 404 | `style_not_found` | Không | No style with that id for your org (or not public). |
| 404 | `run_not_found` | Không | No run with that id for this product. |
| 404 | `not_found` | Không | No such endpoint. |
| 409 | `idempotency_key_reused` | Không | This Idempotency-Key was already used with a different body. Use a new key for a new run. |
| 409 | `run_not_cancelable` | Không | Only queued runs can be canceled. |
| 413 | `file_too_large` | Không | The file is over the size limit for its type. |
| 415 | `unsupported_content_type` | Không | Uploads accept JPEG, PNG, WEBP, MP4, MOV and WEBM. |
| 429 | `end_user_cap_reached` | Có | This end user reached the daily run cap. Retry after the Retry-After header (resets 00:00 UTC). |
| 429 | `gateway_rate_limited` | Có | A gateway key's product reached its runs-per-minute limit. Retry after the Retry-After header. |
| 500 | `internal_error` | Có | Something went wrong on our side. Retry with the same Idempotency-Key; quote X-Request-Id to support. |
| 503 | `style_unavailable` | Có | This style cannot run on a live key right now (no model behind it). Test keys still return a sample. |
| 503 | `uploads_unavailable` | Có | Uploads are not available on this deployment right now. |

Run lỗi sau khi đã được nhận không phải lỗi HTTP: run kết thúc `failed` hoặc `nsfw` kèm [lý do miễn phí](https://docs.wandura.ai/vi/developers/api-v2/concepts#free-runs), và bạn không bị tính tiền.

[Jobs API](https://docs.wandura.ai/vi/developers/api-v2/jobs#errors) dùng mã lỗi riêng.
