Skip to main content
POST
/
billable_metrics
/
evaluate_expression
Evaluate an expression for a billable metric
curl --request POST \
  --url https://core.nozle.app/api/v1/billable_metrics/evaluate_expression \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "expression": "round((ended_at - started_at) * units)",
  "event": {
    "code": "storage",
    "properties": {
      "gb": 10
    },
    "timestamp": "1651240791"
  }
}
'
{
  "expression_result": {
    "value": 1
  }
}

Authorizations

Authorization
string
header
required

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

Body

application/json

Billable metric expression evaluation payload

expression
string
required

Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units. Accepted function are ceil, concat and round as well as +, -, \ and * operations. Round is accepting an optional second parameter to specify the number of decimal.

Example:

"round((ended_at - started_at) * units)"

event
object
required

Response

Billable metric expression evaluation result

expression_result
object
required