> 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/configuration/star-printer.md).

# Star Printer — ロケーション プリンター設定

在庫ロケーションに Star プリンターの device ID を紐付けます。ピッキングリスト等の物理印刷で、ロケーションから印刷先プリンターを解決するための設定マスターです。設定・解除・取得を API で行えます。

> **Base URL** `https://api.lmile.io` · **認証** `x-ingest-secret` ヘッダー（[詳細](/lmile-docs/getting-started/authentication.md)） · set/detach は `shop` をボディ、取得はクエリに含めます（省略するとキーのアカウント）

> マッピングのキーは `(shop, locationId)` = **1 ロケーションに紐づくプリンターは 1 台のみ**。既に device ID が設定済みのロケーションを set すると、新しい device ID に**差し替え**られます。

## エンドポイント

| Method | Path                               | 用途               |
| ------ | ---------------------------------- | ---------------- |
| `POST` | `/api/routing/star-printer`        | プリンター設定（upsert）  |
| `POST` | `/api/routing/star-printer/detach` | プリンター解除（物理削除）    |
| `GET`  | `/api/routing/star-printer`        | 設定状況の取得（ラベル付き一覧） |

***

## `POST` /api/routing/star-printer

ロケーション↔Star プリンター device ID のマッピングを upsert します。

### リクエスト

```http
POST https://api.lmile.io/api/routing/star-printer
x-ingest-secret: {INGEST_SECRET}
Content-Type: application/json
```

```json
{
  "shop": "demo-store.myshopify.com",
  "locationId": "11111111-1111-1111-1111-111111111111",
  "deviceId": "00:11:62:1a:2b:3c",
  "isActive": true
}
```

### ボディパラメータ

| パラメータ        | 型             |  必須 | 説明                                   |
| ------------ | ------------- | :-: | ------------------------------------ |
| `shop`       | string        |     | 店舗ドメイン（省略するとキーのアカウント）                |
| `locationId` | string (uuid) |  ✓  | 紐付ける在庫ロケーション（shop 内に実在すること）          |
| `deviceId`   | string        |  ✓  | Star プリンターの device ID（空文字不可）         |
| `isActive`   | boolean       |     | 有効フラグ（default `true`。`false` で論理無効化） |

### レスポンス

```json
{ "ok": true, "id": "...", "shop": "demo-store.myshopify.com",
  "locationId": "1111...", "deviceId": "00:11:62:1a:2b:3c", "isActive": true }
```

### 挙動

* **upsert キー**: `(shop, locationId)`。同じロケーションに別の `deviceId` を set すると **device ID が差し替わる**（1 ロケーション 1 プリンター）。
* `isActive: false` でマッピングを残したまま無効化。完全に消す場合は detach。

***

## `POST` /api/routing/star-printer/detach

マッピングを物理削除します（ロケーション基準）。

```http
POST https://api.lmile.io/api/routing/star-printer/detach
x-ingest-secret: {INGEST_SECRET}
Content-Type: application/json
```

```json
{ "shop": "demo-store.myshopify.com", "locationId": "11111111-1111-1111-1111-111111111111" }
```

| パラメータ        | 型             |  必須 | 説明                    |
| ------------ | ------------- | :-: | --------------------- |
| `shop`       | string        |     | 店舗ドメイン（省略するとキーのアカウント） |
| `locationId` | string (uuid) |  ✓  | 解除する在庫ロケーション          |

レスポンス: `{ "ok": true, "shop": "...", "locationId": "...", "deleted": 1 }`（`deleted` は削除件数。該当無しは `0`）。

***

## `GET` /api/routing/star-printer

shop（任意でロケーション）の設定状況をラベル付きで取得します。

```http
GET https://api.lmile.io/api/routing/star-printer?shop=demo-store.myshopify.com
x-ingest-secret: {INGEST_SECRET}
```

| クエリ          |  必須 | 説明                      |
| ------------ | :-: | ----------------------- |
| `shop`       |     | 店舗ドメイン（省略するとキーのアカウント）   |
| `locationId` |     | 指定するとそのロケーションの設定のみに絞り込み |

### レスポンス

```json
{
  "ok": true,
  "shop": "demo-store.myshopify.com",
  "count": 1,
  "printers": [
    { "id": "...", "locationId": "1111...", "locationLabel": "BONAVENTURA 日本橋三越本店",
      "deviceId": "00:11:62:1a:2b:3c", "isActive": true }
  ]
}
```

***

## エラー

エンドポイント固有:

| Status | 条件                                                        | レスポンス例                                                                                         |
| :----: | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|  `400` | 必須欠落 / `locationId` が非 UUID / `deviceId` 空 / `shop` クエリ無し | `{ "ok": false, "error": "deviceId required" }`                                                |
|  `422` | location が shop 内に存在しない                                   | `{ "ok": false, "error_kind": "location_unresolved", "error": "location not found for shop" }` |

共通エラー（`401` / `400` / `403` / `405` / `500` / `503`）は [Error Codes](/lmile-docs/reference/error-codes.md) を参照。

## データモデル

* `sot.lm_location_star_printers` — 在庫ロケーション → Star プリンター device ID 紐付け（`UNIQUE shop + location_id` で 1 ロケーション 1 プリンターを強制）
* 読み取り view（管理 UI 用）: `public.lm_v_location_star_printers`


---

# 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/configuration/star-printer.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.
