Skip to Content
Traccia le tue conversioni Telegram con Meta Ads — inizia in pochi minuti!
Riferimento APIIdempotency

Idempotency

Every endpoint accepts an optional Idempotency-Key header. Use it to safely retry requests when your network or our backend has a hiccup.

How it works

  1. Your first request runs normally. We store the response body keyed on (apiKeyId, idempotencyKey).

  2. Any request with the same key within 24h returns the same response with a header:

    X-Idempotent-Replay: true
  3. Two days later the cached row is purged. Calling with the same key again will re-execute the request.

Guidelines

  • The key is string ≤ 128 characters.
  • Generate one per business action: order_<order_id>, signup_<user_id>_<timestamp>, etc.
  • Don’t reuse keys across different operations. Each key represents one logical “attempt”.
  • The Idempotency-Key is scoped per API key — two different keys may use the same string without conflict.

Example

Fire a Purchase event with retry safety:

curl -X POST https://adtarget.io/api/v1/events/conversion \ -H "Authorization: Bearer atk_live_..." \ -H "Idempotency-Key: order_98765" \ -H "Content-Type: application/json" \ -d '{ "telegramUserId": 1234567890, "channelId": "-1001234567890", "eventType": "Purchase", "value": 49.00, "currency": "USD" }'

If your network drops the response and you retry with the same Idempotency-Key, AdTarget returns the original conversionId without firing a second Meta event.

We don’t validate that the body matches the original request. If you reuse a key with a different body, you’ll get back the original response — not the new one. Always generate a fresh key for a different intent.

What gets cached

  • The full response body and HTTP status code.
  • The conversionId for forensic linking.

We do not cache anything about the request body itself. The key is the sole replay identifier.

Combined with Meta dedup

AdTarget has two layers of duplicate protection:

  1. Idempotency-Key replays the same API response for the same logical request within 24h.
  2. Conversion upsert logic reuses recent matching events for the same resolved site, Telegram user, channel, and event type. Pending/failed/skipped events are updated and retried; sent events are returned with deduplicated: true and are not sent again.

Meta CAPI also deduplicates within 48h based on event_id.

Deduplicazione facoltativa delle visite per /track/init

POST /backend/track/init accetta un UUID facoltativo visitRequestId nel corpo JSON. È il campo pubblico consigliato; il precedente nome gatewayRequestId resta accettato come alias retrocompatibile. Se vengono inviati entrambi i campi, devono contenere lo stesso UUID; valori diversi restituiscono HTTP 400. Riutilizza lo stesso UUID per i tentativi della stessa visualizzazione di pagina: AdTarget restituisce la stessa visita e completa solo i dati di attribuzione mancanti. I valori esistenti e il routing non vengono mai sovrascritti. I tentativi devono mantenere gli stessi websiteId, tempId e sessionId; un cambio di identità del browser viene rifiutato.

Senza visitRequestId, il comportamento storico resta invariato: ogni chiamata crea una visita distinta, anche nella stessa sessione browser. Usa un nuovo UUID per ogni nuova visualizzazione reale.

Nuovi tentativi direct-invite senza chiave API

POST /backend/track/direct-invite usa visitRequestId (UUID) nel body, non l’header Idempotency-Key. Il precedente alias gatewayRequestId resta accettato. Riutilizza lo stesso UUID per i tentativi della stessa redirezione.

Le chiamate ripetute creano una visita, una voce PageView e un invito Telegram. Completano solo i campi mancanti senza sovrascrivere valori esistenti. websiteId, tempId e sessionId devono identificare la visita originale. Usa un nuovo UUID per un nuovo clic.

Last updated on