For the complete documentation index, see llms.txt. This page is also available as Markdown.

Order Line Master — 受注

受注明細を Last Mile の受注マスターに取り込みます。1 行 = 1 販売単位(数量の概念を持ちません。5 個販売は 5 行 = line_instance_no 1〜5)。商品は barcode、販売チャネル・拠点は ID で結合します。

Base URL https://api.lmile.io · 認証 x-ingest-secret ヘッダー(詳細) · shop はリクエストボディに含めます(省略するとキーのアカウント)

エンドポイント

Method
Path
用途

POST

/api/order-line-master/bulk-upsert

受注明細の一括登録・更新(1 行 = 1 販売単位)


POST /api/order-line-master/bulk-upsert

受注明細を 1 販売単位 = 1 行で一括登録・更新します。同じ明細(下記の一意キーが同じ行)の再送は上書きになるため、安全に再送できます。変更はすべて変更ログに記録されます。

リクエスト

POST https://api.lmile.io/api/order-line-master/bulk-upsert
x-ingest-secret: {INGEST_SECRET}
Content-Type: application/json
{
  "shop": "demo-store.myshopify.com",
  "dry_run": false,
  "change_source": "shopify_sync",
  "ingest_run_id": "run-2026-06-02-001",
  "idempotency_key": "shopify-2026-06-02-001",
  "rows": [
    {
      "source_system": "shopify",
      "transaction_id": "4567890123",
      "transaction_line_id": "1",
      "line_instance_no": 1,
      "barcode": "1234567890123",
      "ordered_at": "2026-06-02T12:34:56+09:00",
      "currency": "JPY",
      "is_test": false,
      "channel_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
      "location_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "customer_id": "3097658523781",
      "gross_amount_taxincl": 9800,
      "discount_amount_taxincl": 800,
      "net_amount_taxincl": 9000,
      "net_amount_taxexcl": 8182,
      "tax_amount": 818,
      "tax_rate": 0.10,
      "refund_amount": 0,
      "refunded_at": null,
      "refund_reason": null
    }
  ]
}

ボディパラメータ

パラメータ
型
必須
説明

shop

string

店舗ドメイン(省略するとキーのアカウント)

rows

array

✓

受注明細行の配列(最大 5,000 行/バッチ)

dry_run

boolean

true で検証のみ(書込なし)

change_source

string

変更ログの出所(default: external_app)

ingest_run_id

string

取込ラン ID(ログに記録)

idempotency_key

string

監査用キー(ログに記録)

changed_by_user_id

string (uuid)

変更実行ユーザー

rows[] オブジェクト(1 行 = 1 販売単位)

パラメータ
型
必須
説明

source_system

string

✓

取込元(shopify / smaregi 等)

transaction_id

string

✓

取引(注文)ID

transaction_line_id

string

✓

取引明細 ID

line_instance_no

integer (≥1)

✓

明細内の販売単位連番(数量展開。3 個なら 1,2,3)

barcode

string

✓

商品 barcode

ordered_at

ISO 8601

✓

注文日時

currency

string

✓

通貨コード

is_test

boolean

✓

テスト注文フラグ

channel_id

string (uuid)

✓

Last Mile が発行する販売チャネル ID

location_id

string (uuid)

✓

Last Mile が発行する拠点 ID

customer_id

string

顧客識別子(外部 ID、null 可)

gross_amount_taxincl

number

✓

税込総額(割引前)

discount_amount_taxincl

number

✓

税込割引額

net_amount_taxincl

number

✓

税込正味額

net_amount_taxexcl

number

✓

税抜正味額

tax_amount

number

✓

税額

tax_rate

number

✓

税率(0〜1。10% は 0.10)

refund_amount

number

✓

返金額(≥0)

refunded_at

ISO 8601

返金日時(null 可)

refund_reason

string

返金理由(null 可)

バリデーション

  • 金額整合(許容誤差 0.01): gross_amount_taxincl − discount_amount_taxincl ≈ net_amount_taxincl、net_amount_taxincl − tax_amount ≈ net_amount_taxexcl

  • tax_rate は [0, 1]、refund_amount は ≥ 0

  • channel_id / location_id が当該 shop に存在しない行は reject(errors[])

  • barcode が商品マスター未登録でも 投入(warnings[]。agent_read 上で商品名/SKU が NULL になるだけ)

レスポンス

フィールド
説明

accepted_rows

upsert 対象として受理した行数

inserted_rows / updated_rows

新規 / 更新の件数

rejected_rows

バリデーションで除外した行数(errors[])

warnings_count / warnings[]

投入したが要注意の行(商品マスター未登録 等)

errors[]

row_index / field / code / message

挙動・冪等性

  • 明細は (shop, source_system, transaction_id, transaction_line_id, line_instance_no) の組で 1 行に定まります。同じ組の再送は上書きされるだけなので安全です(差分があれば更新、無ければ何も変わりません)。

  • 変更ログ: 登録(insert)/ 更新(update)/ 返金(refund)が、変更したフィールド名と変更前後の値つきで記録されます。

  • per-unit: 数量列は持ちません。数量 N の明細は line_instance_no 1〜N の N 行で表現します。

  • 税・返金は受信時に order_line_master の列として反映されます(別途の refund allocation pipeline は持ちません)。


エラー

行単位の不備は 200 のレスポンス内 errors[](reject)/ warnings[] として返り、正常行の投入は継続します(silent skip しません)。バッチ上限超過は 400。共通エラー(401 / 400 / 403 / 405 / 500 / 503)は Error Codes を参照。

データモデル

  • order_line_master — 受注明細 SoT(1 行 = 1 販売単位)

  • order_line_master_update_logs — 変更監査ログ(insert / update / refund)

  • read は agent_read.order_line_master(safe view)経由

Last updated

Was this helpful?