Skip to main content
POST
/
v1
/
customers
/
{customer_id}
/
previewEvents
Preview events
curl --request POST \
  --url https://api.metronome.com/v1/customers/{customer_id}/previewEvents \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "events": [
    {
      "event_type": "heartbeat",
      "timestamp": "2021-01-01T00:00:00Z",
      "properties": {
        "cpu_hours": 100,
        "memory_gb_hours": 200
      }
    }
  ],
  "mode": "replace"
}'
{
  "data": [
    {
      "id": "6a37bb88-8538-48c5-b37b-a41c836328bd",
      "customer_id": "617e39d8-68f4-4592-b8d2-c2bf26a76989",
      "type": "USAGE",
      "start_timestamp": "2021-01-01T00:00:00Z",
      "end_timestamp": "2021-02-01T00:00:00Z",
      "credit_type": {
        "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
        "name": "USD (cents)"
      },
      "contract_id": "9de042a1-b955-43ce-9ab4-e3c2004570d1",
      "line_items": [
        {
          "credit_type": {
            "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
            "name": "USD (cents)"
          },
          "name": "CPU hours",
          "quantity": 31416,
          "total": 62832,
          "type": "usage",
          "product_id": "5c1f40cd-9ff8-4e90-ae53-5f81b0e9d1e8"
        }
      ],
      "total": 62832,
      "status": "DRAFT"
    },
    {
      "id": "9543ee18-7bed-4b72-9797-729758093cf1",
      "customer_id": "617e39d8-68f4-4592-b8d2-c2bf26a76989",
      "type": "USAGE",
      "start_timestamp": "2021-01-01T00:00:00Z",
      "end_timestamp": "2021-02-01T00:00:00Z",
      "credit_type": {
        "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
        "name": "USD (cents)"
      },
      "contract_id": "cb3b77c4-467c-418a-ab68-a08113760cd2",
      "line_items": [
        {
          "credit_type": {
            "id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
            "name": "USD (cents)"
          },
          "name": "Storage GB-hours",
          "quantity": 15708,
          "total": 31416,
          "type": "usage",
          "product_id": "7ba25fb0-33b0-4dc8-911e-4b4065ed585e"
        }
      ],
      "total": 31416,
      "status": "DRAFT"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

customer_id
string<uuid>
required

Body

application/json

The events to preview

events
object[]
required

Array of usage events to include in the preview calculation. Must contain at least one event in merge mode.

Required array length: 1 - 100 elements
mode
enum<string>
default:replace

Controls how the provided events are combined with existing usage data. Use replace to calculate the preview as if these are the only events for the customer, ignoring all historical usage. Use merge to combine these events with the customer's existing usage. Defaults to replace.

Available options:
replace,
merge
skip_zero_qty_line_items
boolean
default:false

When true, line items with zero quantity are excluded from the response.

Response

Success

data
object[]
required