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
| Method | Path | Key scope |
|---|---|---|
| POST | /api/v1/track/lead | conversions:write |
| POST | /api/v1/track/sale | conversions: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
- You send an SMS with a SLNK short link to
https://bank.example/open-account. - On click, SLNK redirects to
https://bank.example/open-account?slnk_id=LINK_ID&slnk_cid=CLICK_ID.slnk_cidis 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. - 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. - When the account is opened, your back office calls
POST /api/v1/track/leadwith the click id. When the customer pays, it callsPOST /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"}'
| Field | Required | Description |
|---|---|---|
clickId | yes, unless customerExternalId is sent | Value of slnk_cid (UUID) |
eventName | yes | Lower case, digits, ., -, _; 100 characters at most |
customerExternalId | no | Your customer identifier (1 to 255 characters, trimmed). Creates or reuses the customer; stored hashed and masked, never in clear |
customerEmail | no | Valid e-mail, used with customerExternalId. Stored hashed and masked only; never logged or sent in webhooks |
metadata | no | JSON 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 |
occurredAt | no | ISO 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"}'
| Field | Required | Description |
|---|---|---|
clickId | yes, unless customerExternalId is sent | Value of slnk_cid (UUID) |
amount | yes | 0 or more, 2 decimals |
currency | no | MAD, EUR or USD; defaults to the project currency |
orderId or invoiceId | no | Your reference, 255 characters at most. Never both |
eventName | no | Defaults to purchase |
customerExternalId, customerEmail, metadata, occurredAt | no | As 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
| Status | Code | Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid field, metadata over 1,024 bytes, occurredAt out of range |
| 400 | TRACK_SUBJECT_REQUIRED | Neither clickId nor customerExternalId was sent |
| 400 | CUSTOMER_EXTERNAL_ID_INVALID | customerExternalId is blank once trimmed, or longer than 255 characters |
| 400 | TRACK_ORDER_OR_INVOICE | Both orderId and invoiceId were sent |
| 400 | UNSUPPORTED_CURRENCY | Currency other than MAD, EUR or USD |
| 403 | PERMISSION_DENIED | COLLECT key, or SERVER key without conversions:write |
| 403 | FEATURE_NOT_AVAILABLE | Multi-touch attribution is not in your plan |
| 404 | CLICK_NOT_FOUND | Unknown click, click of another project, or click not processed yet |
| 422 | CLICK_EXPIRED | Click older than 90 days |
| 429 | RATE_LIMIT_EXCEEDED, QUOTA_EXCEEDED | 1,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.