Skip to main content

Conversions API

Declare leads (account opening, sign-up) and sales from your back office, without cookie and without SDK. Each conversion is tied to the click of the SLNK short link that brought the visitor and, optionally, to your customer, enters the multi-touch attribution and emits the conversion.created webhook.

Operations​

MethodPathKey scope
POST/api/v1/track/leadconversions:write
POST/api/v1/track/saleconversions:write

Use a SERVER key with the conversions:write scope (Settings > API keys). COLLECT keys are refused (403). The operations require the multi-touch attribution feature of your plan. Limit: 1,000 calls per minute and key; each call counts in the daily API quota.

How it works: SMS to account opening​

  1. You send an SMS with a SLNK short link to https://bank.example/open-account.
  2. On click, SLNK redirects to https://bank.example/open-account?slnk_id=LINK_ID&slnk_cid=CLICK_ID. slnk_cid is the click id: a UUID, unique per click. It is only added to web pages (never to app store pages), and never overwrites a parameter already present in your destination.
  3. Your landing page keeps the click id with the application: read it server-side from the query string, or with the web SDK (slnka.getClickId()) into a hidden form field.
  4. When the account is opened, your back office calls POST /api/v1/track/lead with the click id. When the customer pays, it calls POST /api/v1/track/sale.

slnk_id is still added for the web SDK; accept both parameters if you parse your URLs.

Declare a lead​

curl -X POST https://api.slnk.ma/api/v1/track/lead \
-H "Authorization: Bearer $SLNK_SERVER_KEY" \
-H "Content-Type: application/json" \
-d '{"clickId":"CLICK_ID","eventName":"account_opened"}'
FieldRequiredDescription
clickIdyes, unless customerExternalId is sentValue of slnk_cid (UUID)
eventNameyesLower case, digits, ., -, _; 100 characters at most
customerExternalIdnoYour customer identifier (1 to 255 characters, trimmed). Creates or reuses the customer; stored hashed and masked, never in clear
customerEmailnoValid e-mail, used with customerExternalId. Stored hashed and masked only; never logged or sent in webhooks
metadatanoJSON object of 1,024 bytes at most, relayed in the conversion.created webhook. It is not stored with the conversion; it stays only as long as delivery needs it (7 days in the outbox, 30 days in the webhook log for replay). Never put personal data in it
occurredAtnoISO 8601, defaults to now; at most 5 minutes ahead and 90 days back
{
"conversionId": "CONVERSION_ID",
"kind": "LEAD",
"eventName": "account_opened",
"duplicate": false,
"click": { "id": "CLICK_ID", "linkId": "LINK_ID", "shortCode": "Ab3dE9x" },
"customer": { "id": "CUSTOMER_ID", "externalId": "CLI-000123", "externalIdMasked": "....0123" },
"warnings": []
}

customer is null without customerExternalId; externalId echoes your request, externalIdMasked is the only form SLNK stores besides the hash.

One lead per customer and event (per click and event when no customer is sent): the same call replayed answers 200 with duplicate: true and writes nothing. A first call answers 201.

Conversions of a known customer​

Send customerExternalId to tie every lead and sale of a customer together. The first click declared for a customer stays its origin: a later click never replaces it. Without clickId, the conversion is tied to the customer's first click while that click is less than 90 days old, so a sale declared months after the account opening only needs your customer identifier:

curl -X POST https://api.slnk.ma/api/v1/track/sale \
-H "Authorization: Bearer $SLNK_SERVER_KEY" \
-H "Content-Type: application/json" \
-d '{"customerExternalId":"CLI-000123","amount":900,"orderId":"CMD-042"}'

The customer's totals (leads, sales, revenue) are updated in the same transaction; see the Customers API.

Declare a sale​

curl -X POST https://api.slnk.ma/api/v1/track/sale \
-H "Authorization: Bearer $SLNK_SERVER_KEY" \
-H "Content-Type: application/json" \
-d '{"clickId":"CLICK_ID","amount":350,"orderId":"CMD-001"}'
FieldRequiredDescription
clickIdyes, unless customerExternalId is sentValue of slnk_cid (UUID)
amountyes0 or more, 2 decimals
currencynoMAD, EUR or USD; defaults to the project currency
orderId or invoiceIdnoYour reference, 255 characters at most. Never both
eventNamenoDefaults to purchase
customerExternalId, customerEmail, metadata, occurredAtnoAs for a lead
{
"conversionId": "CONVERSION_ID",
"kind": "SALE",
"eventName": "purchase",
"duplicate": false,
"amount": 350.00,
"currency": "MAD",
"orderId": "CMD-001",
"click": { "id": "CLICK_ID", "linkId": "LINK_ID", "shortCode": "Ab3dE9x" },
"customer": null,
"warnings": []
}

A sale is idempotent per reference: the same orderId sent again answers 200 with duplicate: true. orderId and invoiceId share one namespace per project: an invoice reference equal to an order reference is a duplicate. A sale without reference is always recorded. A sale declared earlier by the web SDK with the same orderId is replaced by the server sale.

Attribution​

The conversion is allocated across the 30-day journey before it, for the five attribution models (first touch, last touch, linear, time decay, position based). The click declared in clickId is part of that journey: with a single click, every model credits its link. The leads, sales and revenue credited to each link are read with the link analytics.

Errors​

StatusCodeMeaning
400VALIDATION_ERRORInvalid field, metadata over 1,024 bytes, occurredAt out of range
400TRACK_SUBJECT_REQUIREDNeither clickId nor customerExternalId was sent
400CUSTOMER_EXTERNAL_ID_INVALIDcustomerExternalId is blank once trimmed, or longer than 255 characters
400TRACK_ORDER_OR_INVOICEBoth orderId and invoiceId were sent
400UNSUPPORTED_CURRENCYCurrency other than MAD, EUR or USD
403PERMISSION_DENIEDCOLLECT key, or SERVER key without conversions:write
403FEATURE_NOT_AVAILABLEMulti-touch attribution is not in your plan
404CLICK_NOT_FOUNDUnknown click, click of another project, or click not processed yet
422CLICK_EXPIREDClick older than 90 days
429RATE_LIMIT_EXCEEDED, QUOTA_EXCEEDED1,000 calls per minute and key exceeded (wait details.retryAfterSeconds), or daily API quota reached (Retry-After header)

A click is usually available within a second of the redirect. On 404 CLICK_NOT_FOUND right after the click, retry a few seconds later. A click id lives at most 90 days and never longer than the analytics retention of your plan.