- Class
- 5xx server error
- Defined in
- RFC 9110, section 15.6.1
- Retry
- If the method is idempotent
- Fix
- On the server
- Cacheable by default
- No
When your API should return 500
A 500 is what your framework sends when an exception escapes, so you rarely return it on purpose. Make sure the body is still your normal JSON error with a request ID, and never a stack trace or a proxy’s HTML error page.
If you know the cause, use a more precise code. A dependency that’s down or a deploy in progress is a 503, a bad response from an upstream server is a 502, and a feature your API hasn’t built is a 501.
How public APIs declare 500 in their OpenAPI specs
Six of the eleven public specs we score declare a 500, as they were on 4 December 2026. Asana does on all but one of its 302 operations, and OpenAI and GitHub on about 120 each.
A declared 500 rarely changes what a client does, since it can’t fix the cause. What it adds is the error schema, which is how the request ID reaches a support ticket.
| API | Operations | Declare 500 | How errors are described |
|---|---|---|---|
| Asana | 302 | 301 | Per status code |
| OpenAI | 406 | 122 | Per status code |
| GitHub | 1,288 | 117 | Per status code |
| Box | 297 | 20 | Per status code, plus a default |
| Adyen Checkout | 28 | 20 | Per status code |
| SendGrid Mail | 3 | 3 | Per status code |
| Stripe | 612 | 0 | One default error response |
| Plaid | 351 | 0 | One default error response |
| Twilio | 197 | 0 | No error responses |
| Slack | 174 | 0 | One default error response |
| Swagger Petstore | 19 | 0 | Per status code, plus a default |
Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.
Declare 500 in your OpenAPI spec
Declare 500 through a shared response with your standard error schema, and make the request ID a required field so every client can quote it.
paths:
/invoices:
get:
operationId: listInvoices
responses:
"200":
$ref: "#/components/responses/InvoiceList"
"500":
$ref: "#/components/responses/InternalError"
components:
responses:
InternalError:
description: Something failed on our side. Quote the request ID to support.
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
schemas:
Error:
type: object
required: [code, message, requestId]
properties:
code:
type: string
message:
type: string
requestId:
type: stringWhat an Octri SDK does with a 500
An Octri SDK retries a 500 when the method is idempotent, which means GET, HEAD, PUT, DELETE and OPTIONS, up to 3 attempts with exponential backoff and jitter. It doesn’t retry a POST or a PATCH on a 500, because the first attempt may have done the work.
When the retries run out, the caller gets an SdkInternalServerError, the class every 5xx maps to in TypeScript, Python, Java, Kotlin, PHP and Ruby. It carries the request ID your API sent, so a bug report can name the exact request.
import { Acme, SdkInternalServerError } from "acme-sdk";
const acme = new Acme({ apiKey: process.env.ACME_API_KEY });
try {
await acme.invoices.list();
} catch (err) {
if (err instanceof SdkInternalServerError) {
// Already retried 3 times. Quote the request ID to support.
console.error(err.statusCode, err.requestId);
}
throw err;
}More on retries and typed errors in SDK error handling.
See which 500s reached your users
Your server logs every 500 it sends. What they don’t show is which of those still failed for the caller after the SDK’s retries, and those are the ones that broke something for a user.
An Octri SDK with monitoring switched on reports each of those to Octri Monitoring with the status code, the operation and the request ID, so you can match it to your server log. Monitoring groups repeats into one issue, and it can alert you on a new issue or on one that comes back after you marked it resolved.
Monitoring is off in the SDK until the developer using it turns it on, so the count covers the users who did.
level = 'error' AND statusCode >= 500
ORDER BY timestamp DESC LIMIT 50HTTP 500 questions
Should a 500 response include error details?
No, not internal ones. Stack traces and SQL errors help attackers more than developers. Send a short message and a request ID, and keep the details in your logs under that ID.
Is it safe to retry a POST after a 500?
Partly. Only when your API supports idempotency keys and the request sent one, so the server can tell a retry from a second order.
Do 500s count against an uptime SLA?
Often, yes. Many API SLAs measure availability as the share of requests that didn’t get a 5xx, so a 500 that should have been a 400 costs you in the uptime report.