> 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/operator-api/locations.md).

# Operator Locations — 拠点一覧

ピッキングアプリ（picking-ios）の店舗（location）選択 UI 用に、shop のアクティブな拠点（店舗 / POPUP / MFC / 倉庫）一覧を返す read 専用 API です。返る `id` は [Operator Queues](/lmile-docs/operator-api/queues.md)（`GET /api/operator/shipments`）の `fromLocationId` フィルタにそのまま渡せます。書き込みは行いません。

> **Base URL** `https://api.lmile.io` · **認証** operator JWT（`Authorization: Bearer`）（[詳細](/lmile-docs/getting-started/authentication.md)） · `shop` は query に含めます

## エンドポイント

| Method | Path                      | 用途                       | テーブル        |
| ------ | ------------------------- | ------------------------ | ----------- |
| `GET`  | `/api/operator/locations` | アクティブな拠点一覧（`type` で絞り込み） | `locations` |

> レスポンスは camelCase（operator 系と同じ）。`shop` は query で受け取り、スタッフに束縛された shop に含まれることを確認します（含まれなければ `403 shop_not_authorized`）。`/api/operator/*` の認証系統は [認証](https://lmile.gitbook.io/lmile-docs/operator-api/pages/7cB70I8yeRnMpvcdLkNu#operator-jwt-認証) を参照してください。

***

## `GET` /api/operator/locations

shop のアクティブな拠点を `label`（表示名）昇順で一覧します。`type` で拠点種別（`location_type`）を CSV 絞り込みできます（例: 店舗スタッフの選択肢は `type=store,popup`、倉庫スタッフは `type=mfc,warehouse`）。`memberOnly=true` を付けると、スタッフが現場で選ぶ拠点（出荷元メンバーの拠点と、来店予約の受付が有効な拠点）だけに絞り込めます。

### リクエスト

```http
GET https://api.lmile.io/api/operator/locations?shop=demo-store.myshopify.com&type=store,popup&memberOnly=true
Authorization: Bearer {OPERATOR_JWT}
```

| クエリ          | 型       |  必須 | 説明                                                                             |
| ------------ | ------- | :-: | ------------------------------------------------------------------------------ |
| `shop`       | string  |  ✓  | 店舗ドメイン（スタッフの束縛 shop 内）                                                         |
| `type`       | string  |     | 指定時のみ拠点種別（`location_type`）でフィルタ（CSV で複数指定可・最大 200 文字）                          |
| `memberOnly` | boolean |     | `true`（または `1`）で、出荷元メンバーの拠点と、来店予約の受付が有効な拠点だけを返す。`type` 絞り込みとは AND。該当が 0 件なら空配列 |
| `limit`      | number  |     | 一覧の件数。正整数・既定 `200`・最大 `500`（超過分は `500` に丸め）                                    |

`type` に指定する値の代表例: `store` / `popup` / `mfc` / `warehouse` / `online` / `display_only`（固定 enum ではないため許可値の検証はせず、該当なしは `200` + `count: 0` で返ります）

### レスポンス

```json
{
  "ok": true,
  "count": 2,
  "locations": [
    {
      "id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
      "label": "FLAGSHIP STORE 表参道店",
      "locationType": "store",
      "region": null
    },
    {
      "id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
      "label": "二子玉川MFC",
      "locationType": "mfc",
      "region": null
    }
  ]
}
```

| フィールド                   | 説明                                                                                         |
| ----------------------- | ------------------------------------------------------------------------------------------ |
| `count` / `locations[]` | 一覧の件数（`limit` まで）/ 配列（`label` 昇順）                                                          |
| `id`                    | 拠点 ID（uuid）。[Operator Queues](/lmile-docs/operator-api/queues.md) の `fromLocationId` に渡せます |
| `label`                 | 拠点の表示名                                                                                     |
| `locationType`          | 拠点種別（未設定は `null`）                                                                          |
| `region`                | 地域（未設定は `null`）                                                                            |

### 挙動

* `is_active = true` の拠点だけを `label`（表示名）昇順で `limit` 件返します。
* `type` は CSV を lower(trim) 正規化して比較します。空要素は無視し、未指定は全種別を返します。
* `memberOnly=true`（または `memberOnly=1`）を付けると、次のどちらかに当てはまる拠点だけを返します（`type` フィルタとは AND）。
  * 出荷元メンバーとして有効な拠点。出荷元（MFC / 倉庫）自体も、メンバーとして登録されていなければ一覧に出ません。
  * 来店予約の受付が有効な拠点。出荷が流れない新店でも、店頭のスタッフが選んで[来店予約](/lmile-docs/operator-api/visit.md)を確認できます。
* どちらにも当てはまる拠点が無ければ `200` + `count: 0` の空配列を返します（全拠点は返しません）。
* read 専用で書き込み・副作用はありません。

## エラー

エンドポイント固有:

| Status | 条件               | レスポンス例                                                         |
| :----: | ---------------- | -------------------------------------------------------------- |
|  `400` | `type` が 200 文字超 | `{ "ok": false, "error": "type too long" }`                    |
|  `400` | `limit` が正整数でない  | `{ "ok": false, "error": "limit must be a positive integer" }` |

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

## データモデル

* `sot.locations` — 拠点マスター（`display_label` / `location_type` / `region` / `is_active`）。本 API は active な拠点の読み取りのみを行います。
* `sot.lm_fulfillment_source_members` — 出荷元 → 在庫ロケーションの紐付け。`memberOnly=true` のとき `is_active=true` な `inventory_location_id` で `locations` を絞り込みます。
* `sot.lm_visit_locations` — 拠点ごとの来店予約の受付設定。`memberOnly=true` のとき `enabled=true` な拠点も一覧に含めます。


---

# 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/operator-api/locations.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.
