ขายสินค้า (Store)
Store & discounts
หน้าร้าน public + โค้ดส่วนลด (percent/fixed) สำหรับแคมเปญ
เชื่อมต่อ
key ถูกเก็บใน httpOnly cookie ฝั่ง server — JavaScript ในเบราว์เซอร์อ่านไม่ได้ · สร้าง test key ที่ Dashboard → API keys
ลองยิง — กด Run ยิงจริง (test mode)
Discount codes
เขียนสร้างโค้ดลด % แล้วปิดโค้ด — ใช้ทำแคมเปญการตลาด
Read public storefront
อ่านอ่านหน้าร้าน public ตาม slug (ทำ embed/marketplace ได้ ไม่ต้องใช้ key)
โค้ด & API
สร้างโค้ดลด % หรือจำนวนบาท จำกัดจำนวนครั้ง/ช่วงเวลาได้ · โค้ดเป็นตัวอักษร+ตัวเลขล้วน
Headers
AuthorizationRequiredstring
Bearer sk_test_/sk_live_
Body
kindRequiredstring
percent | fixed
valueRequiredinteger
percent = เปอร์เซ็นต์, fixed = satang
codestring
กำหนดเอง (ไม่ใส่ = สุ่มให้)
max_usesinteger
จำกัดจำนวนครั้ง
curl -X POST https://api.heysub.co/v1/discount_codes \
-H "Authorization: Bearer sk_test_xxx" \
-H "Heysub-Version: 2026-09-01" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"code":"SAVE20","kind":"percent","value":20,"all_products":true,"max_uses":100}'{
"id": "dc_01J9X",
"code": "SAVE20",
"kind": "percent",
"value": 20,
"active": true
}