API reference

API reference · Recorder

Create an alert rule

POST/api/alertsSigned in session

The threshold is an integer in the metric's own unit: micro USD for spend, basis points for error_rate, milliseconds for ttft_p95.

Request body

application/json, required

Request body fields
FieldTypeWhat it is
namerequiredstring
metricrequiredstringOne of "spend", "error_rate", "ttft_p95".
thresholdrequiredinteger
windowMinutesintegerFrom 5 to 10080.
minSamplesintegerAt least 1.
scopeModelstring or null
scopeKeyIdinteger or null
enabledboolean

Example

{
  "name": "string",
  "metric": "spend",
  "threshold": 0
}

Answer 201

The new rule.

Fields of the 201 answer
FieldTypeWhat it is
ruleAlertRule
rule.idinteger
rule.namestring
rule.metricstringOne of "spend", "error_rate", "ttft_p95".
rule.thresholdintegerMicro USD, basis points, or milliseconds, by metric.
rule.windowMinutesinteger
rule.minSamplesintegerHow many requests the window needs before the number is believed.
rule.scopeModelstring or null
rule.scopeKeyIdinteger or null
rule.enabledboolean
rule.statestringOne of "ok", "firing".
rule.lastValueinteger or nullNull when the last check found nothing to measure.
rule.lastCheckedAtinteger or null
rule.lastTriggeredAtinteger or null
rule.createdAtinteger
rule.updatedAtinteger

Errors

  • 400OpenAI shaped error.
  • 401OpenAI shaped error.

Every error answers in one shape, with its type, code and the field it names. The whole list is in the docs' Errors section.

Antimatter