Skip to main content
Reports usage of a metered feature for a customer.

Mutation

mutation ReportUsage($input: ReportUsageInput!) {
  reportUsage(input: $input) {
    measurementId
    currentUsage
  }
}

Parameters

input
ReportUsageInput
required
Input for reporting usage

Return Type

Returns a UsageMeasurementWithCurrentUsage with:
FieldTypeDescription
measurementIdStringMeasurement ID
currentUsageFloatUpdated current usage

Update Behaviors

BehaviorDescription
DELTAAdd value to current usage (default)
SETSet current usage to value

Examples

Increment Usage

{
  "input": {
    "customerId": "customer-123",
    "featureId": "feature-api-calls",
    "value": 100,
    "updateBehavior": "DELTA"
  }
}

Set Absolute Value

{
  "input": {
    "customerId": "customer-123",
    "featureId": "feature-storage",
    "value": 5.5,
    "updateBehavior": "SET"
  }
}

With Idempotency

{
  "input": {
    "customerId": "customer-123",
    "featureId": "feature-api-calls",
    "value": 100,
    "idempotencyKey": "request-abc-123"
  }
}

Common Use Cases

Report API calls as they happen for rate limiting.
Update storage usage periodically.
Report usage events for billing calculation.