1. Data payload
{
"data": {
"date": "2022-11-24T11:12:20+07:00",
"sku": "7445601428884",
"warehouse": "sgn3",
"qty_salable": 147,
"seller_product_code": "9772945762401",
"partner_id": "4312132323"
}
}
Description
- date: time push data
- sku: Tiki’s sku
- warehouse: Tiki’s warehouse code
- qty_salable: quantity
- seller_product_code: seller product code
- partner_id: seller id or seller code when register webhook
2. Authentication signature
Using HMAC-SHA1 signature. TikiNOW provided webhook secret for client and formula generate HMAC-SHA1 signature. Using this signature to compare with signature on header request (key on header: x-signature).
Example Golang code
func GenerateSignature(secretToken, payloadBody string) string {
mac := hmac.New(sha1.New, []byte(secretToken))
mac.Write([]byte(payloadBody))
expectedMAC := mac.Sum(nil)
return "sha1=" + hex.EncodeToString(expectedMAC)
}
Return HTTP status 2xx when received successfully and 5xx when failed
Example
curl --location 'https://your-domain/stock/webhooks' \
--header 'Content-Type: application/json' \
--header 'x-signature: sha1=d929b12836ce52528db1bc25797186c86b13b4ee' \
--data '{"data":{"date":"2023-05-15T15:36:37+07:00","sku":"1377286379376","warehouse":"sgn","qty_salable":60,"seller_product_code":"HOB-8735","partner_id": "4312132323"}}'
Data response
HTTP Status Code | Description | Response |
2xx | Success | { “success”: true } |
4xx | Error | { “success”: false “error”: { “code”: “CLIENT_NOT_EXIST”, “message”: “Client doesn’t exist”, }, } |
5xx | Server error | { “success”: false “error”: { “code”: “BAD_GATEWAY”, “message”: “Bad gateway”, }, } |