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

# Hightouch

> Sync usage rows from Hightouch to Lago with an HTTP Request destination that posts events to /api/v2/events with external_contract_id.

The Hightouch integration syncs usage rows from your warehouse, database or spreadsheet to Lago as billable events. Use it when usage already lives in a data source and you want Lago to rate it against a contract.

## Prerequisites

**In Lago:**

1. Create a Lago organization to manage your billing and invoicing.
2. Create a [billable metric](https://getlago.com/docs/v2/guide/billable-metrics/create-billable-metrics.md) to track the usage of your customers.
3. Create a [metered product](https://getlago.com/docs/v2/guide/product-catalog/metered-products.md) on that metric, price it with a [rate card](https://getlago.com/docs/v2/guide/rate-cards/overview.md), and add it to a [plan](https://getlago.com/docs/v2/guide/plans/overview.md).
4. Create a [customer](https://getlago.com/docs/v2/guide/customers/customer-management.md) and a [contract](https://getlago.com/docs/v2/guide/contracts/overview.md) for that customer.

**In Hightouch:**

1. Create a Hightouch account.
2. Create a data source (ideally, product usage of your customer).
3. Create an **HTTP Request** destination.

## Send usage from Hightouch to Lago

### Create a data source

First, create a source in Hightouch:

1. Navigate to the **Sources** tab.
2. Add a **new source**.
3. Choose and set up a data source available in Hightouch (a database, a warehouse or a spreadsheet, for instance).

![Hightouch Sources tab listing available data sources](https://mintcdn.com/lago-docs/aaVDsanqVM_V30mw/integrations/usage/images/hightouch-sources-3aa4046d89ec2208963b3e541408a249.png?fit=max\&auto=format\&n=aaVDsanqVM_V30mw\&q=85\&s=23c08f86883b1867132ea4c41179e758)

Hightouch Sources

### Use the HTTP Request destination

Lago uses Hightouch's HTTP Request destination to ingest usage:

1. Go to the **Destinations** tab.
2. Select the **HTTP Request** destination.
3. Define your **Headers**. Lago requires `Authorization` (secret, `Bearer __YOUR_API_KEY__`) and `Content-Type: application/json`.
4. Save the destination.

![Hightouch HTTP Request destination with Authorization and Content-Type headers](https://mintcdn.com/lago-docs/aaVDsanqVM_V30mw/integrations/usage/images/hightouch-http-destination-d613e2e5663423ea83712c055d893333.png?fit=max\&auto=format\&n=aaVDsanqVM_V30mw\&q=85\&s=3db4f863f80ce784b0a2bace0fc668be)

Hightouch HTTP Request Destination

### Create a sync

Go to the **Syncs** tab and create a new sync from your source to the HTTP Request destination.

1. Configure when to trigger the event (row added, row deleted, row updated).
2. Define `POST` as the HTTP method.
3. Define the target URL: `https://api.getlago.com/api/v2/events` (or `https://api.eu.getlago.com/api/v2/events` for EU-hosted organizations).
4. Send data as `JSON` and use the JSON editor.
5. Define rate limits, if applicable.

### Example JSON payload

You define the JSON payload sent to Lago. Hightouch supports the Liquid template language to insert variables from your source: `"{{ row.variable }}"`, where *variable* is the column name in your source.

The payload follows the events schema of [`POST /api/v2/events`](https://getlago.com/docs/v2/api-reference/events/create). Each event targets a contract through `external_contract_id`:

```json theme={"dark"}
{
  "event": {
    "transaction_id": "{{ row.transactionId }}",
    "external_contract_id": "{{ row.contractId }}",
    "code": "api_calls",
    "timestamp": "{{ row.timestamp }}",
    "properties": {
      "invoice_id": "{{ row.invoiceId }}"
    }
  }
}
```

> [!NOTE]
>
> `transaction_id` and `code` are required. `code` must match a billable metric code. `external_contract_id` must match the `external_id` of the contract you bill. `timestamp` is a Unix timestamp in seconds and defaults to the request time. Adapt `properties` to your billable metric.

### Test and activate your sync

Test the sync with a data sample. The event should appear in Lago's events list, or through [`GET /api/v2/events`](https://getlago.com/docs/v2/api-reference/events/list). Once ready, activate the sync and define the periodic trigger.

![Hightouch Test a row dialog before syncing a usage row to Lago](https://mintcdn.com/lago-docs/aaVDsanqVM_V30mw/integrations/usage/images/sync-test-hightouch-34f6e41a10dd05b637841b6f4d1581fa.png?fit=max\&auto=format\&n=aaVDsanqVM_V30mw\&q=85\&s=e4f2232fcdfac5c82d7b335bc80835a7)

Hightouch Test Sync with Lago

## Hightouch to Lago demo video

> [!NOTE]
>
> This video was recorded with the legacy v1 events payload. Its Hightouch setup steps still apply. Use the V2 URL and payload above.

[Hightouch to Lago demo video](https://www.youtube.com/embed/2NBmQYjrz40)

> [card] [Ingest usage](https://getlago.com/docs/v2/guide/events/ingesting-usage.md)
>
> How events target a contract.

> [card] [Ingest a batch of events](https://getlago.com/docs/v2/api-reference/events/batch.md)
>
> `POST /api/v2/events/batch` reference.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.