Guides
Getting started

Quickstart

Activate the sandbox, get a token, publish a campaign, ad group and ad, approve the ad, simulate a click and a lead, and read the metrics.

This guide takes a few minutes: you activate the simulator, get a token without going through the authorization page, publish a traffic campaign with a video ad, play the reviewer, simulate a click, receive a lead on your webhook and query the report.

Prerequisites

  • A Mimicr organization and a write API key (mk_…), created in the organization settings, "Chaves de API" tab.
  • curl, or any HTTP client, and Node 18+ if you want to use the CLI.
  • An https URL that accepts POST, for the webhook of step 8 (a request inspection service will do).

1. Activate the TikTok Ads sandbox

In the console, open the organization at https://app.mimicr.dev, go to TikTok Ads and activate it. Or through the control API:

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

The sandbox starts with a developer app (its own App ID and Secret), a Business Center and three BRL ad accounts in the America/Sao_Paulo time zone: "Mimicr Ads · Principal" and "Mimicr Ads · Filial" (STATUS_ENABLE) and "Mimicr Ads · Bloqueada" (STATUS_LIMIT). Each account has an Instant Form, a Pixel and a custom identity. There are two users: Joana Ribeiro (admin, owner of everything) and Bruno Sem Contas (no_advertisers). If it is already active, the call answers 409 tiktok_ads_already_active.

2. Read the credentials

bash
curl --url https://api.mimicr.dev/v1/tiktok-ads \
  --header 'Authorization: Bearer mk_...'
json
{
  "active": true,
  "host": "https://tiktok-ads.mimicr.dev",
  "api_base_url": "https://tiktok-ads.mimicr.dev/open_api/v1.3",
  "auth_url": "https://tiktok-ads.mimicr.dev/portal/auth",
  "app": {
    "app_id": "7543382796466965341",
    "secret": "<secret>",
    "redirect_uris": [],
    "scopes": [{ "id": 1, "name": "Ad Account Management" }, { "id": 2, "name": "Ads Management" }],
    "rate_level": "BASIC"
  },
  "users": [
    { "core_user_id": "7000000013373458727", "display_name": "Joana Ribeiro", "persona": "admin" },
    { "core_user_id": "7000000013373458728", "display_name": "Bruno Sem Contas", "persona": "no_advertisers" }
  ],
  "advertisers": [
    {
      "advertiser_id": "7000000013373458730",
      "name": "Mimicr Ads · Principal",
      "status": "STATUS_ENABLE",
      "currency": "BRL",
      "instant_forms": [{ "page_id": "7000000013373458731", "title": "Pedido de gás" }],
      "pixels": [{ "pixel_code": "X6R0U4QQZJSZ84ABSF9Q", "events_token": "<token>" }],
      "identities": [{ "identity_id": "7000000013373458733", "display_name": "Mimicr Ads" }]
    }
  ]
}

The response was trimmed and the ids are examples; use your sandbox's. With the CLI: npx mimicr login mk_... once, then npx mimicr status tiktok-ads.

3. Get a token

In the real integration, the advertiser goes through the authorization page and your server exchanges the auth_code at /oauth2/access_token/ (see Authentication). To test quickly, Mimicr does both for you with the admin user and all their advertisers:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/tiktok-ads/token \
  --header 'Authorization: Bearer mk_...'
json
{
  "access_token": "<token>",
  "scope": [1, 2, 3, 4, 5, 6, 8, 12000000],
  "advertiser_ids": ["7000000013373458730", "7000000013373458735", "7000000013373458740"],
  "user_id": "7000000013373458727"
}

The token never expires. It goes in the Access-Token header on every call.

4. Make the first call

Paths end with /, and lists go as JSON in the query:

bash
curl --get https://tiktok-ads.mimicr.dev/open_api/v1.3/advertiser/info/ \
  --header 'Access-Token: <token>' \
  --data-urlencode 'advertiser_ids=["7000000013373458730"]' \
  --data-urlencode 'fields=["advertiser_id","name","currency","timezone","status"]'
json
{
  "code": 0,
  "message": "OK",
  "request_id": "2026110612431854AE75609BDCC1404C",
  "data": {
    "list": [
      { "advertiser_id": "7000000013373458730", "name": "Mimicr Ads · Principal", "currency": "BRL", "timezone": "America/Sao_Paulo", "status": "STATUS_ENABLE" }
    ]
  }
}

Success is code 0. Errors also come back with HTTP 200 and a non-zero code (see Envelope and errors).

5. Publish a campaign, an ad group and an ad

bash
B=https://tiktok-ads.mimicr.dev/open_api/v1.3
H='Access-Token: <token>'
ADV=7000000013373458730

curl -s "$B/campaign/create/" -H "$H" -H 'Content-Type: application/json' -d "{
  \"advertiser_id\": \"$ADV\", \"campaign_name\": \"Gás em Contagem\",
  \"objective_type\": \"TRAFFIC\", \"budget_mode\": \"BUDGET_MODE_INFINITE\", \"operation_status\": \"DISABLE\"}"
# data.campaign_id: "1700013373458745", secondary_status: "CAMPAIGN_STATUS_DISABLE"

curl -s "$B/adgroup/create/" -H "$H" -H 'Content-Type: application/json' -d "{
  \"advertiser_id\": \"$ADV\", \"campaign_id\": \"1700013373458745\", \"adgroup_name\": \"Gás em Contagem\",
  \"promotion_type\": \"WEBSITE\", \"placement_type\": \"PLACEMENT_TYPE_NORMAL\", \"placements\": [\"PLACEMENT_TIKTOK\"],
  \"location_ids\": [\"3469034\"], \"budget_mode\": \"BUDGET_MODE_DAY\", \"budget\": 25,
  \"schedule_type\": \"SCHEDULE_FROM_NOW\", \"schedule_start_time\": \"2026-11-06 12:00:00\",
  \"optimization_goal\": \"CLICK\", \"billing_event\": \"CPC\", \"bid_type\": \"BID_TYPE_NO_BID\",
  \"pacing\": \"PACING_MODE_SMOOTH\", \"operation_status\": \"DISABLE\"}"
# data.adgroup_id: "1700013373458750", secondary_status: "ADGROUP_STATUS_CREATE"

schedule_start_time is UTC+0 and cannot be more than 12 hours in the past; use the current time. The video ad needs the video, a cover image and an identity:

bash
curl -s "$B/file/video/ad/upload/" -H "$H" -H 'Content-Type: application/json' -d "{
  \"advertiser_id\": \"$ADV\", \"upload_type\": \"UPLOAD_BY_URL\", \"video_url\": \"https://cdn.example.com/botijao.mp4\"}"
# data[0].video_id: "v10033g50000rni3aj3fg5q9d6ald8n9"

curl -s "$B/file/image/ad/upload/" -H "$H" -H 'Content-Type: application/json' -d "{
  \"advertiser_id\": \"$ADV\", \"upload_type\": \"UPLOAD_BY_URL\", \"image_url\": \"https://cdn.example.com/capa.jpg\"}"
# data.image_id: "ad-site-i18n-sg/20261106800732b5fcd5cfb46c882e2d"

curl -s "$B/ad/create/" -H "$H" -H 'Content-Type: application/json' -d "{
  \"advertiser_id\": \"$ADV\", \"adgroup_id\": \"1700013373458750\",
  \"creatives\": [{
    \"ad_name\": \"Anúncio 1\", \"ad_format\": \"SINGLE_VIDEO\",
    \"identity_type\": \"CUSTOMIZED_USER\", \"identity_id\": \"7000000013373458733\", \"display_name\": \"PopGás\",
    \"video_id\": \"v10033g50000rni3aj3fg5q9d6ald8n9\", \"image_ids\": [\"ad-site-i18n-sg/20261106800732b5fcd5cfb46c882e2d\"],
    \"ad_text\": \"Peça seu gás agora\", \"call_to_action\": \"ORDER_NOW\",
    \"landing_page_url\": \"https://popgas.example/pedido\", \"operation_status\": \"ENABLE\"}]}"
# data.ad_ids: ["1700013373458754"], secondary_status: "AD_STATUS_AUDIT"

The ad enters review. Details of every field in Create a campaign.

6. Approve the ad and turn it on

Review ends on its own 10 sandbox minutes later. To skip the wait, play the reviewer, then turn the campaign and the ad group on:

bash
npx mimicr action tiktok-ads ad.approve adId=1700013373458754

curl -s "$B/campaign/status/update/" -H "$H" -H 'Content-Type: application/json' \
  -d "{\"advertiser_id\": \"$ADV\", \"campaign_ids\": [\"1700013373458745\"], \"operation_status\": \"ENABLE\"}"
curl -s "$B/adgroup/status/update/" -H "$H" -H 'Content-Type: application/json' \
  -d "{\"advertiser_id\": \"$ADV\", \"adgroup_ids\": [\"1700013373458750\"], \"operation_status\": \"ENABLE\"}"

Now GET /ad/get/ shows the ad as AD_STATUS_DELIVERY_OK, and /ad/review_info/ shows is_approved: true and review_status: ALL_AVAILABLE.

7. Simulate a click and read the metrics

bash
npx mimicr action tiktok-ads traffic.click adId=1700013373458754
# data.landingUrl: "https://popgas.example/pedido?ttclid=E.C.P.…"
npx mimicr action tiktok-ads traffic.deliver campaignId=1700013373458745 hours=24

The click returns the ttclid your landing page receives; send it back in the Events API to attribute the sale. traffic.deliver generates 24 hours of delivery without moving the clock. Now the report:

bash
curl --get "$B/report/integrated/get/" -H "$H" \
  --data-urlencode "advertiser_id=$ADV" \
  --data-urlencode 'report_type=BASIC' \
  --data-urlencode 'data_level=AUCTION_AD' \
  --data-urlencode 'dimensions=["ad_id","stat_time_day"]' \
  --data-urlencode 'metrics=["spend","impressions","clicks","frequency"]' \
  --data-urlencode 'start_date=2026-11-05' \
  --data-urlencode 'end_date=2026-11-06'
json
{
  "code": 0,
  "message": "OK",
  "request_id": "20261106124323DF57D3C0F4DA240D7D",
  "data": {
    "list": [
      { "dimensions": { "ad_id": "1700013373458754", "stat_time_day": "2026-11-05 00:00:00" }, "metrics": { "spend": "20.99", "impressions": "3986", "clicks": "50", "frequency": "1.45" } }
    ],
    "page_info": { "page": 1, "page_size": 10, "total_number": 1, "total_page": 1 }
  }
}

8. Receive a lead on your webhook

Subscribe to the leads of the account's Instant Form. The Subscription API authenticates with app_id and secret in the body:

bash
curl -s "$B/subscription/subscribe/" -H 'Content-Type: application/json' -d '{
  "app_id": "7543382796466965341", "secret": "<secret>",
  "subscribe_entity": "LEAD", "callback_url": "https://seu-servico.example.com/webhooks/tiktok",
  "subscription_detail": { "access_token": "<token>", "advertiser_id": "7000000013373458730", "page_id": "7000000013373458731" }}'

Now someone fills in the ad's form, and you wait for the delivery:

bash
npx mimicr action tiktok-ads lead.submit adId=1700013373458754
npx mimicr wait tiktok-ads delivery entity=LEAD status=delivered

The POST arrives with X-Open-Signature. See the payload in Forms and webhook and the check in Verify the signature.

Next steps

  • Sandbox testing for the rejection and failure triggers and the homologation toggles.
  • Reports for levels, ranges, STATUS_ALL and asynchronous reports.
  • Sandbox control for every action, waiting and the clock.