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
| Attribute | Data type | Remarks | Description |
|---|---|---|---|
| events | EventElem | Required | Details 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
| Attribute | Data type | Remarks | Description |
|---|---|---|---|
| version | string | Required | Currently 1.0.0, follows Semantic Versioning 2.0.0 |
| uuid | string | Required | Unique ID of each webhook event |
| event | string | Required | Event enumeration value 1: Subscribe, 2: Unsubscribe |
| msg | object | Required | Returned message, structure depends on the event value: 1-2: MsgSubscribe |
MsgSubscribe
This message structure corresponds to event=1 or event=2 in EventElem.
| Attribute | Data type | Remarks | Description |
|---|---|---|---|
| string | Required | ||
| old_subscribe | string | Required | Old subscription status 1: Subscribed, 0: Unsubscribed, -1: Non-subscribed |
| new_subscribe | string | Required | New subscription status 1: Subscribed, 0: Unsubscribed, -1: Non-subscribed |
| changed_time | bigint | Required | Timestamp of the change (in seconds) |
| changed_source | string | Required | Source 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.