## Make an HTTP Request

The HTTP step allows you to make various types of HTTP calls (GET, POST, PUT, DELETE, etc.) and receive a structured response including status, headers, and the response body.

### When to Use

*   Call external APIs to fetch or send data.
*   Fetch data to drive conditional logic in your workflows.
*   Send data to another system using POST or PUT requests.
*   Build reliable, auditable flows without relying solely on an LLM for I/O operations.

### Configuration

Configure your HTTP request using the following fields. Exact labels may vary slightly depending on the UI version.

*   **Method**: Select the HTTP method for your request.
    *   `GET`
    *   `POST`
    *   `PUT`
    *   `PATCH`
    *   `DELETE`
*   **URL**: The target URL for the HTTP request. Supports Handlebars expressions (e.g., `{{Variables.myUrl}}`).
*   **Headers**: Key-value pairs for request headers. Supports Handlebars expressions.
    *   > 💡 Note: If you specify `Content-Type` in headers and also provide a JSON body, ensure they match to avoid unexpected behavior.
*   **Query Parameters**: Key-value pairs for URL query parameters. Supports Handlebars expressions.
*   **Body**: The request body, typically used for `POST`, `PUT`, or `PATCH` requests. Can be raw text or JSON. Supports Handlebars expressions.
*   **Content-Type**: Specifies the `Content-Type` header for the request body (e.g., `application/json`, `text/plain`).
*   **(Optional) Timeout**: Sets a maximum duration for the request.
*   **(Optional) Retries**: Configures the number of times the request should be retried in case of failure.
*   **(Optional) Follow redirects**: Determines whether the client should automatically follow HTTP redirects.

### Input

The HTTP step can run with or without upstream input. Input is primarily used when you want to reference dynamic values (e.g., in the URL, body, or headers) via Handlebars expressions.

**Example Input:**

```json
[
  { "$type": "input", "Value": "hey there" }
]
```

### Output Schema

The step returns a structured response containing details about the HTTP call.

```json
{
  "$type": "sdkStep",
  "Output": {
    "Body": "any JSON / text / object / array",
    "Headers": { 
      "Header-Name": ["value1", "value2"] 
    },
    "Success": true,
    "StatusCode": 200,
    "ContentType": "application/json",
    "ErrorMessage": null
  },
  "Success": true
}
```

*   **`Output.Body`**: The response body from the HTTP call. This can be JSON, text, or any other format returned by the server.
*   **`Output.Headers`**: An object containing all response headers.
*   **`Output.Success`**: A boolean indicating if the HTTP request itself was successful (e.g., received a 2xx status code).
*   **`Output.StatusCode`**: The HTTP status code received (e.g., `200`, `404`, `500`).
*   **`Output.ContentType`**: The `Content-Type` of the response body.
*   **`Output.ErrorMessage`**: An error message if the request failed for reasons other than an HTTP status code (e.g., network error, timeout).

### Examples

#### Example: GET a JSON List

This example demonstrates fetching a list of objects from a public API.

**Config:**

*   **Method**: `GET`
*   **URL**: `https://api.restful-api.dev/objects`

**Example Output:**

```json
{
  "$type": "sdkStep",
  "Output": {
    "Success": true,
    "StatusCode": 200,
    "ContentType": "application/json",
    "ErrorMessage": null,
    "Body": [
      { 
        "id": "1", 
        "name": "Google Pixel 6 Pro", 
        "data": { "color": "Cloudy White" } 
      }
    ],
    "Headers": { "Content-Type": ["application/json"] }
  },
  "Success": true
}
```

#### Example: POST JSON with Dynamic Values

This example shows how to send JSON data in a POST request, using Handlebars expressions to insert dynamic values from your workflow variables.

**Config:**

*   **Method**: `POST`
*   **URL**: `https://api.restful-api.dev/objects`
*   **Headers**: `Content-Type`: `application/json`
*   **Body**:

```json
{
  "name": "{{Variables.productName}}",
  "data": {
    "createdAt": "{{Helpers.CurrentDateTime}}"
  }
}
```
