Skip to content
  • Auto
  • Light
  • Dark
Talk to an expert

Ingest

Ingest events
client.v1.usage.ingest(UsageIngestParamsbody?, RequestOptionsoptions?): void
post/v1/ingest

Send usage events to Metronome. The body of this request is expected to be a JSON array of between 1 and 100 usage events. Compressed request bodies are supported with a Content-Encoding: gzip header. See Getting usage into Metronome to learn more about usage events.

Parameters
bodyusagearrayUsageIngestParams
Hide ParametersShow Parameters
usagearray
optional
Array<Usage>
Hide ParametersShow Parameters
customer_idstring
minLength1
event_typestring
minLength1
timestampstring

RFC 3339 formatted

transaction_idstring
minLength1
maxLength128
propertiesRecord<string, unknown>
optional
import Metronome from '@metronome/sdk';

const client = new Metronome({
  bearerToken: 'My Bearer Token',
});

await client.v1.usage.ingest([
  {
    customer_id: '[email protected]',
    event_type: 'heartbeat',
    timestamp: '2021-01-01T00:00:00Z',
    transaction_id: '2021-01-01T00:00:00Z_cluster42',
  },
]);