Skip to main content
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"
        }
      ]
    }
  }
}

Authorizations

Authorization
string
header
required

使用 Laravel Sanctum Token 進行認證。

Token 可在商家後台的「API 設定」頁面取得。

Body

application/json
customers
object[]
required
Required array length: 1 - 100 elements
on_conflict
enum<string>
default:skip

Email 衝突時的處理策略:

  • skip(預設):跳過已存在的 email
  • update:更新已存在客戶的資料
Available options:
skip,
update

Response

批次匯入結果

data
object