API response structure in Postman defines how the server returns information after processing an API request. It helps testers inspect response data and verify whether the API behaves as expected.
- Helps understand the status, headers, body, cookies, and other response details.
- Makes it easier to inspect response data and identify errors.
- Supports API testing by providing response information for validation.
API Response Structure
An API response contains information that describes the result of a request and the data returned by the server. Postman displays this information in different sections to help testers inspect the response.
Components of an API Response
- Status Code: Indicates the result of the API request.
- Response Headers: Provide metadata about the response.
- Response Body: Contains the data, message, or error returned by the server.
- Response Time: Shows how long the API takes to return the response.
- Response Size: Shows the amount of data returned by the server.
- Cookies: Store session or other client-related information when provided by the server.
API Response Body Formats
The response body contains the actual information returned by the API. Depending on the API implementation, the response can be provided in different formats.
- JSON: A lightweight format widely used for exchanging structured API data.
- XML: A markup-based format used to represent structured data, commonly used by SOAP and some legacy APIs.
- HTML: Contains HTML content and may be returned by web-based endpoints.
- Plain Text: Contains simple unformatted text, messages, or other textual information.
JSON Response Structure in Postman
JSON is one of the most commonly used formats for REST API responses. It represents data using objects, arrays, key-value pairs, and different data types.
- JSON Object: A collection of key-value pairs enclosed in
{ }. - JSON Array: An ordered collection of values or objects enclosed in
[ ]. - Key-Value Pair: Represents a field and its corresponding value.
- Nested Object: An object contained inside another object.
- Data Types: JSON supports strings, numbers, booleans, objects, arrays, and
null.
Pretty
The Pretty view formats the response with indentation, line breaks, and syntax highlighting, making structured data easier to read.

- Helps identify JSON objects, arrays, fields, and values.
- Makes large response bodies easier to inspect.
- Useful for manually reviewing API response data.
Raw
The Raw view displays the response body in its original, unformatted form as returned by the server.

- Shows the response content without additional formatting.
- Helps inspect the response as returned by the server.
- Can be difficult to read when the response contains large amounts of data.
Preview
The Preview view attempts to render supported response content in a more user-friendly format.

- Useful for inspecting responses such as HTML.
- Allows supported content to be viewed in a rendered form.
- Pretty or Raw views are generally more suitable for inspecting JSON structure.
Visualize
The Visualize view allows response data to be presented using custom visualizations such as tables, charts, or graphs.

- Useful for displaying response data as charts, tables, graphs, or other custom visualizations.
- Visualization is created using a Postman test/pre-request script with the pm.visualizer functionality.
- If no visualization has been created for the request, the Visualize tab may not show a custom visualization.
XML Response Structure in Postman
An XML response represents API data using tags and nested elements to organize information. In Postman, XML responses can be viewed in a formatted structure, making it easier to read and validate the returned data.
- Root Element: The main element containing the response data.
- XML Elements: Represent individual pieces of information using opening and closing tags.
- Attributes: Provide additional information about an element.
- Nested Elements: Organize related information hierarchically.
- XML Declaration: Can specify the XML version and character encoding.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<product>
<id>4643</id>
<category>coffee</category>
<name>Starbucks Coffee Variety Pack</name>
<inStock>true</inStock>
</product>
Response Headers
Response headers contain metadata that provides additional information about the response and tells the client how the response should be handled.

- Content-Type: Specifies the media type of the response, such as
application/json. - Content-Length: Indicates the size of the response body.
- Date: Indicates when the response was generated or sent.
- Set-Cookie: Instructs the client to store or update a cookie.
- Content-Encoding: Indicates how the response body is encoded or compressed, such as
gzip.
Cookies
Cookies are pieces of data that a server can send to a client to maintain state, manage sessions, or store other information.
.png)
- Postman provides a Cookies section for viewing and managing cookies associated with a domain.
- The Set-Cookie response header instructs the client to create or update a cookie.
- Stored cookies can be automatically included in subsequent requests when applicable.
Example: Here, the server instructs the client to store a cookie named sessionId.
Set-Cookie: sessionId=abc123; Path=/; Secure
Response Time and Response Size
Response time and response size provide useful information about the API's performance and the amount of data returned. Postman displays these values in the response area after the request is executed.

- Response Time: Shows how long the API takes to return the response, usually in milliseconds (ms).
- Response Size: Shows the amount of response data, usually in B, KB, or MB.
- Performance Check: Helps identify unusually slow responses or unexpectedly large response payloads.
Example: If Postman displays
200 OK | 524 ms | 1.89 KB
200 OK-> Status code524 ms-> Response time1.89 KB-> Response size
Test Results
The Test Results section displays the results of tests executed against the API response.
Postman allows you to write JavaScript-based test scripts to validate response data, status codes, headers, and other conditions.
.png)
- pm.test() is used to define a test with a name and test function.
- Assertions inside the test function verify whether the response meets the expected condition.
- Postman displays the test results as passed or failed after the request is executed.
Example:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
Common API Response Errors
API response errors occur when a request cannot be processed successfully or the server returns an unexpected result. HTTP status codes help testers identify the type and cause of the error.
- 400 Bad Request: The server cannot process the request because the request is invalid.
- 401 Unauthorized: Authentication is required or the provided authentication credentials are invalid.
- 403 Forbidden: The client is authenticated but does not have permission to access the requested resource.
- 404 Not Found: The requested resource or endpoint could not be found.
- 405 Method Not Allowed: The HTTP method is not supported for the requested resource.
- 429 Too Many Requests: The client has sent too many requests within a given time period.
- 500 Internal Server Error: The server encountered an unexpected condition while processing the request.
- 502 Bad Gateway: A gateway or proxy received an invalid response from an upstream server.
- 503 Service Unavailable: The server is temporarily unable to handle the request.
Best Practices for API Response Validation
Following response validation practices helps testers detect incorrect data, unexpected errors, and performance issues.
- Verify the expected HTTP status code for each request.
- Validate required fields and values in the response body.
- Check important response headers and their expected values.
- Validate response data types and formats.
- Set reasonable response-time expectations for performance-sensitive APIs.
- Use automated Postman tests for frequently executed validations.
- Check both successful and error responses during API testing.