> For the complete documentation index, see [llms.txt](https://docs.laminar.run/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.laminar.run/building-an-integration/advanced/flows/flow-types/http-request.md).

# HTTP Request

## Basic Structure

In Laminar, to codify an HTTP request, you must update your flow program to return an object with the following format:

```javascript
{
  "lam.httpRequest": {
    "method": "POST", // (or "GET", "PUT", "DELETE")
    "url": "https://api.example.com/endpoint",
    "pathParams": { /* optional */ },
    "queryParams": { /* optional */ },
    "headers": { /* optional */ },
    "body": { /* optional */ }
  }
}
```

#### Examples

1. Let's start with a basic GET request to fetch users:

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users"
    }
  }
}
```

2. Now, let's create a user with a POST request:

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "https://api.example.com/products",
      "body": {
        "name": "John Doe",
        "email": "john@example.com"
      }
    }
  }
}
```

## Optional Attributes

Now let's explore each optional attribute and how to use them effectively.

### Path Parameters

Path parameters are used to replace dynamic segments in your URL path.

**Example:**

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users/{userId}",
      "pathParams": {
        "userId": "12345"
      }
    }
  }
}
```

This will resolve to a request to `https://api.example.com/users/12345`.

### Query Parameters

Query parameters add a query string to your URL.

**Example:**

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users",
      "queryParams": {
        "page": 1,
        "limit": 10,
        "sort": "name"
      }
    }
  }
}
```

This will resolve to a request to `https://api.example.com/users?page=1&limit=10&sort=name`&#x20;

### Headers

Headers allow you to send additional information with your request.

**Example:**

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "GET",
      "url": "https://api.example.com/users",
      "headers": {
        "Authorization": "Bearer token123",
        "Content-Type": "application/json",
        "Accept-Language": "en-US"
      }
    }
  }
}
```

### Body

The body contains data sent with the request. It's typically used with POST, PUT, and PATCH methods.

**Example:**

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "https://api.example.com/users",
      "headers": {
        "Content-Type": "application/json"
      },
      "body": {
        "name": "Jane Smith",
        "email": "jane@example.com",
        "role": "admin"
      }
    }
  }
}
```

## Multiple Requests

Laminar also supports sending multiple HTTP requests in a single operation. This is useful for batch processing or when you need to perform several related actions at once. See [HTTP Request Batching](/building-an-integration/advanced/workflows/http-request-batching.md).

You can make your batch requests more powerful by using dynamic path parameters. This is especially useful when working with lists of IDs:

```javascript
(payload) => {
  const { input } = payload;
  
  return userIds.map(userId => ({
  "lam.httpRequest": {
    "method": "GET",
    "url": "https://api.example.com/users/{userId}",
    "pathParams": {
      "userId": userId
    }
  }
}));
```
