--- url: https://docs.tenderapi.eu/errors.md description: HTTP status codes and the JSON error body returned by the TenderAPI REST API. --- # Errors When something goes wrong, the API responds with an HTTP error status and a small JSON body. ```json { "type": "INVALID_REQUEST", "message": "unknown source: \"TED\"" } ``` | Field | Type | Description | |---|---|---| | `type` | `string` | Machine readable error category. | | `message` | `string` | Human readable explanation. Use it for debugging, not for matching in code. | ## Status codes | Status | `type` | When | |---|---|---| | `400` | `INVALID_REQUEST` | The request is malformed or a value is not allowed. See common causes below. | | `404` | `NOT_FOUND` | No tender or organisation with that id. Only [Get Tender](/get-tender) and [Get Organisation](/get-organisation) return this. | | `500` | `INTERNAL_ERROR` | Something failed on our side. Retry later. The message is always `Something went wrong.` | ## Common 400 causes | Message | Fix | |---|---| | `Failed parsing JSON request` | The body is not valid JSON, or a field has the wrong type. Check quotes and that lists are arrays. | | `Failed parsing query parameters` | A query parameter has the wrong type, for example `limit=abc`. | | `unknown source: "TED"` | Values are case sensitive. Use the exact lowercase identifiers from [Portals](/portals). | | `unknown country: "DE"` | Countries use three letter codes like `DEU`. See [country codes](/getting-started#country-codes). | | `unknown status: "..."`, `unknown sortBy: "..."` | Use one of the values listed on [Search Tenders](/search-tenders). | | `invalid CPV code "4500": expected 8 digits` | CPV codes must be exactly 8 digits. | | `publishedAt.from must not be after publishedAt.until` | Swap the dates. | | `estimatedValue.minValue must not exceed estimatedValue.maxValue` | Swap the values. | | `estimatedValue.currency is required`, `unknown currency: "..."` | Always send `currency` with a value filter, using a supported ISO 4217 code like `EUR` or `USD`. | | `invalid cursor` | The cursor was changed, or the filters differ from the request that produced it. Start from the first page. See [Pagination](/pagination). | | `invalid tender id`, `invalid organisation id` | Ids are UUIDs, for example `0195f1c2-7b3e-7a10-9c4d-3f2a8e6b1d05`. | ## Handling errors Check the HTTP status first. Anything other than `200` means the body is an error object, not a result. ::: code-group ```python [Python] import requests res = requests.post( "https://api.tenderapi.eu/api/v1/tenders/search", json={"sources": ["TED"]}, ) if res.status_code != 200: err = res.json() print(res.status_code, err["type"], err["message"]) ``` ```ts [TypeScript] const res = await fetch("https://api.tenderapi.eu/api/v1/tenders/search", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ sources: ["TED"] }), }); if (!res.ok) { const err = await res.json(); console.error(res.status, err.type, err.message); } ``` :::