# HTTP Response

The **HTTP Response** node is designed to send a response back to the client in an API flow. It's essential for completing the request-response cycle in web applications, allowing you to specify the status code and body content of the response. This ensures that the client receives the necessary information after processing a request.

| **Field**            | **Description**                              | **Required** | **Default** |
| -------------------- | -------------------------------------------- | ------------ | ----------- |
| Node name            | [Node name](/flow-builder/node-name.md)      | true         | -           |
| Response value       | Content to be sent back in the response body | false        | -           |
| Response status code | HTTP status code for the response            | true         | -           |

## Usage

1. Specify the response value. The previous value of node can be used here via [Magical Autocomplete](/flow-builder/cql-cosmocloud-query-language/magical-autocomplete.md).
2. Select the appropriate response status code from the dropdown menu.

## Returns

This node sends an HTTP response to the client.

## Example

Let's say you want to send list of users stored in the database.

1. You've used [List Records](/flow-builder/node-types/database-nodes/list-records.md) to fetch the users and now you can set the response value as `$.listRecords.result` .
2. Set the status code as `200 - OK`.

After the calling the API, you'll receive the list of users in the response body with status code as 200.

## Best Practices

1. Choose appropriate status code for different scenarios. For example, 200 for Successful Request, 201 for Resource Created Successfully, 400 for Invalid Request from Client. For more information, you can refer this [HTTP response status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) document from MDN.

## Supported Status Code

|                 |                       |                                                       |
| --------------- | --------------------- | ----------------------------------------------------- |
| **Status Code** | **Meaning**           | **Use Case**                                          |
| 200             | OK                    | Successful request (GET, PUT, PATCH)                  |
| 201             | Created               | Successful resource creation (POST)                   |
| 202             | Accepted              | Request accepted, but processing not completed        |
| 204             | No Content            | Successful request with no content to return (DELETE) |
| 400             | Bad Request           | Invalid input, missing required fields                |
| 401             | Unauthorized          | Missing or invalid authentication token               |
| 403             | Forbidden             | User doesn't have necessary permissions               |
| 404             | Not Found             | Requested resource doesn't exist                      |
| 409             | Conflict              | Request conflicts with current state of the server    |
| 500             | Internal Server Error | Unexpected condition on the server                    |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cosmocloud.io/flow-builder/node-types/trigger-nodes/http-response.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
