# API Error Response

> What an API sends back when a request fails. It gives a code and a reason.

**Field:** Software Development  
**Category:** APIs  
**Also known as:** Error Response, Problem Details, application/problem+json, RFC 9457

## Think of it like

Think of it like a note on a locked door. It says why you cannot get in and what to do next.

## Definition

An error response is what an API sends back when a request fails. It has an HTTP status code, like 404 or 500. It should also have a body that explains what went wrong. A web standard called Problem Details gives that body a set shape. Its fields include type, title, status and detail.

## Example

Jack asks for order 42, which does not exist. The API answers 404 with the title Order not found.

## Example code

```json
{
  "type": "https://example.com/errors/not-found",
  "title": "Order not found",
  "status": 404,
  "detail": "No order has the number 42.",
  "instance": "/orders/42"
}
```

A Problem Details body: the code for programs, the words for people.

## Why it matters

Good errors tell the caller how to fix the problem, which saves hours of guessing.

## Common mistake

Sending status 200 with an error inside. Programs read the status code first and think it worked.

## Three principles

- **Right status code.** 404, 400, 500 and so on.
- **Say why.** A body that explains it.
- **Same shape.** Every error looks alike.

## Related terms

- [HTTP Status Code](https://learn.benibix.com/term/infrastructure/http-status-code)
- [REST API](https://learn.benibix.com/term/development/rest-api)
- [JavaScript Object Notation (JSON)](https://learn.benibix.com/term/development/json)
- [API Documentation](https://learn.benibix.com/term/development/api-documentation)
- [Response Body](https://learn.benibix.com/term/development/response-body)

![A request comes back with status 404 and a JSON body in the problem details shape, lit up. Its fields read: type, a link to the error's page; title, Order not found; status, 404; detail, No order has the number 42; instance, /orders/42. A note says the status code tells a program what went wrong and the body tells a person why.](https://learn.benibix.com/diagrams/dev3-error-response.svg)

---

Source: https://learn.benibix.com/term/development/error-response
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
