Skip to main content

Webhook

SmartLink sends JSON information through an HTTP request to a specified URL.

SmartLink signs all webhook deliveries by including the signature SL-Webhook-Signature in the header, allowing you to verify its legitimacy. This is not a required step, but is highly recommended.

The signature is generated by the below algorith:

SL-Webhook-Signature = md5 (path + "?" + params + body + webhook key)

  • path: Endpoint path excluding the domain.
  • params: Parameters from the endpoint URL, sorted in ascending ASCII order and concatenated using the "&" symbol, such as gameid=1&seq=abcdefg.
  • body: JSON string, may contain line breaks, such as {"data":{"msg":"abcd"}}.
  • webhook key: Webhook key obtained from SmartLink for the signing of webhook deliveries, see Configure Webhooks for more details.

Request parameters

AttributeData typeRemarksDescription
eventsEventElemRequiredDetails of each webhook event

Code sample

{
"events": [
{
"version": "1.0.0",
"uuid": "xxxxxxxx-xxxx",
"event": 1,
"msg": {
"email": "smartlink@xxx.com",
"old_subscribe": -1,
"new_subscribe": 1,
"changed_time": 12345678,
"changed_source": "API-LI-PASS"
}
}
]
}

EventElem

AttributeData typeRemarksDescription
versionstringRequiredCurrently 1.0.0, follows Semantic Versioning 2.0.0
uuidstringRequiredUnique ID of each webhook event
eventstringRequiredEvent enumeration value
1: Subscribe, 2: Unsubscribe
msgobjectRequiredReturned message, structure depends on the event value:
1-2: MsgSubscribe

MsgSubscribe

This message structure corresponds to event=1 or event=2 in EventElem.

AttributeData typeRemarksDescription
emailstringRequiredEmail
old_subscribestringRequiredOld subscription status
1: Subscribed, 0: Unsubscribed, -1: Non-subscribed
new_subscribestringRequiredNew subscription status
1: Subscribed, 0: Unsubscribed, -1: Non-subscribed
changed_timebigintRequiredTimestamp of the change (in seconds)
changed_sourcestringRequiredSource of the change, obtained from the source attribute in SmartLink

Response information

If the request is successful, return http status code 200 without the JSON to SmartLink.

If the request is unsuccessful, return http status code != 200 to SmartLink, and SmartLink will attempt to resend the webhook. A maximum of 20 times can be retried within 25 minutes, and will retrying after 20 times.