Endpoints
Active /api/v1/* business endpoints require Authorization: Bearer atk_live_.... Responses are JSON.
New API keys are account-scoped. Lead/event endpoints can infer the site and channel from the Telegram user’s existing funnel history. For cold leads or ambiguous matches, supply siteId or websiteId plus channelId.
Do not use /api/v1 for pageviews or invite clicks. First-party reverse proxies should use the keyless tracker-compatible endpoints: /backend/track/init, /backend/track/update-fbp, /backend/track/invite, or the optionally retry-safe /backend/track/init endpoint, or the combined retry-safe /backend/track/direct-invite endpoint.
Forwarding the real client
For API conversion requests, forward the end user’s IP and User-Agent via either:
- Headers:
X-Adtarget-Client-IP,X-Adtarget-Client-User-Agent - Body fields:
clientIp,userAgent
Precedence: headers win over body fields.
For /backend/track/* reverse-proxy requests, forward the real browser context with headers. Do not add an API key.
POST /api/v1/events/conversion
The killer endpoint. Creates a conversion row + dispatches Meta CAPI (and TikTok / Snapchat / Google if configured).
Body:
{
telegramUserId: number,
channelId?: string, // optional when prior lead history can resolve it
siteId?: string, // optional override; required for cold account-key leads
websiteId?: string, // alternative to siteId
eventType: "Contact" | "Lead" | "Purchase" | "CompleteRegistration" | "Subscribe" | "Custom",
customEventName?: string, // required when eventType === "Custom"
value?: number, // required for Purchase
currency?: string, // required for Purchase; ISO 4217 (USD, EUR, ...)
contentName?: string,
pii?: {
email?: string,
phone?: string,
firstName?: string,
lastName?: string
},
externalUserId?: string,
brokerUid?: string, // the lead's client UID at the broker; dashboard only, never sent to ad platforms
eventTime?: number, // Unix millis; defaults to now
// Cold-lead attribution overrides
fbc?: string, fbp?: string,
gclid?: string, ttclid?: string, sccid?: string,
clientIp?: string,
userAgent?: string,
eventSourceUrl?: string,
}Response:
{
conversionId: string,
capiStatus: "pending" | "skipped",
coldLead: boolean,
dispatched: boolean, // false when sends=[] or a sent duplicate was reused
deduplicated?: boolean, // true when an existing matching event was reused/updated
updatedExisting?: boolean, // true when a pending/failed/skipped event was completed
warning?: string, // present when dispatched=false; explains why
sends: [{ sendId: string, platform: string }]
}dispatched: falsemeans no platform CAPI was scheduled. This can happen because the request lacked attribution signals, no pixel is configured for the resolved site, or a recent matching sent event was reused withdeduplicated: true.dispatched: truedoes NOT guarantee the event was accepted by Meta/TikTok/etc. — it means a send was scheduled. If a downstream check (e.g., missinguser_agentfor Meta) rejects the send, the underlyingconversion_sendsrow will be markedskipped. Poll the dashboard or use Axiom logs to confirm final delivery.
Warm vs cold leads
- Warm: AdTarget has prior history for the
telegramUserIdon the account. With an account-scoped key, the API resolves the latest matching site/channel/funnel context and inherits itssessionId/visitId. - Cold: no prior conversion. Supply
siteIdorwebsiteIdpluschannelId; the suppliedfbc/fbp/clientIp/userAgentare written toconversion.apiVisitOverrideand used for CAPI.
For cold leads, always pass fbc, fbp, clientIp, userAgent, eventSourceUrl to keep Meta’s Event Match Quality high.
Duplicate protection
For recent matching events on the same resolved site, Telegram user, channel, and event type:
- pending/failed/skipped events are updated with the new value/PII and dispatched or retried;
- sent events are returned with
deduplicated: trueand are not sent again.
Purchase events require value and currency.
POST /api/v1/leads/{telegramUserId}/events
Fire an additional event on an existing lead. Equivalent to POST /events/conversion, but the Telegram user ID comes from the URL and account-scoped keys can auto-resolve both siteId and channelId from the lead’s most recent conversion.
Body: same as /events/conversion minus telegramUserId; channelId, siteId, and websiteId are optional when lead history is unambiguous.
POST /api/v1/leads/{telegramUserId}/conversions/{conversionId}/value
Submit value + optional PII for a conversion that’s awaitingManualInput (Purchase event with no auto-fire). This is the API equivalent of clicking “Submit value” in the dashboard.
Body:
{
value: number, // > 0
currency: string, // ISO 4217 whitelist
pii?: {
email?, phone?, firstName?, lastName?
}
}Response: { success: boolean }
GET /api/v1/leads/{telegramUserId}
Read everything we know about a lead on the resolved site. Account-scoped keys may pass ?siteId=... or ?websiteId=... when the lead exists on multiple sites. Useful for debugging.
Response:
{
telegramUserId: number,
firstSeenAt: number,
lastSeenAt: number,
externalUserId?: string,
conversions: [{
conversionId: string,
channelId: string,
eventType: string,
capiStatus: string,
attributedAt: number,
eventValue?: number,
eventCurrency?: string,
source?: "tracker" | "webhook" | "api"
}]
}Returns 404 LEAD_NOT_FOUND if no conversion exists for the lead on the resolved site.
GET /api/v1/channels
List active channels. Site-scoped keys return channels for their site. Account-scoped keys return channels across the account, or for one site when ?siteId=... / ?websiteId=... is supplied. Useful when you only know one ID and need the other.
Response:
{
channels: [{
siteId?: string, // present for account-wide channel lists
siteDomain?: string, // present for account-wide channel lists
channelId: string, // Convex ID
telegramChannelId: string, // "-100..."
title: string,
username?: string,
funnelOrder: number,
eventType?: string
}]
}GET /api/v1/channels/{channelId}/joins
List the joins of one channel, oldest first, one page at a time. channelId is the Convex ID or the Telegram ID (-100...) returned by GET /channels. Site-scoped keys only see joins attributed to their site; account-scoped keys see every join of the channel.
Query parameters:
| Parameter | Description |
|---|---|
from | Optional. Unix time in milliseconds: joins at or after it. |
to | Optional. Unix time in milliseconds: joins before it. |
limit | Optional. Page size, 1 to 200 (default 100). |
cursor | Optional. The previous page’s nextCursor, with the same from, to and channel. |
Response:
{
joins: [{
joinId: string,
telegramUserId: number,
joinedAt: number, // when AdTarget recorded the join (ms)
siteId?: string, // site the join was attributed to
interactionType: "join_via_invite" | "passive_upsell" | "re_entry" | "organic",
adClicks: ("meta" | "google" | "tiktok" | "snapchat")[] // ad click IDs present on that visit
}],
nextCursor: string | null // null on the last page
}A page can hold fewer than limit joins (site-scoped keys skip joins of other sites): keep requesting until nextCursor is null. telegramUserId identifies the member, as in GET /leads. Names, usernames, contact details and free-text tracking fields such as UTM tags are never returned. Joins attributed to a site your account does not own are left out. Returns 404 CHANNEL_NOT_FOUND when the channel is not one of the key’s channels.
GET /api/v1/ads
Elenca gli annunci dei progetti della chiave, pagina per pagina. Una chiave di progetto vede gli annunci del suo progetto; una chiave di account vede quelli di tutti i progetti, o di uno solo con ?siteId=... / ?websiteId=....
network | Annunci restituiti |
|---|---|
telegram_ads | Gli annunci Telegram del progetto, archiviati inclusi, dal più vecchio al più recente. |
meta | Gli annunci sincronizzati dalla connessione Meta Ads dell’account: annunci con spesa nel periodo sincronizzato e annunci visti nel traffico tracciato. Appartengono a un account pubblicitario Meta, non a un progetto: sono restituiti solo a una chiave di account senza filtro di progetto, e solo finché Meta Ads è connesso. |
tiktok, snapchat | Nessuno: AdTarget non ha connessioni agli account pubblicitari TikTok o Snapchat. I loro annunci compaiono solo in GET /ads/people. |
Parametri:
| Parametro | Descrizione |
|---|---|
network | Facoltativo. telegram_ads, meta, tiktok o snapchat. Tutte le reti se omesso: prima gli annunci Telegram, poi quelli Meta. |
siteId / websiteId | Facoltativo. Gli annunci di un progetto. |
limit | Facoltativo. Dimensione della pagina, da 1 a 200 (100 predefinito). |
cursor | Facoltativo. Il nextCursor della pagina precedente, con gli stessi filtri. |
Risposta:
{
ads: [{
network: "telegram_ads" | "meta" | "tiktok" | "snapchat",
id: string, // stabile: rinominare l'annuncio lo conserva (l'ID Meta per Meta)
name: string, // nome attuale
siteId: string | null, // progetto dell'annuncio; null per Meta (annuncio di un account pubblicitario)
websiteId: string | null,
projectName: string | null,
campaignId: string | null, // Meta: campagna, gruppo di inserzioni e account pubblicitario
adsetId: string | null,
accountId: string | null,
status: string | null, // Meta: stato di pubblicazione all'ultima sincronizzazione
code: string | null, // annunci Telegram: "ADT-7KQ4M", il codice del primo messaggio
inviteLink: string | null, // annunci Telegram: il link di invito proprio dell'annuncio
createdAt: number | null, // annunci Telegram: ms Unix
archivedAt: number | null // annunci Telegram: gli archiviati continuano a registrare persone
}],
nextCursor: string | null // null nell'ultima pagina
}Eliminare un progetto elimina i suoi annunci Telegram e le loro persone.
GET /api/v1/ads/people
Elenca le persone che gli annunci hanno portato nei progetti della chiave, pagina per pagina. Ogni riga indica quale annuncio, su quale rete, ha portato un utente Telegram in un progetto, e se quell’annuncio riceve il credito. Una chiave di progetto vede le persone del suo progetto.
network | Una riga è |
|---|---|
telegram_ads | Una persona registrata da un annuncio Telegram: un messaggio privato con il codice dell’annuncio, o un’iscrizione tramite il suo link di invito. Una volta per account: il primo annuncio registrato tiene la persona. In ordine di arrivo. |
meta, tiktok, snapchat | Un’iscrizione a un canale accreditata a quell’annuncio, come nel report per annuncio, che conta iscrizioni: una persona che si iscrive più volte ha più righe. Un’iscrizione è accreditata all’annuncio identificato dalla visita tracciata che la precede (ID dell’annuncio nelle UTM o nei parametri del link), con la regola e l’identità di annuncio del report per annuncio. Per progetto, poi per ora di iscrizione. |
Senza network, prima le persone degli annunci Telegram, poi quelle delle altre reti.
Parametri:
| Parametro | Descrizione |
|---|---|
network | Facoltativo. telegram_ads, meta, tiktok o snapchat. Tutte le reti se omesso. |
siteId / websiteId | Facoltativo. Le persone di un progetto. |
adId | Facoltativo, richiede network. Le persone di un annuncio: l’id di GET /ads per un annuncio Telegram, l’ID annuncio dal link della visita per le altre reti. |
telegramUserId | Facoltativo. Le righe di una persona. |
from | Facoltativo. Ora Unix in millisecondi: arrivi da quel momento. |
to | Facoltativo. Ora Unix in millisecondi: arrivi prima di quel momento. |
limit | Facoltativo. Dimensione della pagina, da 1 a 200 (100 predefinito). |
cursor | Facoltativo. Il nextCursor della pagina precedente. |
Risposta:
{
people: [{
network: "telegram_ads" | "meta" | "tiktok" | "snapchat",
joinId: string | null, // l'iscrizione dietro la riga; null per gli annunci Telegram
telegramUserId: number,
adId: string | null, // null se il link identificava solo la campagna
adName: string | null, // nome attuale (vedi sotto)
campaignId: string | null, // null per gli annunci Telegram
adsetId: string | null,
siteId: string, // il progetto
websiteId: string,
via: "code" | "link" | "visit" | null, // codice dell'annuncio in un messaggio, il suo link di invito o una visita tracciata
at: number, // arrivo (ms): data Telegram del messaggio o dell'iscrizione, o ora dell'iscrizione
prior: "new" | "known" | "paid_web" | null, // annunci Telegram: cosa sapeva l'account della persona prima
attributed: boolean // false: un clic a pagamento precedente mantiene il credito
}],
nextCursor: string | null // null nell'ultima pagina
}- Pagine. Una pagina legge al massimo
limitrecord: può contenere meno righe, anche nessuna. Continua finchénextCursornon ènull. Un cursore appartiene alla sua lista: con altri filtri o un altro ambito (progetto o altro account), o se alterato, la richiesta risponde400 INVALID_PAYLOAD. I cursori non sono firmati: un’altra chiave dello stesso account e dello stesso ambito può riprenderne uno. - Credito. Una persona di un annuncio Telegram con
prior: "paid_web"era già arrivata da un clic pubblicitario a pagamento (Meta, Google, TikTok o Snapchat) e haattributed: false: mantiene quell’attribuzione e all’annuncio Telegram non viene accreditato nessuno dei suoi eventi. Quando la visita di quel clic identifica l’annuncio, la sua iscrizione compare sotto la sua rete. Anche un vero clic pubblicitario successivo mantiene il proprio credito. Le righe Meta, TikTok e Snapchat hanno sempreattributed: true. - Identità dell’annuncio. Come nel report per annuncio, un annuncio è il suo
adId. Quando il link portava solo un nome, l’ID TikTok o Snapchat èname:seguito da quel nome, e l’annuncio è identificato danetwork,campaignId,adsetIdeadIdinsieme: due annunci «Video 1» di due campagne sono due annunci. Senza ID annuncio, l’annuncio è la sua campagna e il suo gruppo di inserzioni. ConadId=name:…, il filtro confronta solo quell’ID, quindi può includere annunci omonimi di campagne diverse: filtra le righe anche percampaignId. - Nomi. Per Meta,
adNameè il nome sincronizzato da Meta Ads se connesso, altrimenti l’ad_namedel link, altrimentinull. Per TikTok e Snapchat, il nome del link. - Righe per persona. Una persona può avere più righe: una riga di annuncio Telegram, una riga per iscrizione accreditata sulle altre reti, righe per più annunci o progetti.
joinIdidentifica una riga di iscrizione; una riga di annuncio Telegram si identifica connetwork,siteIdetelegramUserId. Per contare le persone per annuncio, raggruppa pernetwork,siteId,telegramUserIde l’identità di annuncio sopra. - Iscrizioni precedenti. Le iscrizioni registrate solo come eventi prima di marzo 2026 sono state convertite in iscrizioni ai canali e sono elencate come le altre.
- Report per annuncio. Il credito segue la regola del report per annuncio. I suoi totali possono differire quando i suoi aggregati giornalieri sono troncati.
- Nomi, username e dati di contatto non vengono mai restituiti. Risponde
404 AD_NOT_FOUNDquando unadIdTelegram non è un annuncio della chiave.