1. Home
  2. Docs
  3. TikiNOW Smart Logistics
  4. API References
  5. Fulfillment Service Group
  6. Inventory Service
  7. Webhook Sync Stock

Webhook Sync Stock

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 CodeDescriptionResponse
2xxSuccess{
“success”: true
}
4xxError{
    “success”: false
    “error”: {
        “code”: “CLIENT_NOT_EXIST”,
        “message”: “Client doesn’t exist”,
    },
}
5xxServer error{
    “success”: false
    “error”: {
        “code”: “BAD_GATEWAY”,
        “message”: “Bad gateway”,
    },
}

Was this article helpful to you? Yes No 1

How can we help?

Leave a Reply

Your email address will not be published.