Customer Alerts
What is a customer alert?
A customer alert is a watch on one customer: “email me when this customer’s cost passes 10,000.” When the number crosses the line, MarginFront emails a person you name and drops an in-app notification that links straight to that customer’s page. The two numbers you can watch:cost— what this customer costs you to serve (their usage cost).revenue— what this customer is billed.
Who can manage watches
Every endpoint here — reads included — needs a secret key that belongs to an owner, admin, or finance user. Any other key gets a403 Forbidden naming the role. A publishable key (mf_pk_...) is refused. A watch exposes one customer’s money, so it sits with the people who own the numbers.
The window: month, rolling, or custom
Every watch measures its number over a window you pick:month— the current UTC calendar month. Re-arms on its own each month, so a monthly watch keeps working month after month.rolling— the last 30 days. Fires once when the number crosses, so you get one heads-up per crossing.custom— a fixed date range you set withcustomStartDateandcustomEndDate. Fires at most once and expires at the end of the range.
The endpoints
List watches
200 OK):
Create a watch
The recipient gets a confirmation email when the watch is created, then an alert email plus an in-app notification whenever it trips.
Response (
201 Created): the full watch, same shape as the list response.
curl example:
400 Bad Request: an internal coding-spend customer as the target (use Spend Controls for your own AI coding spend), a deleted customer, custom-mode dates that don’t make sense, a recipient who isn’t an org member with a money role, or your organization’s watch limit already reached.403 Forbidden: your key doesn’t belong to an owner, admin, or finance user.404 Not Found: no customer in your organization matches that ID.409 Conflict: an identical watch already exists. Edit that one instead of creating a second.
Update a watch
metric, thresholdUsd, and windowMode (with the custom dates when you switch to custom). The watched customer and the recipient are fixed at create — to change either, delete the watch and create a new one.
Response (200 OK): the updated watch, same shape as the list response.
Common errors:
400 Bad Request: custom-mode dates that don’t make sense for the resulting watch.403 Forbidden: your key doesn’t belong to an owner, admin, or finance user.404 Not Found: no watch with that ID in your organization.409 Conflict: the edit would collide with a watch that already exists.
Delete a watch
200 OK):
403 Forbidden: your key doesn’t belong to an owner, admin, or finance user.404 Not Found: no watch with that ID in your organization.
Good to know
- A watch fires once per window. A
rollingorcustomwatch that has already tripped for its window won’t email you again for that same window, even if you edit its threshold afterward. Amonthwatch re-arms each calendar month. - Editing never re-fires a window that already alerted. The record of what already fired is permanent by design, so changing a threshold can’t spam a fresh alert for a window you’ve already been warned about.
- Internal coding-spend accounts can’t be watched here. For your own team’s Claude Code and Codex spend, use Spend Controls instead.

