Guides
Mimicr

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.

bash
curl --url https://api.mimicr.dev/v1/meta-ads \
  --header 'Authorization: Bearer mk_...'

With the CLI (Node 18+):

bash
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 pathPurpose
GET /v1/meta-adsState: 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/activateActivates the sandbox (201); if already active, 409 meta_ads_already_active
POST /v1/meta-ads/resetRestores 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/sweepProcesses everything already due now (reviews, delivery, videos, reports, retries)
POST /v1/meta-ads/tokenShortcut: a user token without the dialog
PUT /v1/meta-ads/appThe app's redirect_uris, rotate_secret and name
PUT /v1/meta-ads/whatsappLinks or unlinks a WhatsApp sandbox
GET /v1/meta-ads/waitWaits until an object or a delivery shows up (long poll)
GET /v1/meta-ads/clockSandbox time (now) and offset (offset_ms)
POST /v1/meta-ads/clock/advanceMoves the clock forward and processes what became due
GET /v1/meta-ads/objectsLists sandbox objects
GET /v1/meta-ads/objects/{kind}/{ref}One object
GET /v1/meta-ads/deliveriesLists webhook deliveries, with the attempts and the signature
GET /v1/meta-ads/deliveries/{id}One delivery
POST /v1/meta-ads/deliveries/{id}/resendA new manual attempt
GET /v1/meta-ads/actionsLists the actions with their parameters
POST /v1/meta-ads/actions/{id}Runs an action
GET /v1/meta-ads/chaosChaos configuration per area
PUT /v1/meta-ads/chaos/{key}Changes the chaos for api, oauth, insights, capi or webhook
PUT /v1/meta-ads/homologHomologation 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

bash
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 }'
FieldDefaultUse
personaadminadmin, no_accounts, no_business, declines or unavailable
permissionsPopGás's + leads_retrieval, pages_manage_metadata and the WhatsApp onesGranted permissions (public_profile always comes along)
system_userfalsetrue issues a system user token, which doesn't expire
expires_in5183944 (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

bash
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 filterExample
kindkind=campaign,ad
statusstatus=matched_click
refref=120200539998049721
accountaccount=act_100539998049706
parentparent=120200539998049713
sincesince=2026-11-06T20:00:00Z (updated since)
limit50 by default, up to 200
/deliveries filterExample
statuspending, retrying, delivered or failed
fieldleadgen, field_changed, with_issues_ad_objects, in_process_ad_objects
refThe lead or object id
entry_idThe Page or account id
since, limitAs 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).

bash
curl --url 'https://api.mimicr.dev/v1/meta-ads/wait?on=delivery&field=leadgen&ref=100539998049743&status=delivered' \
  --header 'Authorization: Bearer mk_...'
bash
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

bash
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" }'
json
{ "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:

ActionParametersEffect
token.revoketoken or user (id, persona or email)The user's tokens start answering 190/458
token.expiretoken (required)The token expires now: 190/463
token.password_changeduser (required)The user's tokens answer 190/460
login.configpermissions (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:

ActionParametersEffect
account.createname (required), currency (default BRL), timezone_id (default 25), ownedNew account in the Business Manager, without the API's limits
account.set_statusaccount_id, account_status (required: 1, 2, 3, 7, 8, 9, 100, 101), disable_reasonChanges the account_status
account.billing_failureaccount_id (required)Account UNSETTLED (3), ads PENDING_BILLING_INFO, delivery stops
account.billing_restoreaccount_id (required)The account returns to its previous status and delivery resumes

Review:

ActionParametersEffect
ad.approvead_id (required)Approves: leaves IN_PROCESS/PENDING_REVIEW and delivers if everything is active
ad.rejectad_id (required), policy (default "Unacceptable Business Practices"), message, placementDISAPPROVED with ad_review_feedback.global (or placement_specific)
ad.flag_issueobject_id (required: ad, ad set or campaign), error_code (default 1815869), summary, messageWITH_ISSUES with issues_info; children inherit the pause
ad.clear_issueobject_id (required)Removes WITH_ISSUES
review.run_alloutcome (required: approve or reject)Decides every ad in review now

Delivery, clicks and leads:

ActionParametersEffect
traffic.deliverobject_id (required), date (YYYY-MM-DD), hour (0–23), impressions, clicks, spend (cents), conversations, leadsAdds manual delivery to the ad (or to the first ad of the ad set or campaign)
ad.click_to_whatsappad_id (required), wa_id, name, text, placement (facebook, instagram, whatsapp_status), forceA click with ctwa_clid and the message with referral in the linked WhatsApp
ad.click_webad_id (required)Returns the link with ?fbclid=… and the fbc
lead.submitad_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:

ActionParametersEffect
capi.set_outcomeoutcome (required: matched, unmatched, rejected), count (default 1), error_subcode (default 2804050)Forces the outcome of the next Conversions API events
video.set_statusvideo_id, status (required: processing, ready, error)Sets a video's processing state
insights.fail_next_reporterror_code (default -2), error_subcode (2490547 or 1504045)The next asynchronous report ends in Job Failed
webhook.resenddelivery_id (required)Resends a delivery now, without changing the retries
version.expireversion (required: v24.0, v25.0, v26.0), undoExpires the version before its date
whatsapp.linkworkspace (empty unlinks), phone_number_idThe same as PUT /v1/meta-ads/whatsapp

Homologation toggles

bash
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

bash
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

bash
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 }'
FieldMeaning
enabledTurns the area on or off
apiErrorRate% of calls that answer with an error
apiErrorStatus500 (code 2, is_transient: true), 503 (service unavailable) or 429 (answered as 613)
apiErrorWhenbefore (nothing is processed) or after (processes and answers with an error: "created, but reported as a failure")
latencyMinMs, latencyMaxMsExtra latency
opsFailRate, opsFailCode% of operations that fail with the area's code
webhookFailRateOnly in webhook: % of deliveries whose first attempt fails
webhookDuplicateRateOnly in webhook: % of notifications delivered twice
KeyCovers"Operation failures"
apiThe Marketing API (Graph)Random 613, 80004 or 17
oauthThe code exchangeCode 2, transient
insightsSynchronous and asynchronous Insights100/1504018 and Job Failed
capi/{dataset_id}/eventsThe whole batch is rejected (2804050)
webhookpage/leadgen and ad_accountFirst 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

bash
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