> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP Request

> Make HTTP/HTTPS requests to APIs and web services

The HTTP Request command (Command Type: 1001) enables you to make HTTP/HTTPS requests to APIs and web services. This command is essential for fetching data from REST APIs, web services, and other HTTP-based endpoints.

## Overview

The HTTP Request command provides functionality for:

* Making GET, POST, PUT, DELETE, and other HTTP method requests
* Configuring request headers, query parameters, and request bodies
* Handling authentication and authorization
* Managing timeouts and error handling
* Processing HTTP responses

## Command Type

**Command Type ID:** 1001

## Parameters

| Parameter           | Type          | Description                                       | Required              |
| ------------------- | ------------- | ------------------------------------------------- | --------------------- |
| **url**             | string        | The target URL for the HTTP request               | Yes                   |
| **method**          | string        | HTTP method (GET, POST, PUT, DELETE, PATCH, etc.) | No (defaults to GET)  |
| **headers**         | object        | HTTP headers to include in the request            | No                    |
| **body**            | string/object | Request body for POST/PUT requests                | No                    |
| **timeout**         | number        | Maximum wait time in milliseconds                 | No                    |
| **queryParams**     | object        | URL query parameters                              | No                    |
| **followRedirects** | boolean       | Whether to follow HTTP redirects                  | No (defaults to true) |

## Usage Examples

### Basic GET Request

```json theme={null}
{
  "command": "http-request",
  "params": {
    "url": "https://api.example.com/data",
    "method": "GET",
    "timeout": 10000
  }
}
```

### POST Request with Body

```json theme={null}
{
  "command": "http-request",
  "params": {
    "url": "https://api.example.com/data",
    "method": "POST",
    "headers": {
      "Content-Type": "application/json"
    },
    "body": {
      "name": "Example",
      "value": 123
    },
    "timeout": 15000
  }
}
```

### GET Request with Query Parameters

```json theme={null}
{
  "command": "http-request",
  "params": {
    "url": "https://api.example.com/search",
    "method": "GET",
    "queryParams": {
      "q": "search term",
      "limit": 10,
      "offset": 0
    }
  }
}
```

### Request with Authentication

```json theme={null}
{
  "command": "http-request",
  "params": {
    "url": "https://api.example.com/protected",
    "method": "GET",
    "headers": {
      "Authorization": "Bearer %{API_TOKEN}",
      "X-API-Key": "%{API_KEY}"
    }
  }
}
```

### Request with Project Variables

```json theme={null}
{
  "command": "http-request",
  "params": {
    "url": "https://api.example.com/data?project=@{PROJECT_ID}&run=@{RUN_ID}",
    "method": "GET",
    "headers": {
      "X-Request-ID": "@{RUN_ID}",
      "X-Timestamp": "@{START_TIMESTAMP}"
    }
  }
}
```

## Variable Support

The HTTP Request command supports variable interpolation in:

* **URLs**: Use `@{VARIABLE}` in URLs
* **Headers**: Use `@{VARIABLE}` or `%{SECRET}` in header values
* **Query Parameters**: Use variables in query parameter values
* **Request Body**: Use variables in request body content

### Variable Types

* **Project Variables**: `@{PROJECT_ID}`, `@{RUN_ID}`, `@{START_TIMESTAMP}`
* **Secrets**: `%{API_KEY}`, `%{API_TOKEN}`, `%{PROXY_PASSWORD}`
* **Session Variables**: `#{UUID}` for session tracking
* **Event Variables**: `${event_id}` for event-specific values

## Response Handling

The HTTP Request command returns the HTTP response which can be used by subsequent commands:

### Response Structure

```json theme={null}
{
  "status": 200,
  "statusText": "OK",
  "headers": {},
  "body": {},
  "data": {}
}
```

### Using Response Data

The response from HTTP Request can be used as input for subsequent commands:

```json theme={null}
{
  "command": "json-path",
  "params": {
    "jsonPath": "$.data.items[*].id",
    "input": "@{PREVIOUS_OUTPUT}"
  }
}
```

## Error Handling

The HTTP Request command handles various error scenarios:

* **Timeout Errors**: Returns error if request exceeds timeout
* **Network Errors**: Handles connection failures
* **HTTP Errors**: Returns error status for non-2xx responses
* **Invalid URLs**: Validates URL format before request

## Best Practices

* **Use Secrets for Credentials**: Always use `%{SECRET_NAME}` for API keys and passwords
* **Set Appropriate Timeouts**: Configure timeouts based on expected response times (default: 30 seconds)
* **Handle Errors**: Implement error handling for failed requests
* **Use Project Variables**: Leverage `@{PROJECT_ID}` and `@{RUN_ID}` for tracking
* **Validate Responses**: Always validate response structure before processing
* **Use HTTPS**: Prefer HTTPS URLs for secure communication
* **Set Content-Type**: Explicitly set Content-Type header for POST/PUT requests

## Common Use Cases

* **API Integration**: Fetch data from REST APIs
* **Web Scraping**: Retrieve HTML content from web pages
* **Data Synchronization**: Pull data from external services
* **Authentication**: Handle API authentication flows
* **Webhook Processing**: Send data to webhook endpoints

## Related Commands

* [JSON Parse](/stream/commands/parse/json-parse) - Parse HTTP response data
* [Json Path](/stream/commands/parse/json-path) - Extract data from HTTP responses
* [Validation Commands](/stream/commands/validation) - Validate HTTP responses

## Troubleshooting

### Request Timeout

If requests are timing out:

* Increase the `timeout` parameter value
* Check network connectivity
* Verify the target server is accessible

### Authentication Errors

If authentication fails:

* Verify secrets are correctly configured
* Check API key/token format
* Ensure headers are properly formatted

### Invalid Response

If response structure is unexpected:

* Check response status code
* Verify Content-Type header
* Validate response body format
