Skip to main content

Usage

Generated from apiome-rest/openapi.yaml (API version 1.307.0) — do not edit by hand. How to authenticate is on the REST API reference.

Tag: usage · 1 operation

POST /v1/tenants/{tenant_slug}/usage/ingest​

Ingest a batch of usage events

The usage index's one door (RDG-1.2). Each event runs through the pipeline in order and stops at its first refusal:

  1. Tier cap — usage_events_per_day of the workspace's license. Over it, the whole batch is answered 429 usage-quota-exceeded with retryAt and ledgered as rejected.
  2. Head sampling — a deterministic hash of (source, observed_at, path, status) against the source's sampling_rate; counts are scaled by the inverse rate (basis: sampled).
  3. Scrubbing — path segments that look like a credential, an email or a UUID become {param}; query values are discarded and names kept; the user agent is scrubbed and truncated.
  4. Template matching against the project's published revisions — /pets/42 lands on GET /pets/{petId}. Unmatched traffic is counted by inferred template.
  5. Ledger — one row per batch; this response echoes it.

Requires a workspace API key with the usage:ingest scope (or full access). A batch carrying a sample is refused with 422 usage-body-not-accepted unless the source's body window is open.

Operation id: ingest_usage_v1_tenants__tenant_slug__usage_ingest_post

Parameters

NameInTypeRequiredDescription
tenant_slugpathstringyesURL-safe tenant slug that scopes the request.
authorizationheaderstring or nullnoJWT bearer token for authenticated access (Authorization: Bearer <token>).
X-API-Keyheaderstring or nullnoTenant-scoped API key used as an alternative to JWT bearer authentication.
X-Apiome-Usage-Sourceheaderstring (uuid)noThe usage source, when the body has no source_id.

Request body (required)

A batch of at most 5000 apiome.usage.event/v1 events, at most 2097152 bytes (send Content-Encoding: gzip to compress it; the limit applies before and after decompression).

  • application/json — object
PropertyTypeRequiredDescription
source_idstring (uuid)noThe usage source (or send the X-Apiome-Usage-Source header).
eventsarray of objectyesEvents.

Responses

StatusDescriptionBody
200Successful response for ingest a batch of usage events.application/json UsageIngestResponse
400Malformed batch, unknown encoding, or no source named.—
403Not a workspace API key, or the source is disabled.—
404Unknown source.—
413Over 2 MiB or 5,000 events.—
422usage-body-not-accepted: a sample was sent while the body window is closed.—
429usage-quota-exceeded: over today's cap; retryAt says when it resets.—

Schemas used​

UsageIngestResponse​

The ledger row of an admitted batch, echoed back.

PropertyTypeRequiredDescription
batchIdstringyesThe usage_ingest_batch ledger row.
sourceIdstringyesThe source the batch was filed under.
receivedAtstring (date-time)yesWhen the batch was ledgered.
receivedintegeryesEvents in the batch.
acceptedintegeryesKept by sampling and matched to an operation of a published revision.
attributedintegernoOf the accepted events, how many a consumer binding attributed to a consumer (RDG-1.8). The rest are counted under the reserved anonymous consumer, never dropped.
sampledOutintegeryesDropped by head sampling.
unmatchedintegeryesKept, but no published revision declares the operation; counted by inferred template.
rejectedintegeryesRefused; see rejections.
scrubFindingsintegeryesStrings the edge scrub rewrote or dropped (a count, never what was found).
basisstringyescomplete at sampling rate 1; sampled when counts were scaled by the inverse rate.
samplingRatenumberyesThe source's head-sampling rate.
samplesUsageIngestSamplesyesSamples.
rejectionsarray of UsageIngestRejectionyesPer-event rejections, at most 100 (the counts cover every event).
rejectionsTruncatedbooleanyesWhether rejections was cut short.