Skip to main content
POST
/
orders
/
batch
批次匯入訂單
curl --request POST \
  --url https://api.zangsho.com/v1/orders/batch \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "orders": [
    {
      "order_no": "ORD-001",
      "amount": "990.00",
      "status": "paid",
      "customer_email": "user1@example.com",
      "currency": "TWD",
      "payment_method": "credit_card",
      "billing_cycle": "monthly",
      "paid_at": "2026-01-01T00:00:00Z"
    },
    {
      "order_no": "ORD-002",
      "amount": "1990.00",
      "status": "paid",
      "customer_email": "user2@example.com",
      "currency": "TWD",
      "payment_method": "atm",
      "billing_cycle": "yearly",
      "paid_at": "2026-01-05T10:30:00Z"
    },
    {
      "order_no": "ORD-003",
      "amount": "599.00",
      "status": "paid",
      "customer_email": "user3@example.com",
      "currency": "TWD",
      "payment_method": "line_pay",
      "billing_cycle": "monthly",
      "paid_at": "2026-01-10T08:00:00Z"
    },
    {
      "order_no": "ORD-004",
      "amount": "3500.00",
      "status": "paid",
      "customer_email": "user4@example.com",
      "currency": "TWD",
      "payment_method": "cvs",
      "billing_cycle": "one-time",
      "paid_at": "2026-01-12T16:45:00Z"
    }
  ]
}
'
{
  "data": {
    "total": 123,
    "created": 123,
    "updated": 123,
    "skipped": 123,
    "failed": 123,
    "results": {
      "created": [
        {
          "index": 123,
          "id": 123,
          "identifier": "<string>"
        }
      ],
      "updated": [
        {
          "index": 123,
          "id": 123,
          "identifier": "<string>"
        }
      ],
      "skipped": [
        {
          "index": 123,
          "reason": "duplicate_email",
          "identifier": "<string>"
        }
      ],
      "failed": [
        {
          "index": 123,
          "reason": "validation_error",
          "message": "<string>",
          "identifier": "<string>"
        }
      ]
    }
  }
}

Authorizations

Authorization
string
header
required

使用 Laravel Sanctum Token 進行認證。

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

Body

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

order_no 衝突時的處理策略:

  • skip:跳過已存在的訂單
  • update(預設):更新非空欄位(冪等處理)
Available options:
skip,
update

Response

批次匯入結果

data
object