Appearance
Agency API
The agency API runs an agency's sub-accounts from your own systems: a billing tool, a provisioning script, Zapier or Make with a custom request. It is separate from the sub-account API: an agency key cannot read a sub-account's contacts or conversations, and sub-account keys and app tokens cannot call it.
You'll need
- Agency owner or admin rights.
Create a key
- Open Developer portal and select Agency API keys.
- Enter a Name, tick what the key can do, and select Create key. Copy the key (
ak_live_...) now; it is not shown again.
Send it as Authorization: Bearer ak_live_... or X-Agency-Key: ak_live_.... A key stops working when it is revoked, when it expires, or when the person who created it is no longer an owner or admin of the agency.
Scopes
| Scope | What it allows |
|---|---|
agency.subaccounts:read | List sub-accounts with their status and time zone |
agency.subaccounts:write | Create sub-accounts (optionally from a snapshot and on a SaaS plan), rename, suspend, reactivate or archive them, change their plan |
agency.plans:read | See the plans the agency sells to sub-accounts |
agency.snapshots:read | List snapshots |
agency.snapshots:write | Preview or install a snapshot version into sub-accounts |
agency.users:read | See agency staff and their roles |
agency.users:write | Invite staff by email |
agency.wallets:read | See every sub-account's prepaid wallet |
agency.wallets:write | Add or take back prepaid credit |
agency.analytics:read | SaaS analytics (MRR, churn) and plan changes |
agency.customValues:read | See agency custom values |
agency.customValues:write | Add and change agency custom values |
agency.webhooks:write | Send plan changes and cancellations of sub-accounts to your own endpoints, signed |
agency.brands:read | List the agency's franchise brands and each brand's locations |
agency.brandReports:read | A brand's roll-up per location, region and brand (aggregates only) |
agency.brandCampaigns:read | A brand's campaign proposals and how many locations accepted, declined or have not answered |
agency.brandReviews:read | Review counts, average rating, unanswered and insider-flagged reviews per location |
Routes
All under https://api.example.com/api/v1/rest/agency. The agency is always the key's own; no route takes an agency id.
| Method and path | Scope |
|---|---|
GET /rest/agency | any: the agency, the key's name and scopes |
GET /rest/agency/subaccounts | agency.subaccounts:read |
POST /rest/agency/subaccounts { name, timezone?, snapshot?, saasPlan? } | agency.subaccounts:write |
PATCH /rest/agency/subaccounts/{subaccountId} { name?, status?, timezone? } (status active, suspended or archived) | agency.subaccounts:write |
POST /rest/agency/subaccounts/{subaccountId}/plan | agency.subaccounts:write |
GET /rest/agency/plans | agency.plans:read |
GET /rest/agency/snapshots | agency.snapshots:read |
POST /rest/agency/snapshots/{snapshotId}/pushes | agency.snapshots:write |
GET /rest/agency/users, POST /rest/agency/users/invites | agency.users:read, agency.users:write |
GET /rest/agency/wallets, POST /rest/agency/subaccounts/{subaccountId}/wallet/credit | agency.wallets:read, agency.wallets:write |
GET /rest/agency/saas-analytics | agency.analytics:read |
GET /rest/agency/plan-events?after= | agency.analytics:read |
GET, POST /rest/agency/custom-values, PATCH /rest/agency/custom-values/{customValueId} | agency.customValues:read, agency.customValues:write |
GET, POST /rest/agency/webhooks, PATCH, DELETE /rest/agency/webhooks/{webhookId}, GET .../deliveries, POST .../test, POST .../deliveries/{deliveryId}/replay | agency.webhooks:write |
GET /rest/agency/brands, GET /rest/agency/brands/{brandId}/locations | agency.brands:read |
GET /rest/agency/brands/{brandId}/rollup?from=&to=®ion= | agency.brandReports:read |
GET /rest/agency/brands/{brandId}/campaigns | agency.brandCampaigns:read |
GET /rest/agency/brands/{brandId}/reviews-summary | agency.brandReviews:read |
Bodies and answers are the same as the agency screens use. Answers use the usual envelope ({ success, data }).
Brand routes are read only and follow the brand's data-sharing level from the franchise agreement: when the brand shares nothing, roll-ups, campaign status and the reviews summary answer 403 FRANCHISE_SHARING_LEVEL. They never return contacts, legal entity numbers, review text or reviewer names. Each read is written to the brand's audit log as the key's creator. Another agency's brand answers 404.
Plan changes
GET /rest/agency/plan-events lists plan changes across the agency's sub-accounts, oldest first: started, upgraded, downgraded, changed, cancel_scheduled, reactivated, ended and retained, with the plans, the monthly amount before and after, and when. Pass the answer's nextCursor back as ?after= to get only newer changes; poll it from a scheduler or a polling trigger.
Webhooks
Instead of polling, an agency can have plan changes sent to its own endpoint the moment they happen. POST /rest/agency/webhooks with { "targetUrl": "https://...", "eventTypes": ["saas.plan_changed", "saas.subaccount_cancelled"] } answers the endpoint with its signing secret, shown only this once.
saas.plan_changed: a sub-account's plan started, was upgraded, downgraded or changed, was reactivated, or the client took your offer to stay.saas.subaccount_cancelled: a sub-account's plan was set to cancel at the end of the period (kind: cancel_scheduled), or ended (kind: ended).
Each POST body is { id, type, createdAt, agencyId, data: { subaccountId, kind, fromPlanId, toPlanId, currency, mrrBefore, mrrAfter, reason, source } }. It is signed exactly like sub-account webhooks: check X-Webhook-Signature (t=<seconds>,v1=<HMAC-SHA256 of "<t>.<body>">) with the secret, and use Idempotency-Key (the event id, the same on every retry) to ignore repeats. Answer with a 2xx within 10 seconds. Timeouts, 408, 425, 429 and 5xx are retried with growing gaps (8 tries); 410 Gone turns the endpoint off, and so do 5 failed deliveries in a row. Messages are sent as soon as the change happens; failures are retried by the schedule above. PATCH /rest/agency/webhooks/{webhookId} with { "status": "active" } turns it back on and { "status": "disabled" } turns it off (waiting messages are dropped); GET .../deliveries shows the last 50 attempts, POST .../test sends a sample, and POST .../deliveries/{deliveryId}/replay sends a delivered or failed delivery again now with the same event id and Idempotency-Key (409 while it is still waiting for a retry or the endpoint is off). Up to 10 endpoints per agency; the address must be https on a public host. GET /rest/agency/plan-events stays available. Agency owners and admins manage the same endpoints in the app under SaaS mode › Webhooks (see Agency webhooks).
Good to know
- Writes take an
Idempotency-Keyheader: a retry with the same key gets the first answer for 24 hours, and the same key with a different body answers422. - 120 requests a minute per key (
429withRetry-After, andX-RateLimit-*headers). - Another agency's sub-account, snapshot or plan answers
404.