/api/guardrails. Authenticate with your signed-in user’s Firebase ID token and send X-Team-ID with the workspace UUID. Metric API keys do not authorize these routes. The server checks current membership, Guardrails permissions, and account visibility for each request.
Use guardrails.read for reads and preview, and guardrails.manage for writes. A manager can also read. Call capabilities to check your current can_read and can_manage values. Set Guardrails explains the policy behavior.
Routes
Request headers
Keep the same idempotency UUID and request content when you retry a command. A reused key with different content conflicts. Policy replacement must keep the policy type. Create a new policy if you need another type.
Read policies
q (name search, at most 120 characters), enabled, type, account_id, and target_level. target_level is campaign or adset. limit ranges from 1 to 100 and defaults to 25. The response has items and next_cursor. A null cursor marks the last page.
Keep the workspace, principal, filters, and page size unchanged when you send cursor. Cursors expire after one hour. Policy pages sort by creation time and ID, descending.
Policy body
The writable fields arename, type, enabled, selection, and settings. Money uses integer minor units and an ISO currency code. For USD, 10000 means USD 100.00. Select accounts with the same currency for an amount-based policy. Percent-only policies have no currency amount.
This sample allows a daily budget increase of at most 10% and USD 20. Replace the sample account UUID before you use it.
Budget types are
daily and lifetime. Time values range from 1 to 2592000 seconds. Percentage strings allow up to six fractional digits and 18 digits in total. Request bodies have a 64 KiB limit. Unknown fields fail validation. Use capabilities or the MCP schemas for complete bounds.
Create and replace
Save your policy JSON asguardrail.json. Use a fresh UUID in Idempotency-Key for this create command. These examples describe requests; the documentation does not create a production policy.
Preview targets
Sendpolicy, page, and optional summary_page to POST /api/guardrails/targets/preview. Each page object has limit and optional cursor.
The response separates target items from account totals. It reports authoritative: false, authorized account scope, and a selection basis of budget_owner, account_total, or direct_target. Target and summary pages have independent cursors. Keep the draft and page settings unchanged while paging. A change in the analytical data can invalidate a preview cursor.
A preview does not create a policy or authorize a provider action. Execution uses current policies and fresh required facts.
Errors
Errors use this envelope:
A policy-management error differs from an action denial. For
guardrail_blocked, guardrail_evaluation_unavailable, partial results, and saved action receipts, see Set Guardrails.