API response
What is an API response?
An API response is a software message a server sends after an application makes an API request. It reports the result and may return data or an error.
How an API request and response work
- A client calls an API endpoint.
- The server authenticates, validates, and performs work.
- It returns a status, headers, and optional body.
The three parts of an HTTP API response
| Part | Purpose | Example |
|---|---|---|
| Status | Outcome | 200 OK |
| Headers | Metadata | Content-Type: JSON |
| Body | Data or error details | {"name":"Sam"} |
A body is optional, including with 204 No Content.
Common API response status codes
| Code | Meaning |
|---|---|
| 200, 201, 204 | Success, created, or no content |
| 400, 401, 403, 404 | Bad request, missing login, forbidden, or absent resource |
| 422, 429, 500 | Invalid valid-format input, rate limit, or server failure |
How to read an API response
- Check the status code.
- Inspect headers, including request IDs.
- Safely parse the body.
- Match errors to API documentation.
Benefits of clear API responses
- They enable useful messages and dependable testing.
- They help apps recover from temporary failures.
Practical limits and common API response mistakes
- Do not expose secrets or internal stack traces.
- Do not retry every error or assume success includes data.
- Include pagination details for long lists.
API response design tips
- Use standard HTTP meanings and stable JSON fields.
- Return machine-readable codes and clear messages.
- Document cursors and rate-limit headers.
API responses in Emergent
Emergent can build full-stack apps that call services, use API authentication, handle success and failure states, and test integrations. See how this works in a Gmail API tutorial. Build and test API responses with Emergent.
Frequently Asked Questions
Your Questions, Answered
Don't change this element unless you know what you are doing
What is a 422 API response?
A 422 Unprocessable Content response means the server understood the request format but cannot process the submitted values, such as an invalid email address.
What does an API response error mean?
It means the server could not complete the request as expected. Check the status code, response body, and request ID to identify the cause.
What is a 200 response from an API?
200 OK means the request succeeded. The response often includes data, but its exact meaning depends on the API documentation.
What does a 404 response mean in an API?
404 Not Found means the requested endpoint or resource does not exist at the specified URL.
What is the difference between an HTTP 204 response and a 404 response?
204 No Content means the request succeeded but has no response body. 404 means the requested resource or endpoint was not found.
What is the difference between a 400 response and a 404 response?
400 Bad Request means the request itself is malformed or invalid. 404 Not Found means the requested URL or resource is unavailable.
How do you validate the response code in API testing?
Send a known request, assert the expected HTTP status code, then verify relevant headers and body fields. Test both valid and invalid inputs.
How do you check an API response in Chrome?
Open Chrome DevTools, select Network, repeat the action, choose the request, and inspect the Headers, Preview, and Response panels.
on Emergent today


