DOCUMENTATION / API REFERENCE

Measurement connections

Connect an attribution account, match campaigns, and read results through the agent API.

Markdown

Connect measurement once

Cometly is the first supported measurement adapter. It reads an existing Cometly space; it does not import advertising accounts into Cometly. Connect your ad source there first. API subscription eligibility and the upstream account setup must be satisfied. Customer authorization and populated results still need validation with your account.

Use a live key. POST /api/v1/measurement/connections with campaigns:write and {"provider":"cometly"}. The same workspace/provider returns the same connection. Give data.authorization_url to the owner. GET the connection with campaigns:read and follow next_action. Sandbox keys cannot read real measurement data.

The owner signs in to MarketingRouter, clicks Connect Cometly, and approves a Cometly space. The authorization uses PKCE and a one-use state valid for ten minutes. Tokens are encrypted on the server and never returned to agents. MarketingRouter only invokes read tools, although Cometly's underlying space permission also permits some record edits.

Select the account and match campaigns

The owner loads GET /api/v1/measurement/connections/{id}/inventory and selects an account with PUT /api/v1/measurement/connections/{id}/account. Send account_id and its source exactly as returned. USD Meta accounts and USD reporting spaces are currently supported. An agent sees only the selected account. Re-selecting or reconnecting invalidates earlier matches.

Inventory includes up to 500 external campaigns. If truncated is true, absence is not proof that a campaign does not exist; request operator assistance. Our connector never matches names automatically.

PUT /api/v1/measurement/connections/{id}/mappings with campaign_id (MarketingRouter UUID) and external_campaign_id from inventory. A live campaigns:write key can match exact managed campaign/account IDs. Other matches require the owner to confirm in the dashboard. An external campaign can belong to only one MarketingRouter campaign per connection.

Read the same results as the owner

GET /api/v1/measurement/connections/{id}/reports?campaign_id=UUID&from=2026-09-01&to=2026-09-30&attribution=last_touch&window_days=30

Dates are inclusive in the selected space timezone: maximum 90 days, without future dates. Attribution is first_touch or last_touch. Lookback supports 1, 7, 14, 30, 60 or 90 days and uses the relative window definition. Explicit account and campaign filters are applied upstream. No other campaigns are included.

The response includes media_spend_cents, attributed_purchases, attributed_revenue_cents, cost_per_purchase_cents and roas. Missing values are null, never zero. Paying customers and verified checkout revenue remain null: attributed purchases cannot establish distinct customers or payment verification. Fees are not part of this attribution report.

Inspect collected_at, upstream_synced_at, data_status, decision_ready and warnings. A recent collection can still contain old upstream data. decision_ready only indicates complete metrics and a reported sync under one hour old; it is not spending approval or proof of sufficient conversion evidence.

Reports have a 60-second per-campaign cache, with authorization rechecked before reuse. Changing the report window during this interval can return measurement_rate_limited. Back off at least 60 seconds on throttling. Stop on measurement_reauthorization_required or access denied; return the connection to the owner. Missing metrics never fall back silently to another attribution source.

Close the agent loop

Read the chosen attribution source and separately reconcile current Meta delivery. Do not add external attributed revenue to platform-attributed revenue: they are different measurements of overlapping purchases. Read the campaign's current control revision, decide, then send pause/resume/budget through Media buying controls. Existing owner-approved limits, funding checks and idempotency still apply. A measurement connection grants no additional spending authority.

The owner uses /dashboard?tab=measurement for the same account, matches and reports. Open campaign controls from the result. Third-party measurement is optional; built-in reporting remains available independently.

Disconnect

DELETE /api/v1/measurement/connections/{id} is owner-only. It deletes MarketingRouter's saved token and invalidates campaign matches. Revoke the external grant in Cometly's MCP settings too. Credentials never belong in prompts, URLs, client storage or browser JavaScript. No arbitrary MCP tools, PII queries, paid analysis tools, or write operations are exposed by this adapter.

Triple Whale, TrackBee, Omni and Cortana are not implemented connectors in MarketingRouter yet.