openapi: 3.0.3
info:
  title: サスケWorks API v2
  description: |
    サスケWorks の **アプリ設定・項目（フィールド）定義・サブレコード（サブレコードテーブル）・レコードを操作する REST API** です。
    画面で行うアプリの作成・設定変更、項目設定、サブレコードテーブル・項目の管理、レコードの登録・取得・更新・削除・一覧を、プログラムから実行できます。

    - **対象**: サスケWorks を business / enterprise プランで契約中のお客様で、外部システム連携や自動化を行う開発者
    - **形式**: REST（JSON）。認証は API キー＋トークンのヘッダ方式
    - **ベース URL**: `https://api.works.app/v2`

    # はじめに

    最短 3 ステップで最初のリクエストを試せます。

    1. **認証情報を発行する** — サスケWorks の管理者（admin）または開発者（dev）アカウントで、API キー（`x-api-key`）とトークン（`x-token`）を発行します。
    2. **リクエストを送る** — 2 つのヘッダを付けて呼び出します。例（アプリ一覧を取得）:
       ```bash
       curl https://api.works.app/v2/settings/apps \
         -H "x-api-key: YOUR_API_KEY" \
         -H "x-token: YOUR_TOKEN"
       ```
    3. **レスポンスを確認する** — `200` でアプリ一覧が JSON で返れば成功です。あとは左メニューの各エンドポイントを参照してください。

    ## サスケWorks API の全体像

    この API で扱うデータの関係です。**アプリ**が「項目定義」と「レコード」を持ち、レコードは**サブレコード**（明細行）を持てます。ファイルはテナント単位でアップロードし、`fileKey` でレコードの file 型項目に紐付けます。

    <img src='./images/data-model.svg' class='horizontally-long-img' alt='データモデル図: アプリが項目定義とレコードを持ち、レコードがサブレコードを持つ。ファイルは fileKey で紐付け'>

    画面で使っている言葉と API 上の名前の対応:

    | 画面の言葉 | API の名前 | 補足 |
    |---|---|---|
    | アプリ | app（`/settings/apps`・`/apps/{appKey}/...`）| 業務データの入れ物 |
    | 項目 | field | レコードの列。型（`type`）を持つ |
    | レコード | record | メインの表の 1 行 |
    | サブレコード | subrecord | レコードの中の明細行。種別（入れ物）は subrecordTable |
    | 分類 | category | 項目タイプの 1 つ |
    | タグ / マイリスト | tag / mylist | 項目タイプの 1 つ |
    | 利用ユーザー / 組織 | user / group | 項目タイプの 1 つ |

    ## ID 早見表 — どこで取れて、どこで使うか

    URL やボディに出てくる ID の入手先です。**ID は決め打ちせず、必ず API で取得した値を使ってください**。

    | ID | 形の例 | 手に入れる場所 | 使う場所 |
    |---|---|---|---|
    | `{appKey}` | `OQXJ`（4 文字英数大文字）| `GET /settings/apps` → `apps[].key` | ほぼすべての EP の URL |
    | 項目キー | `text01` | `GET /settings/apps/{appKey}/fields` → `fields[].key` | レコードの `fields` のキー・検索の `field` |
    | `{recordId}` | `3`（数値）| 登録応答・一覧の `record.id` / `records[].id` | レコード取得・更新・削除・複製の URL |
    | `{subrecordTableKey}` | `SB-aB3xY9` | `GET /settings/apps/{appKey}/subrecordTables` → `subrecordTables[].key` | サブレコード系 EP の URL |
    | `{subrecordId}` | `5`（数値）| サブレコード登録応答・一覧の `id` | サブレコード取得・更新・削除の URL |
    | `fileKey` | `97-1782492047` | `POST /files` の応答 `file.fileKey` | ファイルダウンロードの URL・file 型項目への書き込み |
    | `{customKey}` | `CA-12`・`TG-3` など | 分類・タグ等の ID に接頭辞（`CA-`/`CO-`/`TG-`/`MY-`/`CL-`）を付ける | 分類・カスタムリスト経由の一覧 URL |

    ## URL の読み方

    一番長い URL を例に、各パーツが何を指すかを示します:

    <div style="font-family: Consolas, Menlo, monospace; font-size: 13px; line-height: 2.3; word-break: break-all; background: #263238; color: #eceff1; padding: 14px 18px; border-radius: 6px;">https://api.works.app/v2/apps/<span style="background: #00b7bc; color: #fff; padding: 2px 6px; border-radius: 3px;">OQXJ</span>/records/<span style="background: #7cb342; color: #fff; padding: 2px 6px; border-radius: 3px;">3</span>/subrecordTables/<span style="background: #fb8c00; color: #fff; padding: 2px 6px; border-radius: 3px;">SB-aB3xY9</span>/subrecords/<span style="background: #8e6cc0; color: #fff; padding: 2px 6px; border-radius: 3px;">5</span></div>

    - <span style="background: #00b7bc; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 12px;">appKey</span> どのアプリか（アプリ一覧で取得）
    - <span style="background: #7cb342; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 12px;">recordId</span> どのレコードか（登録時の応答 `record.id`）
    - <span style="background: #fb8c00; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 12px;">subrecordTableKey</span> どの明細の種別か（サブレコードテーブル一覧で取得）
    - <span style="background: #8e6cc0; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 12px;">subrecordId</span> どの明細行か（サブレコード登録時の応答）

    # 認証

    すべてのエンドポイントで以下の 2 つのヘッダが必須です。

    | ヘッダ | 内容 |
    |---|---|
    | `x-api-key` | クライアント（契約）ごとの API キー |
    | `x-token` | 操作者（管理者 / 開発者アカウント）のトークン |

    - トークンは **管理者（admin）または開発者（dev）アカウント** のものだけが有効です（一般利用者のトークンは `403`）。
    - 認証失敗時は `401` を返します: `auth_token_missing`（ヘッダ未送信）/ `auth_api_key_invalid`（キー不正）/ `auth_token_invalid`（トークン不正・無効化済み）。
    - 接続元 IP 制限を設定している場合、許可外からのアクセスは `403 auth_ip_restricted`。

    ## API キーとトークンの発行・確認方法

    どちらもサスケWorks の画面から発行・確認できます。

    - **API キー** — スペースに 1 つ割り当てられる認証キーです。スペースの利用者は全員同一の API キーを使用します。外部に流出しないよう注意してください。
    - **API アクセストークン** — ユーザーごとに発行する認証キーです。**作成したユーザーと同じ権限範囲**で API を操作でき、流出時の危険度はパスワードと同等です。他者と共有せず、利用者ごとに発行してください。複数ユーザーに跨る権限範囲が必要な場合は、その権限を持つ API 通信用ユーザーを作成してトークンを管理することを推奨します。

    **1. 画面右上の歯車マークをクリックし、メニューの「API の管理」を選択します。**

    <img src='./images/api-gear-menu.png' class='vertical-long-img'>

    **2. 「API の管理」画面の上部に表示されているのが API キーです。**下の一覧で、発行済みトークンの状態・当月接続数も確認できます。

    <img src='./images/api-manage.png' class='horizontally-long-img'>

    **3. API アクセストークンは、一覧右上の「新規登録」ボタンから発行します。**

    トークン名・備考のほか、既存トークンの引き継ぎ、接続元 IP アドレスの制限（前方一致）、複数ユーザーとの共有が設定できます。

    <img src='./images/api-token-form.png' class='horizontally-long-img'>

    # はじめてのレコード登録

    認証情報の発行が済んだら、レコードを 1 件登録して取り出すまでを 4 ステップで通してみましょう。
    コード例の `{APIキー}` / `{APIアクセストークン}` は「認証」で発行した値に置き換えてください。

    ## ステップ 0: アプリの API アクセスを許可する

    レコード操作 API は、**対象アプリの「API 連携機能」が有効**になっている必要があります（無効のままだと 403 `app_api_disabled` になります）。
    アプリ設定（基本情報）の「機能の選択」で「API 連携機能」にチェックを入れてください。

    <img src='./images/app-api-access.png' class='vertical-long-img'>

    > アプリ設定 API（`settings` 配下）はこの許可が無効でも利用できるため、API から有効化することもできます:
    > `PATCH /settings/apps/{appKey}` に `{ "app": { "features": { "api": true } } }` を送信

    ## ステップ 1: アプリキーを調べる

    URL の `{appKey}` に入れる値は、アプリ一覧 API のレスポンス `apps[].key` で確認できます。

    ```bash
    curl "https://api.works.app/v2/settings/apps" \
      -H "x-api-key: {APIキー}" \
      -H "x-token: {APIアクセストークン}"
    ```

    レスポンス（抜粋）:

    ```json
    { "apps": [ { "id": "123", "key": "OQXJ", "name": "日報アプリ", "status": "active" } ] }
    ```

    この例では `OQXJ` が操作対象のアプリキーです。以降の URL の `{appKey}` に入れます。

    ## ステップ 2: 項目キーを確認する

    レコードの値は「項目キー → 値」の形で送ります。項目一覧 API で各項目の `key` と `type` を確認します。

    ```bash
    curl "https://api.works.app/v2/settings/apps/OQXJ/fields" \
      -H "x-api-key: {APIキー}" \
      -H "x-token: {APIアクセストークン}"
    ```

    レスポンス（抜粋）:

    ```json
    { "fields": [ { "id": "229", "key": "text01", "name": "一行テキスト", "type": "text" } ] }
    ```

    ## ステップ 3: レコードを登録する

    項目キーに値を入れて POST します（`text01` は一行テキストなので文字列。型ごとの送る形は「項目タイプ別の値の形式」参照）。

    ```bash
    curl -X POST "https://api.works.app/v2/apps/OQXJ/records" \
      -H "x-api-key: {APIキー}" \
      -H "x-token: {APIアクセストークン}" \
      -H "Content-Type: application/json" \
      -d '{ "record": { "fields": { "text01": "田中商事" } } }'
    ```

    `201 Created` とともに作成されたレコードが返ります。レスポンスの `record.id` がレコード ID です。

    ## ステップ 4: 登録したレコードを取得する

    ```bash
    curl "https://api.works.app/v2/apps/OQXJ/records/3" \
      -H "x-api-key: {APIキー}" \
      -H "x-token: {APIアクセストークン}"
    ```

    レスポンス（抜粋）:

    ```json
    { "record": { "id": "3", "title": "田中商事", "fields": { "text01": "田中商事" } } }
    ```

    ここまで通れば、一覧・検索・更新・削除も同じ要領で使えます（各エンドポイントの右側のコードサンプル参照）。

    ## つまずいたら

    | 症状 | 確認すること |
    |---|---|
    | 401 が返る | ヘッダ名（`x-api-key` / `x-token`）のタイポ、トークンの有効性（→「認証」） |
    | 403 `app_api_disabled` | ステップ 0 の API アクセス許可 |
    | 403 `auth_ip_restricted` | トークンの接続元 IP アドレス制限の設定 |
    | 422 `validation_failed` | 項目キーの綴りと値の形（→「項目タイプ別の値の形式」） |

    # レート制限

    API リクエスト数には **月間 100,000 リクエスト** の上限があります（クライアント単位の月間カウント。**v1・v2 を合算**）。
    上限を超えると `429 rate_limit_exceeded` を返します。時間を空けて再試行してください。

    当月のリクエスト回数は、画面の「契約情報の管理」から確認できます。トークンごとの当月接続数は「API の管理」画面の一覧でも確認できます。

    # エラーハンドリング

    すべてのエラーは共通の形式で返します:
    ```json
    {
      "error": {
        "code": "error_code",
        "message": "エラーメッセージ",
        "logId": 123,
        "details": [...]
      }
    }
    ```
    `code` は機械判別用の固定コード（小文字 snake_case）です。`message` は表示用で文言は予告なく変わりうるため、
    プログラムでの分岐は必ず **`code`** で行ってください。`logId` はサーバー側ログの参照 ID で、問い合わせ時に添えると調査が速くなります。

    ## 届いたエラーの読み方

    実際の 422 レスポンスを例に、見る順番を番号で示します:

    ```json
    {
      "error": {
        "code": "validation_failed",          ← ① まず code（エラーの種類・機械判別用）
        "message": "入力内容に誤りがあります。",
        "logId": 123,                          ← ④ 解決しないとき問い合わせに添える
        "details": [                           ← ② validation_failed なら details へ
          {
            "field": "text01",                 ← ③ どの項目が
            "code": "required",                ← ③ なぜ（この例は未入力）
            "message": "必須項目です。"
          }
        ]
      }
    }
    ```

    1. `error.code` でエラーの種類を判別する（代表コードは下の表）
    2. `validation_failed` のときは `details[]` に項目ごとの原因が入っている
    3. `details[].field`（どの項目が）と `details[].code`（なぜ）を見て入力を直し、再送する
    4. 原因が分からないときは `logId` を添えてお問い合わせください（サーバー側の記録と突き合わせて調査できます）

    ## HTTP ステータスと代表的なエラーコード

    | ステータス | 意味 | 代表的な `code` |
    |---|---|---|
    | 400 | リクエストの形式不正 | `request_param_invalid` / `request_json_parse_error` / `cursor_expired` |
    | 401 | 認証情報の不足・無効 | `auth_token_missing` / `auth_api_key_invalid` / `auth_token_invalid` |
    | 403 | 権限・契約・機能の制限 | `auth_plan_not_supported` / `auth_subscription_expired` / `auth_ip_restricted` / `app_api_disabled` / `app_permission_denied` / `app_copy_not_allowed` |
    | 404 | 対象が存在しない | `app_not_found` / `field_not_found` / `endpoint_not_found` |
    | 405 | 非対応の HTTP メソッド | `request_method_not_allowed` |
    | 409 | 競合（重複・参照中・編集ロック）| `app_duplicate` / `app_in_use` / `field_duplicate` / `field_singleton_exists` / `field_has_linkage` / `field_editing_conflict` |
    | 415 | Content-Type 不一致 | `request_unsupported_media_type` |
    | 422 | 入力値・上限の問題 | `validation_failed`（詳細は `details[]`）/ `field_limit_exceeded` / `plan_limit_exceeded` |
    | 429 | レート制限の超過 | `rate_limit_exceeded` |
    | 500 | サーバー内部エラー | `internal_error` |

    `422 validation_failed` は `details[]` に違反した項目ごとの `{ field, code, message }` を含みます
    （`details[].code` は `required` / `invalid_value` / `invalid_enum` / `out_of_range_max` / `forbidden` / `read_only` / `role_group_conflicts_keyword_search` / `elapsed_time_requires_time_range` / `fixed_time_requires_fixed_time_mode` / `time_settings_require_datetime_pattern` / `decimal_places_requires_decimal_result` / `image_resize_requires_image` / `reset_date_requires_specific_date` など）。

    **details の読み方（機械処理と表示の分担）**:
    - `details[].field` … 違反した項目の**フィールドキー**（例: `fields.text01`）。**プログラムで項目を特定するときはこちらが正**です
    - `details[].code` … 違反の種別（機械判別用）
    - `details[].message` … 人間向けの説明文。項目名は**表示名（項目タイトル）**で表記され、レコード項目のバリデーション違反は
      違反内容に応じた個別の文言になります（例）「金額 が設定された上限値を超えています」「電話番号 にはハイフンを含めてください」

    **レコード書き込みは 2 段階でバリデーションされます**。① API 層の事前チェック（実在照合・選択肢・型・
    ファイル種別・選択制限など）→ ② 画面共通の登録処理内チェック（必須・桁数・日付/時刻の妥当性・重複など）。
    ①で 1 件でもエラーがあると②は実行されないため、**①のエラーを直して再送すると②のエラーが新たに返る**
    ことがあります（各段階内では違反項目をまとめて返します）。エラーが返ったら都度修正して再送してください。

    ## 項目（field）設定の制約

    項目の `config` には、組み合わせに関する制約があります（画面の項目設定と同じルール）。

    | 制約 | 内容 | 違反時 |
    |---|---|---|
    | 権限グループ × キーワード検索の併用不可 | `roleGroup` を設定した項目は `keywordSearchable: true` にできません（権限で絞った項目がキーワード検索で露出するのを防ぐため）。**calc（計算）型は除く** | 422 `validation_failed`（`details[].code` = `role_group_conflicts_keyword_search`）|
    | 経過時間表示 × 入力パターン | `showElapsedTime: true` は入力パターンが「時刻範囲入力」（`inputPattern: hms_hms`）の time 項目でのみ設定できます（画面も範囲入力のときだけ表示） | 422 `validation_failed`（`details[].code` = `elapsed_time_requires_time_range`）|
    | 固定時刻 × 初期値モード | time の `fixedTime` は `initialValueMode: "fixedTime"` のときのみ設定できます | 422 `validation_failed`（`details[].code` = `fixed_time_requires_fixed_time_mode`）|
    | 時刻設定 × 入力パターン | date の `timeRange` / `minuteInterval` は日時系 inputPattern（`ymdhm` 系）のときのみ設定できます（日付のみでは GET も null） | 422 `validation_failed`（`details[].code` = `time_settings_require_datetime_pattern`）|
    | 小数桁 × 計算結果の型 | calc の `decimalPlaces`（1 以上）は `resultType: "decimal"` のときのみ設定できます（0 は許容） | 422 `validation_failed`（`details[].code` = `decimal_places_requires_decimal_result`）|
    | 画像リサイズ × ファイルタイプ | file の `imageResize` は `fileType: "image"` のときのみ設定できます（`extractLocation` の image 条件と対称） | 422 `validation_failed`（`details[].code` = `image_resize_requires_image`）|
    | リセット月日 × リセット周期 | autoNumber の `resetDate` は `resetCycle: "specificDate"` のときのみ設定できます | 422 `validation_failed`（`details[].code` = `reset_date_requires_specific_date`）|
    | 作成後に変更できないキー | 列の型・結果型を決めるキー（例: number `numericKind`、date/time `inputPattern`、calc `resultType`、user/group `selectionCount`、lookup `referenceMethod`/`linkedAppKey`/`sourceFieldKey`）は作成後変更不可 | 422 `validation_failed`（`details[].code` = `read_only`）|

    ## リトライの指針

    | エラー | 再試行 | 対応 |
    |---|---|---|
    | 429 `rate_limit_exceeded` | ✅ 時間を空けて再試行 | 月間上限に注意し、間隔（バックオフ）を空けて送り直してください |
    | 500 系 | ✅ 少し待って再試行 | 続く場合は `logId` を添えてお問い合わせください |
    | 401 / 403 | ❌ そのままでは不可 | 認証情報・権限・契約内容を見直してください |
    | 404 / 409 / 415 / 422 | ❌ そのままでは不可 | リクエスト内容を修正してから送り直してください（同じ内容の再送では解消しません）|

    # 一覧の取得とページング

    v2 API の**一覧 EP**は、対応する画面 UI に合わせて次の2パターンに分かれます。**画面にページ送りが無い一覧は API も全件返し**、**画面にページ送りがある一覧は cursor ページネーション**です。

    | パターン | いつ使うか | レスポンス | クエリ | 本ドキュメントの例 |
    |---|---|---|---|---|
    | **全件返し** | 件数に実質上限があり、画面にページ送り UI が無い | `{ "<リソース>": [ ... ] }` のみ（`pagination` キーなし）| `sort` / `fields` は使える。`limit` / `cursor` は**宣言されない** | `GET /settings/apps`（アプリ一覧）・`GET /settings/apps/{appKey}/fields`（項目一覧）|
    | **cursor ページネーション** | 件数が大きくなり得て、画面にページ送り UI がある | 上記に加え `pagination` オブジェクト | `limit` / `cursor` / `sort` / `fields` 等（EP ごとに宣言）| レコード一覧など（該当 EP が本 yaml に載る場合）|

    **全件返し EP で `limit` や `cursor` を送ると** 422 `validation_failed`（`details[].code` = `forbidden`）になります（未宣言のクエリパラメータ拒否）。

    ## cursor ページネーション（付く EP 向け）

    件数の多い一覧（例: レコード一覧）では **opaque cursor** 方式です。cursor の中身を解釈する必要はなく、前回レスポンスの値をそのまま次リクエストに渡します。

    ```
    GET /v2/apps/{appKey}/records?limit=20
    → { "records": [...], "pagination": { "limit": 20, "total": 42, "hasMore": true, "nextCursor": "..." } }

    GET /v2/apps/{appKey}/records?cursor=<nextCursorの値>
    → 次のページ（hasMore=false なら nextCursor は null）
    ```

    **2 ページ目以降は cursor だけ送れば続きが取れます**（limit・検索条件・並び順の再送は不要。cursor が継続に必要な情報を保持します）。

    | 項目 | 説明 |
    |---|---|
    | `limit` | 1 ページあたりの最大件数（EP ごとに default / max を宣言）。**ページ送り中は最初のリクエストの値で固定**され、cursor と一緒に limit を送っても無視されます |
    | `cursor` | 前ページの `pagination.nextCursor` をそのまま指定 |
    | `pagination.total` | 条件に一致する総件数 |
    | `pagination.hasMore` | 次ページの有無 |
    | `cursor_expired` | cursor の有効期限切れ等で 400（レコード一覧など cursor 付き EP のみ）|

    # fields クエリ（返却項目の絞り込み）

    多くの **GET** EP は、クエリ `fields` で**レスポンスに含めるトップレベル属性**を絞れます。ページネーションとは別概念です（`sort` も同様）。

    ## 基本原則: トップレベル属性名のみ指定可

    **`fields` に書けるのは、レスポンス JSON のトップレベル属性名だけ**です。オブジェクトの中身をドットで指定することはできません。

    | 指定 | 意味 |
    |---|---|
    | `fields=icon` | ✅ `icon` オブジェクト**全体**を返す（`name` / `color` 等を含む）|
    | `fields=icon.name` | ❌ 不可 → 422 `fields_nested_not_supported` |
    | `fields=id,key,name` | ✅ トップレベル属性をカンマ区切りで複数指定 |

    ネストした JSON の一部だけ欲しい場合は、**親キー（例: `icon`）を指定して object ごと受け取り**、クライアント側で必要なプロパティを使います。

    > **例外（レコード系 EP）**: レコードの GET/一覧/検索では、ユーザー定義項目を `fields.{fieldKey}` 形式（例: `fields=fields.text01`）で個別に絞れる拡張があります。`fields.add01.postalCode` のような **2 段以上のドット**は引き続き不可です。該当 EP が本 yaml に載る際に各 EP 説明で明記します。

    ## 2 層の絞り込み

    1. **EP のレスポンススキーマ** … その EP が返しうる属性の上限（契約・重い集計の gating 含む）
    2. **`fields` クエリ** … クライアントが今回欲しい属性（上記の部分集合）

    実際の JSON = スキーマで許可された集合 ∩ `fields` で指定した集合。

    ## 一覧 EP と個別 EP の違い

    | EP の種類 | `fields` 省略時 | `fields=all` | `fields=id,key,name` |
    |---|---|---|---|
    | **一覧**（配列を返す EP）| **最小限だけ**（識別子・軽い表示属性・監査メタ。重い blob や N+1 集計は含まない）| スキーマ上の**全属性** | 指定したトップレベル属性のみ |
    | **個別**（1 件 object を返す EP）| **フル返却**（従来どおり）| 全属性 | 指定属性のみ |

    **一覧で省略時に返る最小セット（例）**

    | EP | 省略時に返る主な属性 | `fields=all` で追加される例 |
    |---|---|---|
    | アプリ一覧 | id, key, name, status, createdBy, createdAt, updatedAt | shortName, icon, features, memo, color 等 |
    | 項目一覧 | id, key, name, type, createdBy, createdAt, updatedAt | required, searchable, remarks, config 等 |
    | アプリ個別取得 | （省略時フル）| — |
    | 項目個別取得 | （省略時フル）| — |

    > 一覧では **`recordCount`（アプリ）など per 行の重い集計は省略時に含まれません**。必要なら `fields=all` または個別 GET EP を使ってください。

    ## 指定ルールとエラー

    | 指定 | 意味 |
    |---|---|
    | 省略 | 上表どおり（一覧＝最小限、個別＝フル）|
    | `all` | 予約語。フィルタ無効化（スキーマ上の全属性）|
    | `id,key,name` | カンマ区切り。**トップレベル属性名のみ**（ドット記法不可）|

    | 送り方 | 結果 |
    |---|---|
    | `fields=icon.name` 等のネスト指定 | 422 `validation_failed`（`fields_nested_not_supported`）|
    | その EP が返さない属性名（例: 一覧で `recordCount`）| 422 `validation_failed`（`fields_unknown`）|
    | 未知のクエリパラメータ全般 | 422 `validation_failed`（`forbidden`）|

    # 項目タイプ別の値の形式

    レコードの読み書き（`fields`）で使う、項目タイプごとの値の形の早見表です。**read で返る形をそのまま送れば write でも通ります**（往復一致）。
    正確な構造定義はスキーマ `RecordFieldValue`（read）/ `RecordFieldValueWrite`（write）を参照してください。

    | 項目タイプ | 返る形（read） | 送る形（write） |
    |---|---|---|
    | 文字列系（text / textarea / radio / select / tel / email / url / zipCode / prefecture / personName） | 文字列 | read と同じ |
    | number（整数 / 小数） | 整数 / 小数 | read と同じ |
    | number（zerofill） | 文字列（`"0001"`・先頭 0 維持） | 数値文字列 |
    | number / date / time の範囲 | `{ "from": ..., "to": ... }` | read と同じ（片方のみも可） |
    | date | `"2026-04-23"`（日付）/ `"2026-04-23T00:30:00Z"`（日時・UTC） | read と同じ（UTC は JST に変換して保存） |
    | time | `"09:30"` / `"09:30:45"` | read と同じ |
    | checkbox | 文字列の配列（`["1","2"]`） | read と同じ |
    | user / group（単一） | `{ "id": ..., "name": ... }` | id 文字列 |
    | user / group（複数） | `[{ "id": ..., "name": ... }, ...]` | id の配列 |
    | category | `{ "id": ..., "name": "親 > 子" }` | `{ "id": ... }` |
    | tag / mylist | `[{ "id": ..., "name": ... }, ...]` | `[{ "id": ... }]` または `["id"]` |
    | address | `{ "postalCode": ..., "prefecture": ..., "city": ..., ... }` | read と同じ（送ったサブキーのみ部分更新） |
    | apps（アプリ間連携） | `{ "appKey": ..., "recordId": ... }` | read と同じ |
    | file | `{ "fileKey": ..., "name": ..., "size": ..., "contentType": ... }` | `{ "fileKey": ..., "name": ... }`（fileKey はアップロード API で取得） |
    | color | 文字列 | read と同じ |
    | numbering（自動採番） | `{ "assign": true }` | 手動採番モードのみ `{ "assign": true }` で採番を実行できる（画面の「採番する」チェックと同じ。番号はフォーマットからサーバーが発番＝任意の値は指定不可）。自動採番モードは読み取り専用 |
    | calc / lookup | **参照先・計算結果の型と同じ形**（数値なら数値、checkbox なら文字列の配列、address なら object、user / group なら `{ "id": ..., "name": ... }`、file なら file object。text 等は文字列） | calc と lookup（**同期参照**）は送信不可（読み取り専用。送ると 422 `read_only`）。lookup（**都度参照**）は**送信可**——直値を送ると手入力として保存され、`{ "sync": true }` を送ると連携先レコードの現在値を取り込む |
    | 未設定・空 | null | `null` / 空でクリア |

    - 参照系（category / tag / mylist / user / group / apps / file）は**実在するコードのみ**受理します（非実在・権限外は 422 `invalid_value`）。tag / mylist に新しい選択肢を作ることはできません（選択肢の追加は項目設定 API の `config.options` から）。
    - password 型・アプリ間連携（apps）は検索条件に指定できません（`POST /apps/{appKey}/records/search` で 422 `invalid_value`）。型ごとに使える検索条件は同 EP の説明を参照してください。

  version: 2.0.0
  contact:
    name: InterPark Co.,Ltd
    email: support@saaske.com

servers:
  - url: https://api.works.app/v2

security:
  - apiKey: []
    token: []

tags:
  - name: settings-apps
    x-displayName: アプリ設定
    description: |
      アプリの基本設定・機能トグル・複製・データクリアを管理します。
      管理者（admin）または開発者（dev）権限のみアクセス可。
  - name: settings-apps-fields
    x-displayName: レコード項目の設定
    description: |
      アプリのメインレコード（メインの表）の項目の定義を管理します。
      一覧・作成・取得・更新・削除・複製（F-1〜F-7）。
      管理者（admin）または開発者（dev）権限のみアクセス可。
  - name: records
    x-displayName: レコード
    description: |
      アプリのレコード（メインの表の 1 行）を操作します。一覧・登録・取得・更新・削除・検索・分類キー取得。
      値は型別の形（数値・日時・選択肢・住所・アカウント・分類・ファイル等）で受け渡しします（各項目の値の形は `RecordFieldValue` を参照）。
      条件を指定した検索は `POST /records/search`、分類・カスタムリスト・サブレコードテーブルキーでの取得は `GET /records/by/{key}` を使います。
      管理者（admin）または開発者（dev）権限のみアクセス可。対象アプリで **API 連携機能が有効**（アプリ設定）である必要があります。
  - name: records-subrecords
    x-displayName: サブレコード
    description: |
      1 件のレコードの中に持つサブレコード（明細行）を操作します。一覧・取得・登録・更新・削除（CRUD）。
      パスは `records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords` で、`{subrecordTableKey}`（`SB-` + 英数字 6 文字）が種別、`{subrecordId}`（数値）が行を指します。
      明細項目の値の形はメインレコードと同じ（`RecordFieldValue` を参照）。種別（サブレコードテーブル）と項目の定義は「サブレコードテーブルの設定」「サブレコード項目の設定」で行います。
      管理者（admin）または開発者（dev）権限のみアクセス可。対象アプリで **API 連携機能**（`app_api_disabled` で拒否）と **サブレコード機能**（`subrecord_disabled` で拒否）が有効である必要があります。
  - name: settings-apps-subrecord-tables
    x-displayName: サブレコードテーブルの設定
    description: |
      アプリの「サブレコード（サブレコードテーブル）」種別を管理します。サブレコードは 1 件のレコードの中に持てる子の表で、その入れ物の種類が「種別」です。
      一覧・作成・取得・更新・削除・行データクリア（SF-1〜SF-6）。
      種別を作ると専用テーブルが作られ、削除するとテーブルごと消える DDL を伴う操作です。
      管理者（admin）または開発者（dev）権限のみアクセス可。
  - name: settings-apps-subrecord-table-fields
    x-displayName: サブレコード項目の設定
    description: |
      サブレコードテーブルの中の項目（列）を管理します。一覧・作成・取得・更新・削除・複製（SFF-1〜SFF-6）。
      項目の契約（送る形・返る形・型別 `config`）は**メインレコードの項目（アプリ項目の設定）と同一**です。
      ただしサブレコードテーブルでは一部の型（カテゴリ／タグ／マイリスト／色／ラベル）は使えず、タイトル項目・ユニークキーの指定もできません。
      管理者（admin）または開発者（dev）権限のみアクセス可。
  - name: files
    x-displayName: ファイル
    description: |
      ファイルのアップロード（FL-1）。ダウンロード EP は提供しない（レコードの file 項目は fileKey 等のメタ情報のみ返す）。
      アップロードはテナント単位（特定アプリに属さない global）で、返却される `fileKey` でダウンロード・レコードへの紐付けに使います。

# サイドバーのタググループ表示（ReDoc 向け vendor 拡張。API 契約には影響しない）
# 注意: ここに載せていないタグは ReDoc のサイドバーに表示されなくなる。タグを追加したら必ずいずれかのグループにも追加すること
x-tagGroups:
  - name: アプリ・項目の設定
    tags:
      - settings-apps
      - settings-apps-fields
  - name: サブレコードの設定
    tags:
      - settings-apps-subrecord-tables
      - settings-apps-subrecord-table-fields
  - name: レコード操作
    tags:
      - records
      - records-subrecords
  - name: ファイル
    tags:
      - files

paths:
  /settings/apps:
    get:
      tags: [settings-apps]
      summary: アプリ一覧取得
      description: |
        テナント内のアプリ一覧を返します。
        - **全件返し**（ページネーションなし）。`limit` / `cursor` / `pagination` は使いません（送ると 422）。詳細は冒頭「一覧の取得方式」
        - **`fields` 省略時**の最小セット: id / key / name / status / createdBy / createdAt / updatedAt。`fields=all` で shortName / icon / features 等を含む
        - `recordCount` は一覧では返さない（個別取得 EP のみ）
      operationId: listApps
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps?fields=all" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - name: sort
          in: query
          description: ソート指定（`{field} {asc|desc}`）
          schema:
            type: string
            default: "id asc"
            enum:
              - "id asc"
              - "id desc"
              - "key asc"
              - "key desc"
              - "name asc"
              - "name desc"
              - "createdAt asc"
              - "createdAt desc"
              - "updatedAt asc"
              - "updatedAt desc"
        - $ref: '#/components/parameters/fieldsQueryList'
      responses:
        '200':
          description: アプリ一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppListResponse'
              example:
                apps:
                  - id: "123"
                    key: "OQXJ"
                    name: "日報アプリ"
                    status: "active"
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    createdAt: "2026-01-01T00:00:00Z"
                    updatedAt: "2026-06-01T00:00:00Z"
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/AppsQueryValidationError'

    post:
      tags: [settings-apps]
      summary: アプリ新規作成
      description: |
        アプリを新規作成します。**必須は `name` のみ**。他は省略時サーバー側で画面準拠のデフォルトを補完します。
        - `key` 省略時はサーバー自動採番（3〜12 桁英数）
        - 作成直後の `status` は `created`
        - 成功時は `201 Created` ＋ `Location` ヘッダ
      operationId: createApp
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"app": {"name": "新規アプリ", "shortName": "新規", "copyAllowed": true}}'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppCreateRequest'
            examples:
              minimal:
                summary: 必須のみ（name だけ・すぐ試せる）
                value:
                  app:
                    name: "新規アプリ"
              full:
                summary: 送信可能な項目をほぼ網羅（コピーして不要分を削る）
                value:
                  app:
                    name: "営業案件管理"
                    key: "SALES"
                    shortName: "案件"
                    group: null
                    memo: "営業案件を管理するアプリ"
                    color: "#4a90d9"
                    icon:
                      name: "Works"
                      color: "#4a90d9"
                    copyAllowed: true
                    features:
                      comment: true
                      dashboard: true
                      workflow: true
                      subrecord: true
                      recordStatus: true
                      viewHistory: true
                      documentExport: true
                      webform: false
                      aiocr: false
                      bulkMail: false
                      automation: true
                      api: true
                    recordPermission:
                      mode: "fixed"
                      fixedGroup: "1"
      responses:
        '201':
          description: 作成成功
          headers:
            Location:
              description: 作成されたアプリの URL
              schema:
                type: string
              example: "/v2/settings/apps/ABCD"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/AppConflict'
        '422':
          description: |
            バリデーションエラー（`validation_failed`）またはプラン上限超過（`plan_limit_exceeded`）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validationFailed:
                  value:
                    error:
                      code: "validation_failed"
                      message: "入力内容に誤りがあります。"
                      details:
                        - field: "name"
                          code: "required"
                          message: "必須項目です"
                planLimit:
                  value:
                    error:
                      code: "plan_limit_exceeded"
                      message: "プラン上限に達しています。"

  /settings/apps/{appKey}:
    get:
      tags: [settings-apps]
      summary: アプリ設定取得
      description: |
        指定アプリ（`appKey`）の設定を 1 件返します。アプリ一覧と同形式に加え `recordCount` を含みます。
        - **個別 GET**: `fields` 省略時はフル返却（一覧の最小限デフォルトとは異なる）。詳細は冒頭「fields クエリ」
      operationId: getApp
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps/{appKey}?fields=all" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/fieldsQueryItem'
      responses:
        '200':
          description: アプリ設定
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppSingleResponse'
              example:
                app:
                  id: "123"
                  key: "OQXJ"
                  name: "日報アプリ"
                  status: "active"
                  shortName: "日報"
                  group: null
                  copyAllowed: true
                  recordCount: 245
                  icon:
                    name: "日報"
                    color: "#4a90d9"
                    url: "https://example.com/icon.png"
                  features:
                    comment: true
                    dashboard: true
                  createdBy: { id: "ac000001", name: "佐藤 花子" }
                  createdAt: "2026-01-01T00:00:00Z"
                  updatedAt: "2026-06-01T00:00:00Z"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/AppsQueryValidationError'

    patch:
      tags: [settings-apps]
      summary: アプリ設定更新
      description: |
        指定アプリの設定を部分更新します（JSON Merge Patch 相当）。
        - 送信したフィールドのみ更新、未送信キーは現在値を維持
        - `"field": null` で初期化（`shortName` 空送信時は `name` にフォールバック）
        - 基本情報（トップレベル）と機能トグル（`features`）を 1 PATCH に統合
        - READ-ONLY フィールド（`id` / `icon.url` / `qrcode` / `url` / `recordCount` 等）への異なる値送信は 422
      operationId: updateApp
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X PATCH "https://api.works.app/v2/settings/apps/{appKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"app": {"name": "更新後のアプリ名", "features": {"comment": false}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppPatchRequest'
            examples:
              minimal:
                summary: 単一フィールドの部分更新（送ったキーだけ更新）
                value:
                  app:
                    name: "更新後のアプリ名"
                    features:
                      comment: false
              full:
                summary: 更新可能な項目をほぼ網羅。status（遷移制約あり・created→active 等は不可）と key（レコード未登録時のみ変更可）は前提条件があるため本例では省略（スキーマ参照）
                value:
                  app:
                    name: "営業案件管理（改訂）"
                    shortName: "案件改"
                    group: null
                    memo: "説明を更新"
                    color: "#7cb342"
                    icon:
                      name: "Works"
                      color: "#7cb342"
                    copyAllowed: false
                    features:
                      comment: true
                      dashboard: true
                      workflow: false
                      subrecord: false
                      recordStatus: true
                      viewHistory: false
                      documentExport: false
                      webform: false
                      aiocr: false
                      bulkMail: false
                      automation: false
                      api: true
                    recordPermission:
                      mode: "fixed"
                      fixedGroup: "1"
      responses:
        '200':
          description: 更新後のアプリ設定
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '409':
          $ref: '#/components/responses/AppConflict'
        '422':
          $ref: '#/components/responses/AppUpdateValidationError'

    delete:
      tags: [settings-apps]
      summary: アプリ削除
      description: |
        指定アプリを削除します。アプリ本体に加え関連データを連動削除する破壊的操作です。
        - 他アプリから `apps` 型項目で参照されている場合は 409
        - レコード数・添付ファイル数が上限超過の場合は 422（タイムアウト予防）
        - 成功時は `204 No Content`（ボディなし）。再 DELETE は 404（冪等でない）
      operationId: deleteApp
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X DELETE "https://api.works.app/v2/settings/apps/{appKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
      responses:
        '204':
          description: 削除成功（ボディなし）
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '409':
          $ref: '#/components/responses/AppInUse'
        '422':
          $ref: '#/components/responses/BatchSizeExceeded'

  /settings/apps/{appKey}/copy:
    post:
      tags: [settings-apps]
      summary: アプリ複製
      description: |
        複製元アプリ（`appKey`）を複製して新規アプリを作成します。
        - フィールド定義・サブレコード・ロール・レイアウト・機能トグルを引き継ぐ（**レコードデータ本体は複製しない**）
        - 複製直後の `status` は `active`（画面のコピーと同じく、複製完了時点でアプリ一覧に表示される）
        - `newAppName` 省略時は「複製元名 - コピー」を自動補完
        - `newAppKey` 省略時はサーバー自動採番
        - 複製元が複製禁止（`copyAllowed:false`）の場合は 403
        - 成功時は `201 Created` ＋ `Location` ヘッダ
      operationId: copyApp
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/copy" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"newAppName": "日報アプリ - コピー", "newAppKey": "NIPPOCOPY"}'
      parameters:
        - $ref: '#/components/parameters/appKey'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppCopyRequest'
            examples:
              minimal:
                summary: 複製先名のみ（キーは自動採番）
                value:
                  newAppName: "日報アプリ - コピー"
              full:
                summary: 複製先名とキーを両方指定
                value:
                  newAppName: "日報アプリ - コピー"
                  newAppKey: "NIPPOCOPY"
      responses:
        '201':
          description: 複製成功
          headers:
            Location:
              description: 複製先アプリの URL
              schema:
                type: string
              example: "/v2/settings/apps/EFGH"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/AppCopyNotAllowed'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '409':
          $ref: '#/components/responses/AppConflict'
        '422':
          description: |
            バリデーションエラー（`validation_failed`）またはプラン上限超過（`plan_limit_exceeded`）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalidKey:
                  value:
                    error:
                      code: "validation_failed"
                      message: "入力内容に誤りがあります。"
                      details:
                        - field: "newAppKey"
                          code: "invalid_value"
                          message: "形式が正しくありません。"
                planLimit:
                  value:
                    error:
                      code: "plan_limit_exceeded"
                      message: "プラン上限に達しています。"

  /settings/apps/{appKey}/clear:
    post:
      tags: [settings-apps]
      summary: アプリ内データクリア
      description: |
        指定アプリ内のデータを `targets` で選んだ種別ごとにクリアします。**設定（項目定義等）は残します**。
        - **`targets` は必須**（1 件以上）。取り消しできない操作のため既定値は持たず、省略・空配列は 422 `required`
        - データの無い target を指定しても 200 ＋ `count:0`（冪等 no-op）
        - `records` を含む場合のみ件数上限チェック（超過時 422）
      operationId: clearAppData
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/clear" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"targets": ["records", "dashboards"]}'
      parameters:
        - $ref: '#/components/parameters/appKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AppClearRequest'
            examples:
              minimal:
                summary: レコードだけクリア（すぐ試せる）
                value:
                  targets: ["records"]
              full:
                summary: 指定できる種別をすべて指定
                value:
                  targets: ["records", "dashboards", "graphs", "customLists", "numbering", "customCodes", "aiOcr"]
      responses:
        '200':
          description: クリア実行サマリ
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AppClearResponse'
              example:
                summary:
                  records: { recordCount: 245, subrecordCount: 1024 }
                  dashboards: { count: 3 }
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          description: |
            バリデーションエラー（`validation_failed`）または件数上限超過（`batch_size_exceeded`）。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                batchSize:
                  value:
                    error:
                      code: "batch_size_exceeded"
                      message: "対象が上限を超えています。件数を分割して実行してください。"
                targetsRequired:
                  summary: targets 未指定・空配列（既定値を持たないため必ずエラー）
                  value:
                    error:
                      code: "validation_failed"
                      message: "入力内容に誤りがあります。"
                      details:
                        - field: "targets"
                          code: "required"
                          message: "クリア対象の種別 は必須項目です"
                invalidTarget:
                  value:
                    error:
                      code: "validation_failed"
                      message: "入力内容に誤りがあります。"
                      details:
                        - field: "targets.0"
                          code: "invalid_enum"
                          message: "許可されていない値です。"

  /settings/apps/{appKey}/fields:
    get:
      tags: [settings-apps-fields]
      summary: 項目一覧取得
      description: |
        アプリの項目定義一覧を返します。
        - **全件返し**（1 アプリあたり最大 100 件・ページネーションなし）。`limit` / `cursor` は使いません。詳細は冒頭「一覧の取得方式」
        - **`fields` 省略時**の最小セット: id / key / name / type / createdBy / createdAt / updatedAt。`fields=all` で required / searchable / remarks / `config` 等を含む
      operationId: listAppFields
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps/{appKey}/fields?fields=all" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - name: sort
          in: query
          description: |
            並び順。`displayOrder`（画面で設定した表示順）/ `name` / `key` / `createdAt` / `updatedAt` に `asc` / `desc` を組み合わせる。
            デフォルトは画面の表示順（配列順がそのまま画面の項目順）。
          schema:
            type: string
            default: "displayOrder desc"
          example: "displayOrder desc"
        - $ref: '#/components/parameters/fieldsQueryList'
      responses:
        '200':
          description: 項目一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldListResponse'
              example:
                fields:
                  - id: "229"
                    key: "text01"
                    name: "一行テキスト"
                    type: "text"
                    displayOrder: 40
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    createdAt: "2026-06-16T00:00:00Z"
                    updatedAt: "2026-06-16T00:00:00Z"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/FieldsQueryValidationError'

    post:
      tags: [settings-apps-fields]
      summary: 項目追加
      description: |
        アプリに新しい項目を追加します。**必須は `name`（項目名）と `type`（項目の型）だけ**。`key` は省略するとサーバーが自動採番します。
        型ごとの細かい設定は `config` にまとめる（中身は型によって異なる）。
        - 作成は **同期反映**（成功レスポンスの時点でデータ列が使える）
        - 成功時は `201 Created` ＋ `Location` ヘッダ（作成された field の URL）
        - 他の人が画面で同じアプリの項目を編集中だと `409 field_editing_conflict`
      operationId: createAppField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/fields" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"field": {"name": "会社名", "type": "text", "required": false, "config": {"matchType": "partial"}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FieldCreateRequest'
            examples:
              minimal:
                summary: 最小（必須のみ・すぐ試せる）
                value:
                  field:
                    name: "会社名"
                    type: "text"
              full:
                summary: 全項目入り（config は text 型の例。コピーして不要分を削る。他の型の config は FieldConfig スキーマで型を選んで確認）
                value:
                  field:
                    displayOrder: 25
                    name: "会社名"
                    type: "text"
                    key: "company"
                    required: true
                    searchable: true
                    sortable: false
                    showInList: true
                    showInDetail: true
                    isTitle: false
                    partOfUniqueKey: false
                    duplicateAllowed: true
                    enabled: true
                    remarks: "正式名称を入力してください"
                    config:
                      defaultValue: "株式会社"
                      matchType: "partial"
                      keywordSearchable: true
                      duplicateSearchable: false
                      inputCondition: null
                      convert: ["fullwidthDigitsToHalf"]
                      prefixText: ""
                      suffixText: ""
                      searchRemarks: null
                      font: { size: "default", color: null, weight: "normal" }
                      formSize: { value: null, unit: null }
                      conditionalDisplay: { fieldKey: null, values: [] }
                      roleGroup: null
      responses:
        '201':
          description: 作成された項目
          headers:
            Location:
              description: 作成された field の URL
              schema:
                type: string
              example: "/v2/settings/apps/OQXJ/fields/text05"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '409':
          $ref: '#/components/responses/FieldCreateConflict'
        '422':
          $ref: '#/components/responses/FieldCreateValidationError'

  /settings/apps/{appKey}/fields/{fieldKey}:
    get:
      tags: [settings-apps-fields]
      summary: 項目個別取得
      description: |
        指定項目の定義を単体で取得します。
        - **個別 GET**: `fields` 省略時はフル返却（`config` 含む）。一覧の最小限デフォルトとは異なる。詳細は冒頭「fields クエリ」
      operationId: getAppField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps/{appKey}/fields/{fieldKey}?fields=all" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/fieldKey'
        - $ref: '#/components/parameters/fieldsQueryItem'
      responses:
        '200':
          description: 項目定義
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldSingleResponse'
              example:
                field:
                  id: "229"
                  key: "text01"
                  name: "一行テキスト"
                  type: "text"
                  enabled: true
                  required: false
                  searchable: true
                  sortable: false
                  showInList: true
                  showInDetail: true
                  isTitle: false
                  partOfUniqueKey: false
                  duplicateAllowed: true
                  remarks: null
                  config:
                    defaultValue: null
                    matchType: "partial"
                    keywordSearchable: true
                    duplicateSearchable: false
                    inputCondition: null
                    convert: []
                    prefixText: ""
                    suffixText: ""
                    searchRemarks: null
                    font: { size: null, color: null, weight: null }
                    formSize: { value: null, unit: null }
                    conditionalDisplay: { fieldKey: null, values: [] }
                    roleGroup: null
                  createdAt: "2026-06-16T00:00:00Z"
                  updatedAt: "2026-06-16T00:00:00Z"
                  createdBy: { id: "ac000001", name: "佐藤 花子" }
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/FieldNotFound'
        '422':
          $ref: '#/components/responses/FieldsQueryValidationError'

    patch:
      tags: [settings-apps-fields]
      summary: 項目更新
      description: |
        指定項目を **部分更新（Merge Patch）** します。送ったキーだけ更新し、送らないキーは現状維持します。
        - `config` はトップレベルでマージ（送ったキーだけ上書き、他は維持）
        - **`config: null`** で config 全体を画面初期値へリセット（Works 独自。キー削除ではない）
        - `id` / `type` / `key` / `createdAt` / `updatedAt` / `createdBy` は変更不可（同値・null は無視、異値は 422 read_only）
        - 列の型を決める設定（number の `numericKind`、date / time の `inputPattern`、calc の `resultType`、user / group の `selectionCount` など）は作成後変更不可（422 read_only）
      operationId: updateAppField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X PATCH "https://api.works.app/v2/settings/apps/{appKey}/fields/{fieldKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"field": {"name": "更新後の項目名", "required": true, "config": {"matchType": "exact"}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/fieldKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FieldUpdateRequest'
            examples:
              minimal:
                summary: 1 項目だけ更新（送ったキーだけ反映）
                value:
                  field:
                    name: "更新後の項目名"
              full:
                summary: 複数項目＋config を更新（config は text 型の例。送ったキーのみ上書き）
                value:
                  field:
                    displayOrder: 40
                    name: "更新後の項目名"
                    required: true
                    showInList: true
                    remarks: "更新後の備考"
                    config:
                      matchType: "exact"
                      convert: ["fullwidthDigitsToHalf", "removeHyphens"]
                      font: { size: "large", color: "#ff0000", weight: "bold" }
              resetConfig:
                summary: config を画面初期値へ一括リセット（Works 独自）
                value:
                  field:
                    config: null
      responses:
        '200':
          description: 更新後の項目
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/FieldNotFound'
        '409':
          $ref: '#/components/responses/FieldUpdateConflict'
        '422':
          $ref: '#/components/responses/FieldUpdateValidationError'

    delete:
      tags: [settings-apps-fields]
      summary: 項目削除
      description: |
        指定項目を削除します。**データ列ごと消える取り消し不可の操作**（DROP COLUMN）。
        - 成功時 `204 No Content`（body なし）
        - 他アプリの lookup（参照項目）から参照されている場合は `409 field_has_linkage`
        - タイトル項目を削除してアプリのタイトル項目が無くなる場合は `422`（最低 1 つ必要）
      operationId: deleteAppField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X DELETE "https://api.works.app/v2/settings/apps/{appKey}/fields/{fieldKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/fieldKey'
      responses:
        '204':
          description: 削除成功（body なし）
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/FieldNotFound'
        '409':
          $ref: '#/components/responses/FieldDeleteConflict'
        '422':
          $ref: '#/components/responses/FieldDeleteValidationError'

  /settings/apps/{appKey}/fields/{fieldKey}/copy:
    post:
      tags: [settings-apps-fields]
      summary: 項目複製
      description: |
        指定項目を **複製**して同じアプリに新しい項目として追加します。複製元の設定（config 全キー）を引き継ぎます。
        - `name` / `key` は任意（省略時はサーバー自動採番：name は「{元の名前} - Copy」、key は連番）
        - ボディ `{}` でも複製可
        - 成功時 `201 Created` ＋ `Location` ヘッダ
        - **複製できない型**：カテゴリ（category）／タグ（tag）／マイリスト（mylist）／色（color）／計算（calc）／アプリ間連携（relation）／参照項目（lookup）。これらは共有マスタ・計算式・他アプリ連携に依存するため複製不可で、複製しようとすると 422 `field_type_not_copyable` を返します（画面でもコピー不可）。
      operationId: copyAppField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/fields/{fieldKey}/copy" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"field": {"name": "会社名（コピー）"}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/fieldKey'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FieldCopyRequest'
            examples:
              minimal:
                summary: 名前・キーは自動（空ボディでも可）
                value: {}
              full:
                summary: 複製先の name / key を指定
                value:
                  field:
                    name: "会社名（コピー）"
                    key: "companycopy"
      responses:
        '201':
          description: 複製された項目
          headers:
            Location:
              description: 作成された field の URL
              schema:
                type: string
              example: "/v2/settings/apps/OQXJ/fields/text06"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/FieldNotFound'
        '409':
          $ref: '#/components/responses/FieldCopyConflict'
        '422':
          $ref: '#/components/responses/FieldCopyValidationError'

  /settings/apps/{appKey}/subrecordTables:
    get:
      tags: [settings-apps-subrecord-tables]
      summary: サブレコードテーブル一覧取得
      description: |
        指定アプリのサブレコードテーブル（サブレコードテーブルの入れ物）を一覧で返します。公開・非公開どちらも全件返します。
        - **cursor ページネーション**（最大 1000 件）。`limit` / `cursor` / `sort` / `fields` が使えます
        - **`fields` 省略時**の最小セット: id / key / name / status / fieldCount / createdBy / createdAt
        - `icon` / `recordCount`（行数＝重い集計）・表示設定群（displayStyle 等）は `fields=all` または明示指定でのみ返します
      operationId: listSubrecordTables
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables?fields=all" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - name: sort
          in: query
          description: ソート指定（`{field} {asc|desc}`）
          schema:
            type: string
            default: "displayOrder desc"
            enum:
              - "displayOrder asc"
              - "displayOrder desc"
              - "name asc"
              - "name desc"
              - "createdAt asc"
              - "createdAt desc"
        - name: limit
          in: query
          description: 1 ページの最大件数（1〜1000）。省略時 1000。
          schema:
            type: integer
            default: 1000
          example: 100
        - name: cursor
          in: query
          description: 次ページ取得用の opaque カーソル（前レスポンスの `pagination.nextCursor`）。cursor だけ送れば続きが取れます（limit・検索条件の再送不要。ページ送り中のページサイズは最初のリクエストの limit で固定）。失効時は 400 `cursor_expired`。
          schema:
            type: string
        - $ref: '#/components/parameters/fieldsQueryList'
      responses:
        '200':
          description: サブレコードテーブル一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableListResponse'
              example:
                subrecordTables:
                  - id: "12"
                    key: "SB-aB3xY9"
                    name: "発注明細"
                    status: "active"
                    displayOrder: 30
                    fieldCount: 4
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    createdAt: "2026-06-20T00:00:00Z"
                pagination:
                  limit: 100
                  total: 3
                  hasMore: false
                  nextCursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/SubrecordTableQueryValidationError'

    post:
      tags: [settings-apps-subrecord-tables]
      summary: サブレコードテーブル作成
      description: |
        サブレコードテーブルを新規作成します。**必須は `name` のみ**。空の専用テーブルを DB に作成する DDL を伴います。
        - 作成直後の `status` は `inactive`（非公開）固定
        - **この操作では項目（列）は作りません**。項目は作成後に項目追加 EP（SFF-2）で足します。`fields` を送ると 422 `forbidden`
        - `id` / `key` / `status` などサーバー管理値の送信は 422 `forbidden`
        - 成功時は `201 Created` ＋ `Location` ヘッダ（`{subrecordTableKey}` は `SB-xxxxxx`・サーバー採番）
      operationId: createSubrecordTable
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"subrecordTable": {"name": "発注明細"}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubrecordTableCreateRequest'
            examples:
              minimal:
                summary: 必須のみ（name だけ・すぐ試せる）
                value:
                  subrecordTable:
                    name: "発注明細"
              full:
                summary: 送信可能な項目をほぼ網羅（コピーして不要分を削る）
                value:
                  subrecordTable:
                    displayOrder: 25
                    name: "発注明細"
                    icon: "fa fa-list"
                    displayStyle: "list"
                    displayScale: 20
                    defaultSortKey: "createdAt desc"
                    showInList: true
                    showSummary: false
                    defaultColumns: ["createdBy", "createdAt"]
                    hideEmptyFields: false
                    notificationEnabled: true
                    permissionGroup:
                      id: "1"
      responses:
        '201':
          description: 作成されたサブレコードテーブル
          headers:
            Location:
              description: 作成されたサブレコードテーブルの URL
              schema:
                type: string
              example: "/v2/settings/apps/OQXJ/subrecordTables/SB-aB3xY9"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/SubrecordTableCreateValidationError'

  /settings/apps/{appKey}/subrecordTables/{subrecordTableKey}:
    get:
      tags: [settings-apps-subrecord-tables]
      summary: サブレコードテーブル詳細取得
      description: |
        指定したサブレコードテーブル（`subrecordTableKey`）を 1 件返します。一覧の 1 件と同形式で、`fields` 省略時はフル返却です。
        - **個別 GET**: `fields` 省略時はフル返却（icon / recordCount / 表示設定を含む）。詳細は冒頭「fields クエリ」
      operationId: getSubrecordTable
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/fieldsQueryItem'
      responses:
        '200':
          description: サブレコードテーブル
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableSingleResponse'
              example:
                subrecordTable:
                  id: "12"
                  key: "SB-aB3xY9"
                  name: "発注明細"
                  status: "active"
                  icon: "fa fa-list"
                  fieldCount: 4
                  recordCount: 128
                  displayStyle: "list"
                  displayScale: 20
                  defaultSortKey: "createdAt desc"
                  showInList: true
                  bulkImport: false
                  showSummary: false
                  defaultColumns: ["createdBy", "createdAt"]
                  hideEmptyFields: false
                  notificationEnabled: true
                  permissionGroup: { id: "1", name: "管理者" }
                  createdBy: { id: "ac000001", name: "佐藤 花子" }
                  createdAt: "2026-06-20T00:00:00Z"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableNotFound'
        '422':
          $ref: '#/components/responses/SubrecordTableQueryValidationError'

    patch:
      tags: [settings-apps-subrecord-tables]
      summary: サブレコードテーブル更新
      description: |
        サブレコードテーブルのメタ・表示設定を **部分更新（Merge Patch）** します。送ったキーだけ更新し、送らないキーは現状維持します。
        - `status` で公開（`active`）/ 非公開（`inactive`）を切替
        - `defaultSortKey` は基本 3 オプション（`createdAt` / `updatedAt` / `displayOrder`）または並べ替え可能フィールドのみ受理（不正値は 422）
        - `id` / `key` などサーバー管理値・宣言外キーの送信は 422 `forbidden`
        - **項目（フィールド）の更新はここでは行いません**（項目更新は SFF-4）
      operationId: updateSubrecordTable
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X PATCH "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"subrecordTable": {"name": "発注明細（改訂）", "status": "active"}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubrecordTablePatchRequest'
            examples:
              minimal:
                summary: 単一フィールドの部分更新（送ったキーだけ更新）
                value:
                  subrecordTable:
                    status: "active"
              full:
                summary: 更新可能な項目をほぼ網羅（送ったキーのみ上書き）
                value:
                  subrecordTable:
                    displayOrder: 40
                    name: "発注明細（改訂）"
                    status: "active"
                    icon: "fa fa-table"
                    displayStyle: "block"
                    displayScale: 10
                    defaultSortKey: "displayOrder"
                    showInList: true
                    showSummary: true
                    defaultColumns: ["createdBy"]
                    hideEmptyFields: true
                    notificationEnabled: false
                    permissionGroup:
                      id: "2"
      responses:
        '200':
          description: 更新後のサブレコードテーブル
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableNotFound'
        '422':
          $ref: '#/components/responses/SubrecordTableUpdateValidationError'

    delete:
      tags: [settings-apps-subrecord-tables]
      summary: サブレコードテーブル削除
      description: |
        サブレコードテーブルを削除します。**専用テーブルごと削除（DROP TABLE）** し、親レコードの更新・ファイル削除・連携解除も連鎖する取り消し不可の破壊的操作です。
        - 既存のサブレコード行が残っている、または計算式から参照されている場合は 409 `subrecord_table_in_use`
        - 成功時は `204 No Content`（ボディなし）。再 DELETE は 404（冪等でない）
      operationId: deleteSubrecordTable
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X DELETE "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
      responses:
        '204':
          description: 削除成功（ボディなし）
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableNotFound'
        '409':
          $ref: '#/components/responses/SubrecordTableInUse'

  /settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/clear:
    post:
      tags: [settings-apps-subrecord-tables]
      summary: サブレコードテーブルの行データクリア
      description: |
        サブレコードテーブルの**行データだけを全消し（TRUNCATE ＋関連ファイル削除）** します。**種別定義・テーブル・項目は残します**（種別自体を消すのは SF-5）。
        - 消した行数を `summary.clearedCount` で返します
        - ボディは空でも構いませんが、`Content-Type: application/json` は必須です
      operationId: clearSubrecordTableData
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/clear" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              description: ボディなし（空オブジェクト）。Content-Type のみ必須。
            example: {}
      responses:
        '200':
          description: クリア実行サマリ
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableClearResponse'
              example:
                summary:
                  clearedCount: 128
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableNotFound'

  /settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields:
    get:
      tags: [settings-apps-subrecord-table-fields]
      summary: サブレコード項目一覧取得
      description: |
        指定したサブレコードテーブルの項目（列）定義を一覧で返します。使用中・未使用の両方を返します。
        - **全件返し**（ページネーションなし。メインの項目一覧に合わせて全件）。`limit` / `cursor` は使えません（送ると 422 `forbidden`）
        - **`fields` 省略時**の最小セット: id / key / name / type / createdBy / createdAt / updatedAt。`fields=all` で required / config 等を含む
        - 項目オブジェクトの形はメインレコードの項目と同一です（`Field` を参照）
      operationId: listSubrecordTableFields
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields?fields=all" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
        - name: sort
          in: query
          description: |
            並び順。`displayOrder`（画面の表示順）/ `name` / `key` / `createdAt` / `updatedAt` に `asc` / `desc` を組み合わせます。省略時は表示順。
          schema:
            type: string
            default: "displayOrder desc"
          example: "displayOrder desc"
        - $ref: '#/components/parameters/fieldsQueryList'
      responses:
        '200':
          description: サブレコード項目一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableFieldListResponse'
              example:
                fields:
                  - id: "512"
                    key: "text01"
                    name: "商品名"
                    type: "text"
                    displayOrder: 30
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    createdAt: "2026-06-20T00:00:00Z"
                    updatedAt: "2026-06-20T00:00:00Z"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableNotFound'
        '422':
          $ref: '#/components/responses/SubrecordTableQueryValidationError'

    post:
      tags: [settings-apps-subrecord-table-fields]
      summary: サブレコード項目追加
      description: |
        サブレコードテーブルに項目（列）を追加します。**必須は `name` と `type`**（`key` は省略でサーバー自動採番）。テーブルへの列追加（ADD COLUMN）を伴います。
        契約はメインレコードの項目追加と同一ですが、サブレコードテーブル固有の制限があります。
        - **使えない型**：カテゴリ（category）／タグ（tag）／マイリスト（mylist）／色（color）／ラベル（label）→ 送ると 422（`field=type`）
        - **タイトル・複合ユニーク非対応**：`isTitle` / `partOfUniqueKey` は送ると 422 `forbidden`（`duplicateAllowed`＝重複登録はサブでも設定できます）
        - **自動採番の制限**：autoNumber の `startNumber` / `resetDate` はサブでは使えず 422 `forbidden`
        - 成功時は `201 Created` ＋ `Location` ヘッダ
      operationId: createSubrecordTableField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"field": {"name": "商品名", "type": "text"}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubrecordTableFieldCreateRequest'
            examples:
              minimal:
                summary: 最小（必須のみ・すぐ試せる）
                value:
                  field:
                    name: "商品名"
                    type: "text"
              full:
                summary: 全項目入り（config は text 型の例。他の型の config は FieldConfig スキーマで型を選んで確認。サブ非対応の isTitle / partOfUniqueKey は含めない）
                value:
                  field:
                    displayOrder: 25
                    name: "商品名"
                    type: "text"
                    key: "item"
                    required: true
                    searchable: true
                    sortable: false
                    showInList: true
                    showInDetail: true
                    enabled: true
                    remarks: "商品の正式名称"
                    config:
                      defaultValue: ""
                      matchType: "partial"
                      keywordSearchable: true
                      convert: []
                      prefixText: ""
                      suffixText: ""
                      font: { size: "default", color: null, weight: "normal" }
                      roleGroup: null
      responses:
        '201':
          description: 作成されたサブレコード項目
          headers:
            Location:
              description: 作成された項目の URL
              schema:
                type: string
              example: "/v2/settings/apps/OQXJ/subrecordTables/SB-aB3xY9/fields/text01"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableFieldSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableNotFound'
        '409':
          $ref: '#/components/responses/SubrecordTableFieldCreateConflict'
        '422':
          $ref: '#/components/responses/SubrecordTableFieldCreateValidationError'

  /settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields/{fieldKey}:
    get:
      tags: [settings-apps-subrecord-table-fields]
      summary: サブレコード項目個別取得
      description: |
        サブレコードテーブルの項目 1 件を単体で取得します。未使用項目も取得できます。
        - **個別 GET**: `fields` 省略時はフル返却（`config` 含む）。詳細は冒頭「fields クエリ」
        - autoNumber 項目でも `startNumber` / `resetDate` は返りません（サブの制限と往復で一致）
      operationId: getSubrecordTableField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields/{fieldKey}?fields=all" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/fieldKey'
        - $ref: '#/components/parameters/fieldsQueryItem'
      responses:
        '200':
          description: サブレコード項目定義
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableFieldSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableFieldNotFound'
        '422':
          $ref: '#/components/responses/SubrecordTableQueryValidationError'

    patch:
      tags: [settings-apps-subrecord-table-fields]
      summary: サブレコード項目更新
      description: |
        サブレコード項目を **部分更新（Merge Patch）** します。送ったキーだけ更新し、送らないキーは現状維持します。契約はメインの項目更新と同一です。
        - `config` はトップレベルでマージ（`config: null` で config 全体を画面初期値へリセット）
        - `id` / `type` / `key` / `createdAt` / `updatedAt` / `createdBy` は変更不可（同値・null は無視、異値は 422 `read_only`）
        - サブ非対応の `isTitle` / `partOfUniqueKey`、autoNumber の `startNumber` / `resetDate` は 422 `forbidden`（`duplicateAllowed`＝重複登録はサブでも更新できます）
      operationId: updateSubrecordTableField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X PATCH "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields/{fieldKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"field": {"name": "商品名（更新）", "required": true}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/fieldKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubrecordTableFieldUpdateRequest'
            examples:
              minimal:
                summary: 1 項目だけ更新（送ったキーだけ反映）
                value:
                  field:
                    name: "商品名（更新）"
              full:
                summary: 複数項目＋config を更新（config は text 型の例。送ったキーのみ上書き）
                value:
                  field:
                    displayOrder: 40
                    name: "商品名（更新）"
                    required: true
                    showInList: true
                    remarks: "更新後の備考"
                    config:
                      matchType: "exact"
                      convert: ["fullwidthDigitsToHalf"]
              resetConfig:
                summary: config を画面初期値へ一括リセット（Works 独自）
                value:
                  field:
                    config: null
      responses:
        '200':
          description: 更新後のサブレコード項目
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableFieldSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableFieldNotFound'
        '409':
          $ref: '#/components/responses/FieldUpdateConflict'
        '422':
          $ref: '#/components/responses/SubrecordTableFieldUpdateValidationError'

    delete:
      tags: [settings-apps-subrecord-table-fields]
      summary: サブレコード項目削除
      description: |
        サブレコード項目を削除します。**データ列ごと消える取り消し不可の操作**（DROP COLUMN）。既存サブレコードのその値は失われます。
        - 成功時 `204 No Content`（body なし）
        - 他アプリの lookup（参照項目）から参照されている場合は 409 `field_has_linkage`
      operationId: deleteSubrecordTableField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X DELETE "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields/{fieldKey}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/fieldKey'
      responses:
        '204':
          description: 削除成功（body なし）
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableFieldNotFound'
        '409':
          $ref: '#/components/responses/FieldDeleteConflict'

  /settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields/{fieldKey}/copy:
    post:
      tags: [settings-apps-subrecord-table-fields]
      summary: サブレコード項目複製
      description: |
        サブレコード項目を **複製**して同じ種別に新しい項目として追加します（ADD COLUMN）。複製元の設定（config 全キー）を引き継ぎます。
        - `name` / `key` は任意（省略時はサーバー自動採番：name は「{元の名前} - Copy」、key は連番）
        - ボディ `{}` でも複製可
        - **複製できない型**：色（color）／計算（calc）／アプリ間連携（relation）／参照項目（lookup）等（共有マスタ・計算式・他アプリ連携依存）は 422 `field_type_not_copyable`
        - 成功時 `201 Created` ＋ `Location` ヘッダ
      operationId: copySubrecordTableField
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/settings/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields/{fieldKey}/copy" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"field": {"name": "商品名（コピー）"}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/fieldKey'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FieldCopyRequest'
            examples:
              minimal:
                summary: 名前・キーは自動（空ボディでも可）
                value: {}
              full:
                summary: 複製先の name / key を指定
                value:
                  field:
                    name: "商品名（コピー）"
                    key: "itemcopy"
      responses:
        '201':
          description: 複製されたサブレコード項目
          headers:
            Location:
              description: 作成された項目の URL
              schema:
                type: string
              example: "/v2/settings/apps/OQXJ/subrecordTables/SB-aB3xY9/fields/text02"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableFieldSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableFieldNotFound'
        '409':
          $ref: '#/components/responses/FieldCopyConflict'
        '422':
          $ref: '#/components/responses/SubrecordTableFieldCopyValidationError'

  /apps/{appKey}/fields:
    get:
      tags: [records]
      summary: 入力スキーマ参照（レコード項目定義の取得）
      description: |
        レコードの登録・更新に必要な項目定義（項目キー・型・必須・単複・値の送信形・書き込み可否・選択肢・入力制約）を返します。
        - **設定権限（アプリ設定の権限）が無いトークンでも取得できます**。レコードを書く人が「どのキーに何をどう送るか」を知るための EP です
        - 返す範囲は画面のレコード登録フォームが見せている情報に限定します（初期値・採番フォーマット・計算式・項目権限・条件付き表示などの設定情報は返しません）
        - 画面が入力時に見せている制約（入力値条件・数値の範囲/桁）は `constraints` で返します（該当しない項目は `null`）
        - 項目設定の全量が必要な場合は `GET /settings/apps/{appKey}/fields` を使います（こちらはアプリ設定の権限が必要です）
        - 閲覧できない項目（項目の権限グループで制限されたもの）は返しません。閲覧はできるが編集できない項目は `writable: false` で返ります
        - 参照項目（`lookup`）は同期参照なら `writable: false`、都度参照なら `writable: true` で返ります。都度参照には通常の値のほか `{"sync": true}`（参照先レコードの現在値を取り込む同期指示）も送れます
        - 値を持たない型（グループラベル）は返しません
        - ページングはありません（項目は最大 100 件のため全件返します）
      operationId: getAppFieldSchema
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/fields"           -H "x-api-key: {APIキー}"           -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
      responses:
        '200':
          description: 項目定義一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldSchemaListResponse'
              example:
                fields:
                  - key: "text01"
                    label: "件名"
                    type: "text"
                    required: true
                    multiple: false
                    valueShape: "scalar"
                    writable: true
                    options: null
                  - key: "checkbox01"
                    label: "対応区分"
                    type: "checkbox"
                    required: false
                    multiple: true
                    valueShape: "scalarList"
                    writable: true
                    options:
                      - value: "A"
                        label: "A"
                        color: "#ff0000"
                      - value: "B"
                        label: "B"
                        color: null
                  - key: "category"
                    label: "分類"
                    type: "category"
                    required: false
                    multiple: false
                    valueShape: "objectId"
                    writable: true
                    options:
                      - value: "22"
                        label: "営業 > 新規"
                        color: null
                  - key: "num02"
                    label: "金額範囲"
                    type: "number"
                    required: false
                    multiple: false
                    valueShape: "range"
                    writable: true
                    options: null
                    constraints: { range: { min: 0, max: 100000 } }
                  - key: "calc01"
                    label: "合計"
                    type: "calc"
                    required: false
                    multiple: false
                    valueShape: "none"
                    writable: false
                    options: null
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/FieldSchemaQueryValidationError'

  /apps/{appKey}/subrecordTables:
    get:
      tags: [records]
      summary: 種別一覧（サブレコードテーブルの取得）
      description: |
        明細（サブレコード）の登録・参照に必要な種別（サブレコードテーブル）の一覧を返します。
        - **設定権限（アプリ設定の権限）が無いトークンでも取得できます**。返った `key` を明細の入力スキーマ参照や明細 CRUD の `subrecordTableKey` に使います
        - 返す範囲は画面のレコード詳細の種別タブが見せている情報（キー・名称）に限定します。種別設定の全量が必要な場合は `GET /settings/apps/{appKey}/subrecordTables` を使います（アプリ設定の権限が必要です）
        - 公開中（画面に表示される）の種別のみ・種別の閲覧権限グループで絞ります（画面と同じ範囲）
        - サブレコード機能が無効のアプリは 403（`subrecord_disabled`）
        - ページングはありません（種別は少数のため全件返します）
      operationId: listSubrecordTableSchemas
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/subrecordTables"           -H "x-api-key: {APIキー}"           -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
      responses:
        '200':
          description: 種別一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubrecordTableSchemaListResponse'
              example:
                subrecordTables:
                  - key: "SB-aB3xY9"
                    name: "対応履歴"
                  - key: "SB-Zk20qP"
                    name: "見積明細"
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordForbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/FieldSchemaQueryValidationError'

  /apps/{appKey}/subrecordTables/{subrecordTableKey}/fields:
    get:
      tags: [records]
      summary: 明細の入力スキーマ参照（サブレコード項目定義の取得）
      description: |
        明細（サブレコード）の登録・更新に必要な項目定義を返します。レスポンスの形・各キーの意味は
        メインの入力スキーマ参照（`GET /apps/{appKey}/fields`）と同じです（`FieldSchema` 参照）。
        - **設定権限（アプリ設定の権限）が無いトークンでも取得できます**
        - 明細には分類・タグ・カラー・マイリスト・グループラベルの型が存在しないため、`type` は明細で使える 23 型のみ・`valueShape` に `objectId` / `objectIdList` は現れません
        - 閲覧できない項目（項目の権限グループで制限されたもの）は返しません。閲覧はできるが編集できない項目は `writable: false` で返ります
        - 非公開・閲覧権限外の種別は 404（`subrecord_table_not_found`）
        - サブレコード機能が無効のアプリは 403（`subrecord_disabled`）
        - ページングはありません（項目は最大 100 件のため全件返します）
      operationId: getSubrecordTableFieldSchema
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/subrecordTables/{subrecordTableKey}/fields"           -H "x-api-key: {APIキー}"           -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/subrecordTableKey'
      responses:
        '200':
          description: 明細の項目定義一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FieldSchemaListResponse'
              example:
                fields:
                  - key: "text01"
                    label: "対応内容"
                    type: "text"
                    required: true
                    multiple: false
                    valueShape: "scalar"
                    writable: true
                    options: null
                  - key: "date01"
                    label: "対応日"
                    type: "date"
                    required: false
                    multiple: false
                    valueShape: "scalar"
                    writable: true
                    options: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordForbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableNotFound'
        '422':
          $ref: '#/components/responses/FieldSchemaQueryValidationError'

  /apps/{appKey}/records:
    get:
      tags: [records]
      summary: レコード一覧取得
      description: |
        指定アプリの閲覧可能なレコードを一覧で返します。
        - 既定の並びは登録順（`dt_code` 昇順）。`sort` / `order` で並べ替え可能
        - opaque cursor 方式のページング（`pagination.nextCursor` を次の `cursor` に渡す）
        - `fields` で返却キーを絞り込み可能（`?fields=id,title,fields.text01`）。省略時はシステム項目のみ（`fields` は含みません）
        - 閲覧権限のないレコード・カテゴリは返しません（画面と同じ権限で絞り込み）
      operationId: listRecords
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/records?limit=100&sort=createdAt&order=desc" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - name: fields
          in: query
          description: |
            返却するトップレベルキーの絞り込み（カンマ区切り）。`fields.{fieldKey}` で `fields` 配下の個別項目も指定できます。
            省略時はシステム項目のみ・`all` で全キー・`fields` で全ユーザー定義項目。
          schema:
            type: string
          example: "id,title,createdAt,fields.text01"
        - name: sort
          in: query
          description: |
            並べ替えキー。システム項目（`id` / `createdAt` / `updatedAt` / `title` / `category`）またはソート可（sortable=true）のユーザー項目。
            非対応キーは 422。省略時は登録順（`dt_code` 昇順）。
            項目キーがシステム項目と同名の場合（例: 項目キー `title`）は `fields.title` のように `fields.` を付けるとユーザー項目を指定できます
            （`fields.` を付けないキーは常にシステム項目が優先。`?fields=` の個別指定と同じ表記）。
          schema:
            type: string
          example: "createdAt"
        - name: order
          in: query
          description: 並び順（`asc` 昇順 / `desc` 降順）。`sort` 指定時のみ有効・省略時 `desc`。
          schema:
            type: string
            enum: [asc, desc]
            default: desc
        - name: limit
          in: query
          description: 1 ページの最大件数（1〜1000。0 以下は既定・1001 以上は 1000 に切り詰め）。省略時 1000。
          schema:
            type: integer
            default: 1000
          example: 100
        - name: cursor
          in: query
          description: 次ページ取得用の opaque カーソル（前レスポンスの `pagination.nextCursor`）。cursor だけ送れば続きが取れます（limit・検索条件の再送不要。ページ送り中のページサイズは最初のリクエストの limit で固定）。失効時は 400 `cursor_expired`。
          schema:
            type: string
      responses:
        '200':
          description: レコード一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordListResponse'
              example:
                records:
                  - id: "3"
                    title: "田中商事"
                    createdAt: "2026-04-23T00:30:00Z"
                    updatedAt: null
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    updatedBy: null
                  - id: "2"
                    title: "山田物産"
                    createdAt: "2026-04-22T05:00:00Z"
                    updatedAt: "2026-04-22T06:00:00Z"
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    updatedBy: { id: "ac000001", name: "佐藤 花子" }
                pagination:
                  limit: 100
                  total: 245
                  hasMore: true
                  nextCursor: "eyJzdiI6IjEyMyIsInBhZ2UiOjJ9"
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/RecordListValidationError'

    post:
      tags: [records]
      summary: レコード登録
      description: |
        アプリにレコードを 1 件登録します。
        - `record.fields` に各項目の値を型別の形で渡します（各型の形は `RecordFieldValueWrite` を参照）
        - `title` はタイトル項目の値から自動設定されます（`title` を直接指定しません）
        - **省略した項目には画面の新規フォームと同じ初期値が入ります**（初期値〔defaultValue〕を持つ型＝一行 / 複数行テキスト・URL・都道府県・数値・カテゴリ、および日付・時刻・ユーザー / グループの動的初期値〔当日・現在時刻・作成者など〕）。空文字・`null` の明示送信は初期値でなくクリアとして扱います
        - 読み取り専用の型（`calc` / `lookup` の同期参照、`numbering` の手動採番以外）への値送信は 422 `read_only`
        - 項目編集権限（editRoleGroup）で編集できない項目に値を送っても反映されません（項目ごとの既定値になります。アプリ所有者は全項目を編集可）
        - バリデーション（必須・形式・一意制約など）は画面ロジックに委譲します
        - 成功時は `201 Created` ＋ `Location` ヘッダ（作成レコードの URL）
      operationId: createRecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"record": {"fields": {"text01": "田中商事"}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordCreateRequest'
            examples:
              minimal:
                summary: 必須のみ（タイトル項目だけ・すぐ試せる）
                value:
                  record:
                    fields:
                      text01: "田中商事"
              full:
                summary: 送信可能な型を代表的に網羅（fieldKey は対象アプリの項目定義に合わせる。読み取り専用の calc / lookup の同期参照は送信不可のため非掲載。lookup の都度参照は送信可）
                value:
                  record:
                    fields:
                      text01: "田中商事"
                      textarea01: "初回訪問メモ"
                      select01: "A"
                      radio01: "1"
                      checkbox01: ["1", "2"]
                      number01: 12345
                      number02: { from: 10, to: 100 }
                      date01: "2026-04-23"
                      datetime01: "2026-04-23T00:30:00Z"
                      time01: "09:30"
                      email01: "info@example.com"
                      url01: "https://example.com"
                      zipCode01: "1500001"
                      prefecture01: "東京都"
                      personName01: "山田 太郎"
                      address01:
                        postalCode: "1500001"
                        prefecture: "東京都"
                        city: "渋谷区"
                        houseNumber: "1-2-3"
                        building: "○○ビル"
                      user01: "ac000001"
                      user02: ["ac000001", "ac000002"]
                      group01: "ug001"
                      password01: "secret123"
                      category01: { id: "5" }
                      color01: "green"
                      tag01: [{ id: "3" }]
                      mylist01: [{ id: "7" }]
                      apps01: { appKey: "ABCD", recordId: "42" }
                      numbering01: "MAN-001"
                      file01: { fileKey: "97-1782492047", name: "report.pdf" }
      responses:
        '201':
          description: 作成成功
          headers:
            Location:
              description: 作成されたレコードの URL
              schema:
                type: string
              example: "/v2/apps/OQXJ/records/3"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordSingleResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/RecordCreateValidationError'

  /apps/{appKey}/records/{recordId}:
    get:
      tags: [records]
      summary: レコード取得（個別）
      description: |
        指定レコード（`recordId` = dt_code 素体）を 1 件返します。
        - `fields` で返却キーを絞り込み可能（一覧 EP と同じルール）
        - アプリ不在・レコード不在・閲覧権限なし・`recordId` 非数値はすべて 404（存在を漏らしません）
      operationId: getRecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/records/{recordId}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - name: fields
          in: query
          description: 返却キーの絞り込み（カンマ区切り・`fields.{fieldKey}` で個別項目・`all` で全キー）
          schema:
            type: string
          example: "id,title,fields.text01"
      responses:
        '200':
          description: レコード
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordSingleResponse'
              example:
                record:
                  id: "3"
                  title: "田中商事"
                  createdAt: "2026-04-23T00:30:00Z"
                  updatedAt: null
                  createdBy: { id: "ac000001", name: "佐藤 花子" }
                  updatedBy: null
                  fields:
                    text01: "田中商事"
                    number01: 12345
                    date01: "2026-04-23"
                    category01: { id: "5", name: "売上 > 首都圏" }
                    user01: { id: "ac000001", name: "佐藤 花子" }
                    file01: { fileKey: "97-1782492047", name: "report.pdf", size: 20480, contentType: "application/pdf" }
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/RecordNotFound'
        '422':
          $ref: '#/components/responses/RecordGetValidationError'

    patch:
      tags: [records]
      summary: レコード部分更新
      description: |
        指定レコードを部分更新します（JSON Merge Patch 相当）。
        - `record.fields` に更新したい項目のみ渡します。**未送信は現在値を維持・`null` / 空はクリア**
        - 値の形は登録（POST）と同じ（`RecordFieldValueWrite` を参照）
        - 読み取り専用の型への値送信は 422 `read_only`
        - 項目編集権限（editRoleGroup）で編集できない項目に値を送っても反映されません（現在値を維持。アプリ所有者は全項目を編集可）
        - 成功時は `200` ＋ 更新後レコード全体（取得 GET と同形式）
      operationId: updateRecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X PATCH "https://api.works.app/v2/apps/{appKey}/records/{recordId}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"record": {"fields": {"text01": "田中商事（更新）"}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordPatchRequest'
            examples:
              minimal:
                summary: 単一項目の部分更新（送ったキーだけ更新）
                value:
                  record:
                    fields:
                      text01: "田中商事（更新）"
              full:
                summary: 複数項目の更新＋クリア（`null`）。未送信キーは現在値を維持
                value:
                  record:
                    fields:
                      text01: "田中商事（更新）"
                      number01: 20000
                      date01: "2026-05-01"
                      checkbox01: ["1"]
                      category01: { id: "6" }
                      user02: ["ac000001"]
                      memo01: null
      responses:
        '200':
          description: 更新後のレコード
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordSingleResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/RecordNotFound'
        '422':
          $ref: '#/components/responses/RecordUpdateValidationError'

    delete:
      tags: [records]
      summary: レコード削除
      description: |
        指定レコードを 1 件削除します。
        - サブレコード・添付ファイル・関連テーブル・アプリ間連携の参照も連動削除します（linkage は自動解除）
        - アプリ不在・レコード不在・閲覧 / 削除権限なし・`recordId` 非数値はすべて 404（存在を漏らしません）
        - 成功時は `204 No Content`（取り消し不可・冪等ではない＝再 DELETE は 404）
      operationId: deleteRecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X DELETE "https://api.works.app/v2/apps/{appKey}/records/{recordId}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
      responses:
        '204':
          description: 削除成功（ボディなし）
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/RecordNotFound'

  /apps/{appKey}/records/{recordId}/copy:
    post:
      tags: [records]
      summary: レコード複製
      description: |
        既存レコード（`recordId`）を複製して新規レコードを 1 件作成します。画面の詳細メニュー「複製」に相当します。
        - `record.fields` で複製先のメイン項目を上書きできます（登録・更新と同じ書き込み契約。省略時は元レコードの値を継承）。読み取り専用型への値は 422 `read_only`
        - `includeSubrecordTables` に複製したいサブレコードテーブル（`SB-xxxx`）を並べます。省略時はサブレコードを複製しません
        - file は別ファイルとして複製・マイリスト/計算はクリア・自動採番は採番し直し（都度参照は継承）・ステータスは継承しません
        - 成功時は `201` ＋ Location ＋ 作成レコード（取得 GET と同形式）。**元レコードは変更されません**
        - `includeSubrecordTables` 指定時、サブレコード機能が無効なら 403 `subrecord_disabled`・種別が存在しなければ 404 `subrecord_table_not_found`・重複禁止かつ必須の項目を持つ種別は複製できず 422 `invalid_value`
      operationId: copyRecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records/{recordId}/copy" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"record": {"fields": {"text01": "田中商事（コピー）"}}, "includeSubrecordTables": ["SB-aB3xY9"]}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordCopyRequest'
            examples:
              minimal:
                summary: そのまま複製（上書き・サブなし・空ボディでも可）
                value: {}
              full:
                summary: メイン項目を上書きしつつ、指定サブ種別も複製
                value:
                  record:
                    fields:
                      text01: "田中商事（コピー）"
                  includeSubrecordTables: ["SB-aB3xY9"]
      responses:
        '201':
          description: 複製された新レコード
          headers:
            Location:
              description: 作成されたレコードの URL
              schema:
                type: string
              example: "/v2/apps/OQXJ/records/128"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordSingleResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/RecordNotFound'
        '422':
          $ref: '#/components/responses/RecordCopyValidationError'

  /apps/{appKey}/records/search:
    post:
      tags: [records]
      summary: レコード検索
      description: |
        条件を指定してアプリのレコードを検索し、一覧で返します（画面の詳細検索と同等）。
        - `filters` に項目ごとの条件を並べます（フィルタ間は AND）。各条件の形は項目の型で変わります（`RecordFilter` を参照）
        - ユーザー項目だけでなく**システム項目**（`id` / `title` / `createdAt` / `updatedAt` / `createdBy` / `updatedBy`＝画面の詳細検索「基本情報」）でも絞り込めます
        - 項目キーがシステム項目と同名のときは `fields.{fieldKey}`（例: `fields.title`）でユーザー項目を指定します（詳細は `RecordFilter` を参照）
        - `keyword` でフリーワード検索（`keywordMatch` で and/or）。`keyword` と `filters` は AND で結合します
        - 並び替え（`sort` / `order`）・ページング（`limit` / `cursor`）・返却キー絞り込み（`fields`）は一覧取得（`listRecords`）と同じ
        - 閲覧権限のないレコード・カテゴリは返しません（画面と同じ権限で絞り込み）
        - パスワード（`pwd`）・アプリ間連携（`relation`）は検索対象外（指定すると 422 `invalid_value`）

        #### よくある検索のレシピ（コピペ用）

        ```json
        { "filters": [ { "field": "text01", "value": "商事" } ] }
        ```
        テキスト項目を値で絞り込み（一致の仕方は項目設定に従う）

        ```json
        { "filters": [ { "field": "updatedAt", "relative": "today" } ] }
        ```
        今日更新されたレコードだけ取得（差分同期の基本形。`createdAt` の `from` / `to` で期間指定も可）

        ```json
        { "filters": [ { "field": "id", "value": "153" }, { "field": "createdBy", "in": ["ac000002"] } ] }
        ```
        レコード ID の完全一致と作成者を AND で組み合わせ（値はレスポンスの `id` / `createdBy.id` と同じ）

        ```json
        { "filters": [ { "field": "num01", "from": "100", "to": "500" } ] }
        ```
        数値・日付・時刻の範囲。`from` / `to` は片方だけでも可

        ```json
        { "filters": [ { "field": "date01", "relative": "thisMonth" } ] }
        ```
        相対期間（`today`=今日 / `thisMonth`=今月 / `lastMonth`=先月 / `nextMonth`=来月 / `thisYear`=今年 / `lastYear`=去年 / `nextYear`=来年 / `none`=未登録）

        ```json
        { "filters": [ { "field": "checkbox01", "in": ["1", "2"], "match": "and" } ] }
        ```
        選択肢は `in` のいずれかに一致。checkbox・複数 user / group は `match` を `"and"` にすると「すべて含む」

        ```json
        { "filters": [ { "field": "text01", "value": "商事" }, { "field": "date01", "relative": "thisMonth" } ], "keyword": "東京" }
        ```
        複合条件 — `filters` 同士も `keyword` との組み合わせもすべて AND
      operationId: searchRecords
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records/search" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"filters":[{"field":"text01","value":"商事"},{"field":"num01","from":"100","to":"500"}],"keyword":"東京","limit":100}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - name: fields
          in: query
          required: false
          description: |
            返却するトップレベルキーの絞り込み（カンマ区切り）。`fields.{fieldKey}` で `fields` 配下の個別項目も指定できます。
            省略時はシステム項目のみ・`all` で全キー・`fields` で全ユーザー定義項目。一覧取得（`listRecords`）と同じ。
          schema:
            type: string
          example: "id,title,createdAt,fields.text01"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordSearchRequest'
            examples:
              minimal:
                summary: テキスト項目の一致で絞り込み
                value:
                  filters:
                    - field: "text01"
                      value: "商事"
                  limit: 100
              full:
                summary: 複数条件（型別＋システム項目）＋キーワード＋並び替え
                value:
                  filters:
                    - field: "text01"
                      value: "商事"
                    - field: "num01"
                      from: "100"
                      to: "500"
                    - field: "date01"
                      relative: "thisMonth"
                    - field: "updatedAt"
                      relative: "today"
                    - field: "createdBy"
                      in: ["ac000002"]
                    - field: "select01"
                      in: ["1", "2"]
                    - field: "checkbox01"
                      in: ["1", "3"]
                      match: "and"
                    - field: "category"
                      in: ["5"]
                    - field: "file01"
                      exists: true
                  keyword: "東京 支店"
                  keywordMatch: "and"
                  sort: "createdAt"
                  order: "desc"
                  limit: 100
      responses:
        '200':
          description: 検索結果（一覧）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordListResponse'
              example:
                records:
                  - id: "900"
                    title: "田中商事"
                    createdAt: "2026-06-25T15:06:40Z"
                    updatedAt: null
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    updatedBy: null
                pagination:
                  limit: 100
                  total: 12
                  hasMore: false
                  nextCursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/AppNotFound'
        '422':
          $ref: '#/components/responses/RecordSearchValidationError'

  /apps/{appKey}/records/by/{key}:
    get:
      tags: [records]
      summary: キー指定でレコード一覧（分類・カスタムリスト・サブレコードテーブル）
      description: |
        分類・カスタムリスト・サブレコードテーブルのキーを指定して、そのキーが指す「既製の一覧」を返します（`by` ＝ キーで一覧を引く）。
        任意の条件を組み立てるアドホック検索は `POST /records/search`（`searchRecords`）を使ってください。この EP はキー照会専用です。
        - `CA-{カテゴリID}`＝カテゴリ、`CO-{カラーID}`＝カラー、`TG-{タグID}`＝タグ、`MY-{マイリストID}`＝マイリスト（本人のもののみ）
        - `CL-{保存リストキー}`＝保存済みカスタムリスト。保存された検索条件で毎回検索し直します（最新データ・現在の閲覧権限を反映）
        - `SB-{サブレコードテーブルキー}`＝サブレコードテーブル一覧。**応答の形が変わります**：該当明細を持つメインレコードの一覧で、各レコード直下にその明細を `subRecords` として内包します（明細をフラットに返すのではなく「メインレコードの中に明細」。ページングは明細粒度で `total` は明細総数）
        - 返却キー絞り込み（`fields`）・ページング（`limit` / `cursor`）は一覧取得と同じ
        - 未定義の接頭辞・接頭辞なしは 400、存在しない / 閲覧権限のないキーは 404
        - `SB-` でサブレコード機能が無効なら 403 `subrecord_disabled`、テーブルが存在しなければ 404 `subrecord_table_not_found`
      operationId: listRecordsByKey
      x-codeSamples:
      - lang: cURL
        label: 分類キー（カテゴリ）
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/records/by/CA-5?limit=100" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      - lang: cURL
        label: サブレコードテーブル
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/records/by/SB-aB3xY9?limit=100" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/byKey'
        - name: fields
          in: query
          required: false
          description: 返却するトップレベルキーの絞り込み（一覧取得と同じ。`SB-` のときはメインレコードのキー）。
          schema:
            type: string
          example: "id,title,createdAt"
        - name: limit
          in: query
          required: false
          description: 1 ページの最大件数（1〜1000。省略時 1000。`SB-` のときは明細粒度）。
          schema:
            type: integer
          example: 100
        - name: cursor
          in: query
          required: false
          description: 次ページ取得用カーソル（前ページ応答の `pagination.nextCursor`）。
          schema:
            type: string
      responses:
        '200':
          description: 該当レコード（一覧）。`SB-` キーのときは明細を内包した形
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/RecordListResponse'
                  - $ref: '#/components/schemas/RecordWithSubRecordsListResponse'
              examples:
                classification:
                  summary: 分類・カスタムリストキー（CA-/CO-/TG-/MY-/CL-）
                  value:
                  records:
                    - id: "900"
                      title: "田中商事"
                      createdAt: "2026-06-25T15:06:40Z"
                      updatedAt: null
                      createdBy: { id: "ac000001", name: "佐藤 花子" }
                      updatedBy: null
                  pagination:
                    limit: 100
                    total: 3
                    hasMore: false
                    nextCursor: null
                subrecordTable:
                  summary: サブレコードテーブルキー（SB-）＝明細を内包
                  value:
                  records:
                    - id: "14"
                      title: "A社 案件"
                      createdAt: "2026-06-25T15:06:40Z"
                      updatedAt: null
                      createdBy: { id: "ac000001", name: "佐藤 花子" }
                      updatedBy: null
                      fields:
                        text01: "A社"
                      subRecords:
                        - id: "10"
                          recordId: "14"
                          createdAt: "2026-06-25T15:10:00Z"
                          updatedAt: null
                          createdBy: { id: "ac000001", name: "佐藤 花子" }
                          updatedBy: null
                          fields:
                            memo: "初回訪問"
                            qty: 3
                  pagination:
                    limit: 100
                    total: 12
                    hasMore: false
                    nextCursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/ByKeyForbidden'
        '404':
          $ref: '#/components/responses/ByKeyNotFound'
        '422':
          $ref: '#/components/responses/RecordGetValidationError'

  /apps/{appKey}/records/by/{key}/search:
    post:
      tags: [records]
      summary: キー指定の一覧に絞り込みを重ねて検索
      description: |
        分類・カスタムリスト・サブレコードテーブルのキーが指す一覧を土台に、さらに条件（`filters` / `keyword`）を AND で重ねて検索します
        （画面の「分類を選んだ状態でさらに詳細検索」と同じ）。土台の指定は `GET /records/by/{key}`（`listRecordsByKey`）、
        重ねる条件の書き方は `POST /records/search`（`searchRecords`）と同じです。
        - `CA-{カテゴリID}` / `CO-{カラーID}` / `TG-{タグID}` / `MY-{マイリストID}`（本人のもののみ）＝分類を土台にする
        - `CL-{保存リストキー}`＝保存済みカスタムリストを土台にする。保存条件で毎回検索し直した上に `filters` / `keyword` を重ねます（最新データ・現在の閲覧権限を反映）
        - `SB-{サブレコードテーブルキー}`＝サブレコードテーブル動的検索。明細を条件で絞り込み、該当明細を持つメインレコードを返します（`subRecords` 内包・`filters` はメイン項目と明細項目を AND 併用可・`keyword` はメインの索引が対象・ページングは明細粒度・`sort` はメイン＋システム項目のみ）
        - `filters` / `keyword` を省略すると土台セットそのまま（`GET /records/by/{key}` と同じ結果。ただし `CL-` はライブ）
        - 未定義の接頭辞・`CL-` のサブレコードテーブル保存検索は 400。存在しない / 閲覧権限のない `CL-` は 404
        - `SB-` でサブレコード機能が無効なら 403 `subrecord_disabled`、テーブルが存在しなければ 404 `subrecord_table_not_found`
      operationId: searchRecordsByKey
      x-codeSamples:
      - lang: cURL
        label: 分類キー（カテゴリ）＋追加条件
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records/by/CA-5/search" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"filters":[{"field":"text01","value":"商事"}],"limit":100}'
      - lang: cURL
        label: サブレコードテーブル＋明細条件
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records/by/SB-aB3xY9/search" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"filters":[{"field":"memo","value":"訪問"}],"limit":100}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/byKey'
        - name: fields
          in: query
          required: false
          description: |
            返却するトップレベルキーの絞り込み（カンマ区切り）。`fields.{fieldKey}` で `fields` 配下の個別項目も指定できます。
            省略時はシステム項目のみ・`all` で全キー・`fields` で全ユーザー定義項目。一覧取得（`listRecords`）と同じ。
          schema:
            type: string
          example: "id,title,createdAt,fields.text01"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordSearchRequest'
            examples:
              baseOnly:
                summary: 追加条件なし（土台セットそのまま）
                value:
                  limit: 100
              refine:
                summary: 土台＋追加の型別条件＋キーワード
                value:
                  filters:
                    - field: "text01"
                      value: "商事"
                    - field: "num01"
                      from: "100"
                      to: "500"
                  keyword: "東京"
                  keywordMatch: "and"
                  sort: "createdAt"
                  order: "desc"
                  limit: 100
              detailFilter:
                summary: サブレコードテーブル（SB-）＝明細項目で絞る
                value:
                  filters:
                    - field: "memo"
                      value: "訪問"
                  limit: 100
      responses:
        '200':
          description: 検索結果（一覧）。`SB-` キーのときは明細を内包した形
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/RecordListResponse'
                  - $ref: '#/components/schemas/RecordWithSubRecordsListResponse'
              examples:
                classification:
                  summary: 分類・カスタムリストキー（CA-/CO-/TG-/MY-/CL-）
                  value:
                  records:
                    - id: "900"
                      title: "田中商事"
                      createdAt: "2026-06-25T15:06:40Z"
                      updatedAt: null
                      createdBy: { id: "ac000001", name: "佐藤 花子" }
                      updatedBy: null
                  pagination:
                    limit: 100
                    total: 4
                    hasMore: false
                    nextCursor: null
                subrecordTable:
                  summary: サブレコードテーブルキー（SB-）＝明細を内包
                  value:
                  records:
                    - id: "14"
                      title: "A社 案件"
                      createdAt: "2026-06-25T15:06:40Z"
                      updatedAt: null
                      createdBy: { id: "ac000001", name: "佐藤 花子" }
                      updatedBy: null
                      fields:
                        text01: "A社"
                      subRecords:
                        - id: "10"
                          recordId: "14"
                          createdAt: "2026-06-25T15:10:00Z"
                          updatedAt: null
                          createdBy: { id: "ac000001", name: "佐藤 花子" }
                          updatedBy: null
                          fields:
                            memo: "初回訪問"
                            qty: 3
                  pagination:
                    limit: 100
                    total: 3
                    hasMore: false
                    nextCursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/ByKeyForbidden'
        '404':
          $ref: '#/components/responses/ByKeyNotFound'
        '422':
          $ref: '#/components/responses/RecordSearchValidationError'

  /apps/{appKey}/records/by/{key}/{customListKey}:
    get:
      tags: [records]
      summary: サブレコードテーブル保存検索（明細を親レコードに内包）
      description: |
        サブレコードテーブルの保存カスタムリスト（`CL-`）の保存条件で明細を検索し、該当明細を持つメインレコードを一覧で返します（`subRecords` 内包）。保存された検索条件で毎回検索し直します（最新データ・現在の閲覧権限を反映）。
        - 2 番目のキーは `CL-{保存リストキー}` のみ指定できます（他の接頭辞は 400 `request_param_invalid`）
        - サブレコードテーブル用に保存されたリストのみ対象です。メイン用リスト・別種別のリストを指定すると 404 `record_not_found`
        - 返却キー絞り込み（`fields`）・ページング（`limit` / `cursor`）は一覧取得と同じ
        - サブレコード機能が無効なら 403 `subrecord_disabled`、種別が存在しなければ 404 `subrecord_table_not_found`、保存リストが存在しない・閲覧権限が無ければ 404 `record_not_found`
      operationId: listSubrecordTableRecordsBySavedList
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/records/by/SB-aB3xY9/CL-abc123?limit=100" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - name: key
          in: path
          required: true
          description: サブレコードテーブルキー（この経路では `SB-` のみ指定できます。形式不正は 400 `request_param_invalid`）。
          schema:
            type: string
          example: "SB-aB3xY9"
        - $ref: '#/components/parameters/byCustomListKey'
        - name: fields
          in: query
          required: false
          description: 返却するトップレベルキーの絞り込み（メインレコードのキー・一覧取得と同じ）。
          schema:
            type: string
          example: "id,title,fields.text01"
        - name: limit
          in: query
          required: false
          description: 1 ページの最大件数（明細粒度・1〜1000。省略時 1000）。
          schema:
            type: integer
          example: 100
        - name: cursor
          in: query
          required: false
          description: 次ページ取得用カーソル（前ページ応答の `pagination.nextCursor`）。
          schema:
            type: string
      responses:
        '200':
          description: 該当メインレコード（明細を内包）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordWithSubRecordsListResponse'
              example:
                records:
                  - id: "14"
                    title: "A社 案件"
                    createdAt: "2026-06-25T15:06:40Z"
                    updatedAt: null
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    updatedBy: null
                    fields:
                      text01: "A社"
                    subRecords:
                      - id: "10"
                        recordId: "14"
                        createdAt: "2026-06-25T15:10:00Z"
                        updatedAt: null
                        createdBy: { id: "ac000001", name: "佐藤 花子" }
                        updatedBy: null
                        fields:
                          memo: "初回訪問"
                          qty: 3
                pagination:
                  limit: 100
                  total: 5
                  hasMore: false
                  nextCursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordForbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableSavedListNotFound'
        '422':
          $ref: '#/components/responses/RecordGetValidationError'

  /apps/{appKey}/records/by/{key}/{customListKey}/search:
    post:
      tags: [records]
      summary: サブレコードテーブル保存検索＋絞り込み（明細を親レコードに内包）
      description: |
        サブレコードテーブルの保存カスタムリスト（`CL-`）の保存条件を土台に、さらに条件（`filters` / `keyword`）を AND で重ねて検索します。土台の指定は `GET /records/by/{key}/{customListKey}`、重ねる条件の書き方は `POST /records/by/{key}/search` と同じです。
        - 2 番目のキーは `CL-{保存リストキー}` のみ指定できます（他の接頭辞は 400 `request_param_invalid`）
        - 保存条件と同じ項目に条件を重ねた場合は、後から指定した条件が優先されます（保存条件をプリフィルしたフォームを編集して検索するのと同じ）
        - `filters` / `keyword` を省略すると保存条件そのまま（`GET /records/by/{key}/{customListKey}` と同じ結果）
        - サブレコード機能が無効なら 403 `subrecord_disabled`、種別が存在しなければ 404 `subrecord_table_not_found`、保存リストが存在しない・閲覧権限が無ければ 404 `record_not_found`
      operationId: searchSubrecordTableRecordsBySavedList
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records/by/SB-aB3xY9/CL-abc123/search" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"filters":[{"field":"text01","value":"A社"}],"limit":100}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - name: key
          in: path
          required: true
          description: サブレコードテーブルキー（この経路では `SB-` のみ指定できます。形式不正は 400 `request_param_invalid`）。
          schema:
            type: string
          example: "SB-aB3xY9"
        - $ref: '#/components/parameters/byCustomListKey'
        - name: fields
          in: query
          required: false
          description: 返却するトップレベルキーの絞り込み（メインレコードのキー・一覧取得と同じ）。
          schema:
            type: string
          example: "id,title,fields.text01"
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordSearchRequest'
            examples:
              baseOnly:
                summary: 追加条件なし（保存条件そのまま）
                value:
                  limit: 100
              refine:
                summary: 保存条件＋追加の絞り込み
                value:
                  filters:
                    - field: "text01"
                      value: "A社"
                  keyword: "案件"
                  limit: 100
      responses:
        '200':
          description: 検索結果（明細を内包したメインレコード）
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecordWithSubRecordsListResponse'
              example:
                records:
                  - id: "14"
                    title: "A社 案件"
                    createdAt: "2026-06-25T15:06:40Z"
                    updatedAt: null
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    updatedBy: null
                    fields:
                      text01: "A社"
                    subRecords:
                      - id: "10"
                        recordId: "14"
                        createdAt: "2026-06-25T15:10:00Z"
                        updatedAt: null
                        createdBy: { id: "ac000001", name: "佐藤 花子" }
                        updatedBy: null
                        fields:
                          memo: "初回訪問"
                          qty: 3
                pagination:
                  limit: 100
                  total: 2
                  hasMore: false
                  nextCursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordForbidden'
        '404':
          $ref: '#/components/responses/SubrecordTableSavedListNotFound'
        '422':
          $ref: '#/components/responses/RecordSearchValidationError'

  /apps/{appKey}/records/{recordId}/files/{fileKey}:
    get:
      tags: [records]
      summary: 添付ファイルのダウンロード
      description: |
        レコードの添付ファイル項目に紐づくファイル実体をバイナリで直接返却します。`fileKey` はレコード取得のレスポンス（`RecordValueFile.fileKey`）に含まれる値をそのまま使います。
        - レスポンスは JSON ではなくファイルバイナリ（`Content-Disposition: attachment`）
        - 認可はレコード取得と同一（アプリの利用権限 → レコードの閲覧権限 → 項目の閲覧権限）
        - 指定した `fileKey` が**そのレコードの閲覧できる添付ファイル項目のものでない**場合は `404`。別レコードのファイル・権限で隠れている項目のファイル・レコードに紐づく前のファイルはいずれも区別せず `404` を返す
      operationId: downloadRecordFile
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/OQXJ/records/1/files/97-1782492047" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -o report.pdf
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/fileKey'
      responses:
        '200':
          description: ファイル実体（バイナリ直レスポンス）
          headers:
            Content-Disposition:
              description: 添付ファイル名
              schema:
                type: string
              example: 'attachment; filename="97-1782492047.pdf"'
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/RecordForbidden'
        '404':
          $ref: '#/components/responses/FileNotFound'

  /apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords:
    get:
      tags: [records-subrecords]
      summary: サブレコード一覧取得
      description: |
        指定レコード（`recordId`）・指定種別（`subrecordTableKey`）配下のサブレコード（明細行）を一覧で返します。
        - 既定の並びは登録順（`id` = ds_code 昇順）。`sort` / `order` で並べ替え可能
        - opaque cursor 方式のページング（`pagination.nextCursor` を次の `cursor` に渡す）
        - `fields` で返却キーを絞り込み可能（`?fields=id,fields.memo`）。省略時はシステム項目のみ（`fields` は含みません）
        - 明細項目の値の形はメインレコードと同じ（`RecordFieldValue` を参照）
      operationId: listSubrecords
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords?limit=100&sort=createdAt&order=desc" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/subrecordTableKey'
        - name: fields
          in: query
          description: |
            返却するトップレベルキーの絞り込み（カンマ区切り）。`fields.{fieldKey}` で `fields` 配下の個別項目も指定できます。
            省略時はシステム項目のみ・`all` で全キー・`fields` で全ユーザー定義項目。
          schema:
            type: string
          example: "id,createdAt,fields.memo"
        - $ref: '#/components/parameters/subrecordSort'
        - $ref: '#/components/parameters/subrecordOrder'
        - name: limit
          in: query
          description: 1 ページの最大件数（1〜1000。0 以下は既定・1001 以上は 1000 に切り詰め）。省略時 1000。
          schema:
            type: integer
            default: 1000
          example: 100
        - name: cursor
          in: query
          description: 次ページ取得用の opaque カーソル（前レスポンスの `pagination.nextCursor`）。cursor だけ送れば続きが取れます（limit の再送不要。ページ送り中のページサイズは最初のリクエストの limit で固定）。失効・破損時は 400 `cursor_expired`。
          schema:
            type: string
      responses:
        '200':
          description: サブレコード一覧
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubRecordListResponse'
              example:
                subRecords:
                  - id: "3"
                    recordId: "1"
                    createdAt: "2026-04-23T00:30:00Z"
                    updatedAt: null
                    createdBy: { id: "ac000001", name: "佐藤 花子" }
                    updatedBy: null
                    fields:
                      memo: "初回訪問"
                      qty: 3
                pagination:
                  limit: 100
                  total: 12
                  hasMore: false
                  nextCursor: null
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordForbidden'
        '404':
          $ref: '#/components/responses/SubrecordParentNotFound'
        '422':
          $ref: '#/components/responses/SubrecordListValidationError'

    post:
      tags: [records-subrecords]
      summary: サブレコード登録
      description: |
        指定レコード・指定種別に明細行を 1 件登録します。
        - `subRecord.fields` に各項目の値を型別の形で渡します（各型の形は `RecordFieldValueWrite` を参照）
        - 省略した項目には画面の新規フォームと同じ初期値が入ります（初期値を持つ型・動的初期値。空文字・`null` の明示送信はクリア）
        - 読み取り専用の型（`calc` / `lookup` の同期参照、`numbering` の手動採番以外）への値送信は 422 `read_only`
        - バリデーション（必須・形式など）は画面ロジックに委譲します
        - 成功時は `201 Created` ＋ `Location` ヘッダ（作成サブレコードの URL）
      operationId: createSubrecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"subRecord": {"fields": {"memo": "初回訪問", "qty": 3}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/subrecordTableKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubRecordCreateRequest'
            examples:
              minimal:
                summary: 1 項目だけ（すぐ試せる）
                value:
                  subRecord:
                    fields:
                      memo: "初回訪問"
              full:
                summary: 送信可能な型を代表的に網羅（fieldKey は対象種別の項目定義に合わせる。読み取り専用の calc / lookup の同期参照は送信不可のため非掲載。lookup の都度参照は送信可・サブレコードテーブルでは分類/色/タグ/マイリストは使用不可）
                value:
                  subRecord:
                    fields:
                      memo: "初回訪問メモ"
                      textarea01: "詳細な記録"
                      select01: "A"
                      checkbox01: ["1", "2"]
                      qty: 12345
                      number02: { from: 10, to: 100 }
                      date01: "2026-04-23"
                      time01: "09:30"
                      user01: "ac000001"
                      user02: ["ac000001", "ac000002"]
                      file01: { fileKey: "97-1782492047", name: "report.pdf" }
      responses:
        '201':
          description: 作成成功
          headers:
            Location:
              description: 作成されたサブレコードの URL
              schema:
                type: string
              example: "/v2/apps/OQXJ/records/1/subrecordTables/SB-aB3xY9/subrecords/3"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubRecordSingleResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordWriteForbidden'
        '404':
          $ref: '#/components/responses/SubrecordParentNotFound'
        '422':
          $ref: '#/components/responses/SubrecordCreateValidationError'

  /apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords/{subrecordId}:
    get:
      tags: [records-subrecords]
      summary: サブレコード取得（個別）
      description: |
        指定のサブレコード（`subrecordId` = ds_code 素体）を 1 件返します。
        - `fields` で返却キーを絞り込み可能（一覧 EP と同じルール）
        - `subrecordId` が別レコード・別種別の行だった場合は 404（親レコード `recordId` ＋種別 `subrecordTableKey` でスコープ）
      operationId: getSubrecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords/{subrecordId}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/subrecordId'
        - name: fields
          in: query
          description: 返却キーの絞り込み（カンマ区切り・`fields.{fieldKey}` で個別項目・`all` で全キー）
          schema:
            type: string
          example: "id,fields.memo"
      responses:
        '200':
          description: サブレコード
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubRecordSingleResponse'
              example:
                subRecord:
                  id: "3"
                  recordId: "1"
                  createdAt: "2026-04-23T00:30:00Z"
                  updatedAt: null
                  createdBy: { id: "ac000001", name: "佐藤 花子" }
                  updatedBy: null
                  fields:
                    memo: "初回訪問"
                    qty: 3
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordForbidden'
        '404':
          $ref: '#/components/responses/SubrecordNotFound'
        '422':
          $ref: '#/components/responses/SubrecordListValidationError'

    patch:
      tags: [records-subrecords]
      summary: サブレコード部分更新
      description: |
        指定のサブレコードを部分更新します（JSON Merge Patch 相当）。
        - `subRecord.fields` の送信した項目だけ更新・未送信は維持・`null` / 空はクリア
        - 読み取り専用の型への値送信は 422 `read_only`
        - `subrecordId` が別レコード・別種別の行だった場合は 404
      operationId: updateSubrecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X PATCH "https://api.works.app/v2/apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords/{subrecordId}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"subRecord": {"fields": {"memo": "更新後メモ"}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/subrecordId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubRecordPatchRequest'
            examples:
              minimal:
                summary: 1 項目だけ更新（他は維持）
                value:
                  subRecord:
                    fields:
                      memo: "更新後メモ"
              clear:
                summary: 項目をクリア（null で空に）
                value:
                  subRecord:
                    fields:
                      memo: null
      responses:
        '200':
          description: 更新成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubRecordSingleResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordWriteForbidden'
        '404':
          $ref: '#/components/responses/SubrecordNotFound'
        '422':
          $ref: '#/components/responses/SubrecordUpdateValidationError'

    delete:
      tags: [records-subrecords]
      summary: サブレコード削除
      description: |
        指定のサブレコードを 1 件削除します。
        - 成功時は `204 No Content`（冪等：2 回目は 404）
        - `subrecordId` が別レコード・別種別の行だった場合は 404（親レコード＋種別でスコープ）
      operationId: deleteSubrecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X DELETE "https://api.works.app/v2/apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords/{subrecordId}" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}"
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/subrecordId'
      responses:
        '204':
          description: 削除成功（ボディなし）
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordWriteForbidden'
        '404':
          $ref: '#/components/responses/SubrecordNotFound'

  /apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords/{subrecordId}/copy:
    post:
      tags: [records-subrecords]
      summary: サブレコード複製
      description: |
        既存のサブレコード（`subrecordId`）を、同じ親レコード・同じ種別内に複製して新規サブレコードを 1 件作成します。画面のサブレコード「複製」に相当します。
        - `subRecord.fields` で複製先の項目を上書きできます（登録・更新と同じ書き込み契約。省略時は複製元の値を継承）。読み取り専用型への値は 422 `read_only`
        - 空ボディ `{}`（またはボディなし）で複製元をそのまま複製します
        - file は別ファイルとして複製・計算はクリア（新行で再計算）・自動採番は採番し直し（都度参照は継承）・その他の型（選択肢/ユーザー/パスワード/アプリ間連携/参照項目など）は値を継承します
        - 成功時は `201` ＋ Location ＋ 作成サブレコード（取得 GET と同形式・行に `subrecordTableKey` は含めません）。**複製元は変更されません**
        - `subrecordId` が別レコード・別種別の行だった場合は 404 `subrecord_not_found`（親レコード `recordId` ＋種別 `subrecordTableKey` でスコープ）
      operationId: copySubrecord
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords/{subrecordId}/copy" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -H "Content-Type: application/json" \
          -d '{"subRecord": {"fields": {"memo": "初回訪問（コピー）"}}}'
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/subrecordId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubRecordCopyRequest'
            examples:
              minimal:
                summary: そのまま複製（上書きなし・空ボディでも可）
                value: {}
              full:
                summary: 一部項目を上書きしつつ複製
                value:
                  subRecord:
                    fields:
                      memo: "初回訪問（コピー）"
      responses:
        '201':
          description: 複製された新サブレコード
          headers:
            Location:
              description: 作成されたサブレコードの URL
              schema:
                type: string
              example: "/v2/apps/OQXJ/records/1/subrecordTables/SB-aB3xY9/subrecords/17"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubRecordSingleResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordWriteForbidden'
        '404':
          $ref: '#/components/responses/SubrecordNotFound'
        '422':
          $ref: '#/components/responses/SubrecordCopyValidationError'

  /apps/{appKey}/records/{recordId}/subrecordTables/{subrecordTableKey}/subrecords/{subrecordId}/files/{fileKey}:
    get:
      tags: [records-subrecords]
      summary: 添付ファイルのダウンロード（サブレコード）
      description: |
        サブレコードの添付ファイル項目に紐づくファイル実体をバイナリで直接返却します。`fileKey` はサブレコード取得のレスポンスに含まれる値をそのまま使います。
        - レスポンスは JSON ではなくファイルバイナリ（`Content-Disposition: attachment`）
        - 認可はサブレコード取得と同一（アプリの利用権限 → サブレコード機能 → 親レコードの閲覧権限 → 種別の閲覧権限 → 項目の閲覧権限）
        - 指定した `fileKey` が**そのサブレコード行の閲覧できる添付ファイル項目のものでない**場合は `404`
      operationId: downloadSubrecordFile
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X GET "https://api.works.app/v2/apps/OQXJ/records/1/subrecordTables/SB-aB3xY9/subrecords/17/files/97-1782492047" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -o report.pdf
      parameters:
        - $ref: '#/components/parameters/appKey'
        - $ref: '#/components/parameters/recordId'
        - $ref: '#/components/parameters/subrecordTableKey'
        - $ref: '#/components/parameters/subrecordId'
        - $ref: '#/components/parameters/fileKey'
      responses:
        '200':
          description: ファイル実体（バイナリ直レスポンス）
          headers:
            Content-Disposition:
              description: 添付ファイル名
              schema:
                type: string
              example: 'attachment; filename="97-1782492047.pdf"'
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/SubrecordForbidden'
        '404':
          $ref: '#/components/responses/FileNotFound'

  /files:
    post:
      tags: [files]
      summary: ファイルアップロード
      description: |
        multipart/form-data の単一パート `file` を 1 件アップロードし、`fileKey` を返却します。
        - アップロードしたファイルはテナント単位で一時保存され、`fileKey` をレコードへの紐付けに使う（実体の取得はレコード添付後の `GET /apps/{appKey}/records/{recordId}/files/{fileKey}`。アップロード時点では所属レコードが未定＝権限判定ができないため、global なダウンロード EP は提供しない）
        - global エンドポイント（特定アプリに属さない・テナント認証のみ）
        - 1 リクエスト 1 ファイル（パート名は `file` 固定）
        - ファイルサイズ上限 10MB は API Gateway が強制し、超過時は Gateway が `413` を返す（本 API 独自のサイズエラーコードは返さない）
      operationId: uploadFile
      x-codeSamples:
      - lang: cURL
        source: |
          curl -X POST "https://api.works.app/v2/files" \
          -H "x-api-key: {APIキー}" \
          -H "x-token: {APIアクセストークン}" \
          -F "file=@./report.pdf"
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: アップロードするファイル（単一パート・パート名は file 固定）
              required: [file]
      responses:
        '201':
          description: アップロード成功（一時保存・fileKey 返却）
          headers:
            Location:
              description: アップロードしたファイルのダウンロード URL
              schema:
                type: string
              example: "/v2/files/97-1782492047"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FileUploadResponse'
              example:
                file:
                  fileKey: "97-1782492047"
                  name: "report.pdf"
                  size: 20480
                  contentType: "application/pdf"
                  createdAt: "2026-06-27T01:00:47Z"
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '415':
          $ref: '#/components/responses/NotMultipart'
        '422':
          $ref: '#/components/responses/FileUploadValidationError'

components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: API キー
    token:
      type: apiKey
      in: header
      name: x-token
      description: アクセストークン

  parameters:
    appKey:
      name: appKey
      in: path
      required: true
      description: アプリキー（4文字英数大文字）
      schema:
        type: string
      example: "OQXJ"
    fieldKey:
      name: fieldKey
      in: path
      required: true
      description: 項目キー（af_name、英数字小文字）
      schema:
        type: string
      example: "text01"
    subrecordTableKey:
      name: subrecordTableKey
      in: path
      required: true
      description: サブレコードテーブルキー（`sb_key`・`SB-` + 英数字 6 文字・サーバー採番）。常に種別を指します。内部連番 `id` を渡した場合や形式不正は 400 `request_param_invalid`、未存在は 404 `subrecord_table_not_found`。
      schema:
        type: string
      example: "SB-aB3xY9"
    fileKey:
      name: fileKey
      in: path
      required: true
      description: ファイルキー（アップロード時に返却される `{数値}-{数値}` 形式のトークン）
      schema:
        type: string
      example: "97-1782492047"
    fieldsQueryList:
      name: fields
      in: query
      description: |
        返却項目の絞り込み（**トップレベル属性名のみ**・カンマ区切り）。`icon.name` 等のドット記法は不可（`fields=icon` で object 全体）。詳細は冒頭「fields クエリ › 基本原則」。
        - **省略**: 一覧 EP 用の最小セットのみ（識別子・軽い表示・監査メタ。`features` / `config` 等の重い属性は含まない）
        - **`all`**: スキーマ上の全属性
        - **`id,key,name`**: 明示指定
        ネスト（`icon.name` 等）→ 422 `fields_nested_not_supported`。未知の属性名 → 422 `fields_unknown`。
      schema:
        type: string
      example: "all"
    fieldsQueryItem:
      name: fields
      in: query
      description: |
        返却項目の絞り込み（**トップレベル属性名のみ**・カンマ区切り）。`icon.name` 等のドット記法は不可。詳細は冒頭「fields クエリ › 基本原則」。
        - **省略**: フル返却（全属性）
        - **`all`**: 全属性（省略と同義）
        - **`id,key,name`**: 指定属性のみ
        ネスト指定不可 → 422 `fields_nested_not_supported`。
      schema:
        type: string

    recordId:
      name: recordId
      in: path
      required: true
      description: レコード ID（サーバー採番の dt_code 素体・数値のみ。非数値は 404）
      schema:
        type: string
      example: "3"
    byKey:
      name: key
      in: path
      required: true
      description: |
        一覧を引くキー（接頭辞付き）。`CA-{カテゴリID}`（カテゴリ）/ `CO-{カラーID}`（カラー）/ `TG-{タグID}`（タグ）/
        `MY-{マイリストID}`（マイリスト・本人のもののみ）/ `CL-{保存リストキー}`（保存済みカスタムリスト）/
        `SB-{サブレコードテーブルキー}`（サブレコードテーブル・応答に明細を内包）。
        未定義の接頭辞・接頭辞なし・非数値 ID（`CL-` / `SB-` を除く）は 400。
      schema:
        type: string
      example: "CA-5"
    byCustomListKey:
      name: customListKey
      in: path
      required: true
      description: |
        サブレコードテーブル（`SB-xxxx`）配下で指定できるキーは `CL-{保存リストキー}`（保存カスタムリスト）のみです（他の接頭辞は 400 `request_param_invalid`）。
        メインレコード配下（`/records/by/{key}`）では `CA-`（カテゴリ）/ `CO-`（カラー）/ `TG-`（タグ）/ `MY-`（マイリスト）/ `CL-`（保存カスタムリスト）と `SB-`（サブレコードテーブル一覧）が使えますが、サブレコードテーブル配下では `CL-` のみです。
      schema:
        type: string
      example: "CL-abc123"
    subrecordId:
      name: subrecordId
      in: path
      required: true
      description: サブレコード行 ID（`ds_code` 素体・数値）。常に行を指します。親レコード（`recordId`）＋種別（`subrecordTableKey`）でスコープされ、別レコード・別種別の行 ID は 404。
      schema:
        type: string
      example: "3"
    subrecordSort:
      name: sort
      in: query
      description: |
        並べ替えキー（システム項目のみ）。`id`=登録順（ds_code）/ `createdAt`=作成日時 / `updatedAt`=更新日時。
        許可外は 422 `invalid_value`。省略時は `id`（登録順）。ユーザー定義項目での並べ替えは非対応。
      schema:
        type: string
        enum: [id, createdAt, updatedAt]
        default: id
    subrecordOrder:
      name: order
      in: query
      description: 並び順（`asc`=昇順 / `desc`=降順）。許可外は 422 `invalid_value`。省略時 `asc`。
      schema:
        type: string
        enum: [asc, desc]
        default: asc

  schemas:
    AccountRef:
      type: object
      nullable: true
      properties:
        id:
          type: string
          description: アカウントコード
        name:
          type: string
          description: アカウント名

    Pagination:
      type: object
      description: |
        cursor ページネーション付き一覧 EP のメタ情報。全件返し EP（アプリ一覧・項目一覧等）のレスポンスには**含まれません**。
        使い方はドキュメント冒頭「cursor ページネーション」を参照。
      properties:
        limit:
          type: integer
          description: リクエストされた取得件数
        total:
          type: integer
          description: 条件に一致する総件数
        hasMore:
          type: boolean
          description: 次ページの有無
        nextCursor:
          type: string
          nullable: true
          description: 次ページ取得用 opaque カーソル（hasMore=false の場合は null）

    AppIcon:
      type: object
      description: アイコン情報
      properties:
        name:
          type: string
          description: |
            アイコン名（works_icon マスタの日本語名）。
            スペースでアップロードした画像をアイコンにしているアプリは空文字を返す。更新で空文字を送った場合はアイコンを変えない。
          example: "日報"
        color:
          type: string
          description: アイコンカラー（hex）
          example: "#4a90d9"
        url:
          type: string
          description: アイコン画像 URL（サーバー生成・READ-ONLY）

    AppFeatures:
      type: object
      description: |
        機能トグル（各キーは boolean。OFF 時はキー自体が省略される場合あり）。
        各機能の説明・契約プラン・オプションの可否は [機能紹介（works.saaske.com/feature/）](https://works.saaske.com/feature/) を参照。
        契約プランで利用できない機能キーを送信すると 422 `validation_failed`（`details[].code` = `forbidden`）になります。
      properties:
        comment:
          type: boolean
          description: コメント
        dashboard:
          type: boolean
          description: ダッシュボード
        workflow:
          type: boolean
          description: ワークフロー
        subrecord:
          type: boolean
          description: サブレコード
        recordStatus:
          type: boolean
          description: レコード状態
        viewHistory:
          type: boolean
          description: 閲覧履歴
        documentExport:
          type: boolean
          description: 帳票エクスポート
        webform:
          type: boolean
          description: Web フォーム
        aiocr:
          type: boolean
          description: AI-OCR
        bulkMail:
          type: boolean
          description: 一括メール
        automation:
          type: boolean
          description: 自動化
        api:
          type: boolean
          description: API 連携

    AppRecordPermission:
      type: object
      description: レコード毎の権限設定
      properties:
        mode:
          type: string
          description: |-
            権限制御モード
            - `none`: 権限制御なし
            - `manual`: レコードごとに手動で権限を設定
            - `fixed`: 固定の権限グループを付与（`fixedGroup` で指定）
          enum: [none, manual, fixed]
        fixedGroup:
          type: string
          nullable: true
          description: 固定先の権限ロール ID（`mode=fixed` のときのみ意味あり）

    App:
      type: object
      description: アプリ設定オブジェクト
      properties:
        id:
          type: string
          description: アプリ ID
          example: "123"
        key:
          type: string
          description: アプリキー（3〜12 桁英数大文字）
          example: "OQXJ"
        status:
          type: string
          description: |-
            公開状態（stopped / created / error はサーバー管理。PATCH で変更できるのは active ⇄ inactive のみ）
            - `active`: 公開中（通常の利用可能状態）
            - `inactive`: 非公開（データは残る）
            - `stopped`: 利用停止中（決済エラー等でシステムが自動設定）
            - `created`: 新規作成中（最初の項目定義前の中間状態）
            - `error`: 致命的エラー／ストアからのインストール処理中
          enum: [active, inactive, stopped, created, error]
        name:
          type: string
          description: アプリ名
        shortName:
          type: string
          description: 短縮名
        group:
          type: string
          nullable: true
          description: アプリグループ ID（未所属は null）
        memo:
          type: string
          description: メモ
        color:
          type: string
          description: カラー
        icon:
          $ref: '#/components/schemas/AppIcon'
        qrcode:
          type: string
          description: QR コード画像 URL
        url:
          type: string
          description: アプリ画面 URL
        copyAllowed:
          type: boolean
          description: アプリ複製許可
        recordCount:
          type: integer
          description: レコード件数（個別取得 EP のみ。一覧では省略）
        recordPermission:
          $ref: '#/components/schemas/AppRecordPermission'
        features:
          $ref: '#/components/schemas/AppFeatures'
        createdBy:
          $ref: '#/components/schemas/AccountRef'
        createdAt:
          type: string
          format: date-time
          description: 作成日時（ISO 8601 UTC）
        updatedAt:
          type: string
          format: date-time
          description: 更新日時（ISO 8601 UTC）

    AppListResponse:
      type: object
      properties:
        apps:
          type: array
          items:
            $ref: '#/components/schemas/App'

    AppSingleResponse:
      type: object
      properties:
        app:
          $ref: '#/components/schemas/App'

    AppCreateRequest:
      type: object
      required: [app]
      properties:
        app:
          type: object
          required: [name]
          description: 作成するアプリ設定。必須は name のみ
          properties:
            name:
              type: string
              description: アプリ名（最大 255 文字）
              example: "新規アプリ"
            key:
              type: string
              description: アプリキー（省略時自動採番）
            shortName:
              type: string
              description: 短縮名（省略時 name と同値）
            group:
              type: string
              nullable: true
              description: アプリグループ ID
            memo:
              type: string
            color:
              type: string
            icon:
              type: object
              properties:
                name:
                  type: string
                color:
                  type: string
            copyAllowed:
              type: boolean
            features:
              $ref: '#/components/schemas/AppFeatures'
            recordPermission:
              $ref: '#/components/schemas/AppRecordPermission'

    AppPatchRequest:
      type: object
      required: [app]
      properties:
        app:
          type: object
          description: 更新するフィールドのみ（Merge Patch）
          properties:
            name:
              type: string
            shortName:
              type: string
            key:
              type: string
            group:
              type: string
              nullable: true
            memo:
              type: string
            color:
              type: string
            icon:
              type: object
              properties:
                name:
                  type: string
                color:
                  type: string
            copyAllowed:
              type: boolean
            status:
              type: string
              description: |-
                公開状態の切替（`active` ⇄ `inactive` のみ。stopped/created/error は変更不可）
                - `active`: 公開
                - `inactive`: 非公開
              enum: [active, inactive]
            features:
              $ref: '#/components/schemas/AppFeatures'
            recordPermission:
              $ref: '#/components/schemas/AppRecordPermission'

    AppCopyRequest:
      type: object
      properties:
        newAppName:
          type: string
          description: 複製先アプリ名（省略時「複製元名 - コピー」）
        newAppKey:
          type: string
          description: 複製先アプリキー（省略時自動採番）

    AppClearRequest:
      type: object
      properties:
        targets:
          type: array
          minItems: 1
          description: |-
            クリア対象の種別（複数可・**必須**。取り消しできない操作のため既定値は持たない）
            - `records`: レコード（サブレコード・添付ファイル含む）
            - `dashboards`: ダッシュボード
            - `graphs`: グラフ
            - `customLists`: カスタムリスト
            - `numbering`: 自動採番カウンタのリセット
            - `customCodes`: カスタムコード（定義と添付ファイル）
            - `aiOcr`: AI-OCR（設定・実行データ・添付ファイル）
          items:
            type: string
            enum: [records, dashboards, graphs, customLists, numbering, customCodes, aiOcr]
      required: [targets]

    AppClearSummaryRecords:
      type: object
      properties:
        recordCount:
          type: integer
          description: クリアしたメインレコード件数
        subrecordCount:
          type: integer
          description: クリアしたサブレコード件数（全種別合計）

    AppClearSummaryCount:
      type: object
      properties:
        count:
          type: integer
          description: 削除件数

    AppClearSummaryNumbering:
      type: object
      properties:
        fieldCount:
          type: integer
          description: リセットした採番項目数

    AppClearSummaryAiOcr:
      type: object
      properties:
        settingCount:
          type: integer
          description: 削除した AI-OCR 設定の件数
        dataCount:
          type: integer
          description: 削除した AI-OCR 実行データの件数

    AppClearResponse:
      type: object
      properties:
        summary:
          type: object
          description: 要求した target のキーのみ含む実行サマリ
          properties:
            records:
              $ref: '#/components/schemas/AppClearSummaryRecords'
            dashboards:
              $ref: '#/components/schemas/AppClearSummaryCount'
            graphs:
              $ref: '#/components/schemas/AppClearSummaryCount'
            customLists:
              $ref: '#/components/schemas/AppClearSummaryCount'
            numbering:
              $ref: '#/components/schemas/AppClearSummaryNumbering'
            customCodes:
              $ref: '#/components/schemas/AppClearSummaryCount'
            aiOcr:
              $ref: '#/components/schemas/AppClearSummaryAiOcr'

    FieldListResponse:
      type: object
      description: 項目定義一覧（ページネーション無し・全件）
      properties:
        fields:
          type: array
          items:
            $ref: '#/components/schemas/Field'

    FieldSingleResponse:
      type: object
      properties:
        field:
          $ref: '#/components/schemas/Field'

    Field:
      type: object
      description: 項目定義オブジェクト
      properties:
        id:
          type: string
          description: 項目ID（af_code、数値文字列）
          example: "229"
        key:
          type: string
          description: 項目キー（af_name、英数字小文字）
          example: "text01"
        name:
          type: string
          description: 項目名（af_title）
          example: "一行テキスト"
        type:
          type: string
          description: |
            項目の型（全 28 型）。`config` の中身はこの型によって変わります。
            （text / textarea / number / personName / tel / email / url / zipCode / prefecture /
            date / time / select / radio / checkbox / color / label / category / tag / mylist /
            user / group / file / password / calc / autoNumber / relation / lookup / address）
          example: "text"
        displayOrder:
          type: integer
          description: 表示順（大きいほど画面上部・常に 10 刻み。作成時に自動採番・PATCH で変更可。指定値は保存時に正規化）
          example: 30
        enabled:
          type: boolean
          description: 使用/未使用
        required:
          type: boolean
          description: 必須項目
        searchable:
          type: boolean
          description: 検索対象
        sortable:
          type: boolean
          description: ソート対象
        showInList:
          type: boolean
          description: 一覧表示の候補にする（実際の列表示はユーザー個別の一覧設定で決まる）
        showInDetail:
          type: boolean
          description: 詳細表示
        isTitle:
          type: boolean
          description: タイトル項目（型により設定可否あり）
        partOfUniqueKey:
          type: boolean
          description: 複合ユニークキーの構成メンバー（型により設定可否あり）
        duplicateAllowed:
          type: boolean
          description: 重複登録を許可する（false にできる対応型は text / number / date / personName / tel / email / url のみ）
        remarks:
          type: string
          nullable: true
          description: 入力時備考（空文字は null）
        config:
          $ref: '#/components/schemas/FieldConfig'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        createdBy:
          $ref: '#/components/schemas/AccountRef'

    FieldConfig:
      description: |-
        型固有設定。フィールドの `type` に応じて下記のいずれかの形になる（type を選んで該当する config を確認する）。
        未設定のキーは `null` またはスケルトンで返り、その値をそのまま PATCH に渡して往復できる。
      oneOf:
        - $ref: "#/components/schemas/FieldConfigText"
        - $ref: "#/components/schemas/FieldConfigTextarea"
        - $ref: "#/components/schemas/FieldConfigEmail"
        - $ref: "#/components/schemas/FieldConfigUrl"
        - $ref: "#/components/schemas/FieldConfigZipCode"
        - $ref: "#/components/schemas/FieldConfigPassword"
        - $ref: "#/components/schemas/FieldConfigTel"
        - $ref: "#/components/schemas/FieldConfigNumber"
        - $ref: "#/components/schemas/FieldConfigDate"
        - $ref: "#/components/schemas/FieldConfigTime"
        - $ref: "#/components/schemas/FieldConfigPrefecture"
        - $ref: "#/components/schemas/FieldConfigPersonName"
        - $ref: "#/components/schemas/FieldConfigAddress"
        - $ref: "#/components/schemas/FieldConfigSelect"
        - $ref: "#/components/schemas/FieldConfigRadio"
        - $ref: "#/components/schemas/FieldConfigCheckbox"
        - $ref: "#/components/schemas/FieldConfigColor"
        - $ref: "#/components/schemas/FieldConfigLabel"
        - $ref: "#/components/schemas/FieldConfigCategory"
        - $ref: "#/components/schemas/FieldConfigTag"
        - $ref: "#/components/schemas/FieldConfigMylist"
        - $ref: "#/components/schemas/FieldConfigUser"
        - $ref: "#/components/schemas/FieldConfigGroup"
        - $ref: "#/components/schemas/FieldConfigCalc"
        - $ref: "#/components/schemas/FieldConfigAutoNumber"
        - $ref: "#/components/schemas/FieldConfigFile"
        - $ref: "#/components/schemas/FieldConfigRelation"
        - $ref: "#/components/schemas/FieldConfigLookup"
    FieldConfigText:
      type: object
      title: text 型
      description: "`text` 型のフィールド設定（config）"
      properties:
        defaultValue:
          type: string
          description: 初期値
        convert:
          type: array
          description: 入力値変換（名前の配列）
          items:
            type: string
        inputCondition:
          type: string
          description: |-
            入力値条件（text の入力制限・1 値）
            - `halfwidthDigits`: 半角数字のみ
            - `fullwidthDigits`: 全角数字のみ
            - `halfwidthAlpha`: 半角アルファベットのみ
            - `fullwidthAlpha`: 全角アルファベットのみ
            - `halfwidthAlnum`: 半角英数字のみ
            - `fullwidthAlnum`: 全角英数のみ
            - `fileName`: ファイル名（半角英数[@][.][-][_][?]）
            - `url`: URL 文字列チェック
            - `hiragana`: 全角ひらがなのみ
            - `katakana`: 全角カタカナのみ
          enum:
            - halfwidthDigits
            - fullwidthDigits
            - halfwidthAlpha
            - fullwidthAlpha
            - halfwidthAlnum
            - fullwidthAlnum
            - fileName
            - url
            - hiragana
            - katakana
          nullable: true
        prefixText:
          type: string
          description: 前後の文字・前
        suffixText:
          type: string
          description: 前後の文字・後
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        searchRemarks:
          type: string
          description: 検索時備考
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象
        formSize:
          type: object
          description: フォームサイズ
          nullable: true
          properties:
            value:
              type: integer
              description: サイズ値（横幅）
            unit:
              type: string
              description: |-
                単位
                - `percent`: パーセント（%）
                - `characters`: 文字数
              enum:
                - percent
                - characters
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigTextarea:
      type: object
      title: textarea 型
      description: "`textarea` 型のフィールド設定（config）"
      properties:
        defaultValue:
          type: string
          description: 初期値
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        searchRemarks:
          type: string
          description: 検索時備考
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
        formSize:
          type: object
          description: フォームサイズ（2 次元）
          nullable: true
          properties:
            value:
              type: integer
              description: サイズ値（横幅）
            unit:
              type: string
              description: |-
                単位
                - `percent`: パーセント（%）
                - `characters`: 文字数
              enum:
                - percent
                - characters
            heightLines:
              type: integer
              description: 高さ（行数）
        listLineClamp:
          type: integer
          description: 一覧表示の行数（0=全行）
    FieldConfigEmail:
      type: object
      title: email 型
      description: "`email` 型のフィールド設定（config）"
      properties:
        inputCondition:
          type: string
          description: |-
            入力値条件（emailSyntax=構文チェック / emailSyntaxAndDns=構文チェック＋DNS実在チェック）
            - `emailSyntax`: メール構文チェックのみ
            - `emailSyntaxAndDns`: メール構文チェック＋DNS 実在チェック
          enum:
            - emailSyntax
            - emailSyntaxAndDns
          nullable: true
        splitInput:
          type: boolean
          description: "@前後で分割入力"
        requireReentry:
          type: boolean
          description: 再入力確認
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        searchRemarks:
          type: string
          description: 検索時備考
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigUrl:
      type: object
      title: url 型
      description: "`url` 型のフィールド設定（config）"
      properties:
        inputCondition:
          type: string
          description: |-
            入力値条件（urlSyntax=構文チェック / urlSyntaxAndHttp=構文チェック＋HTTP実在チェック）
            - `urlSyntax`: URL 構文チェックのみ
            - `urlSyntaxAndHttp`: URL 構文チェック＋HTTP 実在チェック
          enum:
            - urlSyntax
            - urlSyntaxAndHttp
          nullable: true
        defaultValue:
          type: string
          description: 初期値
        linkMethod:
          type: string
          description: |-
            URL のリンク方法
            - `asIs`: URLにそのままリンクを張る
            - `omitDomain`: ドメイン名から後ろを省略する
            - `linkText`: テキストにリンクを張る
            - `noLink`: リンクしない
          enum:
            - asIs
            - omitDomain
            - linkText
            - noLink
        linkText:
          type: string
          description: リンクテキスト
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        searchRemarks:
          type: string
          description: 検索時備考
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigZipCode:
      type: object
      title: zipCode 型
      description: "`zipCode` 型のフィールド設定（config）"
      properties:
        format:
          type: string
          description: |-
            郵便番号フォーマット
            - `japan`: 日本（3桁 - 4桁）
            - `unitedStates`: アメリカ（5桁 - 4桁）
            - `unitedKingdom`: イギリス（4桁 3桁）
            - `sixDigit`: シンガポール（6桁）、中国
            - `southKorea`: 韓国（3桁 - 3桁）
            - `fourDigit`: オーストラリア（4桁）
            - `fiveDigit`: スペイン、フランス（5桁）
            - `free`: フリーフォーマット
          enum:
            - japan
            - unitedStates
            - unitedKingdom
            - sixDigit
            - southKorea
            - fourDigit
            - fiveDigit
            - free
        hyphen:
          type: string
          description: |-
            区切り文字
            - `hyphen`: ハイフンが必要
            - `space`: 半角スペースが必要
            - `none`: 不要
            - `any`: 任意
          enum:
            - hyphen
            - space
            - none
            - any
        inputSeparator:
          type: string
          description: |-
            分割入力
            - `none`: 入力枠を分割しない
            - `hyphen`: ハイフンで分割
            - `space`: スペースで分割
          enum:
            - none
            - hyphen
            - space
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        searchRemarks:
          type: string
          description: 検索時備考
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigPassword:
      type: object
      title: password 型
      description: "`password` 型のフィールド設定（config）"
      properties:
        requireReentry:
          type: boolean
          description: 再入力確認
        hideCharacters:
          type: boolean
          description: 入力中のパスワードを「*」で隠す
        autoGenerate:
          type: boolean
          description: パスワード自動生成ボタンの利用
        passwordChars:
          type: array
          description: |-
            パスワードに含める必須文字種（複数可）
            - `lowercase`: 英小文字（a-z）
            - `uppercase`: 英大文字（A-Z）
            - `digits`: 数字（0-9）
            - `symbols`: 記号
          items:
            type: string
            enum:
              - lowercase
              - uppercase
              - digits
              - symbols
        passwordLength:
          type: object
          description: パスワードの桁数範囲
          nullable: true
          properties:
            min:
              type: integer
              minimum: 4
              maximum: 255
              description: 最小桁数
              nullable: true
            max:
              type: integer
              minimum: 4
              maximum: 255
              description: 最大桁数
              nullable: true
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigTel:
      type: object
      title: tel 型
      description: "`tel` 型のフィールド設定（config）"
      properties:
        allowedNumbers:
          type: array
          description: |-
            許可する電話番号パターン（複数選択可。未指定＝すべての電話番号フォーマットを許可）
            - `all`: 国内全電話番号
            - `landline`: 固定電話（0AB～J）
            - `ipPhone`: IP 電話（050）
            - `mobile`: 携帯電話（070・080・090）
            - `tollFree`: フリーダイヤル（0120・0800）
            - `international`: 国際電話（+ 国番号で始まる番号）
          items:
            type: string
            enum:
              - all
              - landline
              - ipPhone
              - mobile
              - tollFree
              - international
        hyphen:
          type: string
          description: |-
            ハイフンの要否
            - `required`: 必要
            - `notRequired`: 不要
            - `any`: 任意
          enum:
            - required
            - notRequired
            - any
        inputSeparator:
          type: object
          description: 分割入力（分割するか + 分割数）
          nullable: true
          properties:
            split:
              type: boolean
              description: 分割するか
            parts:
              type: integer
              description: 分割数。分割する場合は 2 / 3 / 4 のいずれか（未分割は null）
              nullable: true
              enum:
                - 2
                - 3
                - 4
        prefixText:
          type: string
          description: 前後の文字・前
        suffixText:
          type: string
          description: 前後の文字・後
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigNumber:
      type: object
      title: number 型
      description: "`number` 型のフィールド設定（config）"
      properties:
        numericKind:
          type: string
          description: |-
            数値の型（作成時設定可。PATCH 以降 READ-ONLY）
            - `tinyInteger`: 整数型(小)（-128 〜 127）
            - `integer`: 整数型(中)（-2,147,483,648 〜 2,147,483,647）
            - `bigInteger`: 整数型(大)（最大 19 桁の整数）
            - `decimal`: 小数点型（桁数は decimal で指定）
          enum:
            - tinyInteger
            - integer
            - bigInteger
            - decimal
        inputMode:
          type: string
          description: |-
            入力パターン（作成時設定可。PATCH 以降 READ-ONLY。num→single・num_num→range）
            - `single`: 数値
            - `range`: 数値 ～ 数値
          enum:
            - single
            - range
        range:
          type: object
          description: 数値の範囲（未設定 null）
          nullable: true
          properties:
            min:
              type: integer
              description: 最小値
              nullable: true
            max:
              type: integer
              description: 最大値
              nullable: true
        decimal:
          type: object
          description: 小数桁（小数点型のみ意味を持つ・整数型は両 null）
          nullable: true
          properties:
            integerDigits:
              type: integer
              description: 整数部桁数
              nullable: true
            decimalPlaces:
              type: integer
              description: 小数部桁数
              nullable: true
        thousandsSeparator:
          type: boolean
          description: 桁区切り
          nullable: true
        allowNegative:
          type: boolean
          description: マイナス値の許可（プラスのみ制限で false）
        zeroPadding:
          type: object
          description: 0埋め
          nullable: true
          properties:
            enabled:
              type: boolean
              description: 0埋めする
            length:
              type: integer
              description: 0埋め桁数
              nullable: true
        prefixText:
          type: string
          description: 単位（前）
        suffixText:
          type: string
          description: 単位（後）
        sumCalc:
          type: string
          description: |-
            合計計算
            - `sum`: 合計値で計算
            - `average`: 平均値で計算
            - `none`: 計算しない
          enum:
            - sum
            - average
            - none
        rangeSearchMode:
          type: string
          description: |-
            検索方法（範囲指定/完全一致）
            - `range`: 範囲指定
            - `exact`: 完全一致
          enum:
            - range
            - exact
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        defaultValue:
          type: string
          description: 初期値
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigDate:
      type: object
      title: date 型
      description: "`date` 型のフィールド設定（config）"
      properties:
        inputPattern:
          type: string
          description: |-
            入力パターン（作成時設定可。PATCH 以降 READ-ONLY。日付/日時×単一/範囲）
            - `ymd`: 年-月-日
            - `ymd_ymd`: 年-月-日 ～ 年-月-日
            - `ymdhm`: 年-月-日 時：分
            - `ymdhm_hm`: 年-月-日 時：分 ～ 時：分
            - `ymdhm_ymdhm`: 年-月-日 時：分 ～ 年-月-日 時：分
          enum:
            - ymd
            - ymd_ymd
            - ymdhm
            - ymdhm_hm
            - ymdhm_ymdhm
        yearRange:
          type: object
          description: カレンダーの年範囲（N年前～N年後）
          nullable: true
          properties:
            min:
              type: integer
              description: 年前
              nullable: true
            max:
              type: integer
              description: 年後
              nullable: true
        timeRange:
          type: object
          description: 時刻の範囲（0-23・日時系 inputPattern〔ymdhm 系〕のみ実値・日付のみは null。日付のみに実値を送ると 422 time_settings_require_datetime_pattern）
          nullable: true
          properties:
            start:
              type: integer
              minimum: 0
              maximum: 23
              description: 開始時
              nullable: true
            end:
              type: integer
              minimum: 0
              maximum: 23
              description: 終了時
              nullable: true
        minuteInterval:
          type: integer
          description: 分の間隔（1/5/10/15/20/30・日時系 inputPattern〔ymdhm 系〕のみ実値・日付のみは null。日付のみに実値を送ると 422 time_settings_require_datetime_pattern）
          enum:
            - 1
            - 5
            - 10
            - 15
            - 20
            - 30
          nullable: true
        displayFormat:
          type: string
          description: |-
            日付フォーマット
            - `iso`: YYYY-MM-DD
            - `slash`: YYYY/MM/DD
            - `japanese`: YYYY年MM月DD日
            - `japaneseEra`: 和暦
          enum:
            - iso
            - slash
            - japanese
            - japaneseEra
        calculation:
          type: string
          description: |-
            日付計算（年齢/経過日数/経過年月）
            - `none`: 計算しない
            - `age`: 年齢計算
            - `elapsedDays`: 経過・残り日数（日数）
            - `elapsedMonths`: 経過・残り日数（年月）
          enum:
            - none
            - age
            - elapsedDays
            - elapsedMonths
        initialValueMode:
          type: string
          description: |-
            初期値（相対既定値）
            - `today`: 今日
            - `monthStart`: 今月1日
            - `monthEnd`: 今月末
          enum:
            - today
            - monthStart
            - monthEnd
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象
        ageSearchMode:
          type: string
          description: |-
            年齢/年数の検索
            - `age`: 年齢の検索
            - `years`: 年数の検索
            - `none`: 行わない
          enum:
            - age
            - years
            - none
        daySearchModes:
          type: array
          description: |-
            日数での検索モード（複数可）
            - `elapsedDays`: 経過日数（登録日からの経過日数で検索）
            - `remainingDays`: 残り日数（登録日までの残り日数で検索）
          items:
            type: string
            enum:
              - elapsedDays
              - remainingDays
        monthSearchable:
          type: boolean
          description: 月の検索
        calendarSearchMode:
          type: string
          description: |-
            カレンダー検索
            - `specificDate`: 特定の日付を検索
            - `range`: 範囲を指定して検索
            - `none`: 行わない
          enum:
            - specificDate
            - range
            - none
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigTime:
      type: object
      title: time 型
      description: "`time` 型のフィールド設定（config）"
      properties:
        inputPattern:
          type: string
          description: |-
            入力パターン（作成時設定可。PATCH 以降 READ-ONLY。単一時刻/時刻範囲）
            - `hms`: 単一時刻入力
            - `hms_hms`: 時刻範囲入力（時刻 ～ 時刻）
          enum:
            - hms
            - hms_hms
        timeFormat:
          type: string
          description: |-
            時刻フォーマット（時分/時分秒）
            - `hourMinute`: 時分（HH:MM）
            - `hourMinuteSecond`: 時分秒（HH:MM:SS）
          enum:
            - hourMinute
            - hourMinuteSecond
        timeRange:
          type: object
          description: 選択可能な時刻範囲（0-23）
          nullable: true
          properties:
            start:
              type: integer
              minimum: 0
              maximum: 23
              description: 開始時
              nullable: true
            end:
              type: integer
              minimum: 0
              maximum: 23
              description: 終了時
              nullable: true
        minuteInterval:
          type: integer
          description: 分の間隔（1/5/10/15/20/30）
          enum:
            - 1
            - 5
            - 10
            - 15
            - 20
            - 30
          nullable: true
        initialValueMode:
          type: string
          description: |-
            初期値モード（現在時刻/固定時刻）
            - `now`: 現在時刻
            - `fixedTime`: 固定時刻
          enum:
            - now
            - fixedTime
          nullable: true
        fixedTime:
          type: string
          description: 初期値の固定時刻（HH:MM:SS・initialValueMode=fixedTime のみ実値。それ以外のモードに実値を送ると 422 fixed_time_requires_fixed_time_mode）
          nullable: true
        showElapsedTime:
          type: boolean
          description: 経過時間を表示（入力パターンが「時刻範囲入力」〔inputPattern=hms_hms〕の項目のみ。単一時刻に true を送ると 422 elapsed_time_requires_time_range）
        sumCalc:
          type: string
          description: |-
            合計計算
            - `sum`: 合計値で計算
            - `average`: 平均値で計算
            - `none`: 計算しない
          enum:
            - sum
            - average
            - none
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigPrefecture:
      type: object
      title: prefecture 型
      description: "`prefecture` 型のフィールド設定（config）"
      properties:
        searchControlType:
          type: string
          description: |-
            詳細検索の選択方法
            - `checkbox`: チェックボックス
            - `radio`: ラジオボタン
            - `select`: セレクトボックス
            - `multiSelect`: 複数選択セレクトボックス
          enum:
            - checkbox
            - radio
            - select
            - multiSelect
        exclusionSearchable:
          type: boolean
          description: 除外検索（NOT検索）の対象
        options:
          type: array
          description: 選択肢（47 都道府県・固定マスタ・読み取り専用）
          items:
            type: object
            properties:
              value:
                type: string
                description: 都道府県名
              label:
                type: string
                description: 表示ラベル（都道府県名と同値）
              color:
                type: string
                description: 色
                nullable: true
        defaultValue:
          type: string
          description: 初期値（既定の都道府県名）
          nullable: true
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigPersonName:
      type: object
      title: personName 型
      description: "`personName` 型のフィールド設定（config）"
      properties:
        nameType:
          type: string
          description: |-
            表記タイプ（漢字姓名/カタカナ/ひらがな）
            - `kanji`: 姓名
            - `katakana`: フリガナ（カタカナ）
            - `hiragana`: ふりがな（ひらがな）
          enum:
            - kanji
            - katakana
            - hiragana
        splitInput:
          type: boolean
          description: 姓と名を分割入力する
        prefixText:
          type: string
          description: 前後の文字・前
          nullable: true
        suffixText:
          type: string
          description: 前後の文字・後
          nullable: true
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象にする
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        searchRemarks:
          type: string
          description: 検索時備考
          nullable: true
        duplicateSearchable:
          type: boolean
          description: 重複検索の対象にする
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigAddress:
      type: object
      title: address 型
      description: "`address` 型のフィールド設定（config）"
      properties:
        addressFormat:
          type: string
          description: |-
            住所の構成（固定 9 通り）
            - `postalPrefectureCityStreetBuilding`: 郵便番号＋都道府県＋市区町村＋枝番＋建物名
            - `postalPrefectureAddressBuilding`: 郵便番号＋都道府県＋住所＋建物名
            - `postalPrefectureAddress`: 郵便番号＋都道府県＋住所
            - `postalAddressBuilding`: 郵便番号＋住所＋建物名
            - `postalAddress`: 郵便番号＋住所
            - `prefectureCityStreetBuilding`: 都道府県＋市区町村＋枝番＋建物名
            - `prefectureAddressBuilding`: 都道府県＋住所＋建物名
            - `prefectureAddress`: 都道府県＋住所
            - `addressBuilding`: 住所＋建物名
          enum:
            - postalPrefectureCityStreetBuilding
            - postalPrefectureAddressBuilding
            - postalPrefectureAddress
            - postalAddressBuilding
            - postalAddress
            - prefectureCityStreetBuilding
            - prefectureAddressBuilding
            - prefectureAddress
            - addressBuilding
        postalToAddress:
          type: boolean
          description: 郵便番号からの住所変換ボタンを付ける
        geocoding:
          type: boolean
          description: 地図上に表示する（緯度経度を取得）
        showMap:
          type: boolean
          description: レコード詳細で地図を表示
        widthConversion:
          type: string
          description: |-
            入力値変換（半角全角）
            - `halfToFullWidth`: 半角数字と半角ハイフンを全角に変換する
            - `fullToHalfWidth`: 全角数字と全角ハイフンを半角に変換する
            - `none`: 変換しない
          enum:
            - halfToFullWidth
            - fullToHalfWidth
            - none
        font:
          type: object
          description: フォント設定
          nullable: true
          properties:
            size:
              type: string
              description: |-
                フォントサイズ
                - `small`: スモール（小）
                - `default`: 標準
                - `large`: ラージ（大）
              enum:
                - small
                - default
                - large
            color:
              type: string
              description: フォントカラー（hex）
              nullable: true
            weight:
              type: string
              description: |-
                文字の太さ
                - `normal`: 通常
                - `bold`: 太字
              enum:
                - normal
                - bold
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象にする
        matchType:
          type: string
          description: |-
            マッチング方法
            - `partial`: 部分一致（未設定）
            - `exact`: 完全一致
            - `prefix`: 前方一致
            - `suffix`: 後方一致
          enum:
            - partial
            - exact
            - prefix
            - suffix
        searchRemarks:
          type: string
          description: 検索時備考
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigSelect:
      type: object
      title: select 型
      description: "`select` 型のフィールド設定（config）"
      properties:
        searchControlType:
          type: string
          description: |-
            詳細検索の選択方法
            - `checkbox`: チェックボックス
            - `radio`: ラジオボタン
            - `select`: セレクトボックス
            - `multiSelect`: 複数選択セレクトボックス
          enum:
            - checkbox
            - radio
            - select
            - multiSelect
        exclusionSearchable:
          type: boolean
          description: 除外検索（NOT検索）の対象
        options:
          type: array
          description: 選択肢（ユーザー定義）
          items:
            type: object
            properties:
              value:
                type: string
                description: 選択肢値
              label:
                type: string
                description: 表示ラベル
              color:
                type: string
                description: 色
                nullable: true
        allowOptionAdd:
          type: boolean
          description: 選択値にない値をその場で追加できる
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigRadio:
      type: object
      title: radio 型
      description: "`radio` 型のフィールド設定（config）"
      properties:
        searchControlType:
          type: string
          description: |-
            詳細検索の選択方法
            - `checkbox`: チェックボックス
            - `radio`: ラジオボタン
            - `select`: セレクトボックス
            - `multiSelect`: 複数選択セレクトボックス
          enum:
            - checkbox
            - radio
            - select
            - multiSelect
        exclusionSearchable:
          type: boolean
          description: 除外検索（NOT検索）の対象
        options:
          type: array
          description: 選択肢（ユーザー定義）
          items:
            type: object
            properties:
              value:
                type: string
                description: 選択肢値
              label:
                type: string
                description: 表示ラベル
              color:
                type: string
                description: 色
                nullable: true
        allowOptionAdd:
          type: boolean
          description: 選択値にない値をその場で追加できる
        displayStyle:
          type: string
          description: |-
            ラジオボタンの表示方法
            - `evenlySpaced`: 等間隔に並べる
            - `leftAligned`: 左詰めで並べる
            - `newLine`: 改行で並べる
          enum:
            - evenlySpaced
            - leftAligned
            - newLine
        allowUnselected:
          type: boolean
          description: 未選択の選択値を追加（選択解除を可能に）
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigCheckbox:
      type: object
      title: checkbox 型
      description: "`checkbox` 型のフィールド設定（config）"
      properties:
        searchControlType:
          type: string
          description: |-
            詳細検索の選択方法
            - `checkbox`: チェックボックス
            - `radio`: ラジオボタン
            - `select`: セレクトボックス
            - `multiSelect`: 複数選択セレクトボックス
          enum:
            - checkbox
            - radio
            - select
            - multiSelect
        exclusionSearchable:
          type: boolean
          description: 除外検索（NOT検索）の対象
        options:
          type: array
          description: 選択肢（ユーザー定義）
          items:
            type: object
            properties:
              value:
                type: string
                description: 選択肢値
              label:
                type: string
                description: 表示ラベル
              color:
                type: string
                description: 色
                nullable: true
        allowOptionAdd:
          type: boolean
          description: 選択値にない値をその場で追加できる
        displayStyle:
          type: string
          description: |-
            チェックボックスの表示方法
            - `evenlySpaced`: 等間隔に並べる
            - `leftAligned`: 左詰めで並べる
            - `newLine`: 改行で並べる
            - `multiSelectDropdown`: 複数選択プルダウンに変更
          enum:
            - evenlySpaced
            - leftAligned
            - newLine
            - multiSelectDropdown
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigColor:
      type: object
      title: color 型
      description: "`color` 型のフィールド設定（config）"
      properties:
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
    FieldConfigLabel:
      type: object
      title: label 型
      description: "`label` 型のフィールド設定（config）"
      properties:
        collapsed:
          type: boolean
          description: 初期の開閉状態（true=閉じた状態で表示）
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigCategory:
      type: object
      title: category 型
      description: "`category` 型のフィールド設定（config）"
      properties:
        options:
          type: array
          description: 選択肢（共有カテゴリマスタ・POST/PATCH の options で追加・更新可〔merge・削除なし〕）
          items:
            type: object
            properties:
              value:
                type: string
                description: カテゴリ項目値（ca_code）
              label:
                type: string
                description: 表示ラベル（親 > 子）
              color:
                type: string
                description: 色
                nullable: true
        defaultValue:
          type: string
          description: 初期値（レコード新規作成時に選択された状態にするカテゴリ項目値・ca_code。null/空で未設定。指定できるのは config.options に含まれるカテゴリのみで、同一リクエストの options で追加したカテゴリは指定できないため、追加後に別リクエストで指定する）
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        editRoleGroup:
          type: string
          description: カテゴリ項目の編集権限グループ（ロール ID）
          nullable: true
        allowStatusChange:
          type: boolean
          description: 項目の使用・未使用の変更を許可
        allowRename:
          type: boolean
          description: 項目名の変更を許可
        allowReorder:
          type: boolean
          description: 項目の順序変更を許可
        allowSearchToggle:
          type: boolean
          description: 検索対象の可否変更を許可
        allowSortToggle:
          type: boolean
          description: ソート対象の可否変更を許可
        allowListToggle:
          type: boolean
          description: 一覧表示対象の可否変更を許可
        allowDetailToggle:
          type: boolean
          description: 詳細表示対象の可否変更を許可
    FieldConfigTag:
      type: object
      title: tag 型
      description: "`tag` 型のフィールド設定（config）"
      properties:
        options:
          type: array
          description: 選択肢（共有タグマスタ・flat・POST/PATCH の options で追加・更新可〔merge・削除なし〕）
          items:
            type: object
            properties:
              value:
                type: string
                description: タグ項目値（tg_code）
              label:
                type: string
                description: 表示ラベル（tg_name）
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        editRoleGroup:
          type: string
          description: タグ項目の編集権限グループ（ロール ID）
          nullable: true
        allowStatusChange:
          type: boolean
          description: 項目の使用・未使用の変更を許可
        allowRename:
          type: boolean
          description: 項目名の変更を許可
        allowReorder:
          type: boolean
          description: 項目の順序変更を許可
        allowSearchToggle:
          type: boolean
          description: 検索対象の可否変更を許可
        allowSortToggle:
          type: boolean
          description: ソート対象の可否変更を許可
        allowListToggle:
          type: boolean
          description: 一覧表示対象の可否変更を許可
        allowDetailToggle:
          type: boolean
          description: 詳細表示対象の可否変更を許可
    FieldConfigMylist:
      type: object
      title: mylist 型
      description: "`mylist` 型のフィールド設定（config）"
      properties:
        options:
          type: array
          description: 選択肢（共有マイリストマスタ・flat・本人所有・POST/PATCH の options で追加・更新可〔merge・削除なし〕）
          items:
            type: object
            properties:
              value:
                type: string
                description: マイリスト項目値（my_code）
              label:
                type: string
                description: 表示ラベル（my_name）
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        allowStatusChange:
          type: boolean
          description: 項目の使用・未使用の変更を許可
        allowRename:
          type: boolean
          description: 項目名の変更を許可
        allowReorder:
          type: boolean
          description: 項目の順序変更を許可
        allowSearchToggle:
          type: boolean
          description: 検索対象の可否変更を許可
        allowSortToggle:
          type: boolean
          description: ソート対象の可否変更を許可
        allowListToggle:
          type: boolean
          description: 一覧表示対象の可否変更を許可
        allowDetailToggle:
          type: boolean
          description: 詳細表示対象の可否変更を許可
    FieldConfigUser:
      type: object
      title: user 型
      description: "`user` 型のフィールド設定（config）"
      properties:
        searchControlType:
          type: string
          description: |-
            詳細検索の選択方法
            - `checkbox`: チェックボックス
            - `radio`: ラジオボタン
            - `select`: セレクトボックス
            - `multiSelect`: 複数選択セレクトボックス
          enum:
            - checkbox
            - radio
            - select
            - multiSelect
        exclusionSearchable:
          type: boolean
          description: 除外検索（NOT検索）の対象
        selectionCount:
          type: string
          description: |-
            選択数（single=一人 / multiple=複数人）
            - `single`: １グループを選択
            - `multiple`: 複数グループを選択
          enum:
            - single
            - multiple
        initialValueMode:
          type: string
          description: |-
            初期値（notSelected=未選択 / recordCreator=レコード登録者）
            - `notSelected`: 未選択
            - `recordCreator`: レコード登録者のグループ
          enum:
            - notSelected
            - recordCreator
        restrictToGroups:
          type: array
          description: 特定グループのユーザーのみ選択可（グループ ID 配列。存在しない ID を送ると 422 validation_failed / invalid_value）
          items:
            type: string
        restrictToUsers:
          type: array
          description: 特定ユーザーのみ選択可（アカウント ID 配列。存在しない ID を送ると 422 validation_failed / invalid_value）
          items:
            type: string
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigGroup:
      type: object
      title: group 型
      description: "`group` 型のフィールド設定（config）"
      properties:
        searchControlType:
          type: string
          description: |-
            詳細検索の選択方法
            - `checkbox`: チェックボックス
            - `radio`: ラジオボタン
            - `select`: セレクトボックス
            - `multiSelect`: 複数選択セレクトボックス
          enum:
            - checkbox
            - radio
            - select
            - multiSelect
        exclusionSearchable:
          type: boolean
          description: 除外検索（NOT検索）の対象
        selectionCount:
          type: string
          description: |-
            選択数（single=1グループ / multiple=複数グループ）
            - `single`: １グループを選択
            - `multiple`: 複数グループを選択
          enum:
            - single
            - multiple
        initialValueMode:
          type: string
          description: |-
            初期値（notSelected=未選択 / recordCreator=レコード登録者のグループ）
            - `notSelected`: 未選択
            - `recordCreator`: レコード登録者のグループ
          enum:
            - notSelected
            - recordCreator
        restrictToGroups:
          type: array
          description: 特定グループから選択（グループ ID 配列。存在しない ID を送ると 422 validation_failed / invalid_value）
          items:
            type: string
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigCalc:
      type: object
      title: calc 型
      description: "`calc` 型のフィールド設定（config）"
      properties:
        searchControlType:
          type: string
          description: |-
            詳細検索の選択方法
            - `checkbox`: チェックボックス
            - `radio`: ラジオボタン
            - `select`: セレクトボックス
            - `multiSelect`: 複数選択セレクトボックス
          enum:
            - checkbox
            - radio
            - select
            - multiSelect
        exclusionSearchable:
          type: boolean
          description: 除外検索（NOT検索）の対象
        daySearchModes:
          type: array
          description: |-
            日数での検索モード（複数可）
            - `elapsedDays`: 経過日数（登録日からの経過日数で検索）
            - `remainingDays`: 残り日数（登録日までの残り日数で検索）
          items:
            type: string
            enum:
              - elapsedDays
              - remainingDays
        monthSearchable:
          type: boolean
          description: 月の検索
        calendarSearchMode:
          type: string
          description: |-
            カレンダー検索
            - `specificDate`: 特定の日付を検索
            - `range`: 範囲を指定して検索
            - `none`: 行わない
          enum:
            - specificDate
            - range
            - none
        resultType:
          type: string
          description: |-
            計算結果の型
            - `tinyInteger`: 整数型(小)
            - `integer`: 整数型(中)
            - `bigInteger`: 整数型(大)
            - `decimal`: 小数点型
            - `date`: 日付
            - `time`: 時刻
            - `text`: テキスト
            - `category`: カテゴリ
          enum:
            - tinyInteger
            - integer
            - bigInteger
            - decimal
            - date
            - time
            - text
            - category
        formula:
          type: string
          description: |-
            計算式。**他項目の参照 `${項目キー}` と四則演算（`+ - * /`）・比較で構成**する（例: `${単価} * ${数量}`）。空文字は「式なし（計算しない）」として作成可。
            - **`${...}` に入れる「項目キー」は、フィールド一覧 API（`GET /settings/apps/{appKey}/fields`）が各項目に返す `key`**（＝そのフィールドの識別子）です。まずこの API で対象アプリの項目キーを取得し、`${key}` の形で式に埋め込みます（例: 取得した `key: "price"` → `${price}`）。`key` のほか publicName・項目の表示名でも参照できますが、**一意で確実な `key` の使用を推奨**します。
            - **`today()` / `now()` 等の「現在日時関数」は使用不可**（計算式は項目参照＋演算のみ。現在日付を初期値にしたい場合は date 項目の `initialValueMode: "today"` を使う）。
            - `resultType: "date"` の場合は**日付項目を参照した日付演算**で結果が日付になる式を指定する（例: `${基準日} + 30`）。日付を返さない式や未対応の関数は 422 `config.formula`（invalid_value）。
            - 参照先が解決できない項目キー・複数サブレコード混在等は 422 `config.formula`。
        decimalPlaces:
          type: integer
          description: '小数点以下の桁数（`resultType: "decimal"` の計算結果を小数第何位まで表示するか。decimal 以外に 1 以上を送ると 422 decimal_places_requires_decimal_result・0 は許容）'
        suffixText:
          type: string
          description: 単位等の後置文字
        sumCalc:
          type: string
          description: |-
            合計行の計算方法（sum/average/none）
            - `sum`: 合計値で計算
            - `average`: 平均値で計算
            - `none`: 計算しない
          enum:
            - sum
            - average
            - none
          nullable: true
        font:
          type: object
          description: フォント
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
    FieldConfigAutoNumber:
      type: object
      title: autoNumber 型
      description: "`autoNumber` 型のフィールド設定（config）"
      properties:
        prefix:
          type: string
          description: 接頭辞（採番フォーマット）
        suffix:
          type: string
          description: 接尾辞（採番フォーマット）
        digits:
          type: integer
          minimum: 1
          maximum: 14
          description: 連番の桁数（1〜14）
        generationTiming:
          type: string
          description: |-
            採番タイミング
            - `onCreate`: 新規登録時
            - `manual`: 任意のタイミング
            - `workflowStart`: ワークフロー開始時
            - `workflowApproval`: ワークフロー承認時
            - `automation`: オートメーション機能に連動
          enum:
            - onCreate
            - manual
            - workflowStart
            - workflowApproval
            - automation
        resetCycle:
          type: string
          description: |-
            連番のリセット周期
            - `never`: リセットしない
            - `perPrefix`: プレフィックス毎
            - `yearly`: 毎年1月1日
            - `monthly`: 毎月1日
            - `daily`: 毎日
            - `specificDate`: 指定日
          enum:
            - never
            - perPrefix
            - yearly
            - monthly
            - daily
            - specificDate
        resetDate:
          type: object
          description: リセット指定日（resetCycle=specificDate のみ。それ以外の周期に実値を送ると 422 reset_date_requires_specific_date）
          nullable: true
          properties:
            month:
              type: integer
              description: 月
              nullable: true
            day:
              type: integer
              description: 日
              nullable: true
        startNumber:
          type: integer
          description: 連番の開始番号
        font:
          type: object
          description: フォント
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: キーワード検索対象
        matchType:
          type: string
          description: 検索の一致方法
          nullable: true
        searchRemarks:
          type: string
          description: 検索補足
          nullable: true
    FieldConfigFile:
      type: object
      title: file 型
      description: "`file` 型のフィールド設定（config）"
      properties:
        fileType:
          type: string
          description: |-
            ファイル種別制限（作成時設定可。PATCH 以降 READ-ONLY）
            - `all`: すべて
            - `image`: 画像
            - `video`: 動画
            - `audio`: 音声
            - `pdf`: PDF
            - `text`: テキスト
          enum:
            - all
            - image
            - video
            - audio
            - pdf
            - text
        previewEnabled:
          type: boolean
          description: 詳細でプレビュー表示
        directUrlEnabled:
          type: boolean
          description: 直接参照 URI を生成（未ログインでもアクセス可）
        extractLocation:
          type: boolean
          description: |-
            画像から位置情報を取得（画像の GPS から住所を取得し住所項目へ保存）。
            有効化には `fileType` が `image` であることと、保存先の `locationAddressField`（住所項目）の指定が必須。
            条件を満たさずに true を送ると 422（`file_location_requires_image` / `file_location_requires_address_field`）。
        locationAddressField:
          type: string
          description: 位置情報の保存先住所項目キー（`extractLocation` を true にするとき必須。address 型の項目キーを指定）
          nullable: true
        maxSizeMb:
          type: integer
          description: 容量制限（MB 未満）
          nullable: true
        imageResize:
          type: object
          description: 画像リサイズ（off は null。fileType=image のときのみ設定可・それ以外に実値を送ると 422 image_resize_requires_image）
          nullable: true
          properties:
            width:
              type: integer
              description: 横（px）
              nullable: true
            height:
              type: integer
              description: 縦（px）
              nullable: true
            keepOriginal:
              type: boolean
              description: 元画像を残す
        extensionRestriction:
          type: object
          description: 拡張子制限（制限なしは null）
          nullable: true
          properties:
            mode:
              type: string
              description: |-
                許可/禁止
                - `allow`: 許可リスト（記載した拡張子のみ許可）
                - `deny`: 禁止リスト（記載した拡張子を禁止）
              enum:
                - allow
                - deny
            extensions:
              type: array
              description: 拡張子リスト
              items:
                type: string
        existenceSearchable:
          type: boolean
          description: ファイル存在確認検索
        filenameSearchable:
          type: boolean
          description: ファイル名検索
        sizeSearchable:
          type: boolean
          description: ファイルサイズ検索
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigRelation:
      type: object
      title: relation 型
      description: "`relation` 型のフィールド設定（config）"
      properties:
        linkedAppKey:
          type: string
          description: |-
            連携先アプリのキー。
            作成時（POST）に指定できるのは、公開中で、かつトークン発行元アカウントに利用権限のあるアプリ（自分が作成したアプリは常に可）のみです。該当しないキーは 422 `validation_failed`（`details[].code` = `invalid_value`）になります。
            このアプリ自身のキーも指定できます（同一アプリ内のレコード紐づけ）。ただしメインレコードの項目に限り、1 アプリにつき 1 項目までです（超える指定は 422 `validation_failed`）。
          nullable: true
        multiple:
          type: boolean
          description: |-
            複数選択（作成後変更不可）。このアプリ自身を連携先にした `relation` 型項目（メインレコードの項目）でだけ `true` にできます。それ以外の指定は `false` として保存されます。
            `true` の項目の値は `{appKey, recordId}`（または recordId 文字列）の配列で読み書きします（50件まで。自分自身のレコードは指定できません）。
        targetRecordList:
          type: string
          description: 連携先の対象レコード（カスタムリスト）
          nullable: true
        linkType:
          type: string
          description: |-
            連携先レコードへのリンク方法
            - `newWindow`: 別ウインドウで開く
            - `modal`: モーダルウインドウで開く
            - `none`: リンクしない
          enum:
            - newWindow
            - modal
            - none
        showSourceOnTarget:
          type: boolean
          description: |-
            連携先での参照元表示
            `true` のとき、連携先アプリのレコード詳細に参照元レコードの一覧を表示します（`showSourceOnTargetWhenEmpty` が `false` なら、参照元レコードが0件のときは非表示）。
        showSourceOnTargetWhenEmpty:
          type: boolean
          description: |-
            連携先での参照元表示（0件でも表示）
            `true` のとき、参照元レコードが0件でも連携先アプリのレコード詳細に参照元セクション（見出しと登録ボタン）を表示します（`showSourceOnTarget` も `true` として扱います）。`showSourceOnTarget: false` と同時に `true` を指定すると 422 `validation_failed`（`details[].code` = `invalid_value`）になります。
        allowAddToTarget:
          type: boolean
          description: 連携先アプリへの追加を許可
        keywordSearchable:
          type: boolean
          description: ヘッダーキーワード検索の対象
        matchType:
          type: string
          description: 検索の一致方法
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string
    FieldConfigLookup:
      type: object
      title: lookup 型
      description: "`lookup` 型のフィールド設定（config）"
      properties:
        linkedAppKey:
          type: string
          description: |-
            連携先アプリのキー。
            作成時（POST）に指定できるのは、同じアプリ（サブレコード項目の場合は同じサブレコードテーブル）の `relation` 型項目で連携済みのアプリのみです（画面の参照項目と同じ条件。参照項目は `relation` 型項目で選んだレコードから値を取得します）。該当しないキーは 422 `validation_failed`（`details[].code` = `invalid_value`）になります。
            このアプリ自身を連携先にした `relation` 型項目は参照項目の参照先にできません（このアプリ自身のキーは `invalid_value`）。
          nullable: true
        sourceFieldKey:
          type: string
          description: 参照先フィールドのキー（連携先アプリ）
          nullable: true
        referenceMethod:
          type: string
          readOnly: true
          description: |-
            参照方法（作成後変更不可）。
            - `synced`: 同期参照（参照先の変更が参照元にも反映）
            - `onDemand`: 都度参照（レコード登録時や任意のタイミングで取得）
            作成時（POST）のみ指定可。PATCH で変更しようとすると 422 `read_only`。
            `synced` / `onDemand` いずれで作成した項目も、取得（GET）では `type: "lookup"` として本 config 形式で返ります。
          enum:
            - synced
            - onDemand
        displayMode:
          type: string
          description: |-
            レコード登録画面での表示方法
            - `hidden`: 非表示
            - `shown`: 表示
          enum:
            - hidden
            - shown
        referencedFieldType:
          type: string
          description: 参照先フィールドの型
          nullable: true
        font:
          type: object
          description: フォント
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        conditionalDisplay:
          type: object
          description: 条件付きフォーム
          nullable: true
          properties:
            fieldKey:
              type: string
              description: 条件項目の項目キー
            values:
              type: array
              description: 条件値の配列
              items:
                type: string

    FieldCreateRequest:
      type: object
      required: [field]
      properties:
        field:
          type: object
          required: [name, type]
          description: 作成する項目。必須は name / type のみ（他は省略時デフォルト＝画面準拠）
          properties:
            name:
              type: string
              description: 項目名（af_title）。最大 255 文字（超過は 422 out_of_range_max）
              example: "会社名"
            type:
              type: string
              description: 項目の型（全 28 型のいずれか。未知の型は 422 invalid_enum）
              enum: [text, textarea, email, url, zipCode, password, tel, number, date, time, prefecture, personName, address, select, radio, checkbox, color, label, category, tag, mylist, user, group, calc, autoNumber, file, relation, lookup]
              example: "text"
            key:
              type: string
              description: |
                項目キー（任意）。省略時はサーバー自動採番（`textNN` 形式）。
                半角英数字・`-`・`_` のみ・15 字以内・`dt_` 接頭辞禁止。既存と重複は 409 field_duplicate。
                category / tag / mylist / color はアプリ内シングルトンで key 固定（指定不可）。
            displayOrder:
              type: integer
              minimum: 0
              description: 表示順（任意・非負整数）。大きいほど画面上部。省略時は末尾に自動採番（＝作成順）。指定値は保存時に画面と同じ 10 刻みへ正規化（応答は正規化後の値）
              example: 25
            required:
              type: boolean
              description: 必須項目にする（省略時 false）
            searchable:
              type: boolean
              description: 検索対象にする（省略時 true）
            sortable:
              type: boolean
              description: 並べ替え（ソート）対象にする（型により可否あり・省略時 false）
            showInList:
              type: boolean
              description: 一覧の表示候補にする（実際の列表示はユーザー個別の一覧設定で決まる・省略時 true）
            showInDetail:
              type: boolean
              description: 詳細画面に表示する（省略時 true）
            isTitle:
              type: boolean
              description: タイトル項目にする（型により可否あり・省略時 false）
            partOfUniqueKey:
              type: boolean
              description: 複合ユニークキー（複数項目の組み合わせで重複を禁止）の構成メンバーにする（型により可否あり・省略時 false）
            duplicateAllowed:
              type: boolean
              description: 同じ値の重複登録を許可する（false で重複不可・省略時 true）。false にできるのは text / number / date / personName / tel / email / url のみ（画面の項目設定に「重複登録」欄がある型に準拠。非対応型に false を送ると 422）
            enabled:
              type: boolean
              description: 項目を使用する（false で未使用・省略時 true）
            remarks:
              type: string
              nullable: true
              description: 入力フォームに表示する備考（空文字は null）
            config:
              $ref: '#/components/schemas/FieldConfig'

    FieldUpdateRequest:
      type: object
      required: [field]
      properties:
        field:
          type: object
          description: |
            更新する項目。**送ったキーだけ更新**（Merge Patch）。
            `id` / `type` / `key` / `createdAt` / `updatedAt` / `createdBy` は変更不可（送っても無視、異なる値を送ると 422 `read_only`）。
          properties:
            id:
              type: string
              readOnly: true
              description: 項目ID。読み取り専用（異なる値を送ると 422 read_only）。
            type:
              type: string
              readOnly: true
              description: 項目の型。作成後は変更不可（異なる値を送ると 422 read_only）。
            key:
              type: string
              readOnly: true
              description: 項目キー。読み取り専用（異なる値を送ると 422 read_only）。
            createdBy:
              readOnly: true
              allOf:
                - $ref: '#/components/schemas/AccountRef'
              description: 作成者。読み取り専用。
            createdAt:
              type: string
              format: date-time
              readOnly: true
              description: 作成日時。読み取り専用。
            updatedAt:
              type: string
              format: date-time
              readOnly: true
              description: 更新日時。読み取り専用。
            name:
              type: string
              description: 項目名（最大 255 文字）
            displayOrder:
              type: integer
              minimum: 0
              description: 表示順（非負整数）。指定時のみ更新＝並べ替え。大きいほど画面上部。指定値は保存時に画面と同じ 10 刻みへ正規化（応答は正規化後の値）
              example: 25
            required:
              type: boolean
              description: 必須項目にするか
            searchable:
              type: boolean
              description: 検索対象にするか
            sortable:
              type: boolean
              description: 並べ替え（ソート）対象にするか（型により可否あり）
            showInList:
              type: boolean
              description: 一覧の表示候補にするか（実際の列表示はユーザー個別の一覧設定で決まる）
            showInDetail:
              type: boolean
              description: 詳細画面に表示するか
            isTitle:
              type: boolean
              description: タイトル項目にするか（型により可否あり）
            partOfUniqueKey:
              type: boolean
              description: 複合ユニークキー（複数項目の組み合わせで重複を禁止）の構成メンバーにするか（型により可否あり）
            duplicateAllowed:
              type: boolean
              description: 同じ値の重複登録を許可するか（false で重複不可）。false にできるのは text / number / date / personName / tel / email / url のみ（画面の項目設定に「重複登録」欄がある型に準拠。非対応型に false を送ると 422）
            enabled:
              type: boolean
              description: 項目を使用するか（false で未使用）
            remarks:
              type: string
              nullable: true
              description: 入力フォームに表示する備考（空文字は null）
            config:
              description: 型固有設定（部分更新）。`null` で config 全体を画面初期値へリセット
              nullable: true
              allOf:
                - $ref: '#/components/schemas/FieldConfig'

    FieldCopyRequest:
      type: object
      description: 複製先の上書き設定（すべて任意。`{}` でも複製可）
      properties:
        field:
          type: object
          properties:
            name:
              type: string
              description: 複製先の項目名（省略時は「{元の名前} - Copy」）
            key:
              type: string
              description: 複製先のキー（省略時は連番で自動採番）

            displayOrder:
              type: integer
              minimum: 0
              description: 表示順（任意・非負整数）。省略時はコピー元の直下。大きいほど画面上部。指定値は保存時に画面と同じ 10 刻みへ正規化（応答は正規化後の値）
              example: 25
    SubrecordTablePermissionGroup:
      type: object
      nullable: true
      description: 権限グループ（未設定は null）
      properties:
        id:
          type: string
          description: ロール ID
        name:
          type: string
          description: ロール名（読み取り専用。書き込み時は無視）

    SubrecordTable:
      type: object
      description: サブレコードテーブルオブジェクト
      properties:
        id:
          type: string
          description: サブレコードテーブル ID（sb_code・内部連番。URL には使いません）
          example: "12"
        key:
          type: string
          description: サブレコードテーブルキー（sb_key・`SB-xxxxxx`。URL 識別子 `{subrecordTableKey}`）
          example: "SB-aB3xY9"
        displayOrder:
          type: integer
          description: 表示順（大きいほど画面上部・常に 10 刻み。作成時に自動採番・PATCH で変更可。指定値は保存時に正規化）
          example: 30
        name:
          type: string
          description: サブレコード名
        status:
          type: string
          description: |-
            公開状態（PATCH で切替可）
            - `active`: 公開
            - `inactive`: 非公開（作成直後の既定）
          enum: [active, inactive]
        icon:
          type: string
          nullable: true
          description: アイコン（FontAwesome class。一覧では fields=all 時のみ返却）
        fieldCount:
          type: integer
          description: 項目数（軽い集計。一覧の既定でも返却）
        recordCount:
          type: integer
          description: 行データ件数（重い集計。一覧では fields=all または明示指定でのみ返却）
        displayStyle:
          type: string
          description: |-
            表示スタイル
            - `list`: リスト表示
            - `block`: ブロック表示
          enum: [list, block]
        displayScale:
          type: integer
          nullable: true
          description: 表示件数（未設定は null＝全件）
        defaultSortKey:
          type: string
          nullable: true
          description: 行のデフォルトソート（基本 3 オプション createdAt / updatedAt / displayOrder または並べ替え可能フィールド）
        showInList:
          type: boolean
          description: 一覧表示を行う
        bulkImport:
          type: boolean
          description: 一括インポートを行う（読み取り専用・作成/更新の送信不可）
        showSummary:
          type: boolean
          description: 合計行を表示する
        defaultColumns:
          type: array
          description: 標準項目の表示
          items:
            type: string
        hideEmptyFields:
          type: boolean
          description: 未入力項目を非表示にする
        notificationEnabled:
          type: boolean
          description: 通知の送信機能を利用する
        permissionGroup:
          $ref: '#/components/schemas/SubrecordTablePermissionGroup'
        createdBy:
          $ref: '#/components/schemas/AccountRef'
        createdAt:
          type: string
          format: date-time
          description: 作成日時（ISO 8601 UTC）

    SubrecordTableListResponse:
      type: object
      description: サブレコードテーブル一覧（cursor ページネーション付き）
      properties:
        subrecordTables:
          type: array
          items:
            $ref: '#/components/schemas/SubrecordTable'
        pagination:
          $ref: '#/components/schemas/Pagination'

    SubrecordTableSingleResponse:
      type: object
      properties:
        subrecordTable:
          $ref: '#/components/schemas/SubrecordTable'

    SubrecordTableCreateRequest:
      type: object
      required: [subrecordTable]
      properties:
        subrecordTable:
          type: object
          required: [name]
          description: 作成するサブレコードテーブル。必須は name のみ。id / key / status / fields 等サーバー管理値・別操作項目は送信不可（422 forbidden）
          properties:
            name:
              type: string
              maxLength: 255
              description: サブレコード名（最大 255 文字）
              example: "発注明細"
            displayOrder:
              type: integer
              minimum: 0
              description: 表示順（任意・非負整数）。大きいほど画面上部。省略時は末尾に自動採番（＝作成順）。指定値は保存時に画面と同じ 10 刻みへ正規化（応答は正規化後の値）
              example: 25
            icon:
              type: string
              nullable: true
              description: アイコン（FontAwesome class）
            displayStyle:
              type: string
              description: 表示スタイル
              enum: [list, block]
            displayScale:
              type: integer
              nullable: true
              description: 表示件数（未設定は全件）
            defaultSortKey:
              type: string
              nullable: true
              description: 行のデフォルトソート
            showInList:
              type: boolean
              description: 一覧表示を行う
            showSummary:
              type: boolean
              description: 合計行を表示する
            defaultColumns:
              type: array
              description: 標準項目の表示
              items:
                type: string
            hideEmptyFields:
              type: boolean
              description: 未入力項目を非表示にする
            notificationEnabled:
              type: boolean
              description: 通知の送信機能を利用する
            permissionGroup:
              $ref: '#/components/schemas/SubrecordTablePermissionGroup'

    SubrecordTablePatchRequest:
      type: object
      required: [subrecordTable]
      properties:
        subrecordTable:
          type: object
          description: 更新するキーのみ送信（Merge Patch）。id / key 等サーバー管理値・宣言外キーは送信不可（422 forbidden）
          properties:
            name:
              type: string
              maxLength: 255
              description: サブレコード名（最大 255 文字）。null / 空文字で送ると必須項目のクリアとして 422 required
            displayOrder:
              type: integer
              minimum: 0
              description: 表示順（非負整数）。指定時のみ更新＝並べ替え。大きいほど画面上部。指定値は保存時に画面と同じ 10 刻みへ正規化（応答は正規化後の値）
              example: 25
            status:
              type: string
              description: 公開状態の切替
              enum: [active, inactive]
            icon:
              type: string
              nullable: true
              description: アイコン（FontAwesome class・null でクリア）
            displayStyle:
              type: string
              description: 表示スタイル
              enum: [list, block]
            displayScale:
              type: integer
              nullable: true
              description: 表示件数（未設定は全件）
            defaultSortKey:
              type: string
              nullable: true
              description: 行のデフォルトソート（基本 3 オプション or 並べ替え可能フィールドのみ受理）
            showInList:
              type: boolean
              description: 一覧表示を行う
            showSummary:
              type: boolean
              description: 合計行を表示する
            defaultColumns:
              type: array
              description: 標準項目の表示
              items:
                type: string
            hideEmptyFields:
              type: boolean
              description: 未入力項目を非表示にする
            notificationEnabled:
              type: boolean
              description: 通知の送信機能を利用する
            permissionGroup:
              $ref: '#/components/schemas/SubrecordTablePermissionGroup'

    SubrecordTableClearResponse:
      type: object
      properties:
        summary:
          type: object
          properties:
            clearedCount:
              type: integer
              description: クリアした行数

    SubrecordTableFieldConfigAutoNumber:
      type: object
      title: autoNumber 型（サブレコード）
      description: "`autoNumber` 型のサブレコード項目設定（config）。メインと異なり `startNumber`（開始番号）と `resetDate`（リセット指定日）は非対応（送ると 422 forbidden）。"
      properties:
        prefix:
          type: string
          description: 接頭辞（採番フォーマット）
        suffix:
          type: string
          description: 接尾辞（採番フォーマット）
        digits:
          type: integer
          description: 連番の桁数
        generationTiming:
          type: string
          description: |-
            採番タイミング
            - `onCreate`: 新規登録時
            - `manual`: 任意のタイミング
            - `workflowStart`: ワークフロー開始時
            - `workflowApproval`: ワークフロー承認時
            - `automation`: オートメーション機能に連動
          enum:
            - onCreate
            - manual
            - workflowStart
            - workflowApproval
            - automation
        resetCycle:
          type: string
          description: |-
            連番のリセット周期（サブは差し込みキー非対応のため実質 `never` / `perPrefix`）
            - `never`: リセットしない
            - `perPrefix`: プレフィックス毎
          enum:
            - never
            - perPrefix
        font:
          type: object
          description: フォント
          nullable: true
        roleGroup:
          type: string
          description: 権限グループ（ロール ID）
          nullable: true
        keywordSearchable:
          type: boolean
          description: キーワード検索対象
        matchType:
          type: string
          description: 検索の一致方法
          nullable: true
        searchRemarks:
          type: string
          description: 検索補足
          nullable: true

    SubrecordTableFieldConfig:
      description: |-
        サブレコード項目の型固有設定（config）。**メインレコード項目より使える型が少ない**（23 型）。
        カテゴリ（category）／タグ（tag）／マイリスト（mylist）／色（color）／ラベル（label）はサブレコードでは作れないため、
        それらの config は含まれない。type を選ぶとその型の config が見える。
        未設定のキーは `null` またはスケルトンで返り、その値をそのまま PATCH に渡して往復できる。
      oneOf:
        - $ref: "#/components/schemas/FieldConfigText"
        - $ref: "#/components/schemas/FieldConfigTextarea"
        - $ref: "#/components/schemas/FieldConfigEmail"
        - $ref: "#/components/schemas/FieldConfigUrl"
        - $ref: "#/components/schemas/FieldConfigZipCode"
        - $ref: "#/components/schemas/FieldConfigPassword"
        - $ref: "#/components/schemas/FieldConfigTel"
        - $ref: "#/components/schemas/FieldConfigNumber"
        - $ref: "#/components/schemas/FieldConfigDate"
        - $ref: "#/components/schemas/FieldConfigTime"
        - $ref: "#/components/schemas/FieldConfigPrefecture"
        - $ref: "#/components/schemas/FieldConfigPersonName"
        - $ref: "#/components/schemas/FieldConfigAddress"
        - $ref: "#/components/schemas/FieldConfigSelect"
        - $ref: "#/components/schemas/FieldConfigRadio"
        - $ref: "#/components/schemas/FieldConfigCheckbox"
        - $ref: "#/components/schemas/FieldConfigUser"
        - $ref: "#/components/schemas/FieldConfigGroup"
        - $ref: "#/components/schemas/FieldConfigCalc"
        - $ref: "#/components/schemas/SubrecordTableFieldConfigAutoNumber"
        - $ref: "#/components/schemas/FieldConfigFile"
        - $ref: "#/components/schemas/FieldConfigRelation"
        - $ref: "#/components/schemas/FieldConfigLookup"

    SubrecordTableField:
      type: object
      description: |
        サブレコード項目定義オブジェクト。メインレコード項目（`Field`）と構造は同じですが、
        **サブレコードで使える型は 23 型**（category / tag / mylist / color / label は不可）で、
        `config` はサブレコード用の型別設定（`SubrecordTableFieldConfig`）になります。
      properties:
        id:
          type: string
          description: 項目ID（af_code、数値文字列）
          example: "312"
        key:
          type: string
          description: 項目キー（af_name、英数字小文字）
          example: "text01"
        name:
          type: string
          description: 項目名（af_title）
          example: "一行テキスト"
        type:
          type: string
          description: |
            項目の型（サブレコードで使える 23 型）。`config` の中身はこの型によって変わります。
            category / tag / mylist / color / label はサブレコードでは作れないため含まれません。
          enum:
            - text
            - textarea
            - email
            - url
            - zipCode
            - password
            - tel
            - number
            - date
            - time
            - prefecture
            - personName
            - address
            - select
            - radio
            - checkbox
            - user
            - group
            - calc
            - autoNumber
            - file
            - relation
            - lookup
          example: "text"
        displayOrder:
          type: integer
          description: 表示順（大きいほど画面上部・常に 10 刻み。作成時に自動採番・PATCH で変更可。指定値は保存時に正規化）
          example: 30
        enabled:
          type: boolean
          description: 使用/未使用
        required:
          type: boolean
          description: 必須項目
        searchable:
          type: boolean
          description: 検索対象
        sortable:
          type: boolean
          description: ソート対象
        showInList:
          type: boolean
          description: 一覧表示の候補にする（実際の列表示はユーザー個別の一覧設定で決まる）
        showInDetail:
          type: boolean
          description: 詳細表示
        isTitle:
          type: boolean
          description: タイトル項目。サブレコード項目では設定できないため常に false で返ります。
        partOfUniqueKey:
          type: boolean
          description: 複合ユニークキーの構成メンバー。サブレコード項目では設定できないため常に false で返ります。
        duplicateAllowed:
          type: boolean
          description: 重複登録を許可する（サブレコード項目でも設定できます。false にできる対応型は text / number / date / personName / tel / email / url のみ）
        remarks:
          type: string
          nullable: true
          description: 入力時備考（空文字は null）
        config:
          $ref: '#/components/schemas/SubrecordTableFieldConfig'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        createdBy:
          $ref: '#/components/schemas/AccountRef'

    SubrecordTableFieldListResponse:
      type: object
      description: サブレコード項目定義一覧（ページネーション無し・全件）
      properties:
        fields:
          type: array
          items:
            $ref: '#/components/schemas/SubrecordTableField'

    SubrecordTableFieldSingleResponse:
      type: object
      properties:
        field:
          $ref: '#/components/schemas/SubrecordTableField'

    SubrecordTableFieldCreateRequest:
      type: object
      required: [field]
      description: |-
        サブレコード項目の作成リクエスト。メインの項目追加（`FieldCreateRequest`）と同一契約ですが、サブレコードテーブル固有の制限があります。
        - `type` はサブ非対応型（category / tag / mylist / color / label）を除く
        - `isTitle` / `partOfUniqueKey` はサブ非対応（送ると 422 forbidden）のため本スキーマに含めない
        - `duplicateAllowed`（重複登録）はサブでも設定できます（画面のサブ項目設定と同じ。false にできる対応型は text / number / date / personName / tel / email / url のみ）
        - autoNumber の `config.startNumber` / `config.resetDate` はサブ非対応（送ると 422 forbidden）
      properties:
        field:
          type: object
          required: [name, type]
          properties:
            name:
              type: string
              description: 項目名
            type:
              type: string
              description: |
                項目の型（サブレコードで使える 23 型）。category / tag / mylist / color / label はサブ非対応のため送ると 422。
                `config` の中身はこの型によって変わります（`SubrecordTableFieldConfig` を参照）。
              enum:
                - text
                - textarea
                - number
                - personName
                - tel
                - email
                - url
                - zipCode
                - prefecture
                - address
                - date
                - time
                - select
                - radio
                - checkbox
                - file
                - password
                - user
                - group
                - calc
                - autoNumber
                - relation
                - lookup
            key:
              type: string
              description: 項目キー（省略時サーバー自動採番。小文字英数字と `_`・15 文字以内）
            displayOrder:
              type: integer
              minimum: 0
              description: 表示順（任意・非負整数）。大きいほど画面上部。省略時は末尾に自動採番（＝作成順）。指定値は保存時に画面と同じ 10 刻みへ正規化（応答は正規化後の値）
              example: 25
            required:
              type: boolean
              description: 必須項目にするか
            searchable:
              type: boolean
              description: 検索対象にするか
            sortable:
              type: boolean
              description: ソート対象にするか
            showInList:
              type: boolean
              description: 一覧表示の候補にするか
            showInDetail:
              type: boolean
              description: 詳細表示にするか
            enabled:
              type: boolean
              description: 使用/未使用
            duplicateAllowed:
              type: boolean
              description: 重複登録を許可する（省略時 true。false で同じ値の登録不可。false にできるのは text / number / date / personName / tel / email / url のみ・非対応型は 422）
            remarks:
              type: string
              nullable: true
              description: 入力時備考
            config:
              $ref: '#/components/schemas/SubrecordTableFieldConfig'

    SubrecordTableFieldUpdateRequest:
      type: object
      required: [field]
      description: |-
        サブレコード項目の更新リクエスト（Merge Patch）。送ったキーだけ更新します。メインの項目更新（`FieldUpdateRequest`）と同一契約ですが、
        `isTitle` / `partOfUniqueKey`、autoNumber の `config.startNumber` / `config.resetDate` はサブ非対応（送ると 422 forbidden）のため含めません。
        `duplicateAllowed`（重複登録）はサブでも設定できます（画面のサブ項目設定と同じ。false にできる対応型は text / number / date / personName / tel / email / url のみ）。
        `type` / `key` / `id` 等は変更不可（異値は 422 read_only）。
      properties:
        field:
          type: object
          properties:
            id:
              type: string
              readOnly: true
              description: 項目ID。読み取り専用（異なる値を送ると 422 read_only）。
            type:
              type: string
              readOnly: true
              description: 項目の型。作成後は変更不可（異なる値を送ると 422 read_only）。
            key:
              type: string
              readOnly: true
              description: 項目キー。読み取り専用（異なる値を送ると 422 read_only）。
            createdBy:
              readOnly: true
              allOf:
                - $ref: '#/components/schemas/AccountRef'
              description: 作成者。読み取り専用。
            createdAt:
              type: string
              format: date-time
              readOnly: true
              description: 作成日時。読み取り専用。
            updatedAt:
              type: string
              format: date-time
              readOnly: true
              description: 更新日時。読み取り専用。
            name:
              type: string
              description: 項目名
            displayOrder:
              type: integer
              minimum: 0
              description: 表示順（非負整数）。指定時のみ更新＝並べ替え。大きいほど画面上部。指定値は保存時に画面と同じ 10 刻みへ正規化（応答は正規化後の値）
              example: 25
            required:
              type: boolean
              description: 必須項目にするか
            searchable:
              type: boolean
              description: 検索対象にするか
            sortable:
              type: boolean
              description: ソート対象にするか
            showInList:
              type: boolean
              description: 一覧表示の候補にするか
            showInDetail:
              type: boolean
              description: 詳細表示にするか
            enabled:
              type: boolean
              description: 使用/未使用
            duplicateAllowed:
              type: boolean
              description: 重複登録を許可する（false で同じ値の登録不可。false にできるのは text / number / date / personName / tel / email / url のみ・非対応型は 422）
            remarks:
              type: string
              nullable: true
              description: 入力時備考
            config:
              $ref: '#/components/schemas/SubrecordTableFieldConfig'

    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: エラーコード（小文字 snake_case）
            message:
              type: string
              description: エラーメッセージ（日本語）
            logId:
              type: integer
              nullable: true
              description: API ログ ID（DB接続後のエラーのみ）
            details:
              type: array
              nullable: true
              description: バリデーションエラーの詳細（422 のみ）
              items:
                type: object
                properties:
                  field:
                    type: string
                  code:
                    type: string
                    description: |
                      違反種別（小文字 snake_case）。例: `required` / `invalid_value` / `invalid_enum` /
                      `invalid_format` / `out_of_range_min` / `out_of_range_max` / `forbidden` / `read_only`
                  message:
                    type: string

    FileUploadResponse:
      type: object
      properties:
        file:
          type: object
          properties:
            fileKey:
              type: string
              description: レコード紐付けに使うトークン（`{数値}-{数値}` 形式）。実体の取得はレコード添付後のダウンロード EP から行う
              example: "97-1782492047"
            name:
              type: string
              description: アップロードした元ファイル名
              example: "report.pdf"
            size:
              type: integer
              description: ファイルサイズ（バイト）
              example: 20480
            contentType:
              type: string
              description: MIME タイプ（パートで未指定の場合は application/octet-stream）
              example: "application/pdf"
            createdAt:
              type: string
              format: date-time
              description: アップロード日時（ISO 8601 UTC）
              example: "2026-06-27T01:00:47Z"

    Record:
      type: object
      description: レコード（メインの表の 1 行）。システム項目はトップレベル、ユーザー定義項目は `fields` 配下。
      properties:
        id:
          type: string
          description: レコード ID（dt_code 素体）
        title:
          type: string
          nullable: true
          description: タイトル（タイトル項目の値。空は null）
        createdAt:
          type: string
          format: date-time
          description: 作成日時（ISO 8601 UTC）
        updatedAt:
          type: string
          format: date-time
          nullable: true
          description: 更新日時（ISO 8601 UTC・未更新は null）
        createdBy:
          allOf:
            - $ref: '#/components/schemas/AccountRef'
          description: 作成者
        updatedBy:
          allOf:
            - $ref: '#/components/schemas/AccountRef'
          description: 更新者
        status:
          type: integer
          nullable: true
          description: ステータス（0 未対応 / 1 処理中 / 2 処理済 / 3 完了）。レコードステータス機能 ON のアプリのみキーが出力されます。
        assignee:
          allOf:
            - $ref: '#/components/schemas/AccountRef'
          description: 担当者（レコードステータス機能 ON のアプリのみ）
        startDate:
          type: string
          nullable: true
          description: 開始日（ISO date・レコードステータス機能 ON のアプリのみ）
        dueDate:
          type: string
          nullable: true
          description: 期限日（ISO date・レコードステータス機能 ON のアプリのみ）
        approvalStatus:
          type: integer
          nullable: true
          description: 承認状態（null 未申請 / 1 申請中 / 2 承認済 / 3 却下）。ワークフロー機能 ON のアプリのみ。
        fields:
          type: object
          description: |
            ユーザー定義項目の値。キーは項目キー（fieldKey = af_name）、値は項目の型により形が変わります（`RecordFieldValue` 参照）。
            `?fields=id,title` のようにシステム項目のみを要求した場合、`fields` は含まれません。
          additionalProperties:
            $ref: '#/components/schemas/RecordFieldValue'

    SubrecordTableSchemaListResponse:
      type: object
      description: 種別一覧（`GET /apps/{appKey}/subrecordTables`）のレスポンスです。
      properties:
        subrecordTables:
          type: array
          description: 種別の一覧（画面の表示順）。種別が 1 件も無い場合は空配列。
          items:
            type: object
            properties:
              key:
                type: string
                description: 種別キー。明細の入力スキーマ参照・明細 CRUD の `subrecordTableKey` に使います。
                example: "SB-aB3xY9"
              name:
                type: string
                description: 種別名（画面の種別タブの見出し）。未設定の場合は種別キーを返します。
                example: "対応履歴"

    FieldSchemaListResponse:
      type: object
      description: 入力スキーマ参照（`GET /apps/{appKey}/fields`・`GET /apps/{appKey}/subrecordTables/{subrecordTableKey}/fields`）のレスポンスです。
      properties:
        fields:
          type: array
          description: 項目定義の一覧（画面の表示順）。項目が 1 件も無い場合は空配列。
          items:
            $ref: '#/components/schemas/FieldSchema'

    FieldSchema:
      type: object
      description: |
        1 項目ぶんの入力スキーマです。レコードの `fields.{key}` に何をどう送るかが分かる最小情報だけを返します。
      properties:
        key:
          type: string
          description: 項目キー。レコードの `fields` のキーと一致します。
          example: "text01"
        label:
          type: string
          description: 項目名（画面の入力欄の見出し）。未設定の場合は項目キーを返します。
          example: "件名"
        type:
          type: string
          description: 項目の型。項目設定 API（`/settings/apps/{appKey}/fields`）と同じ型名です。
          enum: [text, textarea, checkbox, radio, select, file, date, time, number, personName, tel, email, url, address, zipCode, prefecture, password, user, group, category, tag, color, mylist, calc, autoNumber, relation, lookup]
          example: "text"
        required:
          type: boolean
          description: 必須項目かどうか。`true` の項目を省略・空で登録すると 422 になります。
          example: true
        multiple:
          type: boolean
          description: 値を配列で送るかどうか（`valueShape` が配列形かどうかの要約）。
          example: false
        valueShape:
          type: string
          description: |
            値の送信形です。型名だけでは形が決まらない（分類は `{"id": …}`、ファイルは `{"fileKey": …}`、範囲は `{"from": …, "to": …}`）ため、送る形をこのキーで示します。
            `scalar`=文字列・数値 / `scalarList`=スカラの配列 / `objectId`=`{"id": "<コード>"}` / `objectIdList`=`[{"id": "<コード>"}]`（`["<コード>"]` も可）/
            `fileRef`=`{"fileKey": …, "name": …}` / `recordRef`=`{"appKey": …, "recordId": …}`（`recordId` 文字列も可）/ `range`=`{"from": …, "to": …}` /
            `addressObject`=住所サブキーのオブジェクト / `none`=値を送れない（`writable` が `false` の型）。
            同じ型でも項目設定で変わります（ユーザー／グループは複数選択なら `scalarList`、数値・日付・時刻は範囲入力なら `range`）。
            なお、ユーザー／グループはレコード取得時 `{id, name}` の形で返りますが、送るときは ID の文字列です。
            都度参照の参照項目（`type` が `lookup` かつ `writable` が `true`）は `scalar` 等の通常の値のほか、`{"sync": true}` を送ると参照先レコードの現在値を取り込み直せます（`RecordValueLookupSync` 参照）。
          enum: [scalar, scalarList, objectId, objectIdList, fileRef, recordRef, range, addressObject, none]
          example: "scalar"
        writable:
          type: boolean
          description: |
            値を送れるかどうか。`false` の項目に値を送ると 422 になります。
            `false` になるのは、値が自動で決まる型（計算式・参照項目・自動採番）か、項目の編集権限が無い場合です。
            例外として参照項目（`lookup`）の都度参照は `true` です（コピーされた値を手入力で書き換えられます。`valueShape` の `{"sync": true}` も参照）。
          example: true
        options:
          type: array
          nullable: true
          description: |
            選択できる値の一覧です。選択肢を持たない型では `null`、選択肢を持つが 1 件も登録されていない場合は空配列を返します。
            送るときは `valueShape` に従って包みます（`objectId` なら `{"id": "<value>"}`）。
          items:
            $ref: '#/components/schemas/FieldSchemaOption'
        constraints:
          type: object
          nullable: true
          description: |
            入力制約です。画面の登録フォームが入力時に利用者へ見せている制約（違反すると登録が 422 になるもの）だけを返します。
            制約を持たない型・何も設定されていない項目は `null` です。設定されている制約のキーだけが現れます。
            - `inputCondition`（string）: 入力値条件。項目設定 API の `config.inputCondition` と同じ語彙（`halfwidthDigits` / `halfwidthAlnum` / `emailSyntax` / `urlSyntax` など）。テキスト・メールアドレス・URL 型のみ
            - `range`（object `{min, max}`）: 数値の範囲。数値型のみ（未設定側は `null`）
            - `decimal`（object `{integerDigits, decimalPlaces}`）: 数値の桁数（整数部・小数部）。数値型の小数のみ
          properties:
            inputCondition:
              type: string
              nullable: true
            range:
              type: object
              nullable: true
            decimal:
              type: object
              nullable: true
          example: { inputCondition: "halfwidthAlnum" }

    FieldSchemaOption:
      type: object
      description: 選択肢 1 件です。
      properties:
        value:
          type: string
          description: 送信に使う値（分類系は共有マスタのコード）。
          example: "22"
        label:
          type: string
          description: 画面に表示される名称（カテゴリは `親 > 子` の形）。表示専用で、送信には使いません。
          example: "営業 > 新規"
        color:
          type: string
          nullable: true
          description: 選択肢の色（未設定・色を持たない選択肢は `null`）。
          example: "#ff0000"

    RecordListResponse:
      type: object
      properties:
        records:
          type: array
          description: レコード一覧
          items:
            $ref: '#/components/schemas/Record'
        pagination:
          $ref: '#/components/schemas/Pagination'

    RecordSearchRequest:
      type: object
      description: レコード検索（`POST /records/search`）のリクエスト。すべて省略可（空で全件）。
      properties:
        filters:
          type: array
          description: 絞り込み条件の配列（省略・空配列で全件）。各要素は `RecordFilter`。フィルタ間は AND。
          items:
            $ref: '#/components/schemas/RecordFilter'
        keyword:
          type: string
          description: フリーワード検索（画面の検索ボックスと同等・空白区切りで複数語）。`filters` とは AND。
          example: "東京 支店"
        keywordMatch:
          type: string
          description: フリーワードの結合（`and`=全語含む / `or`=いずれか含む）。
          enum: [and, or]
          default: and
        keywordTarget:
          type: string
          description: フリーワードの検索対象（fieldKey）。省略時は全文インデックス（全項目）。
        sort:
          type: string
          description: >-
            並べ替えキー（システム項目 `id` / `createdAt` / `updatedAt` / `title` / `category`、またはソート可（sortable=true）のユーザー項目）。
            非対応キーは 422。省略時は画面既定のソート。項目キーがシステム項目と同名の場合は `fields.title` のように `fields.` を付けてユーザー項目を指定します。
          example: "createdAt"
        order:
          type: string
          description: 並び順（`asc` 昇順 / `desc` 降順）。`sort` 指定時のみ有効。
          enum: [asc, desc]
          default: desc
        limit:
          type: integer
          description: 1 ページの最大件数（1〜1000。0 以下は既定・1001 以上は 1000 に切り詰め）。省略時 1000。
          example: 100
        cursor:
          type: string
          description: 次ページ取得用カーソル（前ページ応答の `pagination.nextCursor`）。

    RecordFilter:
      type: object
      description: |
        1 項目の絞り込み条件。`field`（fieldKey またはシステム項目）に対し、**項目の型に応じたキー**を指定します。
        使うキーは型で変わります（下記）。同じ条件内で無関係なキーは指定しません。
        - **システム項目**（画面の詳細検索「基本情報」と同じ。レスポンスのキー名でそのまま指定できます）
          - `id`（レコードID）: `value`（完全一致）
          - `title`（タイトル）: `value`（部分一致）
          - `createdAt`（登録日）/ `updatedAt`（更新日）: `from` / `to`（`YYYY-MM-DD`・片側可）または `relative`（`today` / `thisMonth` / `lastMonth` / `thisYear` / `lastYear`）
          - `createdBy`（作成者）/ `updatedBy`（更新者）: `in`（アカウント ID のいずれか一致）
          - レコードの状態（`status` / `assignee` / `startDate` / `dueDate`）・承認（`approvalStatus` ほか）での絞り込みは未対応です
        - **項目キーがシステム項目と同名のとき**（例: 項目キーが `title` のユーザー項目）は、`fields.title` のように `fields.` を付けるとユーザー項目を指定できます
          （`fields.` を付けないキーは常にシステム項目が優先。`?fields=` の個別指定と同じ表記で、衝突していない項目に付けても構いません）
        - **1 つの条件に別の指定方法を混ぜると 422**（片方が無視されるのを防ぐため）。日付・日時は `relative` / `from`・`to` / `value` のどれか 1 つ、
          数値は `value` / `from`・`to` のどちらか、時刻は `none` / `from`・`to` / `value` のどれか 1 つ、
          複数選択（checkbox・select・radio・user・group・作成者・更新者）は `in` / `value` のどちらかにしてください
        - テキスト系（text / textarea / email / url / prefecture / personName）: `value`（一致。マッチ方式は項目設定に従う）
        - 数値（number）: `from` / `to`（範囲・片側可）または `value`（単値）
        - 日付・日時（date / datetime）: `from` / `to`（範囲）または `relative`（相対期間）。値は `YYYY-MM-DD`（日本時間の日付）で指定します。
          日時の項目も日付単位で絞り込みます（時刻は指定できません）。時刻つき・スラッシュ区切りなど `YYYY-MM-DD` 以外の形式と、ありえない日付は 422
        - 時刻（time）: `from` / `to` または `value`。値は `HH:MM` または `HH:MM:SS`。`none: true` で時刻未登録のレコードを絞り込み。
          時刻以外の形式と、ありえない時刻は 422
        - 選択肢（select / radio / checkbox）: `in`（いずれか一致）。checkbox は `match` で and/or
        - ユーザー・グループ（user / group）: `in`（いずれか一致。単一項目は `value` も可）
        - 分類（category / color / tag / mylist）: `in`（いずれか一致。category / color は `value` も可）。マイリストは本人のもののみ・タグ ID は数値
        - ファイル（file）: `exists`（有無）/ `name`（ファイル名の部分一致）/ `sizeFrom` / `sizeTo` / `sizeUnit`
        - 検索対象外: パスワード（pwd）・アプリ間連携（relation）を指定すると 422
      required: [field]
      properties:
        field:
          type: string
          description: >-
            対象の fieldKey（af_name）、またはシステム項目（`id` / `title` / `createdAt` / `updatedAt` /
            `createdBy` / `updatedBy`）。システム項目と同名の項目キーは `fields.{fieldKey}`（例: `fields.title`）で指定します。
            未知のキーは 422 `fields_unknown`（2 段以上のドットは 422 `fields_nested_not_supported`）。
          example: "text01"
        value:
          description: >-
            一致値（テキスト系 / select・radio / 単一 user・group / category・color / 単値の number・date・time、
            システム項目 `id`〔完全一致〕・`title`〔部分一致〕）。date / datetime は `YYYY-MM-DD`、time は `HH:MM` または `HH:MM:SS`。
        from:
          description: >-
            範囲の下限（number / date / datetime / time の範囲、システム項目 `createdAt`・`updatedAt`〔`YYYY-MM-DD` のみ〕）。
            date / datetime は `YYYY-MM-DD`、time は `HH:MM` または `HH:MM:SS`。
        to:
          description: >-
            範囲の上限（number / date / datetime / time の範囲、システム項目 `createdAt`・`updatedAt`〔`YYYY-MM-DD` のみ〕）。
            date / datetime は `YYYY-MM-DD`、time は `HH:MM` または `HH:MM:SS`。
        relative:
          type: string
          description: >-
            相対期間（date / datetime）。`today`=今日 / `thisMonth`=今月 / `lastMonth`=先月 / `nextMonth`=来月 / `thisYear`=今年（1/1〜12/31） / `lastYear`=去年 / `nextYear`=来年 / `none`=未登録。
            システム項目 `createdAt`・`updatedAt` は画面と同じく `today` / `thisMonth` / `lastMonth` / `thisYear` / `lastYear` のみ（`nextMonth` / `nextYear` / `none` は 422）。
          enum: [today, thisMonth, lastMonth, nextMonth, thisYear, lastYear, nextYear, none]
        in:
          type: array
          description: >-
            複数値のいずれか（checkbox / 複数 user・group / select・radio / tag / mylist / category・color、
            システム項目 `createdBy`・`updatedBy`〔アカウント ID〕）。
          items:
            type: string
        match:
          type: string
          description: 複数値の結合（checkbox / 複数 user・group / システム項目 `createdBy`・`updatedBy`）。`and`=全て含む / `or`=いずれか含む。
          enum: [and, or]
          default: or
        none:
          type: boolean
          description: 時刻未登録の絞り込み（time）。`true`=時刻が入っていないレコードのみ。`from` / `to` / `value` とは同時に指定できません（422）。
        exists:
          type: boolean
          description: ファイルの有無（file）。`true`=添付あり / `false`=添付なし。
        name:
          type: string
          description: ファイル名の部分一致（file）。
        sizeFrom:
          type: integer
          description: ファイルサイズの下限（file・`sizeUnit` で単位換算）。
        sizeTo:
          type: integer
          description: ファイルサイズの上限（file・`sizeUnit` で単位換算）。
        sizeUnit:
          type: integer
          description: ファイルサイズの単位倍率（file・既定 1=バイト。1024=KB 等）。
          default: 1

    RecordSingleResponse:
      type: object
      properties:
        record:
          $ref: '#/components/schemas/Record'

    RecordCreateRequest:
      type: object
      required: [record]
      properties:
        record:
          type: object
          description: 登録するレコード
          required: [fields]
          properties:
            fields:
              type: object
              description: ユーザー定義項目の値（fieldKey → 値）。値の形は `RecordFieldValueWrite` 参照。
              additionalProperties:
                $ref: '#/components/schemas/RecordFieldValueWrite'

    RecordPatchRequest:
      type: object
      required: [record]
      properties:
        record:
          type: object
          description: 更新するレコード（Merge Patch）
          required: [fields]
          properties:
            fields:
              type: object
              description: 更新する項目のみ（fieldKey → 値）。未送信は維持・`null` / 空はクリア。値の形は `RecordFieldValueWrite` 参照。
              additionalProperties:
                $ref: '#/components/schemas/RecordFieldValueWrite'

    RecordCopyRequest:
      type: object
      description: レコード複製リクエスト（すべて任意。空ボディ `{}` で元レコードをそのまま複製）
      properties:
        record:
          type: object
          description: 複製先メイン項目の上書き（省略時は元レコードの値を継承）
          properties:
            fields:
              type: object
              description: 上書きする項目のみ（fieldKey → 値）。値の形は `RecordFieldValueWrite` 参照。読み取り専用型への値は 422 `read_only`。
              additionalProperties:
                $ref: '#/components/schemas/RecordFieldValueWrite'
        includeSubrecordTables:
          type: array
          description: 複製するサブレコードテーブルの subrecordTableKey（`SB-xxxx`）。省略/空はサブレコードを複製しません。重複禁止かつ必須の項目を持つ種別は複製できず 422 `invalid_value`。
          items:
            type: string
          example: ["SB-aB3xY9"]

    RecordFieldValue:
      description: |
        ユーザー定義項目の値（read）。項目の型により形が変わります:
        - passthrough（text / textarea / radio / select / tel / email / url / zipCode / prefecture / personName）・color・numbering・文字列 calc / lookup → 文字列
        - number（整数）・整数 calc → 整数 / number（小数）→ 小数 / number（zerofill）→ 文字列（`"0001"`・先頭 0 維持）
        - number / date / time の範囲 → `{ from, to }`（`RecordValueRange`）
        - date → `"2026-04-23"`（日付）/ `"2026-04-23T00:30:00Z"`（日時・UTC）
        - time → `"09:30"` または `"09:30:45"`
        - checkbox → 文字列の配列（`["1","2"]`）
        - user / group（単一）→ `{ id, name }` / （複数）→ `[{ id, name }]`
        - category → `{ id, name }`（name は「親 > 子」）/ tag・mylist → `[{ id, name }]`
        - address → `{ postalCode, prefecture, city, houseNumber, streetAddress, building }`（`RecordValueAddress`）
        - apps（アプリ間連携）→ `{ appKey, recordId }`（`RecordValueAppsRef`）
        - file → `{ fileKey, name, size, contentType }`（`RecordValueFile`）
        - calc / lookup（計算・参照項目）→ **参照先・計算結果の型と同じ形**（上記の各行に従う。例: 参照先が checkbox なら文字列の配列、address なら object、user / group なら `{ id, name }`、file なら `{ fileKey, ... }`、text 等なら文字列）。同期参照・都度参照のどちらでも同じ形で返ります
        - 未設定・空 → null
      nullable: true
      oneOf:
        - type: string
          description: 文字列型（passthrough・color・numbering・zerofill・文字列 calc / lookup）
        - type: integer
          description: 整数（number 整数・整数 calc）
        - type: number
          description: 小数（number 小数・小数 calc）
        - type: array
          description: checkbox の選択値（value の配列）
          items:
            type: string
        - $ref: '#/components/schemas/RecordValueRange'
        - $ref: '#/components/schemas/RecordRef'
        - type: array
          description: user / group（複数）・tag・mylist（`{ id, name }` の配列）
          items:
            $ref: '#/components/schemas/RecordRef'
        - $ref: '#/components/schemas/RecordValueAddress'
        - $ref: '#/components/schemas/RecordValueAppsRef'
        - $ref: '#/components/schemas/RecordValueFile'

    RecordFieldValueWrite:
      description: |
        ユーザー定義項目に書き込む値（write）。read と同じ形で送れば往復一致します（`RecordFieldValue` 参照）:
        - passthrough・color・numbering（手動採番）・password → 文字列
        - number → 数値（zerofill は数値文字列。小数の項目は設定された小数部の桁数以内、超過は 422）/ number・date・time の範囲 → `{ from, to }`
        - date（日付のみの項目）→ `"2026-04-23"` の日付形式のみ（日時形式を送ると 422。タイムゾーン変換は行いません）
        - date（日時の項目）→ `"2026-04-23T00:30:00Z"`（UTC。API が JST 壁時計へ変換）/ time → `"09:30"`
        - checkbox → 文字列の配列 / user・group（複数）→ id の配列 / user・group（単一）→ id 文字列。選択制限（特定グループ / 特定ユーザーのみ）を設定した項目は制限範囲内の id のみ受理（範囲外は 422）
        - category → `{ id }` / tag → `[{ id }]` または `[ "id" ]` / mylist → 同形（**操作アカウント本人が所有するマイリストの id のみ**受理）
        - address → `{ postalCode, ... }` / apps → `{ appKey, recordId }` / file → `{ fileKey, name }`
        - lookup（都度参照）→ 値の直接指定に加え `{ "sync": true }` で連携先レコードの現在値を取り込み（`RecordValueLookupSync` 参照）
        - 再入力確認（requireReentry）付きの email / password 項目は確認値の送信は不要です（値をそのまま送れば登録されます）
        - `null` / 空 → クリア。読み取り専用型（calc / lookup の**同期参照**、numbering の手動採番以外）への送信は 422 `read_only`
        - 参照系（category / tag / mylist / user / group / apps / file）は実在するコード / 参照のみ受理し、非実在・権限外は 422 `invalid_value`。tag・mylist は既存コードの参照のみで、新規タグ / マイリストの作成はできません（追加は項目設定 API の `config.options` から）
      nullable: true
      oneOf:
        - type: string
          description: 文字列型（passthrough・color・numbering 手動・password・単一 user / group の id）
        - type: integer
          description: number（整数）
        - type: number
          description: number（小数）
        - type: array
          description: checkbox の値 / user・group（複数）・tag・mylist の id 配列
          items:
            oneOf:
              - type: string
              - $ref: '#/components/schemas/RecordIdRef'
        - $ref: '#/components/schemas/RecordValueRange'
        - $ref: '#/components/schemas/RecordIdRef'
        - $ref: '#/components/schemas/RecordValueAddress'
        - $ref: '#/components/schemas/RecordValueAppsRef'
        - $ref: '#/components/schemas/RecordValueFileWrite'
        - $ref: '#/components/schemas/RecordValueLookupSync'

    RecordValueRange:
      type: object
      description: 数値・日時・時刻の範囲。`from` / `to` のいずれか片方のみの指定も可（欠落側は null）。
      properties:
        from:
          nullable: true
          description: 範囲の下限（number＝数値範囲 / string＝日付・時刻範囲 / null＝未指定）
        to:
          nullable: true
          description: 範囲の上限（同上。日時範囲で to が時刻の型〔ymdhm_hm〕の場合は `"HH:MM"`）

    RecordValueAddress:
      type: object
      description: 住所セット。有効なサブキーは項目定義（`af_option.type`）に依存し、空サブキーは省略されます。write は送信したサブキーのみ部分更新（未送信は維持）。
      properties:
        postalCode:
          type: string
          description: 郵便番号
        prefecture:
          type: string
          description: 都道府県
        city:
          type: string
          description: 市区町村
        houseNumber:
          type: string
          description: 番地
        streetAddress:
          type: string
          description: 町名・番地
        building:
          type: string
          description: 建物名

    RecordValueAppsRef:
      type: object
      description: アプリ間連携（relation）の参照先。構造化により連携先レコードを `GET /apps/{appKey}/records/{recordId}` で直接辿れます。未連携は null。
      properties:
        appKey:
          type: string
          description: 連携先アプリキー
        recordId:
          type: string
          description: 連携先レコード ID（dt_code 素体）

    RecordValueFile:
      type: object
      description: 添付ファイル（1 項目＝1 ファイル）。read で返るメタ情報。実体のダウンロードは `GET /apps/{appKey}/records/{recordId}/files/{fileKey}`（サブレコードは subrecords 配下の同名 EP）。
      properties:
        fileKey:
          type: string
          description: ファイルキー（`{数値}-{数値}`）
          example: "97-1782492047"
        name:
          type: string
          description: ファイル名
          example: "report.pdf"
        size:
          type: integer
          description: ファイルサイズ（バイト）
          example: 20480
        contentType:
          type: string
          description: MIME タイプ
          example: "application/pdf"
        downloadUrl:
          type: string
          readOnly: true
          description: |
            ファイル実体のダウンロード先（読み取り専用・相対パス）。この値をそのまま `GET` すれば実体を取得できます。
            - **同じファイルでも、どのレコードから見ているかで URL が変わります**（参照項目〔同期参照〕では 1 つのファイルが複数のレコードから参照されるため）。必ずこの値を使い、`fileKey` から自分で組み立てないでください
            - サブレコードの添付では、URL の組み立てに必要な種別キーがレスポンスに含まれないため、この値が唯一の取得手段です
            - 組み立てられない文脈ではキー自体を返しません
          example: "/v2/apps/OQXJ/records/1/files/97-1782492047"

    RecordValueFileWrite:
      type: object
      description: |
        添付ファイルの紐付け（write）。事前に `POST /files` でアップロードして得た `fileKey` と `name` を指定します。
        項目の設定は添付の時点で検証・適用されます:
        - ファイル種別制限（画像 / 動画 / 音声 / PDF / テキスト）は**ファイルの拡張子**で判定します（アップロード時の Content-Type は見ません。拡張子のないファイルは制限付き項目には添付できず 422）
        - 拡張子の許可 / 拒否リスト・容量制限（maxSizeMb）も添付時に検証します（違反は 422 `invalid_value`）
        - 位置情報取得を設定した項目に GPS 情報付きの画像を添付すると、保存先の住所項目へ住所が自動入力されます（住所項目を明示送信した場合はその値を優先）
        - 画像リサイズを設定した項目では添付時に縮小版が作られます（元画像保持の設定があれば元画像も保存）
      required: [fileKey, name]
      properties:
        fileKey:
          type: string
          description: アップロードで得た fileKey（`{数値}-{数値}`）
          example: "97-1782492047"
        name:
          type: string
          description: アップロードした元ファイル名（stok は元名を保持しないため write に必須）
          example: "report.pdf"

    RecordValueLookupSync:
      type: object
      description: |
        都度参照（onDemand lookup）項目の同期指示（write）。値の代わりに送ると、連携元のアプリ間連携項目が指す
        連携先レコードの現在値を取り込んで保存します（画面の参照ボタンと同じ動作）。
        連携先レコードが未選択の場合は 422 `invalid_value`。`sync` 以外のキーを含むオブジェクトも 422 です。
        値を直接指定する通常の書き込みも引き続き可能です。
      required: [sync]
      properties:
        sync:
          type: boolean
          enum: [true]
          description: true で連携先レコードの現在値を取り込む
          example: true

    RecordRef:
      type: object
      description: id と表示名の参照（read）。アカウント・グループ・分類（category）・タグ・マイリストで共通。
      properties:
        id:
          type: string
          description: コード（ac_code / ug_code / ca_code / タグ / マイリストの ID）
        name:
          type: string
          description: 表示名（分類は「親 > 子」・解決不能時は空）

    RecordIdRef:
      type: object
      description: 参照の指定（write）。id のみ（category・tag・mylist の write 用）。
      required: [id]
      properties:
        id:
          type: string
          description: コード（ca_code / タグ / マイリストの ID）

    SubRecord:
      type: object
      description: サブレコード（1 件のレコードの中の明細行）。システム項目はトップレベル、明細項目は `fields` 配下。タイトル・ステータス・ワークフローは持ちません。
      properties:
        id:
          type: string
          description: サブレコード ID（ds_code 素体）
        recordId:
          type: string
          description: 親レコード ID（ds_data 素体）
        createdAt:
          type: string
          format: date-time
          description: 作成日時（ISO 8601 UTC）
        updatedAt:
          type: string
          format: date-time
          nullable: true
          description: 更新日時（ISO 8601 UTC・未更新は null）
        createdBy:
          allOf:
            - $ref: '#/components/schemas/AccountRef'
          description: 作成者
        updatedBy:
          allOf:
            - $ref: '#/components/schemas/AccountRef'
          description: 更新者
        fields:
          type: object
          description: |
            明細項目の値。キーは項目キー（fieldKey = af_name）、値は項目の型により形が変わります（`RecordFieldValue` 参照）。値の形はメインレコードと同一です。
            `?fields=id` のようにシステム項目のみを要求した場合、`fields` は含まれません。
          additionalProperties:
            $ref: '#/components/schemas/RecordFieldValue'

    SubRecordListResponse:
      type: object
      properties:
        subRecords:
          type: array
          description: サブレコード一覧
          items:
            $ref: '#/components/schemas/SubRecord'
        pagination:
          $ref: '#/components/schemas/Pagination'

    SubRecordSingleResponse:
      type: object
      properties:
        subRecord:
          $ref: '#/components/schemas/SubRecord'

    RecordWithSubRecords:
      type: object
      description: メインレコード＋該当明細（`subRecords`）。サブレコードテーブル一覧・検索の応答要素です。メインレコードのシステム項目・`fields` は通常のレコードと同じで、直下に `subRecords` を持ちます。
      allOf:
        - $ref: '#/components/schemas/Record'
        - type: object
          properties:
            subRecords:
              type: array
              description: このメインレコードに属する明細（サブレコード）。一覧では当該種別の全明細、検索では条件に一致した明細のみが入ります。
              items:
                $ref: '#/components/schemas/SubRecord'

    RecordWithSubRecordsListResponse:
      type: object
      properties:
        records:
          type: array
          description: 該当明細を内包したメインレコードの一覧
          items:
            $ref: '#/components/schemas/RecordWithSubRecords'
        pagination:
          $ref: '#/components/schemas/Pagination'

    SubRecordCreateRequest:
      type: object
      required: [subRecord]
      properties:
        subRecord:
          type: object
          description: 登録するサブレコード
          required: [fields]
          properties:
            fields:
              type: object
              description: 明細項目の値（fieldKey → 値）。値の形は `RecordFieldValueWrite` 参照。
              additionalProperties:
                $ref: '#/components/schemas/RecordFieldValueWrite'

    SubRecordPatchRequest:
      type: object
      required: [subRecord]
      properties:
        subRecord:
          type: object
          description: 更新するサブレコード（Merge Patch）
          required: [fields]
          properties:
            fields:
              type: object
              description: 更新する項目のみ（fieldKey → 値）。未送信は維持・`null` / 空はクリア。値の形は `RecordFieldValueWrite` 参照。
              additionalProperties:
                $ref: '#/components/schemas/RecordFieldValueWrite'

    SubRecordCopyRequest:
      type: object
      description: サブレコード複製時の上書き（すべて任意。空ボディ `{}` で複製元をそのまま複製）
      properties:
        subRecord:
          type: object
          description: 複製先の上書き項目
          properties:
            fields:
              type: object
              description: 複製元を上書きする項目のみ（fieldKey → 値）。未送信は複製元の値を継承・読み取り専用型への値は 422。値の形は `RecordFieldValueWrite` 参照。
              additionalProperties:
                $ref: '#/components/schemas/RecordFieldValueWrite'

  responses:
    BadRequest:
      description: リクエスト不正
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            paramInvalid:
              value:
                error:
                  code: "request_param_invalid"
                  message: "リクエストパラメータが正しくありません。"
            cursorExpired:
              value:
                error:
                  code: "cursor_expired"
                  message: "ページネーションカーソルが失効しました。"

    Unauthorized:
      description: 認証エラー
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            tokenMissing:
              value:
                error:
                  code: "auth_token_missing"
                  message: "認証情報が不足しています。x-api-key と x-token ヘッダを指定してください。"
            tokenInvalid:
              value:
                error:
                  code: "auth_token_invalid"
                  message: "認証トークンが無効です。"
                  logId: 123

    Forbidden:
      description: |
        権限エラー。アプリ権限が足りない場合は `code` が `app_permission_denied` で、**不足している権限の種類は `details[].permission`**（`use` / `add` / `edit` / `delete` / `setting`）で判別します。
        権限は順に判定されるため、複数不足している場合は 1 つずつ返ります（例: 設定系 EP で利用権限も設定権限も無い → まず `use`、付与後に再実行すると `setting`）。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "app_permission_denied"
              message: "このアプリの設定を変更する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
              details:
                - code: "permission_required"
                  field: "app"
                  permission: "setting"
                  message: "このアプリの設定を変更する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"

    AppNotFound:
      description: アプリ未検出
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "app_not_found"
              message: "指定されたアプリが見つかりません。"
              logId: 123

    AppConflict:
      description: 競合（名前・キー重複）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "app_duplicate"
              message: "指定された名前またはキーは既に使用されています。"
              logId: 123

    AppInUse:
      description: 競合（他アプリから参照中で削除不可）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "app_in_use"
              message: "このアプリは他のアプリから参照されているため削除できません。"
              logId: 123
              details:
                - dependencyType: "apps"
                  dependencyCount: 2
                  samples:
                    - { id: "8", label: "参照元アプリ" }

    AppCopyNotAllowed:
      description: 複製禁止
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "app_copy_not_allowed"
              message: "このアプリは複製が禁止されています。"

    BatchSizeExceeded:
      description: 件数上限超過（タイムアウト予防）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "batch_size_exceeded"
              message: "対象が上限を超えています。件数を分割して実行してください。"
              details:
                - totalCount: 50000
                  maxCount: 10000

    PlanLimitExceeded:
      description: プラン上限超過
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "plan_limit_exceeded"
              message: "プラン上限に達しています。"

    AppsQueryValidationError:
      description: バリデーションエラー（fields クエリパラメータ・GET）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldsUnknown:
              summary: 存在しない項目を指定
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "fields"
                      code: "fields_unknown"
                      message: "指定された項目 'foo' は存在しません"
            fieldsNestedNotSupported:
              summary: fields でネスト記法は不可
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 124
                  details:
                    - field: "fields"
                      code: "fields_nested_not_supported"
                      message: "fields ではネスト記法を使用できません"

    AppUpdateValidationError:
      description: バリデーションエラー（アプリ更新・AP-2 PATCH）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            readOnlyField:
              summary: READ-ONLY 項目の変更（key はレコード登録後は変更不可 等）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 125
                  details:
                    - field: "key"
                      code: "read_only"
                      message: "key は変更できません"
            statusTransitionNotAllowed:
              summary: 許可されない status 遷移（active ⇄ inactive 以外へは不可）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 126
                  details:
                    - field: "status"
                      code: "transition_not_allowed"
                      message: "status をこの状態に変更することはできません"
            forbiddenField:
              summary: サーバー管理・宣言外フィールドの送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 127
                  details:
                    - field: "id"
                      code: "forbidden"
                      message: "id は指定できません"

    FieldNotFound:
      description: 項目未検出
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "field_not_found"
              message: "指定された項目が見つかりません。"
              logId: 123

    FieldCreateConflict:
      description: 競合（編集中ロック / key 重複 / singleton 型の既存）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            editingConflict:
              summary: 他アカウントが画面で項目編集中
              value:
                error:
                  code: "field_editing_conflict"
                  message: "他のユーザーが項目を編集中です。"
                  logId: 123
                  details:
                    - lockedBy: { id: "ac000002", name: "山田 太郎" }
            keyDuplicate:
              summary: 指定した key が既存と重複
              value:
                error:
                  code: "field_duplicate"
                  message: "指定されたキーは既に使用されています。"
                  logId: 124
                  details:
                    - field: "key"
                      value: "text01"
            singletonExists:
              summary: singleton 型（color/category/tag/mylist）が既に存在
              value:
                error:
                  code: "field_singleton_exists"
                  message: "この項目型はアプリ内に1つのみ作成できます。既に同じ型の項目が存在します。"
                  logId: 125
                  details:
                    - field: "type"
                      value: "color"

    FieldUpdateConflict:
      description: 競合（編集中ロック。key / type は READ-ONLY のため重複・singleton 競合は更新では発生しません）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            editingConflict:
              summary: 他アカウントが画面で項目編集中
              value:
                error:
                  code: "field_editing_conflict"
                  message: "他のユーザーが項目を編集中です。"
                  logId: 123
                  details:
                    - lockedBy: { id: "ac000002", name: "山田 太郎" }

    FieldCopyConflict:
      description: 競合（編集中ロック / 複製先 key の重複。singleton 型は複製不可＝422 のためここでは発生しません）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            editingConflict:
              summary: 他アカウントが画面で項目編集中
              value:
                error:
                  code: "field_editing_conflict"
                  message: "他のユーザーが項目を編集中です。"
                  logId: 123
                  details:
                    - lockedBy: { id: "ac000002", name: "山田 太郎" }
            keyDuplicate:
              summary: 複製先の key が既存と重複
              value:
                error:
                  code: "field_duplicate"
                  message: "指定されたキーは既に使用されています。"
                  logId: 124
                  details:
                    - field: "key"
                      value: "text01"

    SubrecordTableFieldCreateConflict:
      description: 競合（編集中ロック / key 重複。singleton 型はサブレコードでは作成不可のため singleton 競合はありません）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            editingConflict:
              summary: 他アカウントが画面で項目編集中
              value:
                error:
                  code: "field_editing_conflict"
                  message: "他のユーザーが項目を編集中です。"
                  logId: 123
                  details:
                    - lockedBy: { id: "ac000002", name: "山田 太郎" }
            keyDuplicate:
              summary: 指定した key が既存と重複
              value:
                error:
                  code: "field_duplicate"
                  message: "指定されたキーは既に使用されています。"
                  logId: 124
                  details:
                    - field: "key"
                      value: "text01"

    FieldDeleteConflict:
      description: 競合（編集中ロック / 他アプリから参照中）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            editingConflict:
              summary: 他アカウントが画面で項目編集中
              value:
                error:
                  code: "field_editing_conflict"
                  message: "他のユーザーが項目を編集中です。"
                  logId: 123
                  details:
                    - lockedBy: { id: "ac000002", name: "山田 太郎" }
            hasLinkage:
              summary: 他アプリの lookup（参照項目）から参照中
              value:
                error:
                  code: "field_has_linkage"
                  message: "他のアプリから参照されているため削除できません。"
                  logId: 124
                  details:
                    - dependencyType: "linkage"
                      dependencyCount: 2
                      samples:
                        - { appKey: "ABCD", fieldKey: "lookup01" }

    FieldSchemaQueryValidationError:
      description: バリデーションエラー（入力スキーマ参照・GET）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            forbidden:
              summary: 宣言されていないクエリパラメータを指定
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 9457
                  details:
                    - field: "foo"
                      code: "forbidden"
                      message: "foo は指定できません"

    FieldsQueryValidationError:
      description: バリデーションエラー（fields クエリパラメータ・GET）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldsUnknown:
              summary: 存在しない項目を指定
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 140
                  details:
                    - field: "fields"
                      code: "fields_unknown"
                      message: "指定された項目 'foo' は存在しません"
            fieldsNestedNotSupported:
              summary: fields でネスト記法は不可
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 141
                  details:
                    - field: "fields"
                      code: "fields_nested_not_supported"
                      message: "fields ではネスト記法を使用できません"

    FieldCreateValidationError:
      description: バリデーションエラー（項目追加・F-3）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            requiredMissing:
              summary: 必須（name / type）欠落
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "name"
                      code: "required"
                      message: "必須項目です。"
            invalidType:
              summary: 未知の項目の型
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 124
                  details:
                    - field: "type"
                      code: "invalid_enum"
                      message: "許可された値のいずれかである必要があります。"
            unknownConfigKey:
              summary: 宣言されていない config キー / 型外の config キー
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 125
                  details:
                    - field: "config.defaultValue"
                      code: "forbidden"
                      message: "defaultValue は指定できません。"
            outOfRange:
              summary: 値域外（例：tel の分割数 parts は 2 / 3 / 4 のみ）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 126
                  details:
                    - field: "config.inputSeparator.parts"
                      code: "invalid_enum"
                      message: "分割数。分割する場合は 2 / 3 / 4 のいずれか（未分割は null） は許可された値のいずれかである必要があります"
            fileLocationRequiresImage:
              summary: file の extractLocation はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 127
                  details:
                    - field: "config.extractLocation"
                      code: "file_location_requires_image"
                      message: "位置情報の取得は、ファイルタイプが「画像」のときのみ設定できます"
            fileLocationRequiresAddressField:
              summary: file の extractLocation は保存先の住所項目が必須
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 128
                  details:
                    - field: "config.locationAddressField"
                      code: "file_location_requires_address_field"
                      message: "位置情報の取得を有効にするには、取得した住所の保存先となる住所項目（locationAddressField）を指定してください"
            elapsedTimeRequiresTimeRange:
              summary: time の showElapsedTime は時刻範囲入力のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 129
                  details:
                    - field: "config.showElapsedTime"
                      code: "elapsed_time_requires_time_range"
                      message: "経過時間の表示（showElapsedTime）は入力パターンが「時刻範囲入力（時刻 ～ 時刻）」の項目でのみ設定できます"
            fixedTimeRequiresFixedTimeMode:
              summary: time の fixedTime は初期値モードが固定時刻のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 130
                  details:
                    - field: "config.fixedTime"
                      code: "fixed_time_requires_fixed_time_mode"
                      message: "初期値の時刻（fixedTime）は初期値モードが「固定時刻」（initialValueMode: fixedTime）の項目でのみ設定できます"
            timeSettingsRequireDatetimePattern:
              summary: date の timeRange / minuteInterval は日時（時刻を含む）のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 131
                  details:
                    - field: "config.timeRange"
                      code: "time_settings_require_datetime_pattern"
                      message: "時刻の設定（timeRange / minuteInterval）は入力パターンが日時（時刻を含む）の項目でのみ設定できます"
            decimalPlacesRequiresDecimalResult:
              summary: calc の decimalPlaces は計算結果の型が小数のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 132
                  details:
                    - field: "config.decimalPlaces"
                      code: "decimal_places_requires_decimal_result"
                      message: "小数点以下の桁数（decimalPlaces）は計算結果の型が「小数」（resultType: decimal）の項目でのみ設定できます"
            imageResizeRequiresImage:
              summary: file の imageResize はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 133
                  details:
                    - field: "config.imageResize"
                      code: "image_resize_requires_image"
                      message: "画像リサイズ（imageResize）は、ファイルタイプが「画像」のときのみ設定できます"
            resetDateRequiresSpecificDate:
              summary: autoNumber の resetDate はリセット周期が特定日のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 134
                  details:
                    - field: "config.resetDate"
                      code: "reset_date_requires_specific_date"
                      message: "連番リセットの月日（resetDate）はリセット周期が「特定日」（resetCycle: specificDate）のときのみ設定できます"
            roleGroupConflictsKeywordSearch:
              summary: roleGroup と keywordSearchable は併用不可（calc 型を除く）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 135
                  details:
                    - field: "config.roleGroup"
                      code: "role_group_conflicts_keyword_search"
                      message: "「一括キーワード検索」の検索対象になっている項目には権限グループ（roleGroup）を設定できません。keywordSearchable を無効にしてから設定してください"
            isTitleRequired:
              summary: タイトル項目が必要（最初の項目を非タイトルで作成等）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 129
                  details:
                    - field: "isTitle"
                      code: "is_title_required"
                      message: "アプリには少なくとも 1 つのタイトル項目が必要です。この変更でタイトル項目が無くなるため実行できません"
            fieldLimitExceeded:
              summary: 項目数の上限超過（top-level エラー・details なし）
              value:
                error:
                  code: "field_limit_exceeded"
                  message: "アプリに登録できる項目数の上限に達しています。"
                  logId: 130
            duplicateNotSupported:
              summary: 重複登録の禁止に対応していない型（画面の項目設定に「重複登録」欄が無い型）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 180
                  details:
                    - field: "duplicateAllowed"
                      code: "invalid_value"
                      message: "duplicateAllowed の値が許可されていません"

    FieldUpdateValidationError:
      description: バリデーションエラー（項目更新・F-5）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            unknownConfigKey:
              summary: 宣言されていない config キー / 型外の config キー
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 125
                  details:
                    - field: "config.defaultValue"
                      code: "forbidden"
                      message: "defaultValue は指定できません。"
            outOfRange:
              summary: 値域外（例：tel の分割数 parts は 2 / 3 / 4 のみ）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 126
                  details:
                    - field: "config.inputSeparator.parts"
                      code: "invalid_enum"
                      message: "分割数。分割する場合は 2 / 3 / 4 のいずれか（未分割は null） は許可された値のいずれかである必要があります"
            readOnlyChange:
              summary: 作成後変更不可キーの変更（例：lookup の referenceMethod）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 130
                  details:
                    - field: "config.referenceMethod"
                      code: "read_only"
                      message: "config.referenceMethod は変更できません"
            fileLocationRequiresImage:
              summary: file の extractLocation はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 127
                  details:
                    - field: "config.extractLocation"
                      code: "file_location_requires_image"
                      message: "位置情報の取得は、ファイルタイプが「画像」のときのみ設定できます"
            fileLocationRequiresAddressField:
              summary: file の extractLocation は保存先の住所項目が必須
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 128
                  details:
                    - field: "config.locationAddressField"
                      code: "file_location_requires_address_field"
                      message: "位置情報の取得を有効にするには、取得した住所の保存先となる住所項目（locationAddressField）を指定してください"
            elapsedTimeRequiresTimeRange:
              summary: time の showElapsedTime は時刻範囲入力のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 129
                  details:
                    - field: "config.showElapsedTime"
                      code: "elapsed_time_requires_time_range"
                      message: "経過時間の表示（showElapsedTime）は入力パターンが「時刻範囲入力（時刻 ～ 時刻）」の項目でのみ設定できます"
            fixedTimeRequiresFixedTimeMode:
              summary: time の fixedTime は初期値モードが固定時刻のときのみ（更新後のモードで判定）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 130
                  details:
                    - field: "config.fixedTime"
                      code: "fixed_time_requires_fixed_time_mode"
                      message: "初期値の時刻（fixedTime）は初期値モードが「固定時刻」（initialValueMode: fixedTime）の項目でのみ設定できます"
            timeSettingsRequireDatetimePattern:
              summary: date の timeRange / minuteInterval は日時（時刻を含む）のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 131
                  details:
                    - field: "config.timeRange"
                      code: "time_settings_require_datetime_pattern"
                      message: "時刻の設定（timeRange / minuteInterval）は入力パターンが日時（時刻を含む）の項目でのみ設定できます"
            decimalPlacesRequiresDecimalResult:
              summary: calc の decimalPlaces は計算結果の型が小数のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 132
                  details:
                    - field: "config.decimalPlaces"
                      code: "decimal_places_requires_decimal_result"
                      message: "小数点以下の桁数（decimalPlaces）は計算結果の型が「小数」（resultType: decimal）の項目でのみ設定できます"
            imageResizeRequiresImage:
              summary: file の imageResize はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 133
                  details:
                    - field: "config.imageResize"
                      code: "image_resize_requires_image"
                      message: "画像リサイズ（imageResize）は、ファイルタイプが「画像」のときのみ設定できます"
            resetDateRequiresSpecificDate:
              summary: autoNumber の resetDate はリセット周期が特定日のときのみ（更新後の周期で判定）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 134
                  details:
                    - field: "config.resetDate"
                      code: "reset_date_requires_specific_date"
                      message: "連番リセットの月日（resetDate）はリセット周期が「特定日」（resetCycle: specificDate）のときのみ設定できます"
            roleGroupConflictsKeywordSearch:
              summary: roleGroup と keywordSearchable は併用不可（calc 型を除く）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 135
                  details:
                    - field: "config.roleGroup"
                      code: "role_group_conflicts_keyword_search"
                      message: "「一括キーワード検索」の検索対象になっている項目には権限グループ（roleGroup）を設定できません。keywordSearchable を無効にしてから設定してください"
            isTitleRequired:
              summary: 唯一のタイトル項目を外す変更は不可
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 129
                  details:
                    - field: "isTitle"
                      code: "is_title_required"
                      message: "アプリには少なくとも 1 つのタイトル項目が必要です。この変更でタイトル項目が無くなるため実行できません"
            duplicateNotSupported:
              summary: 重複登録の禁止に対応していない型（画面の項目設定に「重複登録」欄が無い型）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 181
                  details:
                    - field: "duplicateAllowed"
                      code: "invalid_value"
                      message: "duplicateAllowed の値が許可されていません"

    FieldDeleteValidationError:
      description: バリデーションエラー（項目削除・F-6）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldInUse:
              summary: 他項目・画面表示から参照中で削除不可
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 142
                  details:
                    - field: "fieldKey"
                      code: "field_in_use"
                      message: "この項目は他の項目から参照されているか、画面表示の設定に使用されているため削除できません"
            isTitleRequired:
              summary: 唯一のタイトル項目は削除不可
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 143
                  details:
                    - field: "isTitle"
                      code: "is_title_required"
                      message: "アプリには少なくとも 1 つのタイトル項目が必要です。この変更でタイトル項目が無くなるため実行できません"

    FieldCopyValidationError:
      description: バリデーションエラー（項目複製・F-7）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldTypeNotCopyable:
              summary: 複製できない型（category/tag/mylist/color/calc/relation/lookup）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 129
                  details:
                    - field: "type"
                      code: "field_type_not_copyable"
                      message: "この型の項目は複製できません（カテゴリ／タグ／マイリスト／色／計算／アプリ間連携／参照項目）"
            invalidKeyFormat:
              summary: 複製先 key の形式が不正
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 131
                  details:
                    - field: "key"
                      code: "invalid_format"
                      message: "形式が正しくありません"

    SubrecordTableNotFound:
      description: サブレコードテーブル未検出（アプリ不在・種別不在。内部連番を URL に渡した場合も含む）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            subrecordTableNotFound:
              summary: サブレコードテーブルが見つからない（存在しない subrecordTableKey / 内部連番を渡した）
              value:
                error:
                  code: "subrecord_table_not_found"
                  message: "指定されたサブレコードテーブルが見つかりません。"
                  logId: 123
            appNotFound:
              summary: アプリが見つからない
              value:
                error:
                  code: "app_not_found"
                  message: "指定されたアプリが見つかりません。"
                  logId: 124

    SubrecordTableSavedListNotFound:
      description: サブレコードテーブル・保存カスタムリスト・アプリのいずれかが未検出
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            subrecordTableNotFound:
              summary: サブレコードテーブルが見つからない
              value:
                error:
                  code: "subrecord_table_not_found"
                  message: "指定されたサブレコードテーブルが見つかりません。"
                  logId: 123
            recordNotFound:
              summary: 保存リストが存在しない / 閲覧権限が無い / サブレコードテーブル用でない
              value:
                error:
                  code: "record_not_found"
                  message: "指定されたレコードが見つかりません。"
                  logId: 124
            appNotFound:
              summary: アプリが見つからない
              value:
                error:
                  code: "app_not_found"
                  message: "指定されたアプリが見つかりません。"
                  logId: 125

    SubrecordTableFieldNotFound:
      description: サブレコード項目未検出（アプリ不在・種別不在・項目不在のいずれか）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldNotFound:
              summary: 項目が見つからない
              value:
                error:
                  code: "field_not_found"
                  message: "指定された項目が見つかりません。"
                  logId: 123
            subrecordTableNotFound:
              summary: サブレコードテーブルが見つからない
              value:
                error:
                  code: "subrecord_table_not_found"
                  message: "指定されたサブレコードテーブルが見つかりません。"
                  logId: 124
            appNotFound:
              summary: アプリが見つからない
              value:
                error:
                  code: "app_not_found"
                  message: "指定されたアプリが見つかりません。"
                  logId: 125

    SubrecordTableInUse:
      description: 競合（行データ残存・計算式参照中で削除不可）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "subrecord_table_in_use"
              message: "サブレコードテーブルは使用中のため削除できません。"
              logId: 123
              details:
                - dependencyType: "records"
                  dependencyCount: 128

    SubrecordTableQueryValidationError:
      description: バリデーションエラー（fields クエリパラメータ・GET）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldsUnknown:
              summary: 存在しない項目を指定
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 150
                  details:
                    - field: "fields"
                      code: "fields_unknown"
                      message: "指定された項目 'foo' は存在しません"
            fieldsNestedNotSupported:
              summary: fields でネスト記法は不可
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 151
                  details:
                    - field: "fields"
                      code: "fields_nested_not_supported"
                      message: "fields ではネスト記法を使用できません"

    SubrecordTableCreateValidationError:
      description: バリデーションエラー（サブレコードテーブル作成・SF-2）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            requiredMissing:
              summary: 必須（name）欠落
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 152
                  details:
                    - field: "name"
                      code: "required"
                      message: "必須項目です。"
            forbiddenField:
              summary: サーバー管理値・別操作項目の送信（id / key / status / fields 等）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 153
                  details:
                    - field: "fields"
                      code: "forbidden"
                      message: "fields は指定できません（項目の追加は項目追加 EP を使用してください）"

    SubrecordTableUpdateValidationError:
      description: バリデーションエラー（サブレコードテーブル更新・SF-4）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalidSortKey:
              summary: defaultSortKey に無効な並び順キー
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 154
                  details:
                    - field: "defaultSortKey"
                      code: "invalid_value"
                      message: "並べ替えできない項目が指定されました"
            forbiddenField:
              summary: サーバー管理値・宣言外キーの送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 155
                  details:
                    - field: "key"
                      code: "forbidden"
                      message: "key は指定できません"
            nameCleared:
              summary: 必須項目 name を null / 空文字でクリア（種別名は空にできません）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 156
                  details:
                    - field: "name"
                      code: "required"
                      message: "必須項目です。"
            activationRequiresFields:
              summary: 項目 0 件の種別を公開（active）にしようとした（画面同様、項目を追加するまで公開不可。既公開種別への active 再送は 200）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 157
                  details:
                    - field: "status"
                      code: "activation_requires_fields"
                      message: "項目が 1 件も無いサブレコードテーブルは公開（active）にできません。先に項目を追加してください"

    SubrecordTableFieldCreateValidationError:
      description: バリデーションエラー（サブレコード項目追加・SFF-2）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            requiredMissing:
              summary: 必須（name / type）欠落
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 156
                  details:
                    - field: "name"
                      code: "required"
                      message: "必須項目です。"
            typeNotAllowed:
              summary: サブレコードテーブルで使えない型（category / tag / mylist / color / label）は type.enum 外
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 157
                  details:
                    - field: "type"
                      code: "invalid_enum"
                      message: "許可された値のいずれかである必要があります。"
            titleUniqueForbidden:
              summary: サブ非対応の isTitle / partOfUniqueKey の送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 158
                  details:
                    - field: "isTitle"
                      code: "forbidden"
                      message: "isTitle はサブレコードでは指定できません"
            autoNumberForbidden:
              summary: サブ非対応の autoNumber 設定（startNumber / resetDate）の送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 159
                  details:
                    - field: "config.startNumber"
                      code: "forbidden"
                      message: "startNumber はサブレコードでは指定できません"
            fileLocationRequiresImage:
              summary: file の extractLocation はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 160
                  details:
                    - field: "config.extractLocation"
                      code: "file_location_requires_image"
                      message: "位置情報の取得は、ファイルタイプが「画像」のときのみ設定できます"
            fileLocationRequiresAddressField:
              summary: file の extractLocation は保存先の住所項目が必須
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 161
                  details:
                    - field: "config.locationAddressField"
                      code: "file_location_requires_address_field"
                      message: "位置情報の取得を有効にするには、取得した住所の保存先となる住所項目（locationAddressField）を指定してください"
            elapsedTimeRequiresTimeRange:
              summary: time の showElapsedTime は時刻範囲入力のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 164
                  details:
                    - field: "config.showElapsedTime"
                      code: "elapsed_time_requires_time_range"
                      message: "経過時間の表示（showElapsedTime）は入力パターンが「時刻範囲入力（時刻 ～ 時刻）」の項目でのみ設定できます"
            fixedTimeRequiresFixedTimeMode:
              summary: time の fixedTime は初期値モードが固定時刻のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 165
                  details:
                    - field: "config.fixedTime"
                      code: "fixed_time_requires_fixed_time_mode"
                      message: "初期値の時刻（fixedTime）は初期値モードが「固定時刻」（initialValueMode: fixedTime）の項目でのみ設定できます"
            timeSettingsRequireDatetimePattern:
              summary: date の timeRange / minuteInterval は日時（時刻を含む）のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 166
                  details:
                    - field: "config.timeRange"
                      code: "time_settings_require_datetime_pattern"
                      message: "時刻の設定（timeRange / minuteInterval）は入力パターンが日時（時刻を含む）の項目でのみ設定できます"
            decimalPlacesRequiresDecimalResult:
              summary: calc の decimalPlaces は計算結果の型が小数のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 167
                  details:
                    - field: "config.decimalPlaces"
                      code: "decimal_places_requires_decimal_result"
                      message: "小数点以下の桁数（decimalPlaces）は計算結果の型が「小数」（resultType: decimal）の項目でのみ設定できます"
            imageResizeRequiresImage:
              summary: file の imageResize はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 168
                  details:
                    - field: "config.imageResize"
                      code: "image_resize_requires_image"
                      message: "画像リサイズ（imageResize）は、ファイルタイプが「画像」のときのみ設定できます"
            fieldLimitExceeded:
              summary: 項目数の上限超過（top-level エラー・details なし）
              value:
                error:
                  code: "field_limit_exceeded"
                  message: "アプリに登録できる項目数の上限に達しています。"
                  logId: 162
            duplicateNotSupported:
              summary: 重複登録の禁止に対応していない型（画面の項目設定に「重複登録」欄が無い型）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 182
                  details:
                    - field: "duplicateAllowed"
                      code: "invalid_value"
                      message: "duplicateAllowed の値が許可されていません"

    SubrecordTableFieldUpdateValidationError:
      description: バリデーションエラー（サブレコード項目更新・SFF-4）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            readOnlyChange:
              summary: 変更不可キーの変更（type / key など）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 161
                  details:
                    - field: "type"
                      code: "read_only"
                      message: "type は変更できません"
            autoNumberForbidden:
              summary: サブ非対応の autoNumber 設定（startNumber / resetDate）の送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 162
                  details:
                    - field: "config.resetDate"
                      code: "forbidden"
                      message: "resetDate はサブレコードでは指定できません"
            fileLocationRequiresAddressField:
              summary: file の extractLocation は保存先の住所項目が必須
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 163
                  details:
                    - field: "config.locationAddressField"
                      code: "file_location_requires_address_field"
                      message: "位置情報の取得を有効にするには、取得した住所の保存先となる住所項目（locationAddressField）を指定してください"
            fileLocationRequiresImage:
              summary: file の extractLocation はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 160
                  details:
                    - field: "config.extractLocation"
                      code: "file_location_requires_image"
                      message: "位置情報の取得は、ファイルタイプが「画像」のときのみ設定できます"
            elapsedTimeRequiresTimeRange:
              summary: time の showElapsedTime は時刻範囲入力のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 169
                  details:
                    - field: "config.showElapsedTime"
                      code: "elapsed_time_requires_time_range"
                      message: "経過時間の表示（showElapsedTime）は入力パターンが「時刻範囲入力（時刻 ～ 時刻）」の項目でのみ設定できます"
            fixedTimeRequiresFixedTimeMode:
              summary: time の fixedTime は初期値モードが固定時刻のときのみ（更新後のモードで判定）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 170
                  details:
                    - field: "config.fixedTime"
                      code: "fixed_time_requires_fixed_time_mode"
                      message: "初期値の時刻（fixedTime）は初期値モードが「固定時刻」（initialValueMode: fixedTime）の項目でのみ設定できます"
            timeSettingsRequireDatetimePattern:
              summary: date の timeRange / minuteInterval は日時（時刻を含む）のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 171
                  details:
                    - field: "config.timeRange"
                      code: "time_settings_require_datetime_pattern"
                      message: "時刻の設定（timeRange / minuteInterval）は入力パターンが日時（時刻を含む）の項目でのみ設定できます"
            decimalPlacesRequiresDecimalResult:
              summary: calc の decimalPlaces は計算結果の型が小数のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 172
                  details:
                    - field: "config.decimalPlaces"
                      code: "decimal_places_requires_decimal_result"
                      message: "小数点以下の桁数（decimalPlaces）は計算結果の型が「小数」（resultType: decimal）の項目でのみ設定できます"
            imageResizeRequiresImage:
              summary: file の imageResize はファイルタイプが画像のときのみ
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 173
                  details:
                    - field: "config.imageResize"
                      code: "image_resize_requires_image"
                      message: "画像リサイズ（imageResize）は、ファイルタイプが「画像」のときのみ設定できます"
            duplicateNotSupported:
              summary: 重複登録の禁止に対応していない型（画面の項目設定に「重複登録」欄が無い型）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 183
                  details:
                    - field: "duplicateAllowed"
                      code: "invalid_value"
                      message: "duplicateAllowed の値が許可されていません"

    SubrecordTableFieldCopyValidationError:
      description: バリデーションエラー（サブレコード項目複製・SFF-6）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldTypeNotCopyable:
              summary: 複製できない型（色 / 計算 / アプリ間連携 / 参照項目 等）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 164
                  details:
                    - field: "type"
                      code: "field_type_not_copyable"
                      message: "この型の項目は複製できません"
            invalidKeyFormat:
              summary: 複製先 key の形式が不正
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 165
                  details:
                    - field: "key"
                      code: "invalid_format"
                      message: "形式が正しくありません"

    NotMultipart:
      description: Content-Type 不正（ファイルアップロードは multipart/form-data が必須）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "request_content_type_not_multipart"
              message: "このエンドポイントはファイルアップロード専用です。Content-Type に multipart/form-data を指定してください。"

    FileNotFound:
      description: ファイル未検出（不存在・形式不正・別テナント・実体欠落）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: "file_not_found"
              message: "指定されたファイルが見つかりません。"

    FileUploadValidationError:
      description: バリデーションエラー（ファイル未指定・空ファイル・ストレージ上限超過）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fileRequired:
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "file"
                      code: "required"
                      message: "file は必須項目です"
            storageLimit:
              value:
                error:
                  code: "plan_limit_exceeded"
                  message: "プラン上限に達しています。"
                  details:
                    key: "storage"

    ByKeyForbidden:
      description: 権限エラー / API 連携機能が無効 / サブレコード機能が無効（`SB-` 経路のみ）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            permissionDenied:
              summary: 操作に必要なアプリ権限が無い（不足している権限は details[].permission で判別できる）
              description: |
                `code` は権限の種類にかかわらず `app_permission_denied` です。**どの権限が必要かは `details[].permission`** を見てください（`use` 利用 / `add` 追加 / `edit` 更新 / `delete` 削除 / `setting` 設定変更）。`message` は表示用のため文言が変わることがあります。
                権限は順に判定されるため、複数不足している場合は 1 つずつ返ります（例: 利用権限も追加権限も無い → まず `use`、付与後に再実行すると `add`）。
              value:
                error:
                  code: "app_permission_denied"
                  message: "このアプリにレコードを追加する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
                  details:
                    - code: "permission_required"
                      field: "app"
                      permission: "add"
                      message: "このアプリにレコードを追加する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
            apiDisabled:
              summary: 対象アプリの API 連携機能（アプリ設定）が OFF
              value:
                error:
                  code: "app_api_disabled"
                  message: "このアプリは API 連携が無効です。アプリ設定で API 連携を有効にしてください。"
                  logId: 123
            subrecordDisabled:
              summary: 対象アプリでサブレコード機能が無効
              value:
                error:
                  code: "subrecord_disabled"
                  message: "このアプリはサブレコード機能が無効です。アプリ設定でサブレコード機能を有効にしてください。"
                  logId: 123

    ByKeyNotFound:
      description: 指定キーの実体（分類・保存リスト・サブレコードテーブル）またはアプリが未検出
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            recordNotFound:
              summary: レコード不在 / 別アプリ所属 / 閲覧・削除権限なし / recordId 非数値
              value:
                error:
                  code: "record_not_found"
                  message: "指定されたレコードが見つかりません。"
                  logId: 123
            appNotFound:
              summary: appKey 不在 / 別テナント / 停止アプリ
              value:
                error:
                  code: "app_not_found"
                  message: "指定されたアプリが見つかりません。"
                  logId: 124
            subrecordTableNotFound:
              summary: サブレコードテーブルが見つからない（存在しない subrecordTableKey / 内部連番を渡した）
              value:
                error:
                  code: "subrecord_table_not_found"
                  message: "指定されたサブレコードテーブルが見つかりません。"
                  logId: 123
    RecordForbidden:
      description: 権限エラー / API 連携機能が無効
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            permissionDenied:
              summary: 操作に必要なアプリ権限が無い（不足している権限は details[].permission で判別できる）
              description: |
                `code` は権限の種類にかかわらず `app_permission_denied` です。**どの権限が必要かは `details[].permission`** を見てください（`use` 利用 / `add` 追加 / `edit` 更新 / `delete` 削除 / `setting` 設定変更）。`message` は表示用のため文言が変わることがあります。
                権限は順に判定されるため、複数不足している場合は 1 つずつ返ります（例: 利用権限も追加権限も無い → まず `use`、付与後に再実行すると `add`）。
              value:
                error:
                  code: "app_permission_denied"
                  message: "このアプリにレコードを追加する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
                  details:
                    - code: "permission_required"
                      field: "app"
                      permission: "add"
                      message: "このアプリにレコードを追加する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
            apiDisabled:
              summary: 対象アプリの API 連携機能（アプリ設定）が OFF
              value:
                error:
                  code: "app_api_disabled"
                  message: "このアプリは API 連携が無効です。アプリ設定で API 連携を有効にしてください。"
                  logId: 123

    RecordNotFound:
      description: レコードまたはアプリ未検出（存在・権限を区別せず 404 に隠蔽）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            recordNotFound:
              summary: レコード不在 / 別アプリ所属 / 閲覧・削除権限なし / recordId 非数値
              value:
                error:
                  code: "record_not_found"
                  message: "指定されたレコードが見つかりません。"
                  logId: 123
            appNotFound:
              summary: appKey 不在 / 別テナント / 停止アプリ
              value:
                error:
                  code: "app_not_found"
                  message: "指定されたアプリが見つかりません。"
                  logId: 124

    RecordListValidationError:
      description: バリデーションエラー（一覧の絞り込み・並び替え・件数上限）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldsUnknown:
              summary: fields に未知のキー / fieldKey
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "fields"
                      code: "fields_unknown"
                      message: "指定された項目 'unknown01' は存在しません"
            fieldsNested:
              summary: fields にネスト記法（a.b.c）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields"
                      code: "fields_nested_not_supported"
                      message: "fields ではネスト記法を使用できません"
            invalidSort:
              summary: sort に非対応キー / order が enum 外
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "sort"
                      code: "invalid_value"
                      message: "sort の値が許可されていません"
            invalidEnum:
              summary: order が enum 外（asc / desc 以外）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "order"
                      code: "invalid_enum"
                      message: "order は許可された値のいずれかである必要があります"
            resultTooLarge:
              summary: 該当が多すぎる（上限 10 万件）
              value:
                error:
                  code: "result_too_large"
                  message: "該当レコードが多すぎます（上限 10 万件）。検索条件で絞り込んでください。"

    RecordSearchValidationError:
      description: バリデーションエラー（検索の条件・並び替え・件数上限）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldsUnknown:
              summary: filters に未知の field
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "filters.unknown01"
                      code: "fields_unknown"
                      message: "filters に未知のフィールド 'unknown01' が指定されました"
            invalidValue:
              summary: 型不整合・ありえない日時・非対応項目（pwd / relation）・タグ非数値
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "filters.date01"
                      code: "invalid_value"
                      message: "date01 の値が許可されていません"
            invalidEnum:
              summary: keywordMatch / order / relative に enum 外の値
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "keywordMatch"
                      code: "invalid_enum"
                      message: "keywordMatch は許可された値のいずれかである必要があります"
            fieldsNested:
              summary: fields にネスト記法（a.b.c）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields"
                      code: "fields_nested_not_supported"
                      message: "fields ではネスト記法を使用できません"
            invalidSort:
              summary: sort に非対応キー / order が enum 外
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "sort"
                      code: "invalid_value"
                      message: "sort の値が許可されていません"
            paramInvalid:
              summary: filters の構造が不正（配列でない・field 欠落 等）
              value:
                error:
                  code: "request_param_invalid"
                  message: "リクエストパラメータが正しくありません。"
            resultTooLarge:
              summary: 該当が多すぎる（上限 10 万件）
              value:
                error:
                  code: "result_too_large"
                  message: "該当レコードが多すぎます（上限 10 万件）。検索条件で絞り込んでください。"

    RecordGetValidationError:
      description: バリデーションエラー（取得の fields 絞り込み）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            fieldsUnknown:
              summary: fields に未知の fieldKey
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "fields"
                      code: "fields_unknown"
                      message: "指定された項目 'unknown01' は存在しません"
            fieldsNested:
              summary: fields にネスト記法（a.b.c）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields"
                      code: "fields_nested_not_supported"
                      message: "fields ではネスト記法を使用できません"

    RecordCreateValidationError:
      description: バリデーションエラー（レコード登録）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            titleFieldMissing:
              summary: アプリにタイトル項目が無い（API でアプリを作った直後に踏みやすい）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "record"
                      code: "title_field_missing"
                      message: "このアプリにはタイトル項目が設定されていないため、レコードを登録できません。先に項目設定でタイトル項目を作成してください"
            requiredMissing:
              summary: 必須項目の欠落
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "fields.text01"
                      code: "required"
                      message: "顧客名 は必須項目です"
            invalidValue:
              summary: 型に不正な値（数値項目に文字列・passthrough に object 等）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.number01"
                      code: "invalid_value"
                      message: "金額 の値が許可されていません"
            invalidFormat:
              summary: 形式が不正（メール / URL / 日付など）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.email01"
                      code: "invalid_format"
                      message: "メールアドレス の形式が正しくありません"
            fieldsUnknown:
              summary: 存在しない項目キーを送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.unknown01"
                      code: "fields_unknown"
                      message: "指定された項目 'unknown01' は存在しません"
            recordLimit:
              summary: レコード数の上限に達している（プラン上限・従量なしプラン）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "record"
                      code: "record_limit"
                      message: "record の値が許可されていません"
            readOnly:
              summary: 読み取り専用型（calc / lookup の同期参照 / numbering 自動採番）への書き込み
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.calc01"
                      code: "read_only"
                      message: "計算 は変更できません"
            valueDuplicate:
              summary: 一意制約（duplicateAllowed=false / 複合一意）に違反
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.code01"
                      code: "value_duplicate"
                      message: "管理番号 の値は既に使用されています"

    RecordCopyValidationError:
      description: バリデーションエラー（レコード複製）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            titleFieldMissing:
              summary: アプリにタイトル項目が無い（API でアプリを作った直後に踏みやすい）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "record"
                      code: "title_field_missing"
                      message: "このアプリにはタイトル項目が設定されていないため、レコードを登録できません。先に項目設定でタイトル項目を作成してください"
            requiredMissing:
              summary: 元レコードの必須項目が空で、上書きも指定していない
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "fields.text01"
                      code: "required"
                      message: "顧客名 は必須項目です"
            readOnly:
              summary: 読み取り専用型（calc / lookup の同期参照 / numbering 自動採番）への上書き
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.calc01"
                      code: "read_only"
                      message: "計算 は変更できません"
            subrecordTableNotCopyable:
              summary: 重複禁止かつ必須の項目を持つサブ種別は複製できない
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "includeSubrecordTables"
                      code: "invalid_value"
                      message: "includeSubrecordTables の値が許可されていません"
            valueDuplicate:
              summary: 複製で一意制約に違反（`record.fields` で別値に上書きして回避）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.text01"
                      code: "value_duplicate"
                      message: "顧客名 は既に使用されています"
            recordLimit:
              summary: レコード数の上限に達している（プラン上限・従量なしプラン）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "record"
                      code: "record_limit"
                      message: "record の値が許可されていません"

    RecordUpdateValidationError:
      description: バリデーションエラー（レコード部分更新）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            titleFieldMissing:
              summary: アプリにタイトル項目が無い（API でアプリを作った直後に踏みやすい）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "record"
                      code: "title_field_missing"
                      message: "このアプリにはタイトル項目が設定されていないため、レコードを登録できません。先に項目設定でタイトル項目を作成してください"
            requiredCleared:
              summary: 必須項目を null / 空でクリアしようとした
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  logId: 123
                  details:
                    - field: "fields.text01"
                      code: "required"
                      message: "顧客名 は必須項目です"
            invalidValue:
              summary: 型に不正な値
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.number01"
                      code: "invalid_value"
                      message: "金額 の値が許可されていません"
            invalidFormat:
              summary: 形式が不正（メール / URL / 日付など）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.email01"
                      code: "invalid_format"
                      message: "メールアドレス の形式が正しくありません"
            fieldsUnknown:
              summary: 存在しない項目キーを送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.unknown01"
                      code: "fields_unknown"
                      message: "指定された項目 'unknown01' は存在しません"
            readOnly:
              summary: 読み取り専用型への書き込み
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.calc01"
                      code: "read_only"
                      message: "計算 は変更できません"
            valueDuplicate:
              summary: 一意制約に違反
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.code01"
                      code: "value_duplicate"
                      message: "管理番号 の値は既に使用されています"

    SubrecordForbidden:
      description: 権限エラー（アプリの利用権限）/ API 連携機能が無効 / サブレコード機能が無効
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            permissionDenied:
              summary: 対象アプリの利用権限が無い（不足している権限は details[].permission で判別できる）
              description: |
                サブレコードの参照には、対象アプリの利用権限（`details[].permission` が `use`）が必要です。
                `message` は表示用のため文言が変わることがあります。機械判別には `code` と `details[].permission` を使ってください。
              value:
                error:
                  code: "app_permission_denied"
                  message: "このアプリを利用する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
                  logId: 123
                  details:
                    - code: "permission_required"
                      field: "app"
                      permission: "use"
                      message: "このアプリを利用する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
            apiDisabled:
              summary: 対象アプリで API 連携機能が無効
              value:
                error:
                  code: "app_api_disabled"
                  message: "このアプリは API 連携機能が無効です。"
                  logId: 123
            subrecordDisabled:
              summary: 対象アプリでサブレコード機能が無効
              value:
                error:
                  code: "subrecord_disabled"
                  message: "このアプリはサブレコード機能が無効です。アプリ設定でサブレコード機能を有効にしてください。"
                  logId: 123

    SubrecordWriteForbidden:
      description: 権限エラー（アプリのレコード追加・更新・削除権限／種別の権限グループ）/ API 連携機能が無効 / サブレコード機能が無効
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            permissionDenied:
              summary: 操作に必要なアプリ権限が無い（不足している権限は details[].permission で判別できる）
              description: |
                サブレコードの登録・更新・削除・複製にも、レコード本体と同じアプリ権限が必要です（登録・複製＝`add` / 更新＝`edit` / 削除＝`delete`）。
                `code` は権限の種類にかかわらず `app_permission_denied` です。**どの権限が必要かは `details[].permission`** を見てください。`message` は表示用のため文言が変わることがあります。
              value:
                error:
                  code: "app_permission_denied"
                  message: "このアプリにレコードを追加する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
                  logId: 123
                  details:
                    - code: "permission_required"
                      field: "app"
                      permission: "add"
                      message: "このアプリにレコードを追加する権限がありません。アプリの利用権限設定で許可されたアカウントのみ操作できます。"
            apiDisabled:
              summary: 対象アプリで API 連携機能が無効
              value:
                error:
                  code: "app_api_disabled"
                  message: "このアプリは API 連携機能が無効です。"
                  logId: 123
            subrecordDisabled:
              summary: 対象アプリでサブレコード機能が無効
              value:
                error:
                  code: "subrecord_disabled"
                  message: "このアプリはサブレコード機能が無効です。アプリ設定でサブレコード機能を有効にしてください。"
                  logId: 123
            subrecordPermissionDenied:
              summary: 種別に設定された権限グループの操作権限がない（追加/編集/複製は編集権限・削除は削除権限。種別所有者と行登録者〔編集/削除〕は制限対象外）
              value:
                error:
                  code: "subrecord_permission_denied"
                  message: "このサブレコードテーブルに対する操作権限がありません。種別に設定された権限グループの権限が必要です。"
                  logId: 123

    SubrecordParentNotFound:
      description: 親側の未検出（アプリ不在・レコード不在／別アプリ・種別不在。存在・権限を区別せず 404 に隠蔽）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            appNotFound:
              summary: アプリが見つからない
              value:
                error:
                  code: "app_not_found"
                  message: "指定されたアプリが見つかりません。"
                  logId: 123
            recordNotFound:
              summary: 親レコード不在 / 別アプリ所属 / 閲覧権限なし / recordId 非数値
              value:
                error:
                  code: "record_not_found"
                  message: "指定されたレコードが見つかりません。"
                  logId: 123
            subrecordTableNotFound:
              summary: サブレコードテーブルが見つからない（存在しない subrecordTableKey）
              value:
                error:
                  code: "subrecord_table_not_found"
                  message: "指定されたサブレコードテーブルが見つかりません。"
                  logId: 123

    SubrecordNotFound:
      description: サブレコードまたは親側の未検出（親レコード＋種別でスコープ。別レコード・別種別の行 ID も 404 に隠蔽）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            subrecordNotFound:
              summary: サブレコード不在 / 別レコード・別種別の行 ID / subrecordId 非数値
              value:
                error:
                  code: "subrecord_not_found"
                  message: "指定されたサブレコードが見つかりません。"
                  logId: 123
            recordNotFound:
              summary: 親レコード不在 / 別アプリ所属 / 閲覧権限なし
              value:
                error:
                  code: "record_not_found"
                  message: "指定されたレコードが見つかりません。"
                  logId: 123
            subrecordTableNotFound:
              summary: サブレコードテーブルが見つからない
              value:
                error:
                  code: "subrecord_table_not_found"
                  message: "指定されたサブレコードテーブルが見つかりません。"
                  logId: 123

    SubrecordListValidationError:
      description: 一覧・取得のクエリ検証エラー（sort / order / fields の不正）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalidValue:
              summary: sort / order が許可外の値
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "sort"
                      code: "invalid_value"
                      message: "badkey の値が許可されていません"
            fieldsUnknown:
              summary: fields に未知の項目キー
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.nope"
                      code: "fields_unknown"
                      message: "指定された項目 'nope' は存在しません"
            fieldsNestedNotSupported:
              summary: fields にネスト記法（`fields.a.b`）を指定
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.memo.sub"
                      code: "fields_nested_not_supported"
                      message: "fields ではネスト記法を使用できません"

    SubrecordCreateValidationError:
      description: サブレコード登録の検証エラー（必須欠落・未知キー・読み取り専用・値不正）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            required:
              summary: 必須項目の欠落
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.memo"
                      code: "required"
                      message: "メモ は必須項目です"
            fieldsUnknown:
              summary: 未知の項目キー
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.nope"
                      code: "fields_unknown"
                      message: "指定された項目 'nope' は存在しません"
            readOnly:
              summary: 読み取り専用の型（calc / lookup の同期参照 等）へ値送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.calc01"
                      code: "read_only"
                      message: "計算 は読み取り専用の項目です"
            invalidValue:
              summary: 値が型の制約に合わない（選択肢外・範囲外など）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.qty"
                      code: "invalid_value"
                      message: "数量 の値が許可されていません"
            invalidFormat:
              summary: 値の形式が不正（日付・メール・URL などの形式違反）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.date01"
                      code: "invalid_format"
                      message: "日付 の形式が正しくありません"
            valueDuplicate:
              summary: 一意制約（unique）違反（既に使われている値）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.code01"
                      code: "value_duplicate"
                      message: "管理番号 の値は既に使用されています"
            recordLimit:
              summary: アプリのレコード数上限に達している（登録不可）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "subRecord"
                      code: "record_limit"
                      message: "登録できるレコード数の上限に達しました。不要なレコードを削除するか、プランのアップグレードをご検討ください"

    SubrecordUpdateValidationError:
      description: サブレコード更新の検証エラー（未知キー・読み取り専用・値不正）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            readOnly:
              summary: 読み取り専用の型へ値送信
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.calc01"
                      code: "read_only"
                      message: "計算 は読み取り専用の項目です"
            invalidValue:
              summary: 値が型の制約に合わない
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.qty"
                      code: "invalid_value"
                      message: "数量 の値が許可されていません"
            required:
              summary: 必須項目を空・null にした（Merge Patch でクリア不可の必須項目）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.memo"
                      code: "required"
                      message: "メモ は必須項目です"
            fieldsUnknown:
              summary: 未知の項目キー
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.nope"
                      code: "fields_unknown"
                      message: "指定された項目 'nope' は存在しません"
            invalidFormat:
              summary: 値の形式が不正（日付・メール・URL などの形式違反）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.date01"
                      code: "invalid_format"
                      message: "日付 の形式が正しくありません"
            valueDuplicate:
              summary: 一意制約（unique）違反（既に使われている値）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.code01"
                      code: "value_duplicate"
                      message: "管理番号 の値は既に使用されています"

    SubrecordCopyValidationError:
      description: サブレコード複製の検証エラー（上書き項目の読み取り専用・未知キー・値不正・一意違反・上限）
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            readOnly:
              summary: 読み取り専用の型（calc / 自動採番 など）へ上書き
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.numbering01"
                      code: "read_only"
                      message: "自動採番 は変更できません"
            fieldsUnknown:
              summary: 未知の項目キー
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.nope"
                      code: "fields_unknown"
                      message: "指定された項目 'nope' は存在しません"
            invalidValue:
              summary: 上書き値が型の制約に合わない（選択肢外・範囲外など）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.qty"
                      code: "invalid_value"
                      message: "数量 の値が許可されていません"
            valueDuplicate:
              summary: 複製で一意制約に違反（subRecord.fields で別値に上書きして回避）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "fields.code01"
                      code: "value_duplicate"
                      message: "管理番号 の値は既に使用されています"
            recordLimit:
              summary: アプリのレコード数上限に達している（複製不可）
              value:
                error:
                  code: "validation_failed"
                  message: "入力内容に誤りがあります。"
                  details:
                    - field: "subRecord"
                      code: "record_limit"
                      message: "登録できるレコード数の上限に達しました。不要なレコードを削除するか、プランのアップグレードをご検討ください"
