API · Platform · Billing
Create a billing alert.
Create a billing alert. Agents set their own tripwires — an alert only notifies, it never blocks, so creation is tier 2 with no human gate. Alerts fire as billing.alert.fired events and optionally to a webhook endpoint. Idempotency-Key is required. See idempotency.
Last updated
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
metricstringRequiredOne of
"balance_below_cents""budget_percent""usage_unit_threshold""spend_velocity_cents_per_hour"threshold_valueintegerRequiredCents for money metrics, percent for budget_percent, unit count for usage_unit_threshold.
unitstringOptionalRequired when metric is usage_unit_threshold.
One of
"api_call""saga_step""document_render""webhook_attempt""audit_read""filing_submission"recurrencestringOptionalOne of
"once""per_period"webhook_endpoint_idstringOptionalOptional whe_ endpoint to deliver alert events to.
Response Body
application/json
application/problem+json
application/problem+json
application/problem+json
application/problem+json
Request
curl -X POST "https://api.mattermode.com/v1/billing/alerts" \ -H "Content-Type: application/json" \ -d '{ "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period" }'const body = JSON.stringify({ "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period"})fetch("https://api.mattermode.com/v1/billing/alerts", { method: "POST", headers: { "Content-Type": "application/json" }, body})package mainimport ( "fmt" "net/http" "io/ioutil" "strings")func main() { url := "https://api.mattermode.com/v1/billing/alerts" body := strings.NewReader(`{ "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period" }`) req, _ := http.NewRequest("POST", url, body) req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body))}import requestsheaders = { "Authorization": "Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc", "Matter-Version": "2026-06-10", "Idempotency-Key": "ee7c3a9b-3f1a-4d8e-9b2a-7c5e1f0a2d4b",}payload = { "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period"}resp = requests.post( "https://api.mattermode.com/v1/billing/alerts", headers=headers, json=payload,)resp.raise_for_status()print(resp.json())import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.net.http.HttpResponse.BodyHandlers;import java.time.Duration;import java.net.http.HttpRequest.BodyPublishers;var body = BodyPublishers.ofString("""{ "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period"}""");HttpClient client = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) .build();HttpRequest.Builder requestBuilder = HttpRequest.newBuilder() .uri(URI.create("https://api.mattermode.com/v1/billing/alerts")) .header("Content-Type", "application/json") .POST(body) .build();try { HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString()); System.out.println("Status code: " + response.statusCode()); System.out.println("Response body: " + response.body());} catch (Exception e) { e.printStackTrace();}using System;using System.Net.Http;using System.Text;var body = new StringContent("""{ "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period"}""", Encoding.UTF8, "application/json");var client = new HttpClient();var response = await client.PostAsync("https://api.mattermode.com/v1/billing/alerts", body);var responseBody = await response.Content.ReadAsStringAsync();curl --request POST 'https://api.mattermode.com/v1/billing/alerts' \ --header 'Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc' \ --header 'Matter-Version: 2026-06-10' \ --header 'Idempotency-Key: ee7c3a9b-3f1a-4d8e-9b2a-7c5e1f0a2d4b' \ --header 'Content-Type: application/json' \ --data '{ "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period"}'const response = await fetch("https://api.mattermode.com/v1/billing/alerts", { method: "POST", headers: { "Authorization": "Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc", "Matter-Version": "2026-06-10", "Idempotency-Key": "ee7c3a9b-3f1a-4d8e-9b2a-7c5e1f0a2d4b", "Content-Type": "application/json", }, body: JSON.stringify({ "metric": "balance_below_cents", "threshold_value": 1000, "recurrence": "per_period" }),});if (!response.ok) { throw new Error(`Matter API ${response.status}: ${await response.text()}`);}const data = await response.json();console.log(data);Response
application/json{
"id": "alrt_4Kj2m8pQ",
"object": "billing_alert",
"account_id": "acct_4Kj2m8pQ",
"metric": "balance_below_cents",
"threshold_value": 1000,
"unit": null,
"recurrence": "per_period",
"status": "active",
"is_default": false,
"last_fired_at": null,
"webhook_endpoint_id": null,
"created": 1745539200,
"updated": 1745539200,
"livemode": false
}{
"type": "https://mattermode.com/docs/errors/invalid_request",
"title": "Invalid request",
"status": 400,
"code": "invalid_request",
"detail": "Request body could not be parsed as JSON.",
"doc_url": "https://mattermode.com/docs/guides/errors#invalid_request",
"request_id": "req_Qw9xYz8A"
}{
"type": "https://mattermode.com/docs/errors/authentication_required",
"title": "Authentication required",
"status": 401,
"code": "authentication_required",
"detail": "No bearer token was supplied. Pass `Authorization: Bearer sk_live_...` on every request.",
"doc_url": "https://mattermode.com/docs/guides/errors#authentication_required",
"request_id": "req_Qw9xYz8A"
}{
"type": "https://mattermode.com/docs/errors/validation_failed",
"title": "Validation failed",
"status": 422,
"code": "validation_failed",
"detail": "One or more fields failed validation. See `errors[]`.",
"doc_url": "https://mattermode.com/docs/guides/errors#validation_failed",
"request_id": "req_Qw9xYz8A",
"errors": [
{
"field": "founders[0].equity",
"code": "out_of_range",
"message": "Equity must sum to 100% across all founders."
}
]
}{
"type": "https://mattermode.com/docs/errors/rate_limit_exceeded",
"title": "Rate limit exceeded",
"status": 429,
"code": "rate_limit_exceeded",
"detail": "Request rate exceeded for this key. Retry after `retry_after` seconds or honor the `Retry-After` header.",
"doc_url": "https://mattermode.com/docs/guides/errors#rate_limit_exceeded",
"request_id": "req_Qw9xYz8A",
"retry_after": 30
}