> ## 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.

# Events

> Send usage to Contracts with lago v2 events: one event, an NDJSON stream, or a batch.

| Command | Description |
| - | - |
| `v2 events send` | Send one event from flags, or stream NDJSON with `--file`. |
| `v2 events batch` | Send up to 100 events in one request by default. Deployments can set another maximum. |
| `v2 events list` | List ingested events by event time. |

v2 events address a Contract with `external_contract_id`. Send it on every event so the usage reaches that Contract's rate cards.

## send

| Flag | Description |
| - | - |
| `--code` | Billable metric code. Required. |
| `--transaction-id` | Your idempotency key. Required, except with `--file`, where a line without one gets a generated UUID. |
| `--external-contract-id` | The Contract the usage belongs to. |
| `--timestamp` | Unix seconds or an RFC 3339 instant. Defaults to the request time. |
| `--properties` | JSON object of event properties, such as filter keys or the aggregated field. |
| `--precise-total-amount-cents` | Amount in cents, for dynamic pricing. |
| `--file <path>` | Stream newline-delimited JSON events from a file, or `-` for stdin. One request per line. |
| `--concurrency` | Parallel requests with `--file`, 1 to 64. Default 4. |

`transaction_id` plus `timestamp` is the deduplication key. Keep both when you retry. With `--file`, the CLI retries a line on 429 or 5xx only when it carries a timestamp, and warns about lines with a transaction ID but no timestamp. A line can be a bare event or wrapped in `{"event": {...}}`.

## batch

`--events` takes a JSON array of events, or pass `--input` with `{"events": [...]}`.

## list

Filters are `--external-contract-id`, `--code`, `--transaction-id`, `--timestamp-from` and `--timestamp-to`. Newly accepted events may not appear immediately. On ClickHouse organizations, a successful send acknowledges ingestion, not completed enrichment.

See [usage ingestion](https://getlago.com/docs/v2/guide/events/ingesting-usage.md) and [retrieve usage](https://getlago.com/docs/v2/guide/events/retrieve-usage.md).

```bash send theme={"dark"}
lago v2 events send --external-contract-id acme_main --code api_calls \
  --transaction-id api_call_0001 --timestamp 1800007200

lago v2 events send --external-contract-id acme_main --code llm_tokens \
  --transaction-id req_8f2c --timestamp 2027-01-15T10:00:00Z \
  --properties '{"tokens":"1200","model":"large"}'
```

```bash stream NDJSON theme={"dark"}
lago v2 events send --file usage.ndjson
cat usage.ndjson | lago v2 events send --file - --concurrency 8
```

```bash batch theme={"dark"}
lago v2 events batch --events '[
  {"transaction_id":"api_call_0002","code":"api_calls","external_contract_id":"acme_main","timestamp":1800007200},
  {"transaction_id":"api_call_0003","code":"api_calls","external_contract_id":"acme_main","timestamp":1800007200}
]'
```

```bash list theme={"dark"}
lago v2 events list --external-contract-id acme_main --code api_calls \
  --timestamp-from 2027-01-01 --limit 20
```

```text send theme={"dark"}
CODE                  api_calls
EXTERNAL_CONTRACT_ID  acme_main
PROPERTIES            {}
TIMESTAMP             2027-01-15T10:00:00Z
TRANSACTION_ID        api_call_0001
```

```jsonl usage.ndjson theme={"dark"}
{"transaction_id":"api_call_0004","code":"api_calls","external_contract_id":"acme_main","timestamp":1800007200}
{"transaction_id":"api_call_0005","code":"api_calls","external_contract_id":"acme_main","timestamp":"2027-01-15T10:00:00Z"}
```

```text stream NDJSON theme={"dark"}
DRY_RUN  false
FAILED   0
QUEUED   2
RETRIED  0
SENT     2
```


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