Skip to content
Console
Menu

Getting Started

Authentication

KV Store

Batch ingest on an usage event

Records a batch of already-incurred usage from the merchant's own servers (Stripe's meter-event model): the caller is a key of the…

Records a batch of already-incurred usage from the merchant's own servers (Stripe's meter-event model): the caller is a key of the merchant's own org holding the exact grant billing:metering:ingest, which no wildcard covers, and each event names its subject with no subject proof. Each event is keyed by its project, meter, meter version and event id: a replay is a no-op (duplicate), and the same key with different content is a conflict and never counted. One result per event, in request order.

  • Path POST https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/usage_events:batchIngest
  • Scope billing:metering:ingest
  • Effect write — a successful call changes state.
  • Collection usage_events

#Request

FieldTypeWhat it is
parentstringThe environment to record in. Required.
usage_eventsIngestedUsageEvent[]1 to 500 events. Required.

#IngestedUsageEvent

FieldTypeWhat it is
event_idstringThe emitter's id of this event, 1 to 128 characters of [A-Za-z0-9._:-]; with the meter and its version, the dedupe key. Required.
meterstringThe meter. Required.
meter_versionint32The emitter's version of the meter's definition, 1 or more. Required.
subjectSubjectWho used it, as attributed by the emitter. Required.
quantityint64How much, 1 to 2^40. Required.
occurred_timetimestampWhen it happened. Required.

#Subject

FieldTypeWhat it is
end_userstringAn end user's id (Sylphx Auth, or the app's own OIDC issuer). One of the kind group.
customer_organizationstringA customer organization's id. One of the kind group.

#Response

FieldTypeWhat it is
resultsIngestedUsageEventResult[]One per event, in request order.

#IngestedUsageEventResult

FieldTypeWhat it is
event_idstringThe event's event_id.
outcomestringaccepted (recorded now), duplicate (already recorded with the same content: a no-op), conflict (its key was recorded with other content; this one is never counted) or rejected (refused; see reason).
reasonstringFor rejected: invalid (a field is out of range), unpriced (no active meter with a price in force at occurred_time) or reservation_required (the meter records only through a reservation); empty otherwise.
usage_eventstringThe UsageEvent that counts this usage, for accepted and duplicate.

#Errors

Every error arrives in the body Errors describes.

#Examples

curl -X POST "https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/usage_events:batchIngest" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"usage_events":[{"event_id":"…","meter":"…","meter_version":1,"occurred_time":{},"quantity":1,"subject":{}}]}'