Skip to main content
POST
/
events
/
batch
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request POST "$LAGO_URL/api/v1/events/batch" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
	"events": [
      {
        "transaction_id": "__UNIQUE_ID__",
        "external_subscription_id": "__YOUR_SUBSCRIPTION_ID__",
        "code": "__BILLABLE_METRIC_CODE__",
        "timestamp": $(date +%s),
        "properties": {
          "custom_field": 12
        }
      }
    ]
  }'
{
  "status": 422,
  "error": "Unprocessable Entity",
  "code": "validation_errors",
  "error_details": {
    "1": {
      "transaction_id": [
        "value_already_exist"
      ]
    }
  }
}
Batches are atomic. If a single event is invalid, Lago rejects the entire batch with a 422 and persists nothing, including the valid events in the same request. “Invalid” covers a bad schema, an unknown subscription, or a duplicate transaction_id (value_already_exist). The error_details object reports failures by the event’s index in the array you sent, not by transaction_id, so keep your array order to trace an index back to its source event.
LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request POST "$LAGO_URL/api/v1/events/batch" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
	"events": [
      {
        "transaction_id": "__UNIQUE_ID__",
        "external_subscription_id": "__YOUR_SUBSCRIPTION_ID__",
        "code": "__BILLABLE_METRIC_CODE__",
        "timestamp": $(date +%s),
        "properties": {
          "custom_field": 12
        }
      }
    ]
  }'
{
  "status": 422,
  "error": "Unprocessable Entity",
  "code": "validation_errors",
  "error_details": {
    "1": {
      "transaction_id": [
        "value_already_exist"
      ]
    }
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Batch events payload

events
object[]
required

Response

Event received

events
object[]
required