Why is my API “not hitting”?—Understanding HTTP status codes

Why is my API “not hitting”?—Understanding HTTP status codes

⚡Quick answer -

When your application seems to “not hit” the API, check the HTTP status code in the response. Status codes beginning with 2xx confirm success, 3xx indicate redirection, 4xx point to a client-side issue, and 5xx reveal a server-side problem.

When should I use this guide?

Refer to this FAQ whenever a request appears to fail or behave unexpectedly, and you need to decode the server’s reply—without changing the original payload—before deciding your next move.


1. What are HTTP status codes?

API error codes (standard HTTP status codes) are the “language” servers use to tell your application what happened during a request. Think of them as the digital equivalent of a postal-service return stamp. They are grouped into five categories based on the first digit.


2. Success codes (2xx)

These mean the request was received, understood, and accepted.

• 200 OK – The standard “everything went great” response.

• 201 Created – Success! A new resource (such as a user account) was successfully created.

• 204 No Content – The request worked, but there is no data to send back (common for deleting something).


3. Redirection codes (3xx)

The resource has moved, and you need to look elsewhere.

• 301 Moved Permanently – The URL you called is old; update your records to the new one provided.

• 304 Not Modified – Used for caching. It tells the browser, “Nothing has changed, use the version you already have.


4. Client error codes (4xx)

This is usually where the “blame” lies with the person making the request.

• 400 Bad Request – The server can’t understand the request due to invalid syntax (e.g., a typo in the JSON).

• 401 Unauthorised – You forgot to include your API key or login credentials.

• 403 Forbidden – The server knows who you are, but you don’t have permission to see this specific data.

• 404 Not Found – The classic “ghost” error. The endpoint or resource doesn’t exist.

• 429 Too Many Requests – You’ve hit the rate limit. Slow down!


5. Server error codes (5xx)

The server messed up. It’s not your fault, but there’s nothing you can do until the provider fixes it.

• 500 Internal Server Error – A generic “catch-all” for when the server crashes or hits an unexpected snag.

• 502 Bad Gateway – One server received an invalid response from another server it was trying to talk to.

• 503 Service Unavailable – The server is overloaded or down for maintenance.

• 504 Gateway Timeout – The server took too long to respond.


6. “API is not hitting” vs. “API is hitting”

• If the status code starts with 2, the API is hitting—your request succeeded.

• Any status code starting with 3, 4, or 5 signals some form of redirection or error that you need to address before expecting success.


7. Visual overview

image.png

Alt-text: Diagram showing four rectangles that map HTTP status code groups (2xx, 3xx, 4xx, 5xx) to their representative codes.