Guides
Sandbox control
Mimicr's control API, CLI and MCP server to issue tokens, link WhatsApp, play the reviewer, the user and billing, wait for events, move the clock and inject failures.
The Marketing API only lets you act as the advertiser. To test end to end, Mimicr also lets you act as the other side: the ad reviewer, the person who logs in, clicks and fills in forms, billing, Events Manager and the version calendar. All of it lives in the control API, at https://api.mimicr.dev/v1/meta-ads, and the same commands exist in the console, the CLI and the MCP server.
Authentication
Use an organization API key (mk_…), created in the organization settings, "API keys" tab. Read keys can only query; actions, tokens, clock, chaos and reset need a write key.
curl --url https://api.mimicr.dev/v1/meta-ads \ --header 'Authorization: Bearer mk_...'
With the CLI (Node 18+):
npx mimicr login mk_... npx mimicr status meta-ads
The key can also come from --key or the MIMICR_API_KEY variable. Output is JSON and the exit code is 1 on an HTTP error.
Routes
| Method and path | Purpose |
|---|---|
GET /v1/meta-ads | State: host, app (app id, app secret, app token, URIs, login configurations), Business Manager, users, accounts, Pages, linked WhatsApp, webhook subscriptions, toggles, chaos, API usage and clock |
POST /v1/meta-ads/activate | Activates the sandbox (201); if already active, 409 meta_ads_already_active |
POST /v1/meta-ads/reset | Restores the Business Manager, accounts A, B and C, the Pages and the users; deletes campaigns, stats, leads, tokens and subscriptions; keeps the app, settings and the WhatsApp link; returns the clock to real time |
POST /v1/meta-ads/sweep | Processes everything already due now (reviews, delivery, videos, reports, retries) |
POST /v1/meta-ads/token | Shortcut: a user token without the dialog |
PUT /v1/meta-ads/app | The app's redirect_uris, rotate_secret and name |
PUT /v1/meta-ads/whatsapp | Links or unlinks a WhatsApp sandbox |
GET /v1/meta-ads/wait | Waits until an object or a delivery shows up (long poll) |
GET /v1/meta-ads/clock | Sandbox time (now) and offset (offset_ms) |
POST /v1/meta-ads/clock/advance | Moves the clock forward and processes what became due |
GET /v1/meta-ads/objects | Lists sandbox objects |
GET /v1/meta-ads/objects/{kind}/{ref} | One object |
GET /v1/meta-ads/deliveries | Lists webhook deliveries, with the attempts and the signature |
GET /v1/meta-ads/deliveries/{id} | One delivery |
POST /v1/meta-ads/deliveries/{id}/resend | A new manual attempt |
GET /v1/meta-ads/actions | Lists the actions with their parameters |
POST /v1/meta-ads/actions/{id} | Runs an action |
GET /v1/meta-ads/chaos | Chaos configuration per area |
PUT /v1/meta-ads/chaos/{key} | Changes the chaos for api, oauth, insights, capi or webhook |
PUT /v1/meta-ads/homolog | Homologation toggles |
Control API errors use {"error": {...}} with lowercase codes (meta_ads_not_active, unknown_action, action_failed, wait_timeout, invalid_parameter), different from the Graph envelope.
Tokens without the dialog
curl --request POST \
--url https://api.mimicr.dev/v1/meta-ads/token \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "persona": "admin", "permissions": ["ads_read", "ads_management"], "expires_in": 3600 }'| Field | Default | Use |
|---|---|---|
persona | admin | admin, no_accounts, no_business, declines or unavailable |
permissions | PopGás's + leads_retrieval, pages_manage_metadata and the WhatsApp ones | Granted permissions (public_profile always comes along) |
system_user | false | true issues a system user token, which doesn't expire |
expires_in | 5183944 (60 days) | Validity in seconds |
Answers 201 with access_token, token_type, expires_in, user_id and permissions. The token works for all of the persona's accounts and Pages.
App and WhatsApp
curl --request PUT \
--url https://api.mimicr.dev/v1/meta-ads/app \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "redirect_uris": ["https://app.example.com/meta/callback"], "rotate_secret": true }'An empty redirect_uris list (the default) accepts any https and localhost URL. rotate_secret: true generates a new app secret; the old one stops working, and the app token changes with it.
PUT /v1/meta-ads/whatsapp with {"workspace": "<slug>", "phone_number_id": "…"} links a WhatsApp sandbox from the organization; {"workspace": ""} unlinks it. See Click-to-WhatsApp.
Objects and deliveries
kind is one of user, business, page, ad_account, campaign, adset, ad, creative, video, pixel, report_run, form, lead, capi_event or click. The ref is the Graph id (without act_ for accounts); for capi_event it's {dataset}:{event_name}:{event_id}, and for click it's the ctwa_clid or the fbclid. The status is the configured status (ACTIVE, PAUSED…), the account_status for accounts, the outcome for Conversions API events and the async_status for reports.
/objects filter | Example |
|---|---|
kind | kind=campaign,ad |
status | status=matched_click |
ref | ref=120200539998049721 |
account | account=act_100539998049706 |
parent | parent=120200539998049713 |
since | since=2026-11-06T20:00:00Z (updated since) |
limit | 50 by default, up to 200 |
/deliveries filter | Example |
|---|---|
status | pending, retrying, delivered or failed |
field | leadgen, field_changed, with_issues_ad_objects, in_process_ad_objects |
ref | The lead or object id |
entry_id | The Page or account id |
since, limit | As above |
Filters accept several comma-separated values.
Wait
GET /v1/meta-ads/wait answers as soon as something matches the filters, or 408 wait_timeout. Parameters: on (object or delivery), at least one filter among ref, account, parent, kind, status, review, field and entry_id, and timeout in seconds (default 25, maximum 50). While waiting, the simulator processes what became due. For ads, status is what the integration configured (ACTIVE holds even during review); to wait for approval use review=approved (values: in_process, pending, approved, disapproved, with_issues).
curl --url 'https://api.mimicr.dev/v1/meta-ads/wait?on=delivery&field=leadgen&ref=100539998049743&status=delivered' \ --header 'Authorization: Bearer mk_...'
npx mimicr wait meta-ads object kind=report_run ref=100539998049734 'status=Job Completed' npx mimicr wait meta-ads delivery field=leadgen status=delivered --timeout 50
Actions for the other side
curl --request POST \
--url https://api.mimicr.dev/v1/meta-ads/actions/ad.approve \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "ad_id": "120200539998049721" }'{ "ok": true, "action": "ad.approve", "message": "Anúncio 120200539998049721: revisão approved.", "data": { "id": "120200539998049721", "review": "approved", "ad_review_feedback": null } }In the CLI: npx mimicr action meta-ads ad.approve ad_id=<id> (true and false become booleans). An action that doesn't apply to the current state answers 422 action_failed with the reason.
Login and tokens:
| Action | Parameters | Effect |
|---|---|---|
token.revoke | token or user (id, persona or email) | The user's tokens start answering 190/458 |
token.expire | token (required) | The token expires now: 190/463 |
token.password_changed | user (required) | The user's tokens answer 190/460 |
login.config | permissions (required, comma-separated), config_id (empty creates), name, token_type (user or system_user) | Creates or changes a Facebook Login for Business configuration |
Accounts and billing:
| Action | Parameters | Effect |
|---|---|---|
account.create | name (required), currency (default BRL), timezone_id (default 25), owned | New account in the Business Manager, without the API's limits |
account.set_status | account_id, account_status (required: 1, 2, 3, 7, 8, 9, 100, 101), disable_reason | Changes the account_status |
account.billing_failure | account_id (required) | Account UNSETTLED (3), ads PENDING_BILLING_INFO, delivery stops |
account.billing_restore | account_id (required) | The account returns to its previous status and delivery resumes |
Review:
| Action | Parameters | Effect |
|---|---|---|
ad.approve | ad_id (required) | Approves: leaves IN_PROCESS/PENDING_REVIEW and delivers if everything is active |
ad.reject | ad_id (required), policy (default "Unacceptable Business Practices"), message, placement | DISAPPROVED with ad_review_feedback.global (or placement_specific) |
ad.flag_issue | object_id (required: ad, ad set or campaign), error_code (default 1815869), summary, message | WITH_ISSUES with issues_info; children inherit the pause |
ad.clear_issue | object_id (required) | Removes WITH_ISSUES |
review.run_all | outcome (required: approve or reject) | Decides every ad in review now |
Delivery, clicks and leads:
| Action | Parameters | Effect |
|---|---|---|
traffic.deliver | object_id (required), date (YYYY-MM-DD), hour (0–23), impressions, clicks, spend (cents), conversations, leads | Adds manual delivery to the ad (or to the first ad of the ad set or campaign) |
ad.click_to_whatsapp | ad_id (required), wa_id, name, text, placement (facebook, instagram, whatsapp_status), force | A click with ctwa_clid and the message with referral in the linked WhatsApp |
ad.click_web | ad_id (required) | Returns the link with ?fbclid=… and the fbc |
lead.submit | ad_id or form_id, field_data (JSON), platform (fb or ig) | Creates the lead and sends the leadgen webhook; with ad_id it's paid and counts in Insights |
Conversions, media, reports, webhooks, versions and WhatsApp:
| Action | Parameters | Effect |
|---|---|---|
capi.set_outcome | outcome (required: matched, unmatched, rejected), count (default 1), error_subcode (default 2804050) | Forces the outcome of the next Conversions API events |
video.set_status | video_id, status (required: processing, ready, error) | Sets a video's processing state |
insights.fail_next_report | error_code (default -2), error_subcode (2490547 or 1504045) | The next asynchronous report ends in Job Failed |
webhook.resend | delivery_id (required) | Resends a delivery now, without changing the retries |
version.expire | version (required: v24.0, v25.0, v26.0), undo | Expires the version before its date |
whatsapp.link | workspace (empty unlinks), phone_number_id | The same as PUT /v1/meta-ads/whatsapp |
Homologation toggles
curl --request PUT \
--url https://api.mimicr.dev/v1/meta-ads/homolog \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "autoReview": false, "accessTier": "standard", "minDailyBudget": { "conversations": 1000 } }'Booleans: autoReview, preapprove, strictRejected, autoDelivery, autoLeads, autoCtwa, onePixelPerAccount, requirePaymentMethod, strictAccountCreation, objectEditInterval, budgetChangeLimit, requireAppSecretProof, leadgenNumericIds and strictVideo. Numbers: reviewDelayMinutes, deliveryRate, cpmMultiplier, insightsLagMinutes, asyncReportSeconds, maxAdAccounts and videoProcessingSeconds. Also accessTier (development or standard) and minDailyBudget with impressions, clicks, conversations and lowFrequency in cents. Defaults and effects in Testing in the sandbox. In the CLI: npx mimicr put /v1/meta-ads/homolog autoReview=false.
Clock
curl --request POST \
--url https://api.mimicr.dev/v1/meta-ads/clock/advance \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "hours": 24 }'The body accepts seconds, minutes, hours and days, added together, up to 400 days per call. The response is {now, offset_ms}. In the CLI: npx mimicr clock meta-ads +30m, +2h or +1d.
Advancing the clock finishes reviews, generates delivery hours, completes videos and asynchronous reports, expires 60-day tokens and 30-day reports, runs webhook retries (36 h window), moves the Conversions API's 7-day window, resets rate limit windows and crosses the v24.0 expiry (2026-11-10). Reset returns the clock to real time. The linked WhatsApp sandbox has its own clock and doesn't move with it.
Chaos
curl --request PUT \
--url https://api.mimicr.dev/v1/meta-ads/chaos/api \
--header 'Authorization: Bearer mk_...' \
--header 'Content-Type: application/json' \
--data '{ "enabled": true, "apiErrorRate": 20, "apiErrorStatus": 500, "apiErrorWhen": "after", "latencyMinMs": 300, "latencyMaxMs": 1500 }'| Field | Meaning |
|---|---|
enabled | Turns the area on or off |
apiErrorRate | % of calls that answer with an error |
apiErrorStatus | 500 (code 2, is_transient: true), 503 (service unavailable) or 429 (answered as 613) |
apiErrorWhen | before (nothing is processed) or after (processes and answers with an error: "created, but reported as a failure") |
latencyMinMs, latencyMaxMs | Extra latency |
opsFailRate, opsFailCode | % of operations that fail with the area's code |
webhookFailRate | Only in webhook: % of deliveries whose first attempt fails |
webhookDuplicateRate | Only in webhook: % of notifications delivered twice |
| Key | Covers | "Operation failures" |
|---|---|---|
api | The Marketing API (Graph) | Random 613, 80004 or 17 |
oauth | The code exchange | Code 2, transient |
insights | Synchronous and asynchronous Insights | 100/1504018 and Job Failed |
capi | /{dataset_id}/events | The whole batch is rejected (2804050) |
webhook | page/leadgen and ad_account | First attempt failure and duplicates |
The login dialog isn't affected by chaos. Fields you don't send keep their current value.
MCP server
Agents can use https://api.mimicr.dev/mcp (Streamable HTTP, same mk_… key). The tools cover overview, reference, control API calls, simulated API calls, actions, waiting and advancing the clock. npx mimicr mcp shows the command to connect in Claude Code and the JSON for other clients.
End-to-end test example
npx mimicr reset meta-ads TOKEN=$(npx mimicr post /v1/meta-ads/token | jq -r .access_token) # your application publishes the campaign against https://meta-ads.mimicr.dev and stores the ad id npx mimicr action meta-ads ad.approve ad_id=<ad_id> CLID=$(npx mimicr action meta-ads ad.click_to_whatsapp ad_id=<ad_id> wa_id=5511999990000 | jq -r .data.ctwa_clid) # your application receives the WhatsApp message and, when the order closes, sends the Purchase with $CLID npx mimicr wait meta-ads object kind=capi_event status=matched_click