Skip to main content
POST
Create metric

Authorizations

Authorization
string
header
required

API Keys can be issued in the Orb's web application.

Body

application/json
sql
string
required

A sql string defining the metric.

Example:

"SELECT sum(bytes_downloaded) FROM events WHERE download_speed = 'fast'"

name
string
required

The name of the metric.

Example:

"Bytes downloaded"

item_id
string
required

The id of the item

description
string | null
required

A description of the metric.

Example:

"Sum of bytes downloaded in fast mode"

metadata
Metadata · object | null

User-specified key/value pairs for the resource. Individual keys can be removed by setting the value to null, and the entire metadata mapping can be cleared by setting metadata to null.

status
enum<string>
default:active

The status of the metric to create (either active or draft). If not specified, this defaults to active. A draft metric's sql and item_id can be changed until it's published.

Available options:
active,
draft

Response

Created

The Metric resource represents a calculation of a quantity based on events. Metrics are defined by the query that transforms raw usage events into meaningful values for your customers.

metadata
Metadata · object
required

User specified key-value pairs for the resource. If not present, this defaults to an empty dictionary. Individual keys can be removed by setting the value to null, and the entire metadata mapping can be cleared by setting metadata to null.

id
string
required
name
string
required
description
string | null
required
status
enum<string>
required
Available options:
active,
draft,
archived
item
Item · object
required

The Item resource represents a sellable product or good. Items are associated with all line items, billable metrics, and prices and are used for defining external sync behavior for invoices and tax calculation purposes.

sql
string
required

The SQL definition of the metric. For metrics defined via configuration rather than SQL, this is a derived SQL representation.

parameter_definitions
Parameter Definitions · object[] | null