Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sailia-mintlify-docs-reorg-1776565301.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Meter usage tracking lets you record consumption events against named meters and retrieve aggregated summaries over a date range. Use it to monitor resource usage, track billable activity, or build internal dashboards around any metric you define. Each usage entry captures a meter name, a numeric usage amount, and an optional timestamp. Sailia stores every entry and aggregates totals per meter when you query a summary.

How it works

  1. Record usage — send a usage entry with a meter name and amount whenever a billable or trackable event occurs.
  2. Query summaries — retrieve aggregated usage and event counts grouped by meter for a given date range.
All timestamps are handled as Unix seconds. If you omit the timestamp when recording, Sailia uses the current server time.

Record a usage entry

Send a POST request to the meter usage endpoint with the following body:
FieldTypeRequiredDescription
MeterstringYesThe name of the meter (e.g. api-calls, sms-sent, storage-gb)
UsagenumberYesThe usage amount — must be greater than 0
ExtraInfostringNoOptional metadata as a string (e.g. a JSON-encoded payload with additional context)
OccurredAtintegerNoA Unix timestamp (seconds) for when the event occurred. Defaults to the current time if omitted
{
  "Meter": "api-calls",
  "Usage": 1,
  "ExtraInfo": "{\"endpoint\": \"/bookings\"}",
  "OccurredAt": 1742860800
}
A successful request returns a 201 response with the created entry:
{
  "data": {
    "ID": 42,
    "Meter": "api-calls",
    "Usage": 1.0
  }
}

Validation

  • Meter must be a non-empty string.
  • Usage must be numeric and greater than 0.
  • OccurredAt, if provided, must be a valid Unix timestamp integer.
Validation errors return a 422 response with details about which fields failed.

Get a usage summary

Send a GET request to the meter usage endpoint with from and to query parameters in YYYY-MM-DD format:
GET /api/v2/usage/meters?from=2026-03-01&to=2026-03-31
The response includes totals per meter, along with the overall usage and event count for the period:
{
  "data": {
    "Period": {
      "From": "2026-03-01",
      "To": "2026-03-31",
      "FromTimestamp": 1740787200,
      "ToTimestamp": 1743465599
    },
    "Totals": {
      "Usage": 1250.0,
      "Events": 340
    },
    "Meters": [
      {
        "Meter": "api-calls",
        "TotalUsage": 1000.0,
        "EventCount": 300
      },
      {
        "Meter": "sms-sent",
        "TotalUsage": 250.0,
        "EventCount": 40
      }
    ]
  }
}
FieldDescription
PeriodThe requested date range with both human-readable dates and Unix timestamps
Totals.UsageSum of all usage amounts across all meters in the period
Totals.EventsTotal number of usage entries recorded across all meters
MetersA list of per-meter breakdowns, sorted by total usage (highest first)

Query parameters

ParameterTypeRequiredDescription
fromstringYesStart date in YYYY-MM-DD format (inclusive, from 00:00:00)
tostringYesEnd date in YYYY-MM-DD format (inclusive, through 23:59:59)
The to date must be on or after the from date. Both parameters are required — omitting either returns a 422 error.

Built-in meters

Sailia automatically records usage entries for certain platform events. These meters appear in your usage summaries alongside any custom meters you define — no additional setup is required.
MeterTriggerExtra info
order-completedA customer completes a purchase and payment succeedsBasketID — the ID of the completed basket
waitlist-notifiedA waitlist notification email is sent to a customerWaitlistID, MultiBookingID — identifiers for the waitlist entry and booking
workflow-email-sentAn automated workflow sends an email on your behalfNone

Example summary with built-in meters

{
  "data": {
    "Period": {
      "From": "2026-03-01",
      "To": "2026-03-31"
    },
    "Totals": {
      "Usage": 135.0,
      "Events": 135
    },
    "Meters": [
      {
        "Meter": "order-completed",
        "TotalUsage": 72.0,
        "EventCount": 72
      },
      {
        "Meter": "workflow-email-sent",
        "TotalUsage": 50.0,
        "EventCount": 50
      },
      {
        "Meter": "waitlist-notified",
        "TotalUsage": 13.0,
        "EventCount": 13
      }
    ]
  }
}
Built-in meter entries include an ExtraInfo field with a JSON-encoded payload containing contextual identifiers. You can use these to cross-reference events with other parts of the system.

Error handling

All error responses follow the standard problem detail format:
{
  "type": "https://sailia.dev/problems/validation",
  "title": "Unprocessable Entity",
  "status": 422,
  "detail": "Meter is required",
  "instance": "/api/v2/usage/meters"
}
Common error scenarios:
StatusCause
422Missing or invalid fields — check the detail message for specifics
403You do not have permission to access this resource