> 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/integration-design/api-requests.md).

# API Requests

## Overview

Laminar provides multiple ways to make API requests:

1. Using source/destination APIs in flows
2. Using the `httpRequest` keyword directly in transformations

## Source and Destination APIs

Each flow can specify:

* A **source** API to fetch data from at the start of the flow
* A **destination** API to send transformed data to at the end of the flow

These are configured using [API Descriptions](/running-an-integration/api-descriptions.md) and authenticated through the [Configuration Store](https://github.com/laminar-run/docs/blob/main/concepts/configurations.md).

Responses and data transformations are stored in the [Global Workflow Object](/building-an-integration/advanced/workflows/global-workflow-object.md) during execution, and individual API request inputs and outputs are stored in [Flow Runs](/building-an-integration/advanced/flows/flow-runs.md).

## Direct HTTP Requests

### Single Request

Use `lam.httpRequest` to make a single HTTP request within a transformation:

### JavaScript

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequest": {
      "method": "POST",
      "url": "{{props.baseUrl}}/orders",
      "headers": {
        "Authorization": "Bearer {{props.apiKey}}",
        "Content-Type": "application/json"
      },
      "body": {
        "orderId": input.orderId,
        "items": input.items
      }
    }
  };
}
```

### JQ

```jq
.input |
{
  "lam.httpRequest": {
    "method": "POST",
    "url": "{{props.baseUrl}}/orders",
    "headers": {
      "Authorization": "Bearer {{props.apiKey}}",
      "Content-Type": "application/json"
    },
    "body": {
      "orderId": .orderId,
      "items": .items
    }
  }
}
```

### Parallel Requests

Use `lam.httpRequests` to make multiple requests in parallel:

### JavaScript

```javascript
(payload) => {
  const { input } = payload;
  
  return {
    "lam.httpRequests": input.items.map(item => ({
      "method": "GET",
      "url": "{{props.baseUrl}}/inventory/{{itemId}}",
      "pathParams": {
        "itemId": item.id
      }
    }))
  };
}
```

### JQ

```jq
.input.items |
{
  "lam.httpRequests": map({
    "method": "GET",
    "url": "{{props.baseUrl}}/inventory/{{itemId}}",
    "pathParams": {
      "itemId": .id
    }
  })
}
```

## Request Components

| Component  | Description                          | Required |
| ---------- | ------------------------------------ | -------- |
| method     | HTTP method (GET, POST, PUT, DELETE) | Yes      |
| url        | Request URL with optional templates  | Yes      |
| pathParams | URL path parameters                  | No       |
| headers    | HTTP headers                         | No       |
| body       | Request body                         | No       |

## Using Configuration Properties

Reference configuration properties in URLs and headers using `{{props.propertyName}}` syntax:

```javascript
{
  "url": "{{props.baseUrl}}/api/{{version}}/orders",
  "headers": {
    "Authorization": "Bearer {{props.apiKey}}"
  }
}
```

## Choosing an Approach

* Use **Source/Destination APIs** when:
  * You have a fixed API endpoint for input/output
  * You want to reuse API configurations
  * You need clear separation of data flow
* Use **HTTP Request Keywords** when:
  * You need dynamic endpoint selection
  * You want to make requests mid-flow
  * You need to make parallel requests

## Related

* [HTTP Request Keyword](https://github.com/laminar-run/docs/blob/main/platform/keywords/lam.httprequest.md)
* [HTTP Requests Keyword](https://github.com/laminar-run/docs/blob/main/platform/keywords/lam.httprequests.md)
* [API Descriptions](/running-an-integration/api-descriptions.md)
* [Configurations](https://github.com/laminar-run/docs/blob/main/concepts/configurations.md)
