Skip to content

By the Octri team · Updated

404 Not Found

Share

A 404 means the server has nothing at that URL, or won’t admit to having it. In an API that usually means a wrong ID, a deleted resource or a typo in the path.

All HTTP status codes

Class
4xx client error
Defined in
RFC 9110, section 15.5.5
Retry
No
Fix
Check the ID or path
Cacheable by default
Yes

When your API should return 404

Return 404 when the resource in the path doesn’t exist, like /invoices/inv_999, and when the path itself isn’t one your API serves. Say which in the body, since “no such invoice” and “no such endpoint” get fixed in different places.

If the resource existed and was removed for good, a 410 says so. If the path exists and the method doesn’t, like a PATCH on a read-only resource, that’s a 405. A 404 is also the safe answer for a resource the caller isn’t allowed to know about.

How public APIs declare 404 in their OpenAPI specs

Six of the eleven public specs we score declare a 404, as they were on 4 December 2026. GitHub declares it on 717 of its 1,288 operations and Asana on all but one of its 302.

Stripe, Slack, Plaid and Twilio don’t name it, although every one of them has endpoints that take an ID.

APIOperationsDeclare 404How errors are described
GitHub1,288717Per status code
Asana302301Per status code
OpenAI406291Per status code
Box297141Per status code, plus a default
Swagger Petstore198Per status code, plus a default
SendGrid Mail32Per status code
Stripe6120One default error response
Plaid3510One default error response
Twilio1970No error responses
Slack1740One default error response
Adyen Checkout280Per status code

Counted per operation from each vendor’s public OpenAPI document on 4 December 2026.

Declare 404 in your OpenAPI spec

Declare 404 on every operation with an ID in its path, pointing at one shared response.

yaml
paths:
  /invoices/{invoiceId}:
    get:
      operationId: getInvoice
      responses:
        "200":
          $ref: "#/components/responses/Invoice"
        "404":
          $ref: "#/components/responses/NotFound"

components:
  responses:
    NotFound:
      description: No invoice has this ID.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"

What an Octri SDK does with a 404

An Octri SDK doesn’t retry a 404. The caller gets an SdkNotFoundError in TypeScript, Python, Java, Kotlin, PHP and Ruby, so “not found” can be handled as an expected case without parsing a message.

That keeps the common fetch-or-create pattern short. Catch the one class, create the resource, and let every other error through.

typescript
import { Acme, SdkNotFoundError } from "acme-sdk";

const acme = new Acme({ apiKey: process.env.ACME_API_KEY });

async function findInvoice(invoiceId: string) {
  try {
    return await acme.invoices.get({ invoiceId });
  } catch (err) {
    if (err instanceof SdkNotFoundError) return null;
    throw err;
  }
}

More on retries and typed errors in SDK error handling.

HTTP 404 questions

Should an empty list return 404?

No. GET /invoices with no invoices worked and found nothing, so return 200 with an empty array. Keep 404 for a specific resource that doesn’t exist.

Can a 404 be retried?

Partly. A resource created a moment ago may not be visible yet on a read replica, so a short retry can work. Otherwise the same request keeps failing.

Should a 404 include a body?

Yes. A JSON error with the resource type and ID helps the developer spot a typo in the ID, and it tells them the endpoint exists.

Share