> For the complete documentation index, see [llms.txt](https://lmile.gitbook.io/lmile-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lmile.gitbook.io/lmile-docs/getting-started/your-first-request.md).

# クイックスタート

商品を 1 件登録し、在庫を設定して、販売による在庫変動を送る手順です。

> **Base URL** `https://api.lmile.io` · **認証** `x-ingest-secret` ヘッダー · `shop` はボディに含めます（省略するとキーのアカウント）

## 1. 商品登録

```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",
    "products": [{
      "barcode": "1234567890123",
      "product_name": "スマートフォンケース",
      "sku": "DEMO-CASE-001",
      "brand": "Demo Brand",
      "category_l1": "ケース",
      "current_price": 9800
    }]
  }'
```

```json
{ "ok": true, "created": 1, "updated": 0, "unchanged": 0, "errors_count": 0, "errors": [] }
```

## 2. 在庫設定（スナップショット / 絶対値）

```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": "manual_api",
    "location_id": "YOUR_LOCATION_UUID",
    "lines": [
      { "barcode": "1234567890123", "on_hand_qty": 10, "available_qty": 10 }
    ]
  }'
```

```json
{ "ok": true, "lines_processed": 1, "lines_upserted": 1, "lines_unresolved": 0, "logs_written": 1, "unresolved": [] }
```

## 3. 販売による在庫変動（available / 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": "YOUR_LOCATION_UUID",
    "lines": [
      { "barcode": "1234567890123", "available_delta": -1 }
    ]
  }'
```

```json
{ "ok": true, "mode": "delta", "lines_updated": 1, "lines_clamped": 0, "lines_deduped": 0, "unresolved": [], "clamped": [] }
```

販売可能在庫が 10 → 9 に更新され、`inventory_update_logs` に `available_delta` イベントが記録されます。

## 次のステップ

* [Products API](/lmile-docs/ingestion-api/products.md) — 全フィールドの詳細
* [Inventory Levels API](/lmile-docs/ingestion-api/inventory-levels.md) — snapshot と available の詳細
* [Order Line Master API](/lmile-docs/ingestion-api/order-line-master.md) — 受注明細の取込
* [Routing API](/lmile-docs/routing-api/orders.md) — 受注ルーティング（出荷元判定 → 出荷指示）
* [Data Model](/lmile-docs/reference/data-model.md) — テーブル構造


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://lmile.gitbook.io/lmile-docs/getting-started/your-first-request.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
