API

API

Everything on https://go.affilayer.com. The tracking API is read access plus signed conversion intake — offers, users and payouts live in the dashboard, not in this API.

Endpoints

Method & pathWhat it does
GET /healthReturns {"ok":true}. Use it to check the tracking service is up.
GET /c/{affiliate_code}/{offer_id}Records a click and redirects (302) to the offer landing page with ?click_id= appended. Unknown offer → 404.
GET /s/{smartlink_code}Deterministic SmartLink pick and redirect (302). No eligible offer → 404.
POST /conversionSigned conversion intake (see below). New conversion → 201; duplicate → 200.
GET /api/statsServer-side aggregates over recorded events only.
GET /api/clicks/{click_id}The click and its conversion, if one exists. Unknown ID → 404.

POST /conversion

Conversions arrive server-to-server only, signed with HMAC-SHA256. Send a JSON body with the header:

x-affilayer-signature: <HMAC-SHA256 hex of the raw body>

The HMAC key is your postback secret. An optional sha256= prefix on the header is accepted. A bad signature returns 400 {"error":"bad signature"}. If the secret is not configured on the server, it returns 500.

Request body

FieldRequiredMeaning
click_idYesThe click ID the conversion is attributed to.
offer_idYesThe offer the conversion belongs to.
payoutYesNumber, 0 or more. The conversion payout amount.
currencyYesPayout currency, for example USD.
idempotency_keyYesYour unique key for this conversion. Sending it again returns the original instead of creating a duplicate.
statusNoOptional status hint.
sub1NoOptional sub-parameter.

Missing or invalid required fields return 400. Invalid JSON returns 400.

Responses and dedup

Example

curl -X POST https://go.affilayer.com/conversion \
  -H 'Content-Type: application/json' \
  -H "x-affilayer-signature: $(echo -n '{"click_id":"clk_01J…","offer_id":"offer-a","payout":12.5,"currency":"USD","idempotency_key":"conv-0001"}' | openssl dgst -sha256 -hmac 'YOUR_POSTBACK_SECRET' | cut -d' ' -f2)" \
  -d '{"click_id":"clk_01J…","offer_id":"offer-a","payout":12.5,"currency":"USD","idempotency_key":"conv-0001"}'

Keep your secret secret. The postback secret signs conversions and postbacks. Do not put it in client-side code, public repositories or shared documents.