GET /api/v1/invoices/inv-nonexistent-999 • HTTP 404 Not Found

HTTP 404 Not Found Error API Example — Request & Response Example

Illustrates how APIs handle queries for missing, expired, or deleted entities.

1. HTTP Client Request (GET)

GET /api/v1/invoices/inv-nonexistent-999 HTTP/1.1
{
  "Accept": "application/json"
}

2. Server JSON Response (HTTP 404 Not Found)

{
  "error": "Not Found",
  "code": "RESOURCE_NOT_FOUND",
  "message": "Invoice with ID inv-nonexistent-999 does not exist.",
  "resource_type": "invoice"
}

Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)

curl -X GET "https://cometflow.space/api/v1/invoices/inv-nonexistent-999"
fetch('https://cometflow.space/api/v1/invoices/inv-nonexistent-999')
  .then(res => {
    if (res.status === 404) console.warn('Invoice was not found');
  });
import requests

res = requests.get('https://cometflow.space/api/v1/invoices/inv-nonexistent-999')
print(res.status_code) # 404

How This API Call Works Step-by-Step

  1. 1. Client queries ID inv-nonexistent-999.
  2. 2. Database executes SELECT and returns 0 rows.
  3. 3. Server sends 404 Not Found JSON body.

Backend API Functions: The API controller function checks if (!invoice) return res.status(404).json({ error: "Not Found" }).

Frequently Asked Questions

Should an API return HTML or JSON on 404?

API routes under /api/ should always return structured JSON with Content-Type: application/json, never HTML error pages.