Guides
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.
curl --url https://api.mimicr.dev/v1/tiktok-ads \ --header 'Authorization: Bearer mk_...'
With the CLI (Node 18+):
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 path | For |
|---|---|
GET /v1/tiktok-ads | State: 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/activate | Activates the sandbox (201); if already active, 409 tiktok_ads_already_active |
POST /v1/tiktok-ads/reset | Brings 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/token | Shortcut: authorizes and exchanges the code without the page |
PUT /v1/tiktok-ads/app | The app's redirect_uris, scopes, rate_level, rotate_secret and name |
POST /v1/tiktok-ads/sweep | Processes now whatever is already due |
GET /v1/tiktok-ads/wait | Waits until an object or a delivery shows up (long poll) |
GET /v1/tiktok-ads/clock | Sandbox time (now) and offset (offset_ms) |
POST /v1/tiktok-ads/clock/advance | Advances the clock and processes what became due |
GET /v1/tiktok-ads/objects | Lists sandbox objects |
GET /v1/tiktok-ads/objects/{kind}/{ref} | One object |
GET /v1/tiktok-ads/events | Events API events with their outcome |
GET /v1/tiktok-ads/deliveries | Webhook deliveries, with attempts and signature |
GET /v1/tiktok-ads/deliveries/{id} | One delivery |
POST /v1/tiktok-ads/deliveries/{id}/resend | A new manual attempt |
GET /v1/tiktok-ads/actions | Lists the actions with their parameters |
POST /v1/tiktok-ads/actions/{id} | Runs an action |
GET /v1/tiktok-ads/chaos | Chaos configuration per area |
PUT /v1/tiktok-ads/chaos/{key} | Changes the chaos of oauth, management, reporting, events, leads or webhook |
PUT /v1/tiktok-ads/homolog | Homologation 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
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"] }'| Field | Default | Use |
|---|---|---|
user_id | admin | core_user_id or persona (admin, no_advertisers) |
advertiser_ids | All the user's accounts | Accounts granted |
Answers 201 with access_token, scope, advertiser_ids and user_id, like /oauth2/access_token/.
App
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 10http(s)URLs. Only enforced withanyRedirectUrioff.scopes: ids among 1, 2, 3, 4, 5, 6, 8 and 12000000; they apply to the next authorizations.rate_level:BASIC,ADVANCED,PREMIUMorULTIMATE.rotate_secret: truegenerates 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 filter | Example |
|---|---|
kind | kind=campaign,ad |
status | status=ENABLE |
ref | ref=1700013373458754 |
advertiser | advertiser=7000000013373458730 |
parent | parent=1700013373458750 (an ad group's ads) |
review | in_review, rereview, approved, partial or rejected |
since | since=2026-11-06T12:00:00Z (updated since) |
limit | 50 by default, up to 200 |
/deliveries filter | Example |
|---|---|
status | pending, retrying, delivered or failed |
entity | LEAD, AD, AD_GROUP, REPORT_DATA_CHANGE, AD_ACCOUNT_SUSPENSION |
ref | The id of the lead, ad, ad group, account or subscription |
subscription_id | One subscription |
since, limit | As 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.
curl --url 'https://api.mimicr.dev/v1/tiktok-ads/wait?on=object&kind=ad&ref=1700013373458754&review=approved' \ --header 'Authorization: Bearer mk_...'
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
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" }'{ "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:
| Action | Parameters | Effect |
|---|---|---|
oauth.authorize | redirectUri (required), userId (core_user_id or persona; default admin), advertiserIds (comma-separated; default all), state, appId | The Confirm button: returns the auth_code (1 h, single use) and the redirect with auth_code, code and state |
oauth.revoke | accessToken (default all), advertiserId | Revokes tokens: 40105, and the subscriptions created with them stop |
oauth.deauthorize_advertiser | advertiserId (required) | The advertiser removes the app from the account: 40001 when you use it |
Accounts and billing:
| Action | Parameters | Effect |
|---|---|---|
advertiser.create | name (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_status | advertiserId, status (required) | Changes the status; STATUS_LIMIT and STATUS_DISABLE fire AD_ACCOUNT_SUSPENSION |
advertiser.set_custom_identity | advertiserId, allowed (required) | Turns the custom identity on or off (the 2026-01-15 accounts rule) |
billing.fail | advertiserId (required) | Empty balance: delivery stops and statuses become *_BALANCE_EXCEED |
billing.restore | advertiserId (required) | The balance comes back and delivery resumes |
Review:
| Action | Parameters | Effect |
|---|---|---|
ad.approve | adId (required) | Approves (ALL_AVAILABLE) |
ad.partial | adId (required), forbiddenLocations (e.g. BR-SP), forbiddenPlacements (default PLACEMENT_PANGLE) | Partial approval (PART_AVAILABLE) |
ad.reject | adId (required), reasons (separated by |), suggestion | Rejects (UNAVAILABLE, AD_STATUS_AUDIT_DENY) and fires the AD webhook |
ad.rereview | adId (required) | Puts the ad back in review |
adgroup.reject | adgroupId (required), reasons | Rejects the ad group (ADGROUP_STATUS_AUDIT_DENY) and fires the AD_GROUP webhook |
adgroup.approve | adgroupId (required) | Undoes the ad group rejection |
Delivery, clicks and leads:
| Action | Parameters | Effect |
|---|---|---|
traffic.deliver | campaignId (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.click | adId (required), at (ISO 8601) | A click: returns the ttclid and the landing page with ?ttclid=… |
traffic.set_profile | campaignId (required), ctr (%), cpc and cpm (R$), budgetUsage (0–1) | Pins the campaign's delivery factors for the next hours |
lead.submit | adId or pageId, fields (JSON), leadSource (INSTANT_FORM or DIRECT_MESSAGE), at | Creates the lead, counts it in onsite_form and fires the LEAD webhooks |
form.create | advertiserId, title (required), fields (default name,phone_number,email) | A new Instant Form |
Events Manager, reports, limits and webhooks:
| Action | Parameters | Effect |
|---|---|---|
pixel.create | advertiserId, name (required) | A new Pixel with an events token and a test code |
pixel.rotate_events_token | pixelCode (required) | A new events token; the old one answers 40105 |
conversion.set_outcome | eventId or ttclid, outcome (required: attributed or unmatched) | Forces the attribution of events already received and of those to come |
report.fail_task | taskId (required) | The report task ends FAILED |
ratelimit.exhaust | scope (app, default, or advertiser) | Every call answers 40100 (or 40133) until the reset |
ratelimit.reset | Clears counters and exhaustion | |
webhook.resend | deliveryId (required) | Resends a delivery now, without changing the retries |
Homologation toggles
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
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
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 }'| Field | Meaning |
|---|---|
enabled | Turns the area on or off |
apiErrorRate | % of calls that answer an error |
apiErrorStatus | 500 (HTTP 200 with 51003), 503 (HTTP 503 with 50000) or 429 (HTTP 200 with 40100) |
apiErrorWhen | before (nothing is processed) or after (processes and answers an error: "created, but reported as a failure") |
latencyMinMs, latencyMaxMs | Extra latency |
opsFailRate, opsFailCode | % of operations that fail with the area's code (40202 on management only affects writes) |
webhookFailRate | webhook only: % of deliveries whose first attempt fails |
webhookDuplicateRate | webhook 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
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