API response
An API response is a software message that a server sends back after an application makes an API request. It states whether the request succeeded and may include data, instructions, or error details. In web APIs, the response commonly contains an HTTP status code, headers, and an optional body, often formatted as JSON.
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.
Start Building
on Emergent today
on Emergent today
Start Building

