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 recovers the verified acquisition for the exact
telegramUserId. A site-scoped key or explicit site preserves attribution across channels within that site. An account-scoped key resolves the acquisition site first; a supplied channel is kept as the business destination when it belongs to that site. Purchases, registrations, subscriptions, Contacts, Leads, and custom events all use this rule. Downstream business events do not choose a different acquisition site. - 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; missing attribution can be recovered from acquisition evidence that predates the original server receipt;
- 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}/profile
Save contact details for an exact Telegram user. This creates no conversion and sends no event. Subsequent events and pending retries can use the known contact fields on the same project; events already sent are not replayed.
{
siteId?: string,
websiteId?: string,
observedAt?: number, // Unix milliseconds when these contact fields were captured
pii: {
email?: string,
phone?: string,
firstName?: string,
lastName?: string
}
}Site-scoped keys target their own project. Account-scoped keys require an owned siteId/websiteId or unambiguous acquisition evidence. Send observedAt when retrying saved contact updates so an older update cannot replace a newer field. Omitted fields keep their known values. Emails retain dots and aliases; international phone numbers include the country code. An unusable local phone is omitted from matching without discarding a usable email.
Unusable emails and local phone numbers are omitted independently, so a valid contact field is still saved. A profile with no usable email, phone or name returns 400 INVALID_PAYLOAD. Temporary storage failures return 500 INTERNAL_ERROR; retry the profile with the same Idempotency-Key and original observedAt. Successful profile responses remain cached for idempotent replay.
Response: { "success": true }.
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
List the ads of the key’s projects, one page at a time. Site-scoped keys see their project’s ads; account-scoped keys see every project’s ads, or one project’s with ?siteId=... / ?websiteId=....
network | Ads listed |
|---|---|
telegram_ads | The project’s Telegram ads, archived ones included, oldest first. |
meta | The ads synced by the account’s Meta Ads connection: ads with spend in the synced period, and ads seen in tracked traffic. They belong to a Meta ad account, not to a project, so they are listed only for an account-scoped key without a project filter, and only while Meta Ads is connected. |
tiktok, snapchat | None: AdTarget has no TikTok or Snapchat ad account connection. Their ads appear only in GET /ads/people. |
Query parameters:
| Parameter | Description |
|---|---|
network | Optional. telegram_ads, meta, tiktok or snapchat. Every network when omitted: Telegram ads first, then Meta ads. |
siteId / websiteId | Optional. One project’s ads. |
limit | Optional. Page size, 1 to 200 (default 100). |
cursor | Optional. The previous page’s nextCursor, with the same filters. |
Response:
{
ads: [{
network: "telegram_ads" | "meta" | "tiktok" | "snapchat",
id: string, // stable: renaming the ad keeps it (the Meta ad ID for Meta)
name: string, // current name
siteId: string | null, // the ad's project; null for Meta (an ad account's ad)
websiteId: string | null,
projectName: string | null,
campaignId: string | null, // Meta: the ad's campaign, ad set and ad account
adsetId: string | null,
accountId: string | null,
status: string | null, // Meta: the delivery status at the last sync
code: string | null, // Telegram ads: "ADT-7KQ4M", the code in the ad's first message
inviteLink: string | null, // Telegram ads: the ad's own channel invite link
createdAt: number | null, // Telegram ads: Unix ms
archivedAt: number | null // Telegram ads: archived ads still record people
}],
nextCursor: string | null // null on the last page
}Deleting a project removes its Telegram ads and their people.
GET /api/v1/ads/people
List the people ads brought into the key’s projects, one page at a time. Each row says which ad, on which network, brought one Telegram user into one project, and whether that ad gets the credit. Site-scoped keys see their project’s people.
network | A row is |
|---|---|
telegram_ads | A person recorded by a Telegram ad: a private message containing the ad’s code, or a join through the ad’s invite link. Once per account: the first ad recorded keeps the person. Ordered by arrival. |
meta, tiktok, snapchat | One channel join credited to that ad, as in the per-ad report, which counts joins: a person who joins several times has several rows. A join is credited to the ad identified by the tracked visit behind it (ad IDs in the UTM tags or link parameters), with the per-ad report’s rule and ad identity. Ordered by project, then join time. |
Without network, Telegram ad people come first, then the other networks’ people.
Query parameters:
| Parameter | Description |
|---|---|
network | Optional. telegram_ads, meta, tiktok or snapchat. Every network when omitted. |
siteId / websiteId | Optional. One project’s people. |
adId | Optional, requires network. One ad’s people: the id from GET /ads for Telegram ads, the ad ID from the visit’s link for other networks. |
telegramUserId | Optional. One person’s rows. |
from | Optional. Unix time in milliseconds: arrivals at or after it. |
to | Optional. Unix time in milliseconds: arrivals before it. |
limit | Optional. Page size, 1 to 200 (default 100). |
cursor | Optional. The previous page’s nextCursor. |
Response:
{
people: [{
network: "telegram_ads" | "meta" | "tiktok" | "snapchat",
joinId: string | null, // the channel join behind the row; null for Telegram ads
telegramUserId: number,
adId: string | null, // null when the link only identified the campaign
adName: string | null, // current name (see below)
campaignId: string | null, // null for Telegram ads
adsetId: string | null,
siteId: string, // the project
websiteId: string,
via: "code" | "link" | "visit" | null, // the ad's code in a message, its invite link, or a tracked visit
at: number, // arrival (ms): Telegram's date of the message or join, or the join time
prior: "new" | "known" | "paid_web" | null, // Telegram ads: what the account knew of the person before
attributed: boolean // false: an earlier paid click keeps the credit
}],
nextCursor: string | null // null on the last page
}- Pages. A page reads at most
limitrecords, so it can hold fewer rows, even none: keep requesting untilnextCursorisnull. A cursor belongs to its listing: with other filters or another scope (project, or another account), or when altered, the request returns400 INVALID_PAYLOAD. Cursors are not signed: another key of the same account and scope can resume one. - Credit. A Telegram ad person with
prior: "paid_web"had already come through a paid ad click (Meta, Google, TikTok or Snapchat) and hasattributed: false: they keep that attribution and the Telegram ad is credited with none of their events. When the visit behind that click identifies the ad, their join is listed under its network. A later real ad click keeps its own credit too. Meta, TikTok and Snapchat rows are alwaysattributed: true. - Ad identity. As in the per-ad report, an ad is its
adId. When the link only carried a name, TikTok and Snapchat IDs arename:followed by it, and such an ad is identified bynetwork,campaignId,adsetIdandadIdtogether: two “Video 1” ads of two campaigns are two ads. Without an ad ID, the ad is its campaign and ad set. WithadId=name:…, the filter compares that ID alone, so it can cover same-named ads of different campaigns: filter the rows bycampaignIdtoo. - Names. For Meta,
adNameis the name synced by Meta Ads when connected, else thead_namefrom the link, elsenull. For TikTok and Snapchat, the name from the link. - Rows per person. A person can have several rows: a Telegram ad row, one row per credited join on the other networks, rows for several ads or projects.
joinIdidentifies a join row; a Telegram ad row is identified bynetwork,siteIdandtelegramUserId. To count people per ad, group bynetwork,siteId,telegramUserIdand the ad identity above. - Older joins. Joins recorded only as events before March 2026 were converted to channel joins, and are listed like the others.
- Per-ad report. Credit follows the per-ad report’s rule. Its totals can differ when its daily aggregates are truncated.
- Names, usernames and contact details are never returned. Returns
404 AD_NOT_FOUNDwhen a TelegramadIdis not one of the key’s ads.