Guides
Conversions

Conversions API

Datasets, sending server events with hashed data, ctwa_clid and fbc, deduplication, partial failure and how Mimicr matches each event to a click.

The Conversions API receives events from your server (a purchase, an order, a sign-up) and links them to the ads that generated them. In Mimicr, an event that carries the ctwa_clid of a sandbox click-to-WhatsApp, or the fbclid of a website click, is attributed to the ad and shows up in its Insights.

The dataset

Events go to a dataset (pixel). There are two paths:

Ad account pixel.

bash
curl -s 'https://meta-ads.mimicr.dev/v27.0/act_100539998049706/adspixels' \
  -H 'Authorization: Bearer <token>' -F name='Minha loja (ERP)'
# {"id":"100539998049732"}

In Mimicr, with onePixelPerAccount (on by default), a second dataset on the same account answers 6200 "A pixel already exists for this account". List the existing ones with GET /act_{id}/adspixels before creating.

WABA dataset, the path Meta documents for click-to-WhatsApp conversions:

bash
curl -s -X POST 'https://meta-ads.mimicr.dev/v27.0/<waba_id>/dataset' -H 'Authorization: Bearer <token>'
# {"id":"100539998049733"}

Requires whatsapp_business_management and whatsapp_business_manage_events; without them, 200. The waba_id is that of the WhatsApp Business account of the linked WhatsApp sandbox (it appears in GET /v1/meta-ads, in whatsapp.waba_id). GET and POST create the dataset on the first call and then return the same id.

Send events

bash
curl -s 'https://meta-ads.mimicr.dev/v27.0/100539998049733/events' \
  -H 'Authorization: Bearer <token>' \
  -F data='[{
    "event_name": "Purchase",
    "event_time": 1794028091,
    "event_id": "order-1001",
    "action_source": "business_messaging",
    "messaging_channel": "whatsapp",
    "user_data": {
      "ph": ["6bd1037b2be343b22b8b7e323a0f227e1f2a151f1a709536fd2522a1873fc604"],
      "ctwa_clid": "Af1QftRstEi_g2hY9q_3uEx9Q85TARVV7CN8eZInVC4MEu3Q14…",
      "whatsapp_business_account_id": "<waba_id>"
    },
    "custom_data": { "currency": "BRL", "value": 120.0 }
  }]'
json
{ "events_received": 1, "messages": [], "fbtrace_id": "0Ug895_DCzQ" }

Up to 1,000 events per request. Requires ads_management and access to the pixel's account (for the WABA dataset, whatsapp_business_manage_events).

Rules for each event

FieldRule
event_nameRequired: Purchase, Lead or a name of your own
event_timeRequired, UNIX seconds. More than 7 days in the past (62 for physical_store): 100/2804003. More than 1 h in the future: 100/2804004
action_sourceRequired: website, business_messaging, system_generated, physical_store, app, email, phone_call, chat or other
user_dataRequired, with at least one identifier; otherwise 100/2804050
websiteRequires event_source_url and user_data.client_user_agent
business_messagingRequires messaging_channel (whatsapp, messenger, instagram)
WhatsApp with ctwa_clidRequires user_data.whatsapp_business_account_id
WhatsApp without ctwa_clidRequires user_data.page_id (100/2804051) and one hashed value among em, ph, fn, ln, ct, st, zp, country, ge, db
custom_data.valueRequires currency

em, ph, fn, ln, ge, db, ct, st, zp, country and external_id go as SHA-256, lowercase hex, after normalizing (lowercase, no spaces; phone with digits and country code only). An unhashed value is accepted, generates a warning in messages and the event doesn't match. fbc must have the format fb.1.<ms>.<fbclid>; fbp, client_ip_address, client_user_agent, ctwa_clid and page_id go unhashed.

bash
printf '%s' '5511999990000' | sha256sum

Partial failure and deduplication

If one event in the batch is invalid, the whole request answers with an error, with blame_field_specs pointing to the index. Valid events that have an event_id are stored anyway. When you resend the corrected batch, they're dropped as duplicates: the key is event_name + event_id. events_received counts them all, duplicates included. Always send event_id.

How Mimicr matches events

Meta only shows matching in Events Manager. Mimicr stores each event with an outcome, visible in the console ("Conversões" tab) and at GET /v1/meta-ads/objects?kind=capi_event:

OutcomeWhen
matched_clickThe ctwa_clid came from a sandbox click-to-WhatsApp, with the linked WABA's whatsapp_business_account_id, or the fbclid in fbc came from a website click (ad.click_web); click up to 28 days old
matched_userThe ph or em hash belongs to a lead or a contact who clicked an ad in the last 7 days
unmatchedAny other case, including event_id starting with nomatch- and unhashed data
duplicateSame event_name + event_id already received

A Purchase with matched_click adds a purchase and its value to the ad's Insights, at the hour of event_time (purchase, omni_purchase in actions and action_values).

To force outcomes without setting up the click, use capi.set_outcome:

bash
npx mimicr action meta-ads capi.set_outcome outcome=rejected count=1 error_subcode=2804050

An event_id starting with rejeitar- is also rejected (100/2804050). Events with test_event_code are marked as test and still count.

For the full flow with WhatsApp, see Click-to-WhatsApp. Reference: Send events, Create dataset and Create WABA dataset.