# curl

すべて Base URL `https://api.lmile.io`、`x-ingest-secret` ヘッダー認証、`shop` はボディ指定です。

## 商品登録

```bash
curl -X POST https://api.lmile.io/api/ingest/products \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "source_system": "manual_api",
    "products": [
      { "barcode": "1234567890123", "product_name": "スマートフォンケース", "sku": "DEMO-CASE-001", "brand": "Demo Brand", "category_l1": "ケース", "current_price": 9800, "current_cost": 3500 },
      { "barcode": "1234567890456", "product_name": "レザーケーブルホルダー", "sku": "DEMO-HOLDER-001", "brand": "Demo Brand", "category_l1": "アクセサリー", "current_price": 2980 }
    ]
  }'
```

## 在庫スナップショット（絶対値）

```bash
curl -X POST https://api.lmile.io/api/ingest/inventory-snapshot \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "source_system": "smaregi",
    "location": { "identifier_type": "smaregi_store_id", "identifier_value": "4" },
    "lines": [
      { "barcode": "1234567890123", "on_hand_qty": 10, "available_qty": 10 }
    ]
  }'
```

## 販売可能在庫の更新（absolute）

```bash
curl -X POST https://api.lmile.io/api/ingest/inventory-available \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "source_system": "shopify",
    "mode": "absolute",
    "location_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "lines": [ { "barcode": "1234567890123", "available_qty": 8 } ]
  }'
```

## 販売可能在庫の更新（delta）

```bash
curl -X POST https://api.lmile.io/api/ingest/inventory-available \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "source_system": "pos",
    "mode": "delta",
    "idempotency_key": "sale-0001",
    "location_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "lines": [
      { "barcode": "1234567890123", "available_delta": -2 }
    ]
  }'
```

## 受注明細（per-unit）

```bash
curl -X POST https://api.lmile.io/api/order-line-master/bulk-upsert \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "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",
        "gross_amount_taxincl": 9800, "discount_amount_taxincl": 0, "net_amount_taxincl": 9800,
        "net_amount_taxexcl": 8909, "tax_amount": 891, "tax_rate": 0.10, "refund_amount": 0
      }
    ]
  }'
```

## 受注ルーティング（出荷元判定 → 出荷指示）

入力フィールドは camelCase（`sourceSystem` / `externalOrderRef` / `shipTo` / `idempotencyKey`）です。

```bash
curl -X POST https://api.lmile.io/api/routing/orders \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "sourceSystem": "shopify",
    "externalOrderRef": "1001",
    "fulfillmentSourceLocationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "channel": "online_store",
    "idempotencyKey": "shopify:1001",
    "shipTo": { "country": "JP", "prefecture": "東京都", "city": "渋谷区", "postalCode": "150-0001" },
    "lines": [
      { "barcode": "1234567890123", "quantity": 2 },
      { "barcode": "1234567890456", "quantity": 1 }
    ]
  }'
```

## 売越しフラグ + 再引き当て

```bash
# 売越しフラグを立てる
curl -X POST https://api.lmile.io/api/routing/oversell \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "routingOrderId": "0f1e2d3c-4b5a-6789-0abc-def123456789",
    "barcode": "1234567890123",
    "reason": "店舗で実物欠品"
  }'

# 同一出荷元の別メンバーへ再引き当て
curl -X POST https://api.lmile.io/api/routing/reallocate \
  -H "x-ingest-secret: $INGEST_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "shop": "demo-store.myshopify.com",
    "routingOrderId": "0f1e2d3c-4b5a-6789-0abc-def123456789"
  }'
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lmile.gitbook.io/lmile-docs/examples/curl.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
