Homeglossary

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.

Build and test API responses with Emergent.

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

  1. A client calls an API endpoint.
  2. The server authenticates, validates, and performs work.
  3. It returns a status, headers, and optional body.

The three parts of an HTTP API response

PartPurposeExample
StatusOutcome200 OK
HeadersMetadataContent-Type: JSON
BodyData or error details{"name":"Sam"}

A body is optional, including with 204 No Content.

Common API response status codes

CodeMeaning
200, 201, 204Success, created, or no content
400, 401, 403, 404Bad request, missing login, forbidden, or absent resource
422, 429, 500Invalid valid-format input, rate limit, or server failure

How to read an API response

  1. Check the status code.
  2. Inspect headers, including request IDs.
  3. Safely parse the body.
  4. 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
Start Building