# Agent quickstart

Discover, prepare, and monitor Meta campaigns through one API.

## Start with one connection link

Read `GET /api/v1/capabilities`. If you do not have a key, POST `/api/v1/agent-authorizations` with your name, desired mode and scopes. Give the returned approval link **and matching user code** to the owner; keep `device_code` private. Poll `/api/v1/agent-authorizations/token` no faster than every five seconds until approved. Save the returned key securely. [Full connection contract](/docs-markdown/authentication).

Agents do not need an inbox or a copied owner credential. The human still signs in and approves the requested access. Connection, funding and campaign-spend approval are distinct decisions. Read the live-spend and billing capability flags before promising delivery.

## Start with the business, not Ads Manager

GET /api/v1/setup with a live key, or PUT /api/v1/setup to describe the brand and choose create/connect for its Facebook Page. Follow next_actions. The [guided setup](/docs-markdown/setup) and [tracking guide](/docs-markdown/tracking) cover the complete path before your first campaign.

## Discover before acting

MarketingRouter gives agents a scoped API for managed Meta advertising. Humans approve the exact creative, destination, schedule, and lifetime budget. Read runtime capabilities first: deployment gates and advertiser setup determine whether live operations are available.

```bash
export BASE_URL="https://marketingrouter.com"
curl "$BASE_URL/api/v1/capabilities"
```

Use the origin serving these docs if the domain changes. Advertising and funding amounts are integer USD cents. Creative generation reports nullable provider_cost_usd in USD major units; null is unknown, not zero. Sandbox mode is a free application simulation with zero media spend. Live mode uses real provider resources; it is not a synonym for a successful or delivering advertisement.

## Get a quote without credentials

```bash
curl "$BASE_URL/api/v1/quotes" \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://example.com","objective":"purchase","budget_cents":50000,"geo":["US"],"mode":"live"}'
```

Quotes do not charge, crawl the website, or promise results. New plans use a 5% fee on actual media spend. Quotes show the maximum fee on the requested media budget. Sandbox quotes use the same rate but collect nothing. Existing campaigns retain their stored fee terms. A quote is not evidence of available funds or account readiness.

## Start in the sandbox

Request a sandbox connection using the flow above. After the owner approves, store the returned key as MR_API_KEY in your secret store. Owners can also create keys manually in the console.

```bash
curl "$BASE_URL/api/v1/campaigns" \
  -H "Authorization: Bearer $MR_API_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: example-launch-001' \
  -d '{"name":"Example launch","url":"https://example.com","objective":"purchase","budget_cents":50000,"geo":["US"],"mode":"sandbox"}'
```

Save data.id and the idempotency key. Present data.approval_url to the owner. Agent keys cannot approve. Sandbox approval changes the local status; it does not create ads or charge money.

## Move to managed Meta

1. Follow guided setup to create or connect a Facebook Page, get owner authorization, and verify destination tracking.
2. Request a live connection with campaigns:read and campaigns:write; the owner approves its scopes. Add events:write only if this agent reports conversions.
3. Generate and revise copy/images through [Creative Studio](/docs-markdown/creatives), then explicitly publish the chosen variant. Generation can start before advertiser setup when creative.enabled is true. Alternatively, [upload an existing image](/docs-markdown/assets). Both paths yield a ready owned creative_file_id.
4. Create a live campaign with the exact Meta plan, then POST /api/v1/campaigns/{id}/prepare to create a non-delivering Meta draft.
5. For purchase campaigns, complete [checkout receipt setup and owner-reviewed test purchase](/docs-markdown/purchases) for this exact campaign before paid delivery. Then read /api/v1/balance. If more credit is needed, request /api/v1/balance/topups and give the owner its secure checkout link. Wait for verified funding. The owner reviews the plan and funding status in the console. Paid launch requires verified funds, sufficient operator allowance, a working pixel/conversion signal, and the deployment launch gate.
6. Give the owner approval_url. Approval authorizes only the stored plan_hash and lifetime budget.
7. POST /api/v1/campaigns/{id}/reconcile, then GET /api/v1/campaigns/{id}/results. Poll with backoff; inspect delivery_status, not just status.

Read [Campaigns](/docs-markdown/campaigns), [Approvals](/docs-markdown/approvals), and [Funding](/docs-markdown/funding) before live work. There is no autonomous budget increase or creative substitution.

## Read only what you need

Use /openapi.json for schemas, /llms.txt for the index, /llms-full.txt for all guides, /docs-markdown/{slug} for one guide, and /.well-known/agent.json for discovery. HTML pages advertise their Markdown equivalents. No MCP server, x402 payments, website crawler or outbound webhooks are implemented. Optional [cost guards](/docs-markdown/cost-guards) add owner-approved daily budget optimization and protective pauses.

## Generate before account setup

Read data.creative from capabilities. A live campaigns:write key can explicitly request paid OpenAI generation when enabled, without a Facebook connection. The job stores private previews and version history. Generating does not spend advertising credit or authorize a campaign. See [the complete generate → revise → publish → approve workflow](/docs-markdown/creatives). Creative generation, billing, and ad launch have separate gates.

## Operate after launch

Use [Media buying controls](/docs-markdown/media-buying): reconcile, read performance, decide, submit one revision-checked command, then verify delivery.

## Compare performance

GET /api/v1/reports/campaigns powers the dashboard. Filter dates, status, objective and ROAS; inspect weighted totals and daily delivery before following [media buying controls](/docs-markdown/media-buying). Read [Performance reporting](/docs-markdown/reporting) for exact query parameters and data semantics.


## Minimum media budget

New live plans require at least $5 per started 24-hour period of their schedule. A one-day lifetime plan needs 500 cents; two days need 1000 cents. Daily plans require daily_budget_cents >= 500, but their live activation remains unavailable until a provider-enforced total cap is supported. The network may impose a higher minimum for an account or objective. budget_below_minimum provides minimum_budget_cents before a provider draft or charge is created. Never raise the owner's spending authority automatically to satisfy a minimum.
