Guides
Mimicr

Sandbox control

Mimicr's control API, CLI and MCP to issue tokens, configure the app, 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 advertiser on the authorization page, the ad reviewer, the person who taps the ad and fills in the form, billing and the Events Manager. All of that lives in the control API, at https://api.mimicr.dev/v1/tiktok-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, "Chaves de API" tab. Read keys only query; actions, tokens, clock, chaos, settings and reset need a write key.

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

With the CLI (Node 18+):

bash
npx mimicr login mk_...
npx mimicr status tiktok-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 pathFor
GET /v1/tiktok-adsState: host, api_base_url, auth_url, app (App ID, Secret, URLs, scopes, rate level), users, Business Center, advertisers (with Instant Forms, Pixels with the events token and test code, identities and event sets), subscriptions, toggles, chaos, limits and clock. {"active": false} if not activated
POST /v1/tiktok-ads/activateActivates the sandbox (201); if already active, 409 tiktok_ads_already_active
POST /v1/tiktok-ads/resetBrings back the Business Center, the users and the three accounts (with form, Pixel and identity); deletes campaigns, stats, leads, tokens, subscriptions and deliveries; keeps the app and the settings; the clock goes back to real time
POST /v1/tiktok-ads/tokenShortcut: authorizes and exchanges the code without the page
PUT /v1/tiktok-ads/appThe app's redirect_uris, scopes, rate_level, rotate_secret and name
POST /v1/tiktok-ads/sweepProcesses now whatever is already due
GET /v1/tiktok-ads/waitWaits until an object or a delivery shows up (long poll)
GET /v1/tiktok-ads/clockSandbox time (now) and offset (offset_ms)
POST /v1/tiktok-ads/clock/advanceAdvances the clock and processes what became due
GET /v1/tiktok-ads/objectsLists sandbox objects
GET /v1/tiktok-ads/objects/{kind}/{ref}One object
GET /v1/tiktok-ads/eventsEvents API events with their outcome
GET /v1/tiktok-ads/deliveriesWebhook deliveries, with attempts and signature
GET /v1/tiktok-ads/deliveries/{id}One delivery
POST /v1/tiktok-ads/deliveries/{id}/resendA new manual attempt
GET /v1/tiktok-ads/actionsLists the actions with their parameters
POST /v1/tiktok-ads/actions/{id}Runs an action
GET /v1/tiktok-ads/chaosChaos configuration per area
PUT /v1/tiktok-ads/chaos/{key}Changes the chaos of oauth, management, reporting, events, leads or webhook
PUT /v1/tiktok-ads/homologHomologation toggles

Control API errors use {"error": {...}} with lowercase codes (tiktok_ads_not_active, unknown_action, action_failed, wait_timeout, invalid_parameter), unlike TikTok's envelope.

Tokens without the page

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/tiktok-ads/token \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "user_id": "admin", "advertiser_ids": ["7000000013373458730"] }'
FieldDefaultUse
user_idadmincore_user_id or persona (admin, no_advertisers)
advertiser_idsAll the user's accountsAccounts granted

Answers 201 with access_token, scope, advertiser_ids and user_id, like /oauth2/access_token/.

App

bash
curl --request PUT \
  --url https://api.mimicr.dev/v1/tiktok-ads/app \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "redirect_uris": ["https://app.example.com/tiktok/callback"], "scopes": [1, 2, 4, 6], "rate_level": "BASIC" }'
  • redirect_uris: up to 10 http(s) URLs. Only enforced with anyRedirectUri off.
  • scopes: ids among 1, 2, 3, 4, 5, 6, 8 and 12000000; they apply to the next authorizations.
  • rate_level: BASIC, ADVANCED, PREMIUM or ULTIMATE.
  • rotate_secret: true generates a new Secret: code exchanges and webhook signatures start using it.

Objects and deliveries

kind is one of user, bc, advertiser, campaign, adgroup, ad, video, image, identity, pixel, event_set, event, click, form, lead, subscription, report_task, lead_task, auth_code or token. The ref is the TikTok id (a token is stored by its hash). Ads carry review.

/objects filterExample
kindkind=campaign,ad
statusstatus=ENABLE
refref=1700013373458754
advertiseradvertiser=7000000013373458730
parentparent=1700013373458750 (an ad group's ads)
reviewin_review, rereview, approved, partial or rejected
sincesince=2026-11-06T12:00:00Z (updated since)
limit50 by default, up to 200
/deliveries filterExample
statuspending, retrying, delivered or failed
entityLEAD, AD, AD_GROUP, REPORT_DATA_CHANGE, AD_ACCOUNT_SUSPENSION
refThe id of the lead, ad, ad group, account or subscription
subscription_idOne subscription
since, limitAs above

Filters take several comma-separated values.

Wait

GET /v1/tiktok-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, advertiser, parent, kind, status, review, entity and subscription_id, and timeout in seconds (default 25, max 50). While waiting, the simulator processes whatever becomes due.

bash
curl --url 'https://api.mimicr.dev/v1/tiktok-ads/wait?on=object&kind=ad&ref=1700013373458754&review=approved' \
  --header 'Authorization: Bearer mk_...'
bash
npx mimicr wait tiktok-ads object kind=report_task ref=7000000013373458790 status=SUCCESS
npx mimicr wait tiktok-ads delivery entity=LEAD status=delivered --timeout 50

Actions from the other side

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/tiktok-ads/actions/ad.approve \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "adId": "1700013373458754" }'
json
{ "ok": true, "action": "ad.approve", "message": "Anúncio 1700013373458754 aprovado.", "data": { "ad_id": "1700013373458754", "review_status": "ALL_AVAILABLE" } }

In the CLI: npx mimicr action tiktok-ads ad.approve adId=<id> (true and false become booleans). An action that does not apply to the current state answers 422 action_failed with the reason. Action messages are in Portuguese.

Authorization:

ActionParametersEffect
oauth.authorizeredirectUri (required), userId (core_user_id or persona; default admin), advertiserIds (comma-separated; default all), state, appIdThe Confirm button: returns the auth_code (1 h, single use) and the redirect with auth_code, code and state
oauth.revokeaccessToken (default all), advertiserIdRevokes tokens: 40105, and the subscriptions created with them stop
oauth.deauthorize_advertiseradvertiserId (required)The advertiser removes the app from the account: 40001 when you use it

Accounts and billing:

ActionParametersEffect
advertiser.createname (required), currency (default BRL), timezone (default America/Sao_Paulo), status (default STATUS_ENABLE), bcId, customIdentity (default true)A new account with an Instant Form, a Pixel and an identity, granted to the admin. Tokens already issued do not see it
advertiser.set_statusadvertiserId, status (required)Changes the status; STATUS_LIMIT and STATUS_DISABLE fire AD_ACCOUNT_SUSPENSION
advertiser.set_custom_identityadvertiserId, allowed (required)Turns the custom identity on or off (the 2026-01-15 accounts rule)
billing.failadvertiserId (required)Empty balance: delivery stops and statuses become *_BALANCE_EXCEED
billing.restoreadvertiserId (required)The balance comes back and delivery resumes

Review:

ActionParametersEffect
ad.approveadId (required)Approves (ALL_AVAILABLE)
ad.partialadId (required), forbiddenLocations (e.g. BR-SP), forbiddenPlacements (default PLACEMENT_PANGLE)Partial approval (PART_AVAILABLE)
ad.rejectadId (required), reasons (separated by |), suggestionRejects (UNAVAILABLE, AD_STATUS_AUDIT_DENY) and fires the AD webhook
ad.rereviewadId (required)Puts the ad back in review
adgroup.rejectadgroupId (required), reasonsRejects the ad group (ADGROUP_STATUS_AUDIT_DENY) and fires the AD_GROUP webhook
adgroup.approveadgroupId (required)Undoes the ad group rejection

Delivery, clicks and leads:

ActionParametersEffect
traffic.delivercampaignId (default all), hours (default 24, max 720)Generates the previous hours as if the campaign were already live, without moving the clock. Only delivers what is ENABLE and approved
traffic.clickadId (required), at (ISO 8601)A click: returns the ttclid and the landing page with ?ttclid=…
traffic.set_profilecampaignId (required), ctr (%), cpc and cpm (R$), budgetUsage (0–1)Pins the campaign's delivery factors for the next hours
lead.submitadId or pageId, fields (JSON), leadSource (INSTANT_FORM or DIRECT_MESSAGE), atCreates the lead, counts it in onsite_form and fires the LEAD webhooks
form.createadvertiserId, title (required), fields (default name,phone_number,email)A new Instant Form

Events Manager, reports, limits and webhooks:

ActionParametersEffect
pixel.createadvertiserId, name (required)A new Pixel with an events token and a test code
pixel.rotate_events_tokenpixelCode (required)A new events token; the old one answers 40105
conversion.set_outcomeeventId or ttclid, outcome (required: attributed or unmatched)Forces the attribution of events already received and of those to come
report.fail_tasktaskId (required)The report task ends FAILED
ratelimit.exhaustscope (app, default, or advertiser)Every call answers 40100 (or 40133) until the reset
ratelimit.resetClears counters and exhaustion
webhook.resenddeliveryId (required)Resends a delivery now, without changing the retries

Homologation toggles

bash
curl --request PUT \
  --url https://api.mimicr.dev/v1/tiktok-ads/homolog \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "lenientRequiredFields": true, "adgroupUpdateAsPatch": true }'

Booleans: autoReview, anyRedirectUri, lenientRequiredFields, disableOutranksReview, adgroupUpdateAsPatch, uniqueNames, enforceRateLimits, autoLeads, batchWebhooks and reportWebhooks. Numbers: reviewDelayMinutes (0–10080) and asyncReportSeconds (0–3600). Defaults and effects in Sandbox testing. In the CLI: npx mimicr put /v1/tiktok-ads/homolog lenientRequiredFields=true.

Clock

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/tiktok-ads/clock/advance \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "hours": 24 }'

The body takes seconds, minutes, hours and days, added up, up to 400 days per call. The response is {now, offset_ms}. In the CLI: npx mimicr clock tiktok-ads +30m, +2h or +1d.

Advancing the clock expires auth_codes, completes reviews, generates delivery hours, crosses ad group start and end times, applies scheduled budgets at midnight, finishes asynchronous reports and lead tasks, opens the REPORT_DATA_CHANGE windows, runs webhook retries (24 h window) and rolls the daily rate-limit counters. Tokens do not expire. Reset sets the clock back to real time.

Chaos

bash
curl --request PUT \
  --url https://api.mimicr.dev/v1/tiktok-ads/chaos/management \
  --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 an error
apiErrorStatus500 (HTTP 200 with 51003), 503 (HTTP 503 with 50000) or 429 (HTTP 200 with 40100)
apiErrorWhenbefore (nothing is processed) or after (processes and answers an error: "created, but reported as a failure")
latencyMinMs, latencyMaxMsExtra latency
opsFailRate, opsFailCode% of operations that fail with the area's code (40202 on management only affects writes)
webhookFailRatewebhook only: % of deliveries whose first attempt fails
webhookDuplicateRatewebhook only: % of notifications delivered twice

Areas: oauth (the auth_code exchange), management (accounts, campaigns, ad groups, ads, files, identities), reporting, events, leads (leads and subscriptions) and webhook. The authorization page, the form, the click and the report files are exempt. Fields you do not 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, calls to the simulated API already authenticated, actions, waiting and advancing the clock. npx mimicr mcp shows the command to connect it in Claude Code and the JSON for other clients.

End-to-end test example

bash
npx mimicr reset tiktok-ads
TOKEN=$(npx mimicr post /v1/tiktok-ads/token | jq -r .access_token)
# your application publishes the campaign against https://tiktok-ads.mimicr.dev/open_api/v1.3 and stores the ad id
npx mimicr action tiktok-ads ad.approve adId=<ad_id>
npx mimicr wait tiktok-ads object kind=ad ref=<ad_id> review=approved
# your application turns the campaign, ad group and ad on
npx mimicr action tiktok-ads traffic.deliver hours=24
npx mimicr action tiktok-ads lead.submit adId=<ad_id>
npx mimicr wait tiktok-ads delivery entity=LEAD status=delivered