Skip to main content

Customers API

A customer is a person of your back office, known by your identifier (customerExternalId): a customer number, an account id. SLNK keeps one customer per identifier and project, with its origin click, its leads, its sales, its revenue and its lifetime value. Customers are created by /api/v1/track/lead and /track/sale when the call carries customerExternalId, or declared here.

What SLNK stores​

DataStored asNever stored
Your identifierHMAC-SHA256 hash keyed by the project secret, and a mask: four dots then the last four characters (....0123; the last character only for an identifier of four characters or less)The identifier in clear
E-mailSHA-256 of the trimmed lower-case address, and a mask (k****i@g****.com)The address in clear

Consequences:

  • The search by identifier is an exact match, case and inner spaces included (leading and trailing spaces are trimmed). A partial search is impossible.
  • The hash is the one of the web SDK identify(userId): when your site calls slnka.identify("CLI-000123"), the sessions and touchpoints of that visitor appear in the customer's timeline.
  • Rotating the project's token secret makes existing customers unreachable by identifier, like identified visitors. Their totals and timelines stay readable from the list.

Operations​

MethodPathAccess
GET/api/v1/customersanalytics:read key, or member with Attribution view
GET/api/v1/customers/{id}idem
GET/api/v1/customers/{id}/timelineidem
POST/api/v1/customersconversions:write key, or member with Attribution edit
PATCH/api/v1/customers/{id}idem
DELETE/api/v1/customers/{id}Console only (member with Attribution edit); API keys get 403

The operations require the multi-touch attribution feature of your plan. A member session sends the project in the X-Project-Id header; a key is bound to its project.

List customers​

curl "https://api.slnk.ma/api/v1/customers?sort=revenue&page=0&size=20" \
-H "Authorization: Bearer $SLNK_SERVER_KEY"
ParameterDefaultDescription
externalIdYour identifier, exact match: 0 or 1 customer
sortlastActivitylastActivity (latest confirmed conversion; customers without one last), revenue or createdAt, always descending
page0Page index
size201 to 100

The response is a page (content, totalElements, totalPages, number, size) of:

{
"id": "CUSTOMER_ID",
"externalIdMasked": "....0123",
"firstLinkId": "LINK_ID",
"firstShortCode": "Ab3dE9x",
"firstTouchAt": "2026-11-06T09:12:00Z",
"leadsCount": 1,
"salesCount": 2,
"revenue": 1250.00,
"currency": "MAD",
"lastActivityAt": "2026-11-20T15:03:00Z",
"createdAt": "2026-11-06T09:15:00Z"
}
  • leadsCount and salesCount count confirmed conversions; a cancelled sale is excluded.
  • revenue is the sum of the confirmed sales in the project currency. A sale in another currency is counted in salesCount but not in revenue.

Get a customer​

GET /api/v1/customers/{id} returns the list fields and:

FieldDescription
emailMaskedMasked e-mail, null when unknown
originFirst click: clickId, linkId, shortCode, channel and campaignId of its touchpoint, firstTouchAt. null when the customer was declared without click
ltvLifetime value: cumulative revenue to date (equals revenue)
averageOrderValuerevenue divided by the confirmed sales in the project currency, 0 without sale
otherCurrencySalesConfirmed sales in another currency, excluded from revenue
firstLeadAt, firstSaleAtFirst confirmed lead and sale
sessionsCount, lastSeenAtSessions and last visit of the visitors linked by identify; null without linked visitor

The response never contains the identifier nor the e-mail in clear.

Timeline​

GET /api/v1/customers/{id}/timeline?limit=20 returns the events of the customer, most recent first:

{
"items": [
{ "type": "sale", "occurredAt": "2026-11-20T15:03:00Z", "id": "CONVERSION_ID", "shortCode": "Ab3dE9x", "eventName": "purchase", "amount": 900.00, "currency": "MAD", "status": "CONFIRMED" },
{ "type": "lead", "occurredAt": "2026-11-06T09:15:00Z", "id": "CONVERSION_ID", "eventName": "account_opened", "status": "CONFIRMED" },
{ "type": "touchpoint", "occurredAt": "2026-11-06T09:12:00Z", "id": "TOUCHPOINT_ID", "linkId": "LINK_ID", "shortCode": "Ab3dE9x", "channel": "sms" },
{ "type": "click", "occurredAt": "2026-11-06T09:12:00Z", "id": "CLICK_ID", "linkId": "LINK_ID", "shortCode": "Ab3dE9x", "deviceType": "mobile", "city": "Casablanca" }
],
"nextCursor": "MjAyNi0xMS0wNlQwOToxMjowMFp8Y2xpY2t8Q0xJQ0tfSUQ"
}
TypeSource
clickFirst click of the customer
touchpointTouchpoints of the customer's clicks, and of the visitors linked by identify
lead, saleConfirmed conversions
cancelledCancelled sale

Pass nextCursor as cursor to read the next page; it is null on the last page. limit goes from 1 to 100 (default 20).

Declare a customer​

curl -X POST https://api.slnk.ma/api/v1/customers \
-H "Authorization: Bearer $SLNK_SERVER_KEY" \
-H "Content-Type: application/json" \
-d '{"externalId":"CLI-000123","email":"karim@example.ma"}'

Idempotent per identifier: 201 when the customer is created, 200 with the existing customer otherwise (its e-mail replaced when one is sent). Most integrations do not need this call: /track/lead and /track/sale create the customer.

Replace the e-mail​

PATCH /api/v1/customers/{id} with {"email":"new@example.ma"}. The e-mail is the only editable field; {"email":null} forgets it.

Erase a customer​

DELETE /api/v1/customers/{id}, from the console (customer page, Erase data), answers 204:

  1. its conversions are kept without customer (anonymized): amounts, click and attribution are unchanged, so your revenue reports stay exact;
  2. the visitors linked to its identifier by identify enter the CNDP erasure queue, which deletes their clicks, touchpoints, sessions and profiles;
  3. the customer is deleted.

The action is irreversible and recorded in the audit log (customer.erased). A visitor erasure requested by the SDK or the Privacy Requests page erases the customers linked to that visitor the same way.

Errors​

StatusCodeMeaning
400VALIDATION_ERRORInvalid sort, page, size, limit or e-mail
400CUSTOMER_EXTERNAL_ID_INVALIDIdentifier blank once trimmed, or longer than 255 characters
400CURSOR_INVALIDUnreadable timeline cursor: start again from the first page
403PERMISSION_DENIEDMissing scope or role, or erasure with an API key
403FEATURE_NOT_AVAILABLEMulti-touch attribution is not in your plan
404CUSTOMER_NOT_FOUNDUnknown customer in this project