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

# HTTP Request

> Make HTTP requests to any API endpoint with full control over method, headers, and body content.

# HTTP Request

The HTTP Request step allows you to make HTTP requests to any API endpoint. This enables integration with external services, webhooks, and custom APIs.

## Overview

HTTP Request steps are powerful for:

* Integrating with third-party APIs
* Calling webhooks
* Fetching data from external services
* Triggering actions in other systems
* Building custom integrations

## Configuration

When you add an HTTP Request step, you'll configure:

### HTTP Method

Select the HTTP method for your request:

* **GET**: Retrieve data from an endpoint
* **POST**: Create new resources or send data
* **PUT**: Update or replace resources
* **PATCH**: Partially update resources
* **DELETE**: Remove resources
* **HEAD**: Retrieve headers without body
* **OPTIONS**: Get allowed methods for an endpoint

### URL

Enter the full URL of the API endpoint:

```
https://api.example.com/v1/users
```

<Note>
  URLs can include workflow variables. Use `{{variable.name}}` syntax to insert dynamic values into the URL.
</Note>

### Headers

Add custom HTTP headers for your request:

* **Authorization**: API keys, Bearer tokens, etc.
* **Content-Type**: Specify the request body format
* **Custom headers**: Any additional headers required by the API

<CodeGroup>
  ```json Example: API Key Authentication theme={null}
  {
    "Authorization": "Bearer {{api.key}}",
    "Content-Type": "application/json"
  }
  ```

  ```json Example: Basic Authentication theme={null}
  {
    "Authorization": "Basic {{credentials}}",
    "Content-Type": "application/json"
  }
  ```
</CodeGroup>

### Request Body

Configure the request body based on the body type:

#### Body Type

Choose the format for your request body:

* **JSON**: Send JSON data (most common for REST APIs)
* **Form Data**: Send form-encoded data
* **Raw Text**: Send plain text
* **XML**: Send XML data

#### Body Content

Enter the body content. You can use workflow variables to insert dynamic values:

<CodeGroup>
  ```json JSON Body Example theme={null}
  {
    "userId": "{{user.id}}",
    "email": "{{user.email}}",
    "name": "{{user.name}}"
  }
  ```

  ```text Form Data Example theme={null}
  userId={{user.id}}&email={{user.email}}&name={{user.name}}
  ```

  ```xml XML Body Example theme={null}
  <user>
    <id>{{user.id}}</id>
    <email>{{user.email}}</email>
    <name>{{user.name}}</name>
  </user>
  ```
</CodeGroup>

## Response Handling

HTTP Request steps return response data that can be used in subsequent steps:

* **Response Body**: The response content (JSON, text, etc.)
* **Status Code**: HTTP status code (200, 404, 500, etc.)
* **Headers**: Response headers from the API

<Note>
  Response data is automatically parsed and available as workflow variables in subsequent steps. JSON responses are parsed into accessible variables.
</Note>

## Example Use Cases

### User Creation API

Create a user in an external system:

```
Trigger (Event: User Signs Up)
  ↓
HTTP Request
  Method: POST
  URL: https://api.example.com/users
  Headers:
    Authorization: Bearer {{api.token}}
    Content-Type: application/json
  Body:
    {
      "email": "{{user.email}}",
      "name": "{{user.name}}"
    }
```

### Webhook Notification

Send a webhook notification:

```
Trigger (Event: Order Completed)
  ↓
HTTP Request
  Method: POST
  URL: {{webhook.url}}
  Headers:
    X-API-Key: {{webhook.key}}
    Content-Type: application/json
  Body:
    {
      "event": "order.completed",
      "orderId": "{{order.id}}",
      "amount": {{order.amount}}
    }
```

### Data Fetching

Fetch data from an external API:

```
Trigger (Event: User Profile View)
  ↓
HTTP Request
  Method: GET
  URL: https://api.example.com/users/{{user.id}}/preferences
  Headers:
    Authorization: Bearer {{api.token}}
  ↓
Send Email (Use fetched preferences in email)
```

## Error Handling

HTTP Request steps can fail for various reasons:

* **Network errors**: Connection timeouts, DNS failures
* **HTTP errors**: 4xx (client errors) or 5xx (server errors)
* **Invalid responses**: Malformed JSON or unexpected formats

<Tip>
  Use flow control steps to check response status codes and handle errors gracefully. For example, retry on 5xx errors or send notifications on 4xx errors.
</Tip>

## Best Practices

<AccordionGroup>
  <Accordion title="Use Secure Headers">
    Store sensitive data like API keys in workflow variables rather than hardcoding them. This keeps credentials secure and makes them reusable.
  </Accordion>

  <Accordion title="Validate Responses">
    Use flow control steps to check response status codes and handle different outcomes appropriately.
  </Accordion>

  <Accordion title="Handle Timeouts">
    Be aware that HTTP requests have timeout limits. For long-running operations, consider using webhooks or polling instead.
  </Accordion>

  <Accordion title="Test API Endpoints">
    Test your HTTP requests with sample data before deploying workflows to ensure endpoints are accessible and responses are as expected.
  </Accordion>

  <Accordion title="Use Appropriate Methods">
    Use GET for retrieving data, POST for creating resources, PUT/PATCH for updates, and DELETE for removals. This follows REST API conventions.
  </Accordion>
</AccordionGroup>

<Warning>
  Never expose API keys or sensitive credentials in workflow configurations. Use workflow variables or secure storage for authentication credentials.
</Warning>

<Tip>
  Use the preview feature in the HTTP Request configuration to test your request before saving. This helps catch configuration errors early.
</Tip>
