curl --request POST \
--url https://api.zangsho.com/v1/customers/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customers": [
{
"email": "user1@example.com",
"name": "User 1"
},
{
"email": "user2@example.com",
"name": "User 2"
}
]
}
'{
"data": {
"total": 50,
"created": 45,
"updated": 0,
"skipped": 3,
"failed": 2,
"results": {
"created": [
{
"index": 0,
"id": 123,
"identifier": "user1@example.com"
}
],
"skipped": [
{
"index": 5,
"reason": "duplicate_email",
"identifier": "existing@example.com"
}
],
"failed": [
{
"index": 10,
"reason": "validation_error",
"message": "Invalid email format",
"identifier": "invalid-email"
}
]
}
}
}{
"message": "Unauthenticated."
}{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required.",
"The email must be a valid email address."
]
}
}客戶 Customers
批次匯入客戶
批次建立多位客戶,適合匯入歷史資料。
限制
- 每次請求最多 100 筆
- 採用部分成功策略,不會全部回滾
衝突處理 (on_conflict)
skip(預設):跳過已存在的 emailupdate:更新已存在客戶的資料
POST
/
customers
/
batch
curl --request POST \
--url https://api.zangsho.com/v1/customers/batch \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"customers": [
{
"email": "user1@example.com",
"name": "User 1"
},
{
"email": "user2@example.com",
"name": "User 2"
}
]
}
'{
"data": {
"total": 50,
"created": 45,
"updated": 0,
"skipped": 3,
"failed": 2,
"results": {
"created": [
{
"index": 0,
"id": 123,
"identifier": "user1@example.com"
}
],
"skipped": [
{
"index": 5,
"reason": "duplicate_email",
"identifier": "existing@example.com"
}
],
"failed": [
{
"index": 10,
"reason": "validation_error",
"message": "Invalid email format",
"identifier": "invalid-email"
}
]
}
}
}{
"message": "Unauthenticated."
}{
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required.",
"The email must be a valid email address."
]
}
}Authorizations
使用 Laravel Sanctum Token 進行認證。
Token 可在商家後台的「API 設定」頁面取得。
Body
application/json
Response
批次匯入結果
Show child attributes
Show child attributes