# Batching HTTP Requests

When you need to make multiple HTTP requests concurrently within a single step, `lam.httpRequests` is your go-to. This is more efficient than creating multiple sequential `lam.httpRequest` steps if the requests don't depend on each other's immediate output.

The value associated with `lam.httpRequests` is an array of objects, where each object has the same structure as a single `lam.httpRequest` definition.

The output of a `lam.httpRequests` step will be an array of response objects, corresponding to the order of requests defined.

**Example:** Suppose we want to handle incoming orders and we want to send them to different fulfillment centres.

{% stepper %}
{% step %}

### Send Orders to Warehouse

```javascript
(data) => {
  const { input } = data;
  
  return {
    "lam.httpRequests": [
      {
        "method": "POST",
        "url": "{{config.baseUrl}}/send-to-warehouse/premium",
        "body": input.premiumOrder
      },
      {
        "method": "POST",
        "url": "{{config.baseUrl}}/send-to-warehouse/regular",
        "pathParams": {
          "itemId": input.regularOrder
        }
      }
    ]
  };
}
```

{% endstep %}

{% step %}

### Update Status Orders

```javascript
(data) => {
  const { input } = data;
  const { response } = data;
  
  return {
    "lam.httpRequests": [
      {
        "method": "PUT",
        "url": `{{config.baseUrl}}/order/${input.premiumOrder.id}`,
        "body": {
          "status": "Processing",
          "tracking_url": response[0].tracking_url,
          "shipment_reference_id": response[0].tracking_number,
        }
      },
      {
        "method": "PUT",
        "url": `{{config.baseUrl}}/order/${input.regularOrder.id}`,
        "body": {
          "status": "Processing",
          "tracking_url": response[1].tracking_url,
          "shipment_reference_id": response[1].tracking_number,
        }
      }
    ]
  };
}
```

{% endstep %}
{% endstepper %}


---

# 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.laminar.run/advanced/batching-http-requests.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.
