Guides
Leads

Forms and webhook

Instant Forms, real and test leads, the Subscription API, the LEAD, AD, AD_GROUP, AD_ACCOUNT_SUSPENSION and REPORT_DATA_CHANGE payloads, retries and lead downloads.

In a lead generation ad, the person fills in an Instant Form without leaving TikTok. The lead reaches your server by webhook and can also be read through the API.

The form

Each sandbox account already has an Instant Form, "Pedido de gás" (name, phone and e-mail). /page/get/ with business_type=LEAD_GEN lists the forms:

json
{ "page_id": "7000000013373458731", "status": "PUBLISHED", "title": "Pedido de gás", "preview_url": "https://tiktok-ads.mimicr.dev/mimicr/form/7000000013373458731", "template_name": "Instant Form" }

preview_url is the form hosted by Mimicr, as the user sees it. More forms: the form.create advertiserId=… title=… fields=name,phone_number,email,city action. /lead/field/get/ returns the fields.

To use it in an ad: a LEAD_GENERATION campaign, an ad group with promotion_type LEAD_GENERATION, promotion_target_type INSTANT_PAGE and optimization_goal LEAD_GENERATION (OCPM billing), and the ad with the form's page_id.

Subscribe to leads

The Subscription API authenticates with the app's app_id and secret in the body; the advertiser token goes inside subscription_detail:

bash
curl --request POST \
  --url https://tiktok-ads.mimicr.dev/open_api/v1.3/subscription/subscribe/ \
  --header 'Content-Type: application/json' \
  --data '{
    "app_id": "<app_id>",
    "secret": "<secret>",
    "subscribe_entity": "LEAD",
    "callback_url": "https://app.example.com/webhooks/tiktok",
    "subscription_detail": { "access_token": "<token>", "advertiser_id": "7000000013373458730", "page_id": "7000000013373458731" }
  }'
# data.subscription_id: "7000000013373458779"
subscribe_entitysubscription_detailFires when
LEADadvertiser_id, page_id (optional), lead_source (INSTANT_FORM or DIRECT_MESSAGE)Each new lead
ADadvertiser_id, ad_idThe ad is rejected
AD_GROUPadvertiser_id, adgroup_idThe ad group is rejected
AD_ACCOUNT_SUSPENSIONadvertiser_ids or bc_idThe account becomes STATUS_LIMIT or STATUS_DISABLE
REPORT_DATA_CHANGEadvertiser_ids, notify_frequency (5_MINUTE, 15_MINUTE, 30_MINUTE, 60_MINUTE)The day's metrics changed, at most once per window

callback_url must be https (or localhost). An identical subscription answers 40002 Subscription already exists. CREATIVE_FATIGUE, TCM_VIDEOS and API_SERVICE_STATUS answer 40014. /subscription/get/ lists the app's subscriptions and /subscription/unsubscribe/ cancels one. If the subscription's token is revoked, it silently stops firing.

Generate a lead

  • Through the form: open https://tiktok-ads.mimicr.dev/mimicr/form/{page_id}?ad_id={ad_id} in a browser (or Playwright), fill it in and submit.
  • Through the action: npx mimicr action tiktok-ads lead.submit adId=1700013373458754 'fields={"name":"Maria Souza","phone_number":"+5531999990000"}'. Missing fields get synthetic data.
  • Test lead: /page/lead/mock/create/ creates the form's test lead, with TikTok's demo values (Jane Doe). One per form: delete it at /page/lead/mock/delete/ before creating another.
  • Through delivery: with the autoLeads toggle, the leads delivery counts on a LEAD_GENERATION ad group become real leads.

Each lead counts in onsite_form at its hour and fires the account's LEAD subscriptions.

The LEAD webhook

text
POST https://app.example.com/webhooks/tiktok
Content-Type: application/json
User-Agent: tiktok-webhook
X-Open-Signature: 5f0c1e…
X-Mimicr-Delivery-Id: 6c2d…
json
{"request_id":7432095102384751616,"object":1,"entry":[{"id":7000000013373458786,"lead_source":"INSTANT_FORM","page_id":7000000013373458731,"page_name":"Pedido de gás","advertiser_id":7000000013373458730,"advertiser_name":"Mimicr Ads · Principal","library_id":0,"campaign_id":1700013373458749,"campaign_name":"Gás em Betim","adgroup_id":1700013373458750,"adgroup_name":"Gás em Betim","ad_id":1700013373458754,"ad_name":"Anúncio 1","create_time":1762400000,"changes":[{"field":"name","value":"Maria Souza"},{"field":"phone_number","value":"+5531999990000"},{"field":"email","value":"maria@example.com"}]}],"time":1762400003}
  • object is 1 for LEAD, 2 for AD_GROUP, 3 for AD, 11 for REPORT_DATA_CHANGE and 12 for AD_ACCOUNT_SUSPENSION (TikTok does not publish this last one; it is Mimicr's decision).
  • Ids, request_id and object are 64-bit JSON integers, and every non-ASCII character is escaped (á). See Verify the signature.
  • A test lead, with no ad, carries campaign_name: "test lead: dummy data for campaign name" and 0 ids.

Other payloads:

json
{"request_id":7432095102384751617,"object":12,"entry":[{"advertiser_id":7000000013373458735,"status":"STATUS_DISABLE"}],"time":1762400100}
json
{"request_id":7432095102384751618,"object":11,"entry":[{"data_level":"advertiser_id","changed_metrics_values":{"7000000013373458730":{"currency":"BRL","adv_timezone":"America/Sao_Paulo","spend":"34.07","impressions":"5856","clicks":"72","video_play_actions":"5387"}}}],"time":1762400400}

The rejection ones (AD and AD_GROUP) are in Ads and review.

Delivery and retries

  • Answer any 2xx within 5 seconds. Any other status, a timeout or a network error is a failure.
  • TikTok retries right away and then at growing intervals for 24 hours. In Mimicr: right away, once more immediately, and at 1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h; after that the delivery is dropped.
  • Delivery is "at least once": deduplicate by the lead id. The webhook chaos can duplicate deliveries on purpose.
  • By default, one lead per POST. With the batchWebhooks toggle, the leads due in the same sweep go together in entry.
bash
npx mimicr get '/v1/tiktok-ads/deliveries?entity=LEAD&status=retrying'
npx mimicr post /v1/tiktok-ads/deliveries/<id>/resend

The phone number +550000000000 on a lead makes the first attempt fail, to test the retry.

Read leads through the API

RouteFor
/lead/get/A lead of the form (page_id and lead_source). The parameters have no lead id: Mimicr returns the most recent one
/page/lead/mock/get/The form's test lead (without one: 40007)
/page/lead/task/Creates the download task for a form or an ad; call it again with the task_id until SUCCEED (10 sandbox seconds)
/page/lead/task/download/The CSV with every lead of the task
text
lead_id,create_time,ad_id,ad_name,adgroup_id,adgroup_name,campaign_id,campaign_name,page_id,name,phone_number,email
7000000013373458786,2026-11-06 06:06:34,1700013373458754,Anúncio 1,1700013373458750,Gás em Betim,1700013373458749,Gás em Betim,7000000013373458731,Maria Souza,+5531999990000,maria@example.com