costs.setMarginAlert
Set a profit alert (owner only): when an invoiced job's margin drops under below_percent, the job.margin_low event fires once for it (subscribe with a webhook). It fires again only after the margin climbs back and drops again. The check reads job costing as you see it. null turns it off.
| Who | Agents can call this |
| REST | POST /v1/costs/margin-alert |
| MCP tool | costs_setMarginAlert |
| Writes | yes, send an Idempotency-Key |
| Area | Costs, expenses and reports |
When to use it
Set a profit alert (owner only): when an invoiced job's margin drops under below_percent, the job.margin_low event fires once for it (subscribe with a webhook). It fires again only after the margin climbs back and drops again.
What to tell the owner
Say what you did in plain words and what happens next.
Input
| Field | Type | Required |
|---|---|---|
shop_id | string (uuid) | yes |
below_percent | ['number', 'null'] | yes |
Example
POST https://doingwork.work/v1/costs/margin-alert
content-type: application/json
Idempotency-Key: 3f1c...
{
"shop_id": "00000000-0000-4000-8000-000000000000",
"below_percent": "..."
}Output
JSON. The response shape isn't published yet; read the fields you need and ignore the rest. Errors are {code, message, status}.
Errors
| Code | Status | What to do |
|---|---|---|
invalid_input, invalid_token, rate_limited | Can happen on any call. See errors. |