<%= it.Breadcrumb(it.title, [ { label: "Home", href: "/" }, { label: "Import Data", href: "/import-data/lead" }, { label: "Customer", href: "/import-data/customer" }, { label: "คู่มือ API", current: true }, ]) %>

คู่มือ API นำเข้า Customer

นำเข้าข้อมูลลูกค้า (B2B/B2C) ได้ 2 วิธี: อัปโหลดไฟล์ (CSV/XLSX) และ ส่งผ่าน API (JSON) — รองรับ type: individual (ชื่อคน) และ company (ชื่อบริษัท)

1. นำเข้าด้วยไฟล์ (CSV / XLSX)

POST /api/v1/customers/import/file — Content-Type: multipart/form-data, Authorization: Bearer <JWT>

Form fields: file (ไฟล์), property_id

2. โครงสร้างไฟล์ CSV/XLSX

แถวแรก = Header. คอลัมน์: name (ชื่อคนหรือชื่อบริษัท), type (individual | company), email, phone, company, title, notes. แต่ละแถวต้องมี name หรือ email อย่างน้อย 1 ฟิลด์. ไม่ระบุ type = individual

3. นำเข้าด้วย API (JSON)

POST /api/v1/customers/import — Content-Type: application/json

{
  "property_id": "prop-001",
  "customers": [
    { "name": "สมชาย ใจดี", "type": "individual", "email": "somchai@example.com", "phone": "0812345678", "company": "บริษัท ABC", "title": "ผู้จัดการ", "notes": "ลูกค้า B2C" },
    { "name": "บริษัท ดีไซน์โปร จำกัด", "type": "company", "email": "contact@designpro.co.th", "phone": "022345678", "notes": "ลูกค้า B2B" }
  ]
}
4. ดาวน์โหลดไฟล์ตัวอย่าง

GET /api/v1/customers/import/example/csvGET /api/v1/customers/import/example/xlsx (ต้องส่ง Authorization)

← กลับไปหน้านำเข้า Customer