เริ่มใช้งานGetting started
สร้าง API keyCreate an API key
เจ้าของร้านเปิด Dashboard › จัดการร้าน › API แล้วกด "สร้าง key" ตั้งชื่อตามระบบที่จะเชื่อม เช่น ระบบบัญชี key จะแสดงเต็มแค่ครั้งเดียว ให้คัดลอกเก็บไว้ทันทีThe shop owner opens Dashboard › Manage shop › API and creates a key named after the system it's for, such as Accounting. The full key is shown only once, so copy it right away.
ทดสอบด้วย /meTest with /me
เรียก
GET /meพร้อม key ใน header ถ้าได้ชื่อร้านกลับมา แปลว่าเชื่อมต่อสำเร็จCallGET /mewith the key in the header. If your shop's name comes back, you're connected.ซิงก์เฉพาะที่เปลี่ยนSync only what changed
ครั้งถัดไปส่ง
updated_sinceเป็นเวลาที่ซิงก์ครั้งก่อน จะได้เฉพาะรายการที่แก้หลังจากนั้นOn later runs, passupdated_sincewith your last sync time to get only records changed since then.
# API host ของคุณจะแจ้งพร้อมเปิดใช้ APIYour API host is provided when API access is enabled curl https://<api-host>/api/ext/v1/me \ -H "Authorization: Bearer chann_live_…"
ยืนยันตัวตนและข้อผิดพลาดAuthentication & errors
- ส่ง key ทุกครั้งใน header
Authorization: Bearer <key>key ขึ้นต้นด้วยchann_live_Send the key on every request asAuthorization: Bearer <key>. Keys start withchann_live_. - key หนึ่งตัวผูกกับร้านเดียว และเข้าถึงได้เฉพาะ 8 กลุ่มข้อมูลในหน้านี้ ไม่มีการจัดการสมาชิก บทบาท หรือการตั้งค่าร้านผ่าน APIEach key belongs to one shop and reaches only the 8 resource groups on this page. Members, roles and shop settings are not available through the API.
- เพิกถอน key ได้ทุกเมื่อจากหน้า API หรือพิมพ์ในแชท LINE ของร้าน การเรียกด้วย key ที่เพิกถอนแล้วจะได้ 401 ทันทีRevoke a key any time from the API page or in your shop's LINE chat. Calls with a revoked key get 401 immediately.
- ในประวัติการใช้งานของร้าน ผู้ทำรายการผ่าน API จะแสดงเป็น
api:<key id>จึงแยกได้ว่ารายการไหนมาจากระบบภายนอกIn the shop's activity history, API changes show the actor asapi:<key id>, so you can tell which records came from outside systems.
| HTTP | error.code | ความหมายMeaning |
|---|---|---|
| 401 | missing_or_malformed_key | ไม่ได้ส่ง header หรือรูปแบบไม่ถูกต้องThe header is missing or malformed |
| 401 | unknown_or_revoked_key | ไม่พบ key หรือ key ถูกเพิกถอนแล้วThe key doesn't exist or was revoked |
| 422 | — | ข้อมูลที่ส่งไม่ครบหรือไม่ถูกต้อง ข้อความจะบอกว่าขาดอะไร เช่น ออกใบแจ้งหนี้จากดีลที่ยังไม่มีสินค้าThe request data is missing or invalid; the message says what's missing, e.g. invoicing a deal with no line items |
| 429 | — | เกินโควตา 600 request ต่อนาที รอตามเวลาใน header Retry-After แล้วค่อยเรียกใหม่Over 600 requests per minute; wait for the Retry-After header before retrying |
# ทุกข้อผิดพลาดใช้รูปแบบเดียวกันEvery error has the same shape { "error": { "code": "unknown_or_revoked_key", "message": "…" } }
รายการและการซิงก์Lists & incremental sync
- ทุก endpoint แบบรายการรับ
limit(1–200 ค่าเริ่มต้น 50) และoffset(ค่าเริ่มต้น 0)Every list endpoint takeslimit(1–200, default 50) andoffset(default 0). - ผลลัพธ์มี
items,total,limit,offsetและ headerX-Total-CountResponses includeitems,total,limit,offsetand anX-Total-Countheader. updated_since(ISO-8601) ใช้ได้กับ customers, deals, invoices และ tickets คืนเฉพาะรายการที่แก้หลังเวลานั้นupdated_since(ISO-8601) works on customers, deals, invoices and tickets and returns only records changed after that time.- ลูกค้าที่ร้านรวมเข้ากับอีกรายแล้วจะไม่อยู่ในรายการ ส่วน
GET /customers/{id}ของรายนั้นยังตอบ 200 พร้อมmerged_into_idและmerged_into(id,customer_id,name) ใช้ย้ายข้อมูลฝั่งคุณไปหารายหลักA customer the shop has merged into another one is left out of lists.GET /customers/{id}for it still returns 200 withmerged_into_idandmerged_into(id,customer_id,name), so you can re-key your records to the surviving customer.
curl "https://<api-host>/api/ext/v1/customers?updated_since=2026-09-01T00:00:00%2B07:00&limit=100" \ -H "Authorization: Bearer chann_live_…" { "items": [ … ], "total": 128, "limit": 100, "offset": 0 }
ตัวอย่าง: ออกใบแจ้งหนี้และบันทึกรับชำระExample: issue an invoice and record payment
ออกใบแจ้งหนี้จากดีลที่มีสินค้าแล้ว ขอลิงก์ PDF แล้วบันทึกว่ารับชำระเต็มยอด ใบแจ้งหนี้จะเปลี่ยนเป็นชำระแล้ว และเห็นตรงกันใน DashboardInvoice a deal that has line items, get the PDF link, then record full payment. The invoice becomes paid and shows the same in the Dashboard.
# 1 · ออกใบแจ้งหนี้และ PDF ทันทีCreate the invoice and issue its PDF POST /api/ext/v1/invoices { "deal_id": "<deal id>", "issue": true } # 2 · ขอลิงก์ PDFGet the PDF link GET /api/ext/v1/invoices/<invoice id>/pdf # 3 · บันทึกรับชำระเต็มยอดRecord full payment POST /api/ext/v1/invoices/<invoice id>/payments { "full": true, "method": "transfer" }
Endpoints
path ทั้งหมดต่อท้าย /api/ext/v1 · สร้างใหม่ตอบ 201 · ข้อมูลไม่ถูกต้องตอบ 422All paths are relative to /api/ext/v1 · creates return 201 · invalid input returns 422
ร้านและ key นี้Your shop and key me
- GET
/meร้านและ key นี้Who am I
ลูกค้าCustomers customers
- GET
/customersรายชื่อลูกค้าList customersพารามิเตอร์Parameters
Query
q- string
stage- string
updated_since- ISO-8601 datetime
limit- integer 1–200 · default 50
offset- integer · default 0
- POST
/customersเพิ่มลูกค้าCreate a customerพารามิเตอร์Parameters
Body · JSON
first_nameจำเป็นrequired- string
last_name- string
phone- string
email- string
address- string
notes- string
stage- lead | contact · default contact
- GET
/customers/{customer_id}ลูกค้าหนึ่งรายOne customer - PATCH
/customers/{customer_id}แก้ไขลูกค้าUpdate a customerพารามิเตอร์Parameters
Body · JSON
first_name- string
last_name- string
phone- string
email- string
address- string
notes- string
ดีลDeals deals
- GET
/dealsรายการดีลList dealsพารามิเตอร์Parameters
Query
q- string
stage- string
updated_since- ISO-8601 datetime
limit- integer 1–200 · default 50
offset- integer · default 0
- POST
/dealsสร้างดีลCreate a dealพารามิเตอร์Parameters
Body · JSON
customer_idจำเป็นrequired- string
amount- number
currency- string
expected_close_date- date
notes- string
- GET
/deals/{deal_id}ดีลพร้อมรายการสินค้าOne deal with its lines - PATCH
/deals/{deal_id}แก้ไขดีลUpdate a dealพารามิเตอร์Parameters
Body · JSON
amount- number
currency- string
expected_close_date- date
notes- string
- POST
/deals/{deal_id}/stageย้ายสถานะดีลMove a deal's stageพารามิเตอร์Parameters
Body · JSON
stageจำเป็นrequired- new | proposed | won | lost
lost_reason- string
ใบเสนอราคาQuotes quotes
- GET
/quotesรายการใบเสนอราคาList quotesพารามิเตอร์Parameters
Query
deal_id- string
status- string
q- string
limit- integer 1–200 · default 50
offset- integer · default 0
- GET
/quotes/{quote_id}ใบเสนอราคาพร้อมรายการOne quote with its lines - GET
/quotes/{quote_id}/pdfลิงก์ PDF ใบเสนอราคาQuote PDF link
ใบแจ้งหนี้และรับชำระInvoices & payments invoices
- GET
/invoicesรายการใบแจ้งหนี้List invoicesพารามิเตอร์Parameters
Query
status- string
deal_id- string
quote_id- string
overdue- boolean · default false
updated_since- ISO-8601 datetime
limit- integer 1–200 · default 50
offset- integer · default 0
- POST
/invoicesออกใบแจ้งหนี้จากดีลหรือใบเสนอราคาCreate an invoice from a deal or quoteพารามิเตอร์Parameters
Body · JSON
deal_id- string
quote_id- string
note- string
issue- boolean · true = issue the PDF now (draft → issued)
- GET
/invoices/{invoice_id}ใบแจ้งหนี้พร้อมการชำระOne invoice with payments - POST
/invoices/{invoice_id}/paymentsบันทึกรับชำระRecord a paymentพารามิเตอร์Parameters
Body · JSON
amount- number
full- boolean · default false
method- cash | transfer | card | other
reference- string
note- string
paid_at- ISO-8601 datetime
- GET
/invoices/{invoice_id}/pdfลิงก์ PDF ใบแจ้งหนี้Invoice PDF link - GET
/invoices/{invoice_id}/receipt-pdfลิงก์ PDF ใบเสร็จReceipt PDF link
งานซ่อมService tickets tickets
- GET
/ticketsรายการงานซ่อมList ticketsพารามิเตอร์Parameters
Query
status- string
customer_id- string
q- string
updated_since- ISO-8601 datetime
limit- integer 1–200 · default 50
offset- integer · default 0
- POST
/ticketsแจ้งงานซ่อมLog a ticketพารามิเตอร์Parameters
Body · JSON
problemจำเป็นrequired- string
customer_id- string
address- string
appointment_at- ISO-8601 datetime
- GET
/tickets/{ticket_id}งานซ่อมหนึ่งรายการOne ticket
ทะเบียนสินค้าและประกันWarranties warranties
- GET
/warrantiesรายการประกันList warrantiesพารามิเตอร์Parameters
Query
q- string
status- string
limit- integer 1–200 · default 50
offset- integer · default 0
- POST
/warrantiesลงทะเบียนประกันRegister a warrantyพารามิเตอร์Parameters
Body · JSON
serial_numberจำเป็นrequired- string
product_id- string
customer_id- string
purchase_date- date
warranty_months- integer
- GET
/warranties/{warranty_id}ประกันหนึ่งรายการOne warranty
สินค้าProducts products
- GET
/productsรายการสินค้าList productsพารามิเตอร์Parameters
Query
q- string
category- string
include_archived- boolean · default false
limit- integer 1–200 · default 50
offset- integer · default 0
- POST
/productsเพิ่มสินค้าCreate a productพารามิเตอร์Parameters
Body · JSON
nameจำเป็นrequired- string
product_id- string
sku- string
category- string
unit_price- number
description- string
warranty_months- integer
- GET
/products/{product_id}สินค้าหนึ่งรายการOne product - PATCH
/products/{product_id}แก้ไขสินค้าUpdate a productพารามิเตอร์Parameters
Body · JSON
name- string
sku- string
category- string
unit_price- number
description- string
warranty_months- integer
อยากเชื่อมระบบของร้านกับ Chann1?Want to connect your systems to Chann1?
API เปิดใช้ในแพ็กเกจ Enterprise ขึ้นไป ทีมงานช่วยวางแผนการเชื่อมต่อให้ได้API access comes with Enterprise and above. Our team can help you plan the integration.