What does a good API error response look like?
A good API error uses the right status code and a consistent, machine-readable body. RFC 9457 (Problem Details) standardises that body: a type URI, a short title, the status, a human-readable detail and an instance identifier, in application/problem+json. It tells the caller what went wrong and how to fix it without exposing stack traces, SQL or internal paths.
How to use Mock Error Response Generator
- Select the error kind and the format your API uses.
- For validation errors, list the field names.
- Generate and paste the body into your client tests or mock server.
Mock Error Response Generator features
- Eleven formats: RFC 9457, JSON:API, Google, AWS, Stripe, Laravel, Django REST, ASP.NET Core, JSend, simple and GraphQL
- Eleven error kinds from validation (422) to gateway timeout (504) with matching headers
- Field-level messages inferred from field names
- Custom detail message override
- Raw HTTP output plus a status and header summary
Mock Error Response Generator example
Laravel-style validation error
Input:
Fields: email, age
Error: validation, format: LaravelOutput:
HTTP/1.1 422 Unprocessable Content
{
"message": "Email must be a valid email address.",
"errors": {
"email": ["Email must be a valid email address."],
"age": ["Age must be between 1 and 100."]
}
}Frequently asked questions about Mock Error Response Generator
Which formats are available?
RFC 9457 Problem Details, JSON:API errors, Google API, AWS, Stripe, Laravel, Django REST Framework, ASP.NET Core ValidationProblemDetails, JSend, a simple { error } object and GraphQL errors.
Which error kinds can I generate?
Validation (422), bad request (400), authentication (401), forbidden (403), not found (404), conflict (409), payment required (402), rate limit (429), server error (500), unavailable (503) and gateway timeout (504) — each with matching headers.
How are field errors chosen?
From the field names: email gets an invalid-format message, password too-short, terms must-be-true, ids not-found, and so on. Add your own fields to see the mapping.
Can I set the message?
Yes, the custom message replaces the default detail in every format while codes, status and structure stay correct.
References
- RFC 9457: Problem Details for HTTP APIsThe application/problem+json error format (type, title, status, detail, instance) for machine-readable API errors.
- OWASP Cheat Sheet Series: Error HandlingError responses that help the caller without leaking stack traces, versions or internal paths.
- RFC 9110: HTTP SemanticsThe meaning of HTTP methods, header fields, status codes and content negotiation, independent of the wire version.