# ムームードメイン API v2 (Me API) OpenAPI 仕様書
# 公開URL: https://muumuu-domain.com/developers/openapi-me.yaml
# OpenAPI 定義から自動生成されたファイルです。
---
openapi: 3.1.0
info:
  title: ムームードメイン API v2
  version: 2.0.0
  description: |-
    ムームードメインの外部連携用 API です。

    <details>
    <summary><strong>サンドボックス環境</strong></summary>
    <p>MeAPI を試す環境として <code>https://api-sandbox.muumuu-domain.com</code> を公開しています。本番DBとは分離されており、テスト用 Personal Access Token（PAT）を curl で自己発行できます。</p>
    <p><strong>Quickstart</strong></p>
    <ol>
      <li>
        <p>サンドボックス用のテストアカウントを発行する</p>
        <pre><code class="language-sh">curl -X POST https://api-sandbox.muumuu-domain.com/sandbox/signup \
      -H 'Content-Type: application/json' \
      -d '{"email":"partner@example.com"}'</code></pre>
        <p>応答例: <code>201 { "data": { "muu_id": "xxxxxxxxxxxx", "password": "&lt;password&gt;" } }</code></p>
        <p>※ <code>muu_id</code> と <code>password</code> はレスポンス受信時に必ず保存してください。再発行はできません。</p>
      </li>
      <li>
        <p>受け取った <code>muu_id</code> と <code>password</code> で PAT を発行する</p>
        <pre><code class="language-sh">curl -X POST https://api-sandbox.muumuu-domain.com/sandbox/personal-access-tokens \
      -u '&lt;muu_id&gt;:&lt;password&gt;' \
      -H 'Content-Type: application/json' \
      -d '{"name":"my-test","scopes":["domains:read"],"expires_in":604800}'</code></pre>
        <p>応答例: <code>201 { "data": { "token": "muu_pat_sandbox_xxx", ... } }</code></p>
      </li>
      <li>
        <p>発行された PAT を <code>Authorization: Bearer</code> ヘッダで MeAPI に渡す</p>
        <pre><code class="language-sh">curl https://api-sandbox.muumuu-domain.com/api/v2/me/domains \
      -H 'Authorization: Bearer muu_pat_sandbox_xxx'</code></pre>
      </li>
    </ol>
    <p><strong>制約・上限</strong></p>
    <ul>
      <li>許可スコープ: <code>domains:read</code>, <code>domains:search</code>, <code>dns:read</code>, <code>dns:write</code></li>
      <li><code>expires_in</code> のデフォルト 7 日 / 最大 30 日（無期限不可）</li>
      <li>発行上限: 1 muu_id あたり同時保持 20 件、24 時間あたり新規発行 10 件</li>
      <li><code>muu_pat_sandbox_</code> プレフィックスを持つ PAT は本番環境（<code>muumuu-domain.com</code>）では受け付けられません</li>
    </ul>
    </details>
  contact:
    name: ムームードメイン
    url: https://muumuu-domain.com
servers:
- url: https://muumuu-domain.com/api/v2
  description: Production
- url: https://api-sandbox.muumuu-domain.com/api/v2
  description: Sandbox（外部公開・検証用）
security:
- oauth2: []
tags:
- name: Domains
  description: ドメイン管理
- name: DNS Records
  description: DNSレコード管理
- name: Domain Search
  description: ドメイン空き検索
- name: Maintenances
  description: メンテナンス情報
- name: Domain Purchase
  description: ドメイン購入（有料操作）
- name: Personal Access Tokens
  description: Personal Access Token 管理
- name: Payment History
  description: 支払い履歴
paths:
  "/me/personal-access-tokens":
    get:
      operationId: list-me-personal-access-tokens
      summary: 自分の PAT 一覧を取得する
      description: |
        認証ユーザーが発行した Personal Access Token の一覧を取得します。
        トークン本体は返しません。

        JWT 認証のみ対応しています（PAT 認証は使用不可）。

        created_at の降順で返します。
      tags:
      - Personal Access Tokens
      security:
      - jwt: []
      responses:
        '200':
          description: PAT 一覧の取得に成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/PersonalAccessTokenListResponse"
              example:
                data:
                - id: 1
                  name: My CI Token
                  token-prefix: muu_pat_abcdefgh…
                  scopes:
                  - domains:read
                  expires-at: '2026-06-06T00:00:00Z'
                  last-used-at:
                  status: active
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
  "/me/personal-access-tokens/{id}":
    delete:
      operationId: delete-me-personal-access-token
      summary: 自分の PAT を失効する
      description: |
        認証ユーザーが発行した Personal Access Token を失効させます。

        失効後、当該 PAT を `Authorization: Bearer` に指定したリクエストは 401 を返します。

        JWT 認証のみ対応しています（PAT 認証は使用不可・自己増殖防止）。
        他アカウントが発行した PAT を指定した場合は 404 を返します（IDOR 対策）。
        既に失効済みの PAT を指定した場合も 204 を返します（冪等）。
      tags:
      - Personal Access Tokens
      security:
      - jwt: []
      parameters:
      - name: id
        in: path
        required: true
        description: PAT の内部 ID
        schema:
          type: integer
          minimum: 1
      responses:
        '204':
          description: PAT の失効に成功
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
  "/me/payment-history":
    get:
      operationId: list-me-payment-history
      summary: 支払い履歴の一覧を取得する
      description: |
        ドメイン支払いとオプション支払いの2系統のデータを統合し、支払い日の降順で返します。

        フィルタ条件（期間・金額・サービス種別・ドメイン名）とページネーションに対応しています。

        `domain-name` フィルタを指定した場合、オプション支払いは結果から除外されます
        （ドメイン名はドメイン支払いにのみ紐づくため）。

        認証トークンからアカウントを自動識別するため、自分の支払い履歴のみ取得可能です。
      tags:
      - Payment History
      security:
      - jwt: []
      - oauth2:
        - payments:read
      parameters:
      - name: page
        in: query
        required: false
        description: ページ番号（1〜50）
        schema:
          type: integer
          default: 1
          minimum: 1
          maximum: 50
        example: 1
      - name: page-size
        in: query
        required: false
        description: 1ページあたりの件数（1〜100。範囲外はクランプ）
        schema:
          type: integer
          default: 20
          minimum: 1
          maximum: 100
        example: 20
      - name: date-from
        in: query
        required: false
        description: 支払い日の開始日（YYYY-MM-DD）
        schema:
          type: string
          format: date
        example: '2026-01-01'
      - name: date-to
        in: query
        required: false
        description: 支払い日の終了日（YYYY-MM-DD）。date-from以降の日付を指定すること。
        schema:
          type: string
          format: date
        example: '2026-12-31'
      - name: amount-min
        in: query
        required: false
        description: 金額の下限（税込、0以上の整数）
        schema:
          type: integer
          minimum: 0
        example: 1000
      - name: amount-max
        in: query
        required: false
        description: 金額の上限（税込、0以上の整数）。amount-min以上の値を指定すること。
        schema:
          type: integer
          minimum: 0
        example: 5000
      - name: service-type
        in: query
        required: false
        description: |
          サービス種別でフィルタ。
          - `domain`: ドメイン
          - `google_workspace`: Google Workspace
          - `wordpress`: WordPress
          - その他のオプション種別
        schema:
          "$ref": "#/components/schemas/PaymentHistoryServiceType"
      - name: domain-name
        in: query
        required: false
        description: ドメイン名の部分一致検索。指定時はオプション支払いは除外される。
        schema:
          type: string
          maxLength: 253
        example: example
      responses:
        '200':
          description: 支払い履歴一覧の取得に成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/PaymentHistoryListResponse"
              example:
                data:
                - id: MB00000001
                  paid-at: '2026-03-20'
                  service-type: domain
                  target-name: example.com
                  description: 更新（1年）
                  amount: 1628
                  amount-breakdown:
                    base-price: 1480
                    tax: 148
                    surcharge: 0
                    discount: 0
                  payment-method: creditcard
                  status: 2
                  refunded: false
                - id: OC00000001
                  paid-at: '2026-02-15'
                  service-type: google_workspace
                  target-name: example.com
                  description: 新規契約
                  amount: 748
                  amount-breakdown:
                    base-price: 680
                    tax: 68
                    surcharge: 0
                    discount: 0
                  payment-method: creditcard
                  status: 2
                  contract-start-date: '2026-02-15'
                  contract-end-date: '2027-02-15'
                meta:
                  total: 42
                  page: 1
                  page-size: 20
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
  "/me/domains":
    get:
      operationId: list-me-domains
      summary: 保有ドメインの一覧を取得する
      description: |
        認証ユーザーが保有するドメインの一覧を取得します。
        ドメイン名（FQDN）、状態、契約情報などを含みます。

        `fqdn` パラメータでFQDN完全一致のドメインを検索できます（例: `?fqdn=example.com`）。
        `state` パラメータでドメインの状態（有効・無効など）をフィルタリングできます。
        `q` パラメータでドメイン名（`sld.tld`）の部分一致検索ができます。

        `status-group` パラメータを指定すると、コントロールパネルのドメイン一覧と同じ区分（期限切れ・未入金・移管申請中・契約中・移管の未払い）で取得できます。
        このときだけ、各ドメインに `status-group` などの追加項目が含まれ、`sort=status-group` で区分順に並べられます。
        1つのドメインが複数の区分に当たる場合は、区分の順位が高いほう（`expired-recoverable` → `pending-payment` → `pending-transfer` → `contracted` → `transfer-unpaid`）に入ります。
        ページネーションに対応しており、`page` と `page-size` パラメータで取得範囲を指定できます。

        認証トークンからアカウントを自動識別するため、自分が保有するドメインのみ取得可能です。
      tags:
      - Domains
      security:
      - jwt: []
      - oauth2:
        - domains:read
      parameters:
      - name: page
        in: query
        required: false
        description: ページ番号（1始まり）
        schema:
          type: integer
          default: 1
          minimum: 1
        example: 1
      - name: page-size
        in: query
        required: false
        description: 1ページあたりの件数（最大100件）
        schema:
          type: integer
          default: 20
          minimum: 1
          maximum: 100
        example: 20
      - name: fqdn
        in: query
        required: false
        description: |
          FQDN（完全修飾ドメイン名）で完全一致フィルタリング。末尾ドットは省略可。日本語ドメインは punycode でも生の日本語でも指定できます。
          指定した場合、そのFQDNに一致するドメインのみを返します。
          例: `?fqdn=example.com`, `?fqdn=example.co.jp`
        schema:
          type: string
          maxLength: 253
        example: example.com
      - name: state
        in: query
        required: false
        description: |
          ドメイン状態でフィルタリング。
          - `active`: 有効なドメイン
          - `inactive`: 無効なドメイン
          - `pending-setup`: セットアップ前
          - `pending-transfer`: 移管申請中
          - `pending-bulk`: 一括取得待ち
        schema:
          type: string
          enum:
          - active
          - inactive
          - pending-setup
          - pending-transfer
          - pending-bulk
      - name: status-group
        in: query
        required: false
        description: |
          カンマ区切りで区分を指定する（例: `?status-group=expired-recoverable,contracted`）。指定した区分のドメインを返す。
          未知の値を含む場合は 400。指定しない場合は従来どおり（有効な取得済みドメインと期限切れで復旧可能なドメイン）を返す。
          - `expired-recoverable`: 期限切れで復旧可能（ユーザーが破棄したもの・復旧期限を過ぎたものを除く）
          - `pending-payment`: 新規申込の未入金
          - `pending-transfer`: 移管申請中
          - `contracted`: 契約中
          - `transfer-unpaid`: 移管の未払い
        schema:
          type: string
        example: expired-recoverable,pending-payment,pending-transfer,contracted,transfer-unpaid
      - name: sort
        in: query
        required: false
        description: |
          並び順。`status-group` パラメータを指定したときだけ有効で、指定しないときは無視してドメインIDの降順で返す。
          `status-group` 指定時に未知の値を指定すると 400。
          - `id-desc`: ドメインIDの降順（既定）
          - `status-group`: 区分の順位 → 区分内の並び（`contracted`・`transfer-unpaid` は契約終了日、`pending-payment` は入金締切日の昇順で、日付が無いものが先。`pending-transfer` は移管の契約のものが先）→ ドメインIDの昇順
        schema:
          type: string
          enum:
          - id-desc
          - status-group
          default: id-desc
      - name: q
        in: query
        required: false
        description: |
          ドメイン名（`sld.tld`）の部分一致検索。大文字小文字は区別しない。日本語ドメインは日本語でも punycode でも指定できる。
          `status-group` の有無にかかわらず、`q` を指定したときだけ絞り込む（空白だけの値は指定なしとして扱う）。
          `q` を指定したときだけ、`fqdn` との同時指定と254文字以上の値を 400 にする。
        schema:
          type: string
          minLength: 1
          maxLength: 253
        example: example
      responses:
        '200':
          description: ドメイン一覧の取得に成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/MeDomainListResponse"
              example:
                data:
                - id: MU00000001
                  sld: example
                  tld: com
                  fqdn: example.com
                  state: active
                  setup-state: acquired
                  registrar: onamae
                  whois-proxy-enabled: true
                  auto-renew-enabled: true
                  is-japanese-domain: false
                  contract:
                    id: MC00000001
                    state: new
                    term: 1
                    start-date: '2025-01-01T00:00:00+09:00'
                    end-date: '2026-01-01T00:00:00+09:00'
                meta:
                  total: 1
                  page: 1
                  page-size: 20
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
  "/me/domains/{domain-id}":
    get:
      operationId: get-me-domain
      summary: ドメインの詳細情報を取得する
      description: |
        指定したドメインの詳細情報を取得します。
        ドメイン名、状態、レジストラ、WHOIS代理公開設定、自動更新設定、契約情報などを含みます。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのみ取得可能です。
      tags:
      - Domains
      security:
      - jwt: []
      - oauth2:
        - domains:read
      parameters:
      - name: domain-id
        in: path
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        required: true
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
          example: MU00000001
      responses:
        '200':
          description: ドメイン詳細の取得に成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DomainResponse"
              example:
                data:
                  id: MU00000001
                  sld: example
                  tld: com
                  fqdn: example.com
                  state: active
                  setup-state: acquired
                  registrar: onamae
                  whois-proxy-enabled: true
                  auto-renew-enabled: true
                  is-japanese-domain: false
                  contract:
                    id: MC00000001
                    state: new
                    term: 1
                    start-date: '2025-01-01T00:00:00+09:00'
                    end-date: '2026-01-01T00:00:00+09:00'
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
    patch:
      operationId: update-me-domain
      summary: ドメインの自動更新設定を変更する
      description: |
        指定したドメインのクレジットカードによる自動更新設定（ON/OFF）を変更します。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのみ変更可能です。

        - `auto-renew-enabled: true`: クレジットカード自動更新を有効化します。
          クレジットカードが未登録、または有効期限切れのアカウントは `422` で拒否します。
          既に自動更新が有効（クレジットカード / おさいぽ!）なドメインに対しては値を変更せず冪等に `200` を返します。
        - `auto-renew-enabled: false`: 自動更新を無効化します。

        おさいぽ!による自動更新は本 API の設定対象外です（おさいぽ! → クレジットカードへの切り替えは行いません）。

        **409 Conflict**: 取得済みでない（更新可能状態でない）ドメインに対して変更を試みた場合に返します。
        ドメインロックで自動更新をロックしているドメインは、ON/OFF どちらへの変更も `auto_renew_locked` で拒否します。
        **422 Unprocessable Entity**: `true` への変更時にクレジットカードが未登録、または有効期限切れの場合に返します。
      tags:
      - Domains
      security:
      - jwt: []
      - oauth2:
        - domains:write
      parameters:
      - name: domain-id
        in: path
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        required: true
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
          example: MU00000001
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/DomainUpdateRequest"
            example:
              auto-renew-enabled: true
      responses:
        '200':
          description: 自動更新設定の変更に成功（変更後の状態を返す）
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DomainResponse"
              example:
                data:
                  id: MU00000001
                  sld: example
                  tld: com
                  fqdn: example.com
                  state: active
                  setup-state: acquired
                  registrar: onamae
                  whois-proxy-enabled: true
                  auto-renew-enabled: true
                  is-japanese-domain: false
                  contract:
                    id: MC00000001
                    state: new
                    term: 1
                    start-date: '2025-01-01T00:00:00+09:00'
                    end-date: '2026-01-01T00:00:00+09:00'
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '409':
          "$ref": "#/components/responses/Conflict"
        '422':
          "$ref": "#/components/responses/UnprocessableEntity"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
        '503':
          "$ref": "#/components/responses/ServiceUnavailable"
  "/me/domains/{domain-id}/dns-records":
    get:
      operationId: list-me-dns-records
      summary: ドメインのDNSレコード一覧を取得する
      description: |
        指定したドメインのDNSレコード一覧を取得します。
        A、AAAA、CNAME、MX、TXT、NS、ALIASレコードを含みます（SOAレコードは除外）。

        `type` パラメータでレコードタイプ（A、MX等）をフィルタリングできます。
        `fqdn` パラメータで特定のFQDNに完全一致するレコードのみ取得できます。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのDNSレコードのみ取得可能です。
      tags:
      - DNS Records
      security:
      - jwt: []
      - oauth2:
        - dns:read
      parameters:
      - name: domain-id
        in: path
        required: true
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
        example: MU00000001
      - name: type
        in: query
        required: false
        description: |
          レコードタイプでフィルタリング。
          指定可能な値: A, AAAA, CNAME, MX, TXT, NS, ALIAS
        schema:
          "$ref": "#/components/schemas/DnsRecordType"
      - name: fqdn
        in: query
        required: false
        description: 'レコード名（FQDN）で完全一致フィルタリング。レコード作成時と同じ表記を受け付けます: 末尾ドットは省略可、ゾーンアペックス（ドメイン自身）は
          `@`、ワイルドカードは左端のラベルを `*` にした `*.example.com`、日本語のラベルは punycode に正規化して照合します。

          '
        schema:
          type: string
          minLength: 1
          maxLength: 253
        example: www.example.com.
      - name: page
        in: query
        required: false
        description: ページ番号（1始まり）
        schema:
          type: integer
          default: 1
          minimum: 1
        example: 1
      - name: page-size
        in: query
        required: false
        description: 1ページあたりの件数（最大100件）
        schema:
          type: integer
          default: 20
          minimum: 1
          maximum: 100
        example: 20
      responses:
        '200':
          description: DNSレコード一覧
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DnsRecordsResponse"
              example:
                data:
                - id: 1
                  fqdn: www.example.com.
                  type: A
                  value: 192.0.2.1
                  ttl: 3600
                  created-at: '2025-01-15T09:00:00+09:00'
                  updated-at: '2025-01-15T09:00:00+09:00'
                - id: 2
                  fqdn: mail.example.com.
                  type: MX
                  value: mail.example.com.
                  ttl: 3600
                  priority: 10
                  created-at: '2025-01-15T09:00:00+09:00'
                  updated-at: '2025-01-15T09:00:00+09:00'
                meta:
                  total: 2
                  page: 1
                  page-size: 20
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
    post:
      operationId: create-me-dns-record
      summary: ドメインにDNSレコードを作成する
      description: |
        指定したドメインに新しいDNSレコードを作成します。

        作成可能なレコードタイプ: A, AAAA, CNAME, MX, TXT, NS, ALIAS。
        MXレコードの場合は `priority` フィールドが必須です（0〜65535）。
        CNAMEレコードは同一FQDNに他のレコードタイプと共存できません（RFC 1034準拠）。
        1ドメインあたりのレコード数は200件まで（SOAを除く）です。上限に達している場合は400（Record limit exceeded）を返します。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのみ操作可能です。
      tags:
      - DNS Records
      security:
      - jwt: []
      - oauth2:
        - dns:write
      parameters:
      - name: domain-id
        in: path
        required: true
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
        example: MU00000001
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/DnsRecordCreateRequest"
            example:
              fqdn: www.example.com.
              type: A
              value: 192.0.2.1
      responses:
        '201':
          description: DNSレコード作成成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DnsRecordResponse"
              example:
                data:
                  id: 1
                  fqdn: www.example.com.
                  type: A
                  value: 192.0.2.1
                  ttl: 3600
                  created-at: '2025-01-15T09:00:00+09:00'
                  updated-at: '2025-01-15T09:00:00+09:00'
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '409':
          "$ref": "#/components/responses/Conflict"
        '422':
          "$ref": "#/components/responses/UnprocessableEntity"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
  "/me/domains/{domain-id}/dns-records/{record-id}":
    patch:
      operationId: update-me-dns-record
      summary: DNSレコードの value / priority を更新する（ttl は変更不可）
      description: |
        指定したDNSレコードを部分更新します。
        `value` と `priority`（MXレコードのみ）を変更できます。`ttl` は変更できません。

        `fqdn` と `type` は変更できません。変更が必要な場合は削除後に再作成してください。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのみ操作可能です。
      tags:
      - DNS Records
      security:
      - jwt: []
      - oauth2:
        - dns:write
      parameters:
      - name: domain-id
        in: path
        required: true
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
        example: MU00000001
      - name: record-id
        in: path
        required: true
        description: DNSレコードID（整数）
        schema:
          type: integer
          format: int64
        example: 1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/DnsRecordUpdateRequest"
            example:
              value: 192.0.2.2
      responses:
        '200':
          description: DNSレコード更新成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DnsRecordResponse"
              example:
                data:
                  id: 1
                  fqdn: www.example.com.
                  type: A
                  value: 192.0.2.2
                  ttl: 3600
                  created-at: '2025-01-15T09:00:00+09:00'
                  updated-at: '2025-01-15T10:00:00+09:00'
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '422':
          "$ref": "#/components/responses/UnprocessableEntity"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
    delete:
      operationId: delete-me-dns-record
      summary: DNSレコードを削除する
      description: |
        指定したDNSレコードを削除します。
        SOAレコードは削除できません。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのみ操作可能です。
      tags:
      - DNS Records
      security:
      - jwt: []
      - oauth2:
        - dns:write
      parameters:
      - name: domain-id
        in: path
        required: true
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
        example: MU00000001
      - name: record-id
        in: path
        required: true
        description: DNSレコードID（整数）
        schema:
          type: integer
          format: int64
        example: 1
      responses:
        '204':
          description: DNSレコード削除成功
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
  "/me/domains/{domain-id}/nameservers":
    get:
      operationId: get-me-domain-nameservers
      summary: ドメインのネームサーバ設定を取得する
      description: |
        指定したドメインのネームサーバ設定（setup-type・ネームサーバ一覧）を取得します。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのみ取得可能です。
      tags:
      - DNS Records
      security:
      - jwt: []
      - oauth2:
        - dns:read
      parameters:
      - name: domain-id
        in: path
        required: true
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
        example: MU00000001
      responses:
        '200':
          description: ネームサーバ設定
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/NameserverSettingsResponse"
              example:
                data:
                  domain-id: MU00000001
                  setup-type: muumuu_dns
                  nameservers:
                  - dns01.muumuu-domain.com
                  - dns02.muumuu-domain.com
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
    patch:
      operationId: update-me-domain-nameservers
      summary: ドメインのネームサーバ設定を変更する（サイト・メールの参照先が切り替わります）
      description: |
        指定したドメインのネームサーバ設定（setup-type・ネームサーバ一覧）を変更します。

        `setup-type` は以下のいずれかを指定できます（レジストラAPI経由で即時反映）。
        - `custom`: 他のネームサーバ（`nameservers` に1〜6件指定。お名前.com等一部レジストラ・TLDでは2件以上必須）
        - `acquired_domain`: 取得したドメイン（`nameservers` の指定要件は custom と同じ）
        - `lolipop`: ロリポップ（`nameservers` は無視され、サーバ側の固定値が設定される）
        - `muumuu_dns`: ムームーDNS（`nameservers` は無視され、サーバ側の固定値が設定される）
        - `parking`: パーキング（`nameservers` は無視され、サーバ側の固定値が設定される）

        `lolipop` / `acquired_domain` / `muumuu_dns` / `parking` 以外の設定タイプ（各種サービス連携によるもの）は
        本APIから設定できません。GETでは `other` として返却されます。

        他社・custom から `muumuu_dns` へ切り替える際、既存の mdns レコード（メールMX等）が残っていると
        デフォルトでは `409 existing_dns_records` で拒否されます。レコードを保持したまま切り替えたい場合は
        `confirm-existing-records: true` を指定してください（レコードは削除されません）。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのみ操作可能です。
      tags:
      - DNS Records
      security:
      - jwt: []
      - oauth2:
        - dns:write
      parameters:
      - name: domain-id
        in: path
        required: true
        description: 'ドメインID（MU + 8桁の数字、例: MU00000001）'
        schema:
          type: string
          pattern: "^MU[0-9]{8}$"
          maxLength: 11
        example: MU00000001
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/NameserverUpdateRequest"
            example:
              setup-type: custom
              nameservers:
              - ns1.example.com
              - ns2.example.com
      responses:
        '200':
          description: ネームサーバ変更成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/NameserverSettingsResponse"
              example:
                data:
                  domain-id: MU00000001
                  setup-type: custom
                  nameservers:
                  - ns1.example.com
                  - ns2.example.com
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '409':
          description: |
            リソースの競合。以下のいずれかの理由で変更できません。
            - `dns_not_initialized`: DNS設定がまだ初期化されていないドメイン
            - `existing_dns_records`: muumuu_dns への切替時に、削除されずに残っているDNSレコードがある
              （`confirm-existing-records: true` を指定するとレコードを保持したまま切替可能）
            - `nameserver_locked`: ネームサーバがロック中
            - `muumuu_mail_in_use`: ムームーメール利用中のため muumuu_dns 以外へ変更できない
            - `domain_not_updatable`: ドメインが失効中で変更できない
            - `dns_zone_not_created`: muumuu_dns への切替時に DNS ゾーンが未作成
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              examples:
                dns_not_initialized:
                  summary: DNS設定が未初期化
                  value:
                    error:
                      code: dns_not_initialized
                      message: Nameservers cannot be changed until DNS is initialized
                        for this domain
                existing_dns_records:
                  summary: muumuu_dns切替時の残存DNSレコード
                  value:
                    error:
                      code: existing_dns_records
                      message: Cannot switch to muumuu_dns while DNS records still
                        exist. Delete them first.
                nameserver_locked:
                  summary: ネームサーバロック中
                  value:
                    error:
                      code: nameserver_locked
                      message: The nameserver setting is locked and cannot be changed.
                muumuu_mail_in_use:
                  summary: ムームーメール利用中
                  value:
                    error:
                      code: muumuu_mail_in_use
                      message: Cannot change nameservers away from muumuu_dns while
                        Muumuu Mail is in use.
                domain_not_updatable:
                  summary: ドメインが失効中
                  value:
                    error:
                      code: domain_not_updatable
                      message: The domain is not in an updatable state
                dns_zone_not_created:
                  summary: muumuu_dns 切替時のゾーン未作成
                  value:
                    error:
                      code: dns_zone_not_created
                      message: Nameservers cannot be switched to muumuu_dns until
                        the DNS zone is created
        '422':
          "$ref": "#/components/responses/UnprocessableEntity"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
        '503':
          "$ref": "#/components/responses/ServiceUnavailable"
  "/me/dns-records":
    get:
      operationId: list-me-dns-records-by-fqdn
      summary: FQDNを指定してDNSレコード一覧を取得する
      description: |
        ドメインのFQDN（完全修飾ドメイン名）を指定して、そのドメインのDNSレコード一覧を取得します。
        ドメインIDが不明な場合に、FQDNから直接DNSレコードを検索するために使用します。

        `domain-fqdn` パラメータは必須です。
        `type` パラメータでレコードタイプ（A、MX等）をフィルタリングできます。

        認証トークンからアカウントを自動識別し、自分が保有するドメインのDNSレコードのみ取得可能です。
      tags:
      - DNS Records
      security:
      - jwt: []
      - oauth2:
        - dns:read
      parameters:
      - name: domain-fqdn
        in: query
        required: true
        description: |
          検索対象のドメインFQDN（完全修飾ドメイン名）。完全一致で検索します。末尾ドットは省略可。日本語ドメインは punycode でも生の日本語でも指定できます。
          例: `example.com`, `example.co.jp`
        schema:
          type: string
          maxLength: 253
        example: example.com
      - name: type
        in: query
        required: false
        description: |
          レコードタイプでフィルタリング。
          指定可能な値: A, AAAA, CNAME, MX, TXT, NS, ALIAS
        schema:
          "$ref": "#/components/schemas/DnsRecordType"
      - name: fqdn
        in: query
        required: false
        description: 'レコード名（FQDN）で完全一致フィルタリング。レコード作成時と同じ表記を受け付けます: 末尾ドットは省略可、ゾーンアペックス（ドメイン自身）は
          `@`、ワイルドカードは左端のラベルを `*` にした `*.example.com`、日本語のラベルは punycode に正規化して照合します。

          '
        schema:
          type: string
          minLength: 1
          maxLength: 253
        example: www.example.com.
      - name: page
        in: query
        required: false
        description: ページ番号（1始まり）
        schema:
          type: integer
          default: 1
          minimum: 1
        example: 1
      - name: page-size
        in: query
        required: false
        description: 1ページあたりの件数（最大100件）
        schema:
          type: integer
          default: 20
          minimum: 1
          maximum: 100
        example: 20
      responses:
        '200':
          description: DNSレコード一覧
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DnsRecordsResponse"
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
  "/me/domain-purchase/quote":
    post:
      operationId: quote-domain-purchase
      summary: ドメイン購入の見積もり（金額・空き状況・クレカ状態）を取得する
      description: |
        ドメインの購入前に、以下の情報を確認します:
        - ドメインの空き状況
        - 登録料金（サービス維持調整費・消費税込み）
        - クレジットカードの登録状態
        - 購入トークン（purchase-token）

        **ドメインを購入する前に、必ずこの見積もりAPIを呼び出してください。**
        見積もりで取得した purchase-token.token は購入実行APIで必要です（有効期限: 10分）。

        クレジットカードが未登録の場合は、カード登録画面のURLが返されます。
        ユーザーにカード登録を案内してください。

        本 API は OAuth 認証と `muu_pat_` プレフィックスの Personal Access Token (PAT) の
        双方で利用でき、いずれも `domains:purchase` スコープが必須です。
        PAT 単体で見積もり（quote）から直接購入（direct）まで完結できます。
        JWT 認証（コントロールパネル）からは利用できません（403 Forbidden）。
      tags:
      - Domain Purchase
      security:
      - oauth2:
        - domains:purchase
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/DomainPurchasePreviewRequest"
            example:
              fqdn: example.com
              term: 1
      responses:
        '200':
          description: プレビューに成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DomainPurchasePreviewResponse"
              example:
                data:
                  fqdn: example.com
                  availability: available
                  term: 1
                  domain-price: 750
                  service-fee: 158
                  tax: 91
                  total: 999
                  currency: JPY
                  credit-card-registered: true
                  credit-card-registration-url:
                  purchase-token:
                    token: tok_xxxxxxxxxxxxxxxxxxxxxxxx
                    expires-at: '2025-06-01T12:10:00+09:00'
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '422':
          "$ref": "#/components/responses/UnprocessableEntity"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
        '502':
          "$ref": "#/components/responses/BadGateway"
        '503':
          "$ref": "#/components/responses/ServiceUnavailable"
  "/me/domain-purchase":
    post:
      operationId: purchase-domain
      summary: ドメイン購入を開始する（実行すると課金が発生します）
      description: |
        見積もりAPIで取得した purchase-token を使用してドメイン購入を開始します。

        レスポンスの checkout-url をユーザーのブラウザで開いてもらい、購入確認を完了してください。
        購入の進捗は GET /api/v2/me/domain-purchase/{purchase-id}/status でポーリングしてください。

        必ず事前に見積もりAPIで金額をユーザーに提示し、同意を得てから実行してください。
        checkout-url の有効期限は10分です。レート制限: 10件/日。
      tags:
      - Domain Purchase
      security:
      - oauth2:
        - domains:purchase
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/DomainPurchaseRequest"
            example:
              purchase-token: tok_xxxxxxxxxxxxxxxxxxxxxxxx
      responses:
        '201':
          description: 購入セッションの作成に成功
          headers:
            X-DailyPurchase-Limit:
              description: 1日あたりの購入上限数
              schema:
                type: integer
              example: 10
            X-DailyPurchase-Remaining:
              description: 本日の残り購入可能数
              schema:
                type: integer
              example: 9
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DomainPurchaseResponse"
              example:
                data:
                  purchase-id: 1
                  checkout-url: https://muumuu-domain.com/checkout/mcp/abc123def456
                  status: pending
                  fqdn: example.com
                  term: 1
                  expires-at: '2025-06-01T12:10:00+09:00'
        '400':
          description: |
            リクエストエラー。以下のケースが含まれます:
            - purchase-token が無効または期限切れ
            - クレジットカード未登録
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              examples:
                purchase-token-expired:
                  summary: 購入トークン期限切れ
                  value:
                    error:
                      code: purchase_token_expired
                      message: The purchase token has expired. Please request a new
                        quote.
                purchase-token-invalid:
                  summary: 購入トークン無効
                  value:
                    error:
                      code: purchase_token_invalid
                      message: The purchase token is invalid.
                credit-card-required:
                  summary: クレジットカード未登録
                  value:
                    error:
                      code: credit_card_required
                      message: A registered credit card is required to purchase a
                        domain.
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          description: 'レート制限超過。購入APIは1ユーザーあたり10件/日の制限があります。

            '
          headers:
            X-DailyPurchase-Limit:
              description: 1日あたりの購入上限数
              schema:
                type: integer
              example: 10
            X-DailyPurchase-Remaining:
              description: 本日の残り購入可能数
              schema:
                type: integer
              example: 0
            Retry-After:
              description: リトライまでの待機時間（秒）
              schema:
                type: integer
              example: 3600
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: rate_limit_exceeded
                  message: Daily purchase limit exceeded. Please retry tomorrow.
        '500':
          "$ref": "#/components/responses/InternalServerError"
        '502':
          description: 外部サービスとの通信に失敗
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: external_service_error
                  message: Failed to communicate with external service
        '503':
          "$ref": "#/components/responses/ServiceUnavailable"
  "/me/domain-purchase/direct":
    post:
      operationId: purchase-domain-direct
      summary: ドメインを 1 リクエストで購入する（事前申請制／実行すると課金が発生します）
      description: |
        ## 事前申請が必要なエンドポイント

        本 API は通常アカウントでは利用できません。
        ご利用には事前にムームードメインへの利用申請と承認が必要です。
        未申請または未承認のアカウントから呼び出した場合は **403 Forbidden** が返ります。

        利用をご希望の場合は
        [お問い合わせフォーム](https://muumuu-domain.com/?mode=conpane&state=inq)
        よりご連絡ください。

        ---

        ## 概要

        申請が承認されたアカウント専用の、ブラウザ画面遷移なしで決済とドメイン登録を
        1 リクエストで完結するドメイン購入エンドポイント。

        見積もりAPI（`POST /api/v2/me/domain-purchase/quote`）で取得した purchase-token を
        リクエストボディに含めてください。

        **必ず事前に見積もりAPIで金額をユーザーに提示し、同意を得てから実行してください。**
        purchase-token の有効期限は10分、同一トークンの再送は409エラーになります（リプレイ防止）。

        ## ステータス照会は不要です

        本 API はレスポンス到着時点で決済とドメイン登録が完了しているため、
        GET /api/v2/me/domain-purchase/{purchase_id}/status によるポーリングは不要です。
        また、本 API が返す purchase-id（`TP########` 形式）は
        checkout フロー（POST /api/v2/me/domain-purchase）の整数 ID とは別体系で、
        ステータス照会APIには指定できません。

        ## 5xx が返った場合の扱い

        **5xx は「課金されていない」ことを意味しません。** 決済が成立した後の工程で
        失敗した場合も 5xx になります。決済の成否は `error.code` で判別してください。
        不明と書かれたものは、決済確定処理そのものが中断していて成否を断定できません。

        | ステータス | error.code | 決済の成否 | クライアントの対処 |
        |---|---|---|---|
        | 500 | `internal_error` | **不明** | 再実行せず、下記の方法で結果を確認してください |
        | 502 | `external_service_error` | **未成立** | 時間をおいて再実行して構いません |
        | 502 | `domain_registration_failed` | **成立**（課金済み・ドメイン未登録） | **再実行しないでください。** レスポンスの purchase-id を添えてサポートへご連絡ください |
        | 504 | `service_unavailable` | **不明** | 再実行せず、下記の方法で結果を確認してください |

        ### 決済の成否が不明なときの確認方法

        `GET /api/v2/me/domains?fqdn=<購入したFQDN>` を実行してください。
        ドメインが返れば購入は成立しています。返らない場合は課金だけ成立している可能性があるため、
        再実行せずサポートへご連絡ください
        （`GET /api/v2/me/payment-history` は課金の有無しか分からず、登録の成否は判定できません）。

        ## 認証要件

        本 API は `muu_pat_` プレフィックスの Personal Access Token (PAT) でのみ利用可能で、
        `domains:purchase` スコープが必須です。
        JWT 認証（コントロールパネル）や OAuth Doorkeeper の通常アクセストークンは
        403 Forbidden になります。
      tags:
      - Domain Purchase
      security:
      - oauth2:
        - domains:purchase
      requestBody:
        required: true
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/DomainPurchaseRequest"
            example:
              purchase-token: tok_xxxxxxxxxxxxxxxxxxxxxxxx
      responses:
        '201':
          description: |
            決済完了。本レスポンス到着時点でドメイン登録まで完結した状態。
            status は常に completed で、domain-id / contract-id が確定済み。
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DirectDomainPurchaseResponse"
              example:
                data:
                  purchase-id: TP00000001
                  status: completed
                  fqdn: example.com
                  term: 1
                  domain-id: MU00000001
                  contract-id: MC00000001
                  completed-at: '2025-06-01'
        '400':
          description: |
            リクエストエラー。以下のケースが含まれます:
            - purchase-token が無効または期限切れ
            - クレジットカード未登録
            - 顧客情報未入力（KYC）
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              examples:
                purchase-token-expired:
                  summary: 購入トークン期限切れ
                  value:
                    error:
                      code: purchase_token_expired
                      message: The purchase token has expired. Please request a new
                        quote.
                purchase-token-invalid:
                  summary: 購入トークン無効
                  value:
                    error:
                      code: purchase_token_invalid
                      message: The purchase token is invalid.
                credit-card-required:
                  summary: クレジットカード未登録
                  value:
                    error:
                      code: credit_card_required
                      message: A registered credit card is required to purchase a
                        domain.
                customer-info-required:
                  summary: 顧客情報未入力
                  value:
                    error:
                      code: customer_info_required
                      message: Customer information is incomplete. Please complete
                        your profile before purchasing a domain.
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '402':
          description: '決済処理が明示的に失敗（カード会社による否認等）。

            '
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: payment_failed
                  message: The payment was declined.
        '403':
          "$ref": "#/components/responses/Forbidden"
        '409':
          "$ref": "#/components/responses/Conflict"
        '422':
          description: |
            purchase-token の契約年数を TLD が受け付けない（見積もり後に TLD の取り扱い年数が変わった場合）。
            決済は行わず、purchase-token も消費しません。見積もりからやり直してください。
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: validation_error
                  message: term must be between 1 and 1 for .example domains
        '500':
          description: |
            内部エラー。**決済の成否は判別できません。**
            決済成立前の失敗と、決済成立後にドメイン登録まで到達できなかった失敗の
            どちらもここに含まれます。再実行せず `GET /api/v2/me/domains?fqdn=` で
            結果を確認してください。
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: internal_error
                  message: Internal server error
        '502':
          description: |
            外部サービス起因の失敗。決済の成否は `error.code` で判別してください。

            - `external_service_error`: 決済に到達する前に外部サービスから想定外の応答を受けた場合。
              **決済は成立していません。** 時間をおいて再実行して構いません。
            - `domain_registration_failed`: **決済は成立し、ドメイン登録だけが失敗しました。**
              課金済みでドメインが手元に無い状態のため、同一内容での再実行は二重課金になります。
              レスポンスの purchase-id を添えてサポートへご連絡ください。
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              examples:
                external-service-error:
                  summary: 決済前の外部サービスエラー（未課金）
                  value:
                    error:
                      code: external_service_error
                      message: Failed to communicate with external service.
                domain-registration-failed:
                  summary: 決済成立後の登録失敗（課金済み・ドメイン未登録）
                  value:
                    error:
                      code: domain_registration_failed
                      message: The payment was completed but the domain registration
                        failed. Do not retry this purchase; please contact support.
                      purchase-id: TP00000001
                      fqdn: example.jp
        '503':
          description: |
            レジストラ/レジストリのメンテナンス中のため、決済を実行せずに中断しました。
            **決済は成立していません。** メンテナンス終了後に再実行してください
            （purchase-token が期限切れの場合は quote からやり直してください）。
          headers:
            Retry-After:
              description: |
                リトライまでの待機時間（秒）。
                メンテナンス終了時刻が判明している場合にのみ付与されます。
              schema:
                type: integer
                example: 3600
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: registrar_maintenance
                  message: The registrar for this domain is currently under maintenance.
                    Please try again later.
        '504':
          description: |
            サーバー側タイムアウト。決済結果が確定できなかった可能性があるため、
            同一の purchase-token での即時リトライは行わず、必ず購入結果を確認してから対処してください
            （詳細は API 開発者ポータルの運用ガイドを参照）。
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/ErrorResponse"
              example:
                error:
                  code: service_unavailable
                  message: The payment service timed out. Please check the purchase
                    status before retrying.
  "/me/domain-purchase/{purchase_id}/status":
    get:
      operationId: get-domain-purchase-status
      summary: ドメイン購入の進捗を取得する
      description: |
        購入セッションのステータスをポーリングで確認します。
        購入API（POST /api/v2/me/domain-purchase）で取得した purchase-id を指定してください。

        **ポーリング推奨間隔:** 3〜5秒

        **ステータス遷移:**
        - pending → ユーザーがまだブラウザで確認していない
        - processing → 3DS認証中または決済処理中
        - completed → 購入完了（domain-id, contract-id が確定）
        - failed → 購入失敗（failure-reason で原因を確認）

        このAPIはOAuth認証（domains:purchase スコープ）専用です。
      tags:
      - Domain Purchase
      security:
      - oauth2:
        - domains:purchase
      parameters:
      - name: purchase_id
        in: path
        required: true
        description: |
          購入セッションID（purchase-domain API のレスポンスで取得した整数 ID）。
          直接購入API（POST /api/v2/me/domain-purchase/direct）が返す `TP########` 形式の ID は
          別体系のため指定できません。
        schema:
          type: integer
        example: 1
      responses:
        '200':
          description: ステータス取得に成功
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DomainPurchaseStatusResponse"
              examples:
                pending:
                  summary: チェックアウト待ち
                  value:
                    data:
                      purchase-id: 1
                      status: pending
                      fqdn: example.com
                      term: 1
                      domains:
                      - domain-name: example.com
                        term: 1
                        status: pending
                        domain-id:
                        contract-id:
                        failure-reason:
                completed:
                  summary: 購入完了
                  value:
                    data:
                      purchase-id: 1
                      status: completed
                      fqdn: example.com
                      term: 1
                      domains:
                      - domain-name: example.com
                        term: 1
                        status: completed
                        domain-id: MU00000001
                        contract-id: MC00000001
                        failure-reason:
                failed:
                  summary: 購入失敗
                  value:
                    data:
                      purchase-id: 1
                      status: failed
                      fqdn: example.com
                      term: 1
                      domains:
                      - domain-name: example.com
                        term: 1
                        status: failed
                        domain-id:
                        contract-id:
                        failure-reason: payment_failed
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '404':
          "$ref": "#/components/responses/NotFound"
  "/domain-search":
    get:
      operationId: search-domains
      summary: ドメインの空き状況を検索する
      description: |
        指定したキーワードでドメインの空き状況と価格を検索します。

        「example.comが取れるか調べて」「exampleで取れるドメインを探して」
        といったリクエストに対応します。

        キーワードにTLDを含める場合（例: `example.com`）、そのドメインの空き状況を返します。
        TLDを含めない場合（例: `example`）、`tlds` パラメータで指定したTLD群で検索します。
        `tlds` を省略した場合は、主要なTLD（com, net, jp 等）で検索します。

        検索結果には空き状況（available/unavailable/premium）と価格が含まれます。

        `unavailable` には、既に取得されている場合と、レジストラ/レジストリのメンテナンス中で
        空き状況を判定できない場合があります。`unavailable-reason` で区別できます。
        `maintenance` の場合はメンテナンス終了後に取得できる可能性があります。

        注意: `premium`（プレミアムドメイン）は検索結果に `premium` として表示されますが、
        現在 API 経由では取得（購入）できません。`premium` のドメインは価格が `null` で返り、
        購入見積もり（`POST /api/v2/me/domain-purchase/quote`）でも購入トークンが発行されません。
        取得をご希望の場合はムームードメインのサイトからお手続きください。

        このAPIはOAuth認証（domains:search スコープ）が必要です。
        コントロールパネル（JWT認証）からは別途検索UIを利用してください。
      tags:
      - Domain Search
      security:
      - oauth2:
        - domains:search
      parameters:
      - name: q
        in: query
        required: true
        description: |
          検索キーワード。
          TLD付き（例: `example.com`）またはTLDなし（例: `example`）で指定できます。
          TLDなしの場合は `tlds` パラメータで検索対象のTLDを指定してください。
        schema:
          type: string
          minLength: 1
          maxLength: 253
        example: example.com
      - name: tlds
        in: query
        required: false
        description: |
          検索対象のTLD一覧。
          `q` にTLDが含まれていない場合に使用します。
          省略した場合は主要なTLD（com, net, jp 等）で検索します。
        schema:
          type: array
          items:
            type: string
            minLength: 2
            maxLength: 20
          maxItems: 20
        style: form
        explode: false
        example:
        - com
        - net
        - jp
      responses:
        '200':
          description: ドメイン検索に成功
          headers:
            Cache-Control:
              description: キャッシュ制御。検索結果は短時間キャッシュ可能です。
              schema:
                type: string
              example: max-age=60
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/DomainSearchResponse"
              example:
                data:
                  query: example
                  truncated: false
                  results:
                  - fqdn: example.com
                    availability: unavailable
                    unavailable-reason: registered
                    domain-price:
                    service-fee:
                    tax:
                    total:
                    currency: JPY
                  - fqdn: example.net
                    availability: available
                    unavailable-reason:
                    domain-price: 1280
                    service-fee: 158
                    tax: 144
                    total: 1582
                    currency: JPY
                  - fqdn: example.jp
                    availability: available
                    unavailable-reason:
                    domain-price: 1650
                    service-fee: 158
                    tax: 181
                    total: 1989
                    currency: JPY
                  - fqdn: example.org
                    availability: unavailable
                    unavailable-reason: maintenance
                    domain-price:
                    service-fee:
                    tax:
                    total:
                    currency: JPY
        '400':
          "$ref": "#/components/responses/BadRequest"
        '401':
          "$ref": "#/components/responses/Unauthorized"
        '403':
          "$ref": "#/components/responses/Forbidden"
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
        '502':
          "$ref": "#/components/responses/BadGateway"
  "/maintenances":
    get:
      operationId: list-maintenances
      summary: 進行中・予定のメンテナンス情報を取得する
      description: |
        終了していないメンテナンス（進行中と開始前の予定）を、レジストラ・レジストリ（TLD）・サービスの
        種別ごとに返します。終了済みのメンテナンスは含みません。

        進行中か予定かは、`begin-at` を現在時刻と比較して判定してください。レスポンスはキャッシュされるため、
        サーバー側で判定した状態を返すと開始時刻の前後で実際と食い違うことがあります。

        ドメイン検索（`GET /api/v2/domain-search`）で `unavailable-reason` が `maintenance` の
        ドメインについて、どのメンテナンスがいつ終わるかを確認する用途を想定しています。
        新規取得だけを止めるメンテナンス（`onamae_registration`）は、`registrars` ではなく `services` に載ります。

        このAPIは認証不要です。
      tags:
      - Maintenances
      security: []
      responses:
        '200':
          description: メンテナンス情報の取得に成功
          headers:
            Cache-Control:
              description: |
                キャッシュ制御。レスポンスはサーバー側で最大 5 分キャッシュされ、クライアント側でも
                最大 5 分キャッシュしてよい値を返します。そのため、メンテナンスの開始・終了の反映は
                最大で約 10 分遅れることがあります。
              schema:
                type: string
              example: max-age=300
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/MaintenanceListResponse"
              example:
                data:
                  registrars:
                  - name: jprs
                    begin-at: '2026-10-01T02:00:00+09:00'
                    end-at: '2026-10-01T06:00:00+09:00'
                    information-id: 1234
                  registries:
                  - tlds:
                    - com
                    - net
                    begin-at: '2026-10-08T02:00:00+09:00'
                    end-at: '2026-10-08T04:00:00+09:00'
                    information-id: 1235
                  services:
                  - name: creditcard
                    begin-at: '2026-10-01T01:00:00+09:00'
                    end-at: '2026-10-01T03:00:00+09:00'
                    information-id:
        '429':
          "$ref": "#/components/responses/TooManyRequests"
        '500':
          "$ref": "#/components/responses/InternalServerError"
components:
  securitySchemes:
    oauth2:
      type: oauth2
      description: |-
        OAuth 2.0 認証を使用します。

        ## フロー
        ### Authorization Code（ユーザーコンテキスト）
        `/api/v2/me/*` エンドポイントで使用します。
        ユーザーがブラウザで認可した後、アクセストークンを取得します。
        PKCE (RFC 7636) が必須です。
      flows:
        authorizationCode:
          authorizationUrl: "/oauth/authorize"
          tokenUrl: "/oauth/token"
          scopes:
            domains:read: ドメイン情報の読み取り（保有ドメイン一覧・詳細の取得）
            dns:read: DNSレコード・ネームサーバの読み取り（DNSレコード一覧・ネームサーバ設定の取得）
            dns:write: DNSレコード・ネームサーバの操作（DNSレコードの作成・更新・削除、ネームサーバの変更）
            domains:search: ドメインの空き検索
            domains:purchase: ドメインの購入
            options:read: オプション契約の読み取り（AIホームページの契約一覧・詳細の取得）
            options:write: オプション契約の作成・変更・解約（AIホームページの契約作成（無料期間後に自動課金）・解約・ドメイン紐づけ。ドメイン紐づけには
              dns:write も必要）
            domains:write: ドメインの登録・更新
    jwt:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        JWT認証（ユーザーコンテキスト）。
        `/api/v2/me/*` エンドポイントで使用します。
        ログイン時に発行されるJWTトークンをAuthorizationヘッダーに含めてください。

        ```
        Authorization: Bearer <jwt_token>
        ```
  schemas:
    Error:
      type: object
      description: エラー情報
      required:
      - code
      - message
      properties:
        code:
          type: string
          description: |
            エラーコード
            - bad_request: リクエストパラメータが不正
            - unauthorized: 認証が必要
            - invalid_token: トークンが無効または期限切れ
            - forbidden: 権限不足
            - insufficient_scope: 必要なスコープがない
            - context_mismatch: 認証コンテキストが不正
            - account_recovery_cooldown: アカウント復旧直後のクールダウン期間中で操作が抑止されている
            - not_found: リソースが見つからない
            - conflict: リソースの競合（既に存在する等）
            - validation_error: バリデーションエラー
            - rate_limit_exceeded: レート制限超過
            - internal_error: サーバー内部エラー
            - service_unavailable: 外部サービスタイムアウト
            - timeout: サーバー側タイムアウト（同期決済等で結果不明・運用に問い合わせ要）
            - external_service_error: 外部サービスエラー
            - payment_service_rejected: 決済会社（GMO 掛け払い）が要求を業務エラーとして受け付けなかった。通信は成立している（入力内容の不備・取引状態の不整合など）
            - payment_failed: 決済処理の失敗
            - domain_registration_failed: 決済は成立したがドメイン登録に失敗（課金済み・ドメイン未登録）
            - domain_unavailable: ドメインが取得不可
            - price_mismatch: プレビュー時と価格が変動
            - purchase_token_expired: 購入トークンの期限切れ
            - purchase_token_invalid: 購入トークンが無効
            - credit_card_required: クレジットカード未登録
            - customer_info_required: 顧客情報未入力
            - quote_token_invalid: 見積もりトークンが無効
            - quote_token_expired: 見積もりトークンが期限切れ
            - checkout_token_invalid: 決済トークンが無効
            - checkout_token_expired: 決済トークンが期限切れ
            - payment_method_required: 決済方法が未設定
            - domain_already_registered: ドメインが既に登録済み
            - unsupported_tld: 登録者/組織情報が必要でこのフローでは購入できないTLD（属性型JP/汎用JP/.asia等）
            - invalid_request: リクエスト形式エラー（OAuth/OIDC 等で使用）
            - invalid_scope: OAuth スコープ指定が不正
            - invalid_path_pattern: パスパターン指定が不正
            - scope_not_applicable: スコープが対象アクションに適用されない
            - unsupported_media_type: サポート外の Content-Type
            - unsupported_response_type: OAuth response_type が未サポート
            - credit_card_not_registered: クレジットカードが未登録（決済前提が不足）
            - credit_card_expired: 登録済みクレジットカードの有効期限切れ
            - cloud_identity_setup_failed: Google Workspace Cloud Identity セットアップ失敗
            - customer_creation_failed: Google Workspace Customer 作成失敗
            - entitlement_creation_failed: Google Workspace Entitlement 作成失敗
            - domain_check_failed: ドメインチェック処理失敗
            - license_update_failed: ライセンス更新失敗
            - offer_selection_failed: オファー選択失敗
            - plan_upgrade_failed: プランアップグレード失敗
            - renewal_settings_update_failed: 更新設定の更新失敗
            - customer_already_exists: 対象ドメインの顧客が既に存在する
            - cloud_identity_conflict: 管理者メールアドレスが既存の Google アカウントと衝突している
            - cloud_identity_already_provisioned: 顧客に既に Cloud Identity が紐づいている
            - upstream_already_exists: 上位 API からの既存リソース衝突
            - upstream_invalid_argument: 上位 API からの引数不正
            - upstream_not_found: 上位 API がリソースを見つけられない
            - upstream_permission_denied: 上位 API から権限拒否
            - upstream_quota_exceeded: 上位 API のクォータ超過
            - upstream_timeout: 上位 API のタイムアウト
            - upstream_unavailable: 上位 API が利用不可
            - upstream_unknown: 上位 API からの未分類エラー
            - missing_required_parameter: 必須パラメータの欠落・空値（details[].field に対象フィールドを示す）
            - active_trial_option_exists: 既にトライアル中のオプションが存在
            - canceling_trial_option_exists: 解約処理中のトライアルオプションが存在
            - buyer_not_registered: 掛け払いの購入企業情報が未登録（取引作成の前提不足）
            - amount_mismatch: 取引金額と再算出した注文金額が不一致（請求確定の拒否）
            - existing_dns_records: DNS の書き込み先に既存レコードがあり自動で上書き・削除しない（muumuu_dns への切替時の残存レコード、AIホームページのドメイン紐づけ時の同名・同タイプのレコード）
            - nameserver_locked: ネームサーバがロック中で変更できない
            - auto_renew_locked: ドメインロックで自動更新がロック中のため変更できない
            - muumuu_mail_in_use: ムームーメール利用中のため muumuu_dns 以外へ変更できない
            - xxx_tld_not_supported: .xxx ドメインはネームサーバ変更に対応していない
            - dns_not_initialized: DNSレコードが未初期化のドメインはネームサーバ変更に対応していない
            - dns_zone_not_created: muumuu_dns への切替時に DNS ゾーンが未作成
            - domain_not_updatable: 失効中のドメインは更新できない
            - registrar_maintenance: レジストラ/レジストリのメンテナンス中で処理できない
            - browser_required: 金銭が確定する操作（AIホームページの公開等）は OAuth 経路の API では実行できず、ブラウザ画面で行う必要がある
            - feature_disabled: 機能が無効化されている（フィーチャーフラグ OFF またはサンドボックス非対応）
            - active_option_exists: 有効なオプション契約（trial / active / canceling）が既に存在する（1 件目の契約だけを作成できる経路で 2 件目を作ろうとした）
          enum:
          - bad_request
          - unauthorized
          - invalid_token
          - forbidden
          - insufficient_scope
          - context_mismatch
          - account_recovery_cooldown
          - not_found
          - validation_error
          - conflict
          - rate_limit_exceeded
          - internal_error
          - service_unavailable
          - timeout
          - external_service_error
          - payment_service_rejected
          - payment_failed
          - domain_registration_failed
          - domain_unavailable
          - price_mismatch
          - purchase_token_expired
          - purchase_token_invalid
          - credit_card_required
          - customer_info_required
          - quote_token_invalid
          - quote_token_expired
          - checkout_token_invalid
          - checkout_token_expired
          - payment_method_required
          - domain_already_registered
          - unsupported_tld
          - invalid_request
          - invalid_scope
          - invalid_path_pattern
          - scope_not_applicable
          - unsupported_media_type
          - unsupported_response_type
          - credit_card_not_registered
          - credit_card_expired
          - cloud_identity_setup_failed
          - customer_creation_failed
          - entitlement_creation_failed
          - domain_check_failed
          - license_update_failed
          - offer_selection_failed
          - plan_upgrade_failed
          - renewal_settings_update_failed
          - customer_already_exists
          - cloud_identity_conflict
          - cloud_identity_already_provisioned
          - upstream_already_exists
          - upstream_invalid_argument
          - upstream_not_found
          - upstream_permission_denied
          - upstream_quota_exceeded
          - upstream_timeout
          - upstream_unavailable
          - upstream_unknown
          - missing_required_parameter
          - active_trial_option_exists
          - canceling_trial_option_exists
          - buyer_not_registered
          - amount_mismatch
          - existing_dns_records
          - nameserver_locked
          - auto_renew_locked
          - muumuu_mail_in_use
          - xxx_tld_not_supported
          - dns_not_initialized
          - dns_zone_not_created
          - domain_not_updatable
          - registrar_maintenance
          - browser_required
          - feature_disabled
          - active_option_exists
          example: invalid_token
        message:
          type: string
          description: エラーメッセージ
          example: The access token is invalid or expired
        details:
          type: array
          description: |
            フィールド単位のエラー詳細。
            validation_error のほか、bad_request（必須項目の欠落: `missing_required_parameter`）や
            conflict（上流 API との衝突: `cloud_identity_conflict` 等）でも、原因を特定できる場合に含まれる。
            複数のフィールドでエラーがある場合に、各エラーの詳細を配列で返します。
          items:
            "$ref": "#/components/schemas/ErrorDetail"
        purchase-id:
          type: string
          description: |
            決済が成立した購入ID。domain_registration_failed の場合にのみ含まれる。
            サポートへ問い合わせる際の識別子として使用してください。
          example: TP00000001
        fqdn:
          type: string
          description: '購入対象のFQDN。domain_registration_failed の場合にのみ含まれる。

            '
          example: example.jp
    ErrorDetail:
      type: object
      description: フィールド単位のエラー詳細
      required:
      - field
      - message
      properties:
        field:
          type: string
          description: |
            エラーが発生したフィールド名。ネストしたフィールドは `org-postal-address.postal-code` のように `.` 区切り。
            フィールドを特定できない場合は `base`
          example: value
        message:
          type: string
          description: フィールド固有のエラーメッセージ
          example: Invalid format
        code:
          type: string
          description: 'エラーコード（任意。例: `missing_required_parameter`）'
          example: invalid_format
    ErrorResponse:
      type: object
      description: エラーレスポンス
      required:
      - error
      properties:
        error:
          "$ref": "#/components/schemas/Error"
    PaginationMeta:
      type: object
      description: ページネーション情報
      required:
      - total
      - page
      - page-size
      properties:
        total:
          type: integer
          description: 総件数
          example: 100
        page:
          type: integer
          description: 現在のページ番号
          example: 1
        page-size:
          type: integer
          description: 1ページあたりの件数
          example: 20
    Domain:
      type: object
      description: ドメイン情報
      required:
      - id
      - sld
      - tld
      - fqdn
      - state
      - setup-state
      properties:
        id:
          type: string
          description: ドメインID（MU00000001形式）
          example: MU00000001
          pattern: "^MU[0-9]{8}$"
        sld:
          type: string
          description: セカンドレベルドメイン（ホスト名部分）
          example: example
        tld:
          type: string
          description: トップレベルドメイン（拡張子部分）
          example: com
        fqdn:
          type: string
          description: 完全修飾ドメイン名（FQDN）
          example: example.com
        state:
          type: string
          description: |
            ドメイン状態
            - active: 有効
            - inactive: 無効
            - pending-setup: セットアップ前
            - pending-transfer: 移管申請中
            - pending-bulk: 一括取得待ち
          enum:
          - active
          - inactive
          - pending-setup
          - pending-transfer
          - pending-bulk
          example: active
        setup-state:
          type: string
          description: |
            セットアップ状態
            - not-acquired: 未取得
            - acquired: 取得済
            - pending: 取得待ち
            - transfer-pending: 移管申請中
            - transfer-reserved: 移管予約
            - bulk-pending: 一括取得中
          enum:
          - not-acquired
          - acquired
          - pending
          - transfer-pending
          - transfer-reserved
          - bulk-pending
          example: acquired
        registrar:
          type: string
          description: レジストラ
          enum:
          - jprs
          - onamae
          - enom
          example: jprs
        whois-proxy-enabled:
          type: boolean
          description: WHOIS代理公開が有効か
          example: true
        auto-renew-enabled:
          type: boolean
          description: 自動更新が有効か
          example: true
        is-japanese-domain:
          type: boolean
          description: 日本語ドメインか
          example: false
        contract:
          "$ref": "#/components/schemas/DomainContract"
        status-group:
          "$ref": "#/components/schemas/DomainStatusGroup"
        contract-end-date:
          type:
          - string
          - 'null'
          format: date
          description: |
            区分の判定に使った契約の終了日（`status-group` 指定時のみ）。
            `contracted` / `transfer-unpaid` は対象契約の最も遅い終了日、`expired-recoverable` は最新の入金済み契約の終了日、
            `pending-payment` は入金締切日が最も早い請求の契約の終了日、`pending-transfer` は移管の契約があればその中で最も遅い終了日（無ければ移管更新の契約の中で最も遅い終了日）
          example: '2026-01-01'
        contract-total-term:
          type:
          - integer
          - 'null'
          description: '契約年数（`status-group` 指定時のみ）。`contracted` / `transfer-unpaid`
            は対象契約の年数の合計（すべて null なら null）、それ以外は区分の判定に使った契約の年数

            '
          example: 3
        payment-due-date:
          type:
          - string
          - 'null'
          format: date
          description: 入金締切日（`status-group` 指定時のみ。`pending-payment`・`pending-transfer`・`transfer-unpaid`
            のときだけ値が入る。`pending-payment` は最も早い入金締切日、`pending-transfer` は対象請求の入金締切日の最大値、`transfer-unpaid`
            は終了日が最も遅い契約の請求の入金締切日）
          example: '2026-01-08'
        cancellation-scheduled:
          type: boolean
          description: 契約終了日が今日以降の契約に解約予約が入っているか（`status-group` 指定時のみ）
          example: false
        expired:
          anyOf:
          - "$ref": "#/components/schemas/DomainExpiredInfo"
          - type: 'null'
          description: 期限切れの情報（`status-group` 指定時のみ。`expired-recoverable` のときだけ値が入る）
        contract-state:
          anyOf:
          - "$ref": "#/components/schemas/ContractState"
          - type: 'null'
          description: 区分の判定に使った契約の契約状態（`status-group` 指定時のみ。値は `contract.state` と同じ
            `new` / `renewal` / `transfer` など）
        treat-service-name:
          type:
          - string
          - 'null'
          description: 特典（優待）対象ドメインのときの特典名（`status-group` 指定時のみ）。対象外は null
          example: ずっと無料
        unrenewable-start-date:
          type:
          - string
          - 'null'
          format: date
          description: |
            契約終了日より前に更新できなくなる TLD のとき、更新できなくなる日（`status-group` 指定時のみ）。
            `contract-end-date` − TLD ごとの日数 + 1。対象外の TLD、または `contract-end-date` が null のときは null
          example: '2026-01-01'
    DomainContract:
      type: object
      description: ドメイン契約情報
      required:
      - id
      - state
      properties:
        id:
          type: string
          description: 契約ID（MC00000001形式）
          example: MC00000001
          pattern: "^MC[0-9]{8}$"
        state:
          "$ref": "#/components/schemas/ContractState"
        term:
          type:
          - integer
          - 'null'
          description: 契約期間（年）
          minimum: 1
          maximum: 10
          example: 1
        start-date:
          type:
          - string
          - 'null'
          format: date-time
          description: 契約開始日
          example: '2024-01-01T00:00:00+09:00'
        end-date:
          type:
          - string
          - 'null'
          format: date-time
          description: 契約終了日
          example: '2025-01-01T00:00:00+09:00'
        payment-method:
          anyOf:
          - "$ref": "#/components/schemas/ContractPaymentMethod"
          - type: 'null'
          description: 支払い方法
        auto-renew-enabled:
          type:
          - boolean
          - 'null'
          description: 自動更新が有効かどうか
          example: true
    MeDomainListResponse:
      type: object
      description: ドメイン一覧レスポンス（`/me/domains`）
      required:
      - data
      - meta
      properties:
        data:
          type: array
          items:
            "$ref": "#/components/schemas/Domain"
        meta:
          "$ref": "#/components/schemas/DomainListMeta"
    DomainListMeta:
      type: object
      description: ページネーション情報（`/me/domains`）
      required:
      - total
      - page
      - page-size
      properties:
        total:
          type: integer
          description: 総件数
          example: 100
        page:
          type: integer
          description: 現在のページ番号
          example: 1
        page-size:
          type: integer
          description: 1ページあたりの件数
          example: 20
        total-unfiltered:
          type: integer
          description: |
            `q` で絞り込む前の総件数（`status-group` と `q` を両方指定したときだけ返す）。
            `status-group`・`fqdn`・`state` の条件は掛けた後の件数
          example: 250
    DomainResponse:
      type: object
      description: ドメイン詳細レスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/Domain"
    DnsRecordType:
      type: string
      description: DNSレコードタイプ
      enum:
      - A
      - AAAA
      - CNAME
      - MX
      - TXT
      - NS
      - ALIAS
      - SRV
      - CAA
      example: A
    DnsRecordValue:
      type: string
      description: |
        レコード値。Route53の `ResourceRecords[].Value` に相当。
        レコードタイプに応じた形式で指定すること。

        **バリデーションパターン（実装時に使用）**:
        - A: IPv4アドレス形式
          `^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$`
          例: 192.0.2.1
        - AAAA: IPv6アドレス形式
          `^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$` または省略形
          例: 2001:db8::1
        - CNAME/NS: FQDN形式
          `^([a-zA-Z0-9_]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])?\.)+$`
          例: mail.example.com.
        - MX: FQDN形式（priorityフィールドと組み合わせ）
          例: mail.example.com.
        - TXT: 任意の文字列（適切なエスケープが必要）
          例: v=spf1 include:_spf.example.com ~all
        - ALIAS: FQDN形式（CNAMEと同様だが、他のレコードタイプと共存可能）
          例: www.example.com.
      minLength: 1
      maxLength: 4096
      example: 192.0.2.1
    DnsRecord:
      type: object
      description: |
        DNSレコード。
        Route53の `ResourceRecordSet` にマッピング可能な構造。
      required:
      - id
      - fqdn
      - type
      - value
      - ttl
      properties:
        id:
          type: integer
          format: int64
          description: レコードID
          example: 12345
          readOnly: true
        fqdn:
          type: string
          description: |
            完全修飾ドメイン名（FQDN）。
            Route53の `Name` に相当。
            末尾にドット（.）を含む。ワイルドカードのレコードは左端のラベルが `*` になる（例: `*.example.com.`）。
          example: www.example.com.
          minLength: 1
          maxLength: 255
          pattern: "^(\\*\\.)?([a-zA-Z0-9_]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])?\\.)+$"
        type:
          "$ref": "#/components/schemas/DnsRecordType"
        value:
          "$ref": "#/components/schemas/DnsRecordValue"
        ttl:
          type: integer
          format: int32
          description: |
            TTL（秒）。
            Route53の `TTL` に相当。
          example: 3600
          minimum: 1
          maximum: 2147483647
        priority:
          type: integer
          format: int32
          description: |
            優先度（MXレコード用）。
            MXレコードの場合のみ使用。
          example: 10
          minimum: 0
          maximum: 65535
        created-at:
          type: string
          format: date-time
          description: 作成日時
          example: '2025-01-15T09:00:00+09:00'
          readOnly: true
        updated-at:
          type: string
          format: date-time
          description: 更新日時
          example: '2025-01-15T09:00:00+09:00'
          readOnly: true
    DnsRecordCreateRequest:
      type: object
      description: DNSレコード作成リクエスト
      required:
      - fqdn
      - type
      - value
      properties:
        fqdn:
          type: string
          description: |
            完全修飾ドメイン名（FQDN）。ゾーンアペックス（ドメイン自身）は `@` でも指定できる。
            末尾のドット（.）は省略できる（省略した場合も同じレコードとして扱う）。
            ワイルドカードのレコードは左端のラベルを `*` にする（例: `*.example.com.`）。
          example: www.example.com.
          minLength: 1
          maxLength: 255
          pattern: "^(@|(\\*\\.)?([a-zA-Z0-9_]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])?\\.)*[a-zA-Z0-9_]([a-zA-Z0-9_-]{0,61}[a-zA-Z0-9_])?\\.?)$"
        type:
          "$ref": "#/components/schemas/DnsRecordType"
        value:
          "$ref": "#/components/schemas/DnsRecordValue"
        priority:
          type:
          - integer
          - 'null'
          format: int32
          description: 優先度（MXレコード用）。null は省略と同じ。
          example: 10
          minimum: 0
          maximum: 65535
        ttl:
          type: integer
          format: int32
          description: |
            TTL（秒）。コントロールパネルと同じく 3600 固定。
            省略できる。指定する場合は 3600 のみ受け付ける。
          enum:
          - 3600
          example: 3600
    DnsRecordUpdateRequest:
      type: object
      description: |
        DNSレコード更新リクエスト。
        `fqdn` と `type` は変更できません。変更が必要な場合は削除後に再作成してください。
        `ttl` は変更できません。
        少なくとも1つのフィールドを指定する必要があります。
      minProperties: 1
      properties:
        value:
          "$ref": "#/components/schemas/DnsRecordValue"
        priority:
          type: integer
          format: int32
          description: 優先度（MXレコード用）
          example: 20
          minimum: 0
          maximum: 65535
    DnsRecordResponse:
      type: object
      description: DNSレコード単一レスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/DnsRecord"
    DnsRecordsResponse:
      type: object
      description: DNSレコード一覧レスポンス
      required:
      - data
      - meta
      properties:
        data:
          type: array
          items:
            "$ref": "#/components/schemas/DnsRecord"
        meta:
          "$ref": "#/components/schemas/PaginationMeta"
    ContractPaymentMethod:
      type: string
      description: |
        支払い方法
        - credit: クレジットカード
        - osaipo: おさいぽ!
        - bank: 銀行振込
        - convenience: コンビニ決済
      enum:
      - credit
      - osaipo
      - bank
      - convenience
      example: credit
    ContractState:
      type: string
      description: |
        契約状態
        - new: 新規契約
        - renewal: 継続（更新済み）
        - cancelled: キャンセル
        - invalid: 無効
        - transfer: 移管
        - custom-dns: カスタムDNS
      enum:
      - new
      - renewal
      - cancelled
      - invalid
      - transfer
      - custom-dns
      example: new
    DomainAvailability:
      type: string
      description: |
        ドメインの空き状況
        - available: 取得可能
        - unavailable: 取得不可（既に登録済み、またはレジストラ/レジストリのメンテナンス中で空き状況を判定できない）
        - premium: プレミアムドメインとして取得可能（通常より高額）
      enum:
      - available
      - unavailable
      - premium
      example: available
    DomainSearchResult:
      type: object
      description: |
        個別ドメインの検索結果。
        ドメイン名、空き状況、価格情報を含みます。
      required:
      - fqdn
      - availability
      - unavailable-reason
      - domain-price
      - service-fee
      - tax
      - total
      - currency
      properties:
        fqdn:
          type: string
          description: 検索対象のドメイン名（FQDN）
          maxLength: 253
          example: example.com
        availability:
          "$ref": "#/components/schemas/DomainAvailability"
        unavailable-reason:
          "$ref": "#/components/schemas/DomainUnavailableReason"
        domain-price:
          type:
          - integer
          - 'null'
          description: |
            ドメイン料金（税抜、円）。キャンペーン適用後の価格。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
            ただし truncated が true の場合、available でも価格照会を打ち切って null になることがあります。
          example: 1280
        service-fee:
          type:
          - integer
          - 'null'
          description: |
            サービス維持調整費（税抜、円）。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
            ただし truncated が true の場合、available でも価格照会を打ち切って null になることがあります。
          example: 158
        tax:
          type:
          - integer
          - 'null'
          description: |
            消費税額（円）。domain-price + service-fee に対する消費税。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
            ただし truncated が true の場合、available でも価格照会を打ち切って null になることがあります。
          example: 144
        total:
          type:
          - integer
          - 'null'
          description: |
            合計金額（税込、円）。domain-price + service-fee + tax の合計。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
            ただし truncated が true の場合、available でも価格照会を打ち切って null になることがあります。
          example: 1582
        currency:
          type: string
          description: 通貨コード（ISO 4217）。常にJPYが返されます。
          enum:
          - JPY
          example: JPY
    DomainSearchData:
      type: object
      description: ドメイン検索結果データ
      required:
      - query
      - results
      properties:
        query:
          type: string
          description: 検索に使用したキーワード
          example: example
        results:
          type: array
          description: 検索結果の一覧
          maxItems: 50
          items:
            "$ref": "#/components/schemas/DomainSearchResult"
        truncated:
          type: boolean
          description: |
            検索が時間予算を超過し、結果が途中で打ち切られた場合に true を返します。

            true の場合、results は以下のいずれか、または両方の状態になります。

            - 指定した TLD の一部しか含まれない（残りの検索を打ち切ったため）
            - 取得可能（available）なのに価格フィールドがすべて null の要素が含まれる
              （空き状況の判定までは完了したが、価格照会を打ち切ったため）

            価格が null の要素については、購入見積もり
            （`POST /api/v2/me/domain-purchase/quote`）で価格を取得するか、
            時間をおいて再検索してください。
          default: false
          example: false
    DomainSearchResponse:
      type: object
      description: ドメイン検索レスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/DomainSearchData"
    RegistrarMaintenance:
      type: object
      description: |
        レジストラ（ドメインの登録事業者）のメンテナンス。
        メンテナンス中は、そのレジストラが扱うドメインの取得・更新・移管等ができません。
        開始前（予定）のメンテナンスも含みます。
      required:
      - name
      - begin-at
      - end-at
      - information-id
      properties:
        name:
          type: string
          description: |
            レジストラの識別子
            - onamae: GMOインターネットグループ（お名前.com）
            - jprs: 日本レジストリサービス（JPRS）
            - enom: eNom
          enum:
          - onamae
          - jprs
          - enom
          example: jprs
        begin-at:
          type: string
          format: date-time
          description: メンテナンス開始日時（ISO 8601）
          example: '2026-10-01T02:00:00+09:00'
        end-at:
          type: string
          format: date-time
          description: メンテナンス終了予定日時（ISO 8601）
          example: '2026-10-01T06:00:00+09:00'
        information-id:
          "$ref": "#/components/schemas/MaintenanceInformationId"
    RegistryMaintenance:
      type: object
      description: |
        レジストリ（TLD の管理事業者）のメンテナンス。
        メンテナンス中は、対象 TLD のドメインの取得・更新・移管等ができません。
        開始前（予定）のメンテナンスも含みます。
      required:
      - tlds
      - begin-at
      - end-at
      - information-id
      properties:
        tlds:
          type: array
          description: メンテナンス対象の TLD（先頭のドットを含まない）
          items:
            type: string
            example: com
          example:
          - com
          - net
        begin-at:
          type: string
          format: date-time
          description: メンテナンス開始日時（ISO 8601）
          example: '2026-10-01T02:00:00+09:00'
        end-at:
          type: string
          format: date-time
          description: メンテナンス終了予定日時（ISO 8601）
          example: '2026-10-01T06:00:00+09:00'
        information-id:
          "$ref": "#/components/schemas/MaintenanceInformationId"
    ServiceMaintenance:
      type: object
      description: |
        ムームードメインのサービス機能・連携先のメンテナンス。
        レジストラの全操作を止めるメンテナンスは registrars に載るため、ここには含みません。
        レジストラの新規取得だけを止めるメンテナンス（name: onamae_registration）はここに載ります。
        開始前（予定）のメンテナンスも含みます。
      required:
      - name
      - begin-at
      - end-at
      - information-id
      properties:
        name:
          type: string
          description: |
            メンテナンス対象の識別子（例: creditcard, muu_dns, google_workspace_card）。
            対象は今後追加されることがあるため、未知の値を受け取っても処理を継続してください。

            - onamae_registration: お名前.com での新規ドメイン取得だけを止めるメンテナンス。
              お名前.com の更新・移管・DNS 等は止まりません。
              お名前.com の全操作を止めるメンテナンスは、こちらではなく registrars に `name: onamae` として載ります。
          example: creditcard
        begin-at:
          type: string
          format: date-time
          description: メンテナンス開始日時（ISO 8601）
          example: '2026-10-01T02:00:00+09:00'
        end-at:
          type: string
          format: date-time
          description: メンテナンス終了予定日時（ISO 8601）
          example: '2026-10-01T06:00:00+09:00'
        information-id:
          "$ref": "#/components/schemas/MaintenanceInformationId"
    MaintenanceInformationId:
      type:
      - integer
      - 'null'
      description: |
        メンテナンスを告知しているお知らせの ID。
        お知らせは `https://muumuu-domain.com/information/maintenances/{information-id}` で閲覧できます。
        お知らせが紐づいていない場合は null です。
      example: 1234
    MaintenanceListData:
      type: object
      description: |
        終了していないメンテナンス（進行中と開始前の予定）の一覧。終了済みのメンテナンスは含みません。
        各配列は開始日時の昇順です。進行中か予定かは begin-at を現在時刻と比較して判定してください。
      required:
      - registrars
      - registries
      - services
      properties:
        registrars:
          type: array
          description: 進行中・開始前のレジストラメンテナンス
          items:
            "$ref": "#/components/schemas/RegistrarMaintenance"
        registries:
          type: array
          description: 進行中・開始前のレジストリメンテナンス
          items:
            "$ref": "#/components/schemas/RegistryMaintenance"
        services:
          type: array
          description: 進行中・開始前のサービスメンテナンス
          items:
            "$ref": "#/components/schemas/ServiceMaintenance"
    MaintenanceListResponse:
      type: object
      description: メンテナンス情報レスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/MaintenanceListData"
    DomainPurchasePreviewRequest:
      type: object
      description: |
        ドメイン購入見積もりのリクエスト。
        購入前に金額・空き状況・クレジットカード登録状態を確認するために使用します。
        **ドメインを購入する前に、必ずこの見積もりAPIを呼び出してください。**
      required:
      - fqdn
      properties:
        fqdn:
          type: string
          description: '購入したいドメイン名（例: example.com）'
          minLength: 1
          maxLength: 253
          example: example.com
        term:
          type:
          - integer
          - 'null'
          description: |
            契約期間（年）。省略時・null の場合は1年。
            申し込める年数は TLD ごとに異なります。TLD が受け付けない年数を指定すると
            422（validation_error）を返し、purchase-token は発行しません。
          default: 1
          minimum: 1
          maximum: 10
          example: 1
    DomainPurchasePreview:
      type: object
      description: |
        ドメイン購入見積もりの結果。
        ドメインの空き状況、料金、クレジットカードの登録状態を返します。
        purchase-token は購入実行時に必要です（有効期限: 10分）。
        availability が unavailable の場合、domain-price/service-fee/tax/total/purchase-token は null になります。
      required:
      - fqdn
      - availability
      - term
      - domain-price
      - service-fee
      - tax
      - total
      - currency
      - credit-card-registered
      - credit-card-registration-url
      - purchase-token
      properties:
        fqdn:
          type: string
          description: ドメイン名
          maxLength: 253
          example: example.com
        availability:
          "$ref": "#/components/schemas/DomainAvailability"
        term:
          type: integer
          description: 契約期間（年）
          example: 1
        domain-price:
          type:
          - integer
          - 'null'
          description: |
            ドメイン料金（税抜、円）。キャンペーン適用後の価格。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
          example: 750
        service-fee:
          type:
          - integer
          - 'null'
          description: |
            サービス維持調整費（税抜、円）。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
          example: 158
        tax:
          type:
          - integer
          - 'null'
          description: |
            消費税額（円）。domain-price + service-fee に対する消費税。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
          example: 91
        total:
          type:
          - integer
          - 'null'
          description: |
            合計金額（税込、円）。domain-price + service-fee + tax の合計。
            取得可能（available）またはプレミアム（premium）の場合に返されます。
            取得不可（unavailable）の場合はnullです。
          example: 999
        currency:
          type: string
          description: 通貨コード（ISO 4217）
          enum:
          - JPY
          example: JPY
        credit-card-registered:
          type: boolean
          description: |
            クレジットカードが登録済みかどうか。
            未登録の場合、ドメインの購入にはクレジットカードの登録が必要です。
            credit-card-registration-url にカード登録画面のURLが含まれます。
          example: true
        credit-card-registration-url:
          type:
          - string
          - 'null'
          description: |
            クレジットカード登録画面のURL。
            credit-card-registered が false の場合にのみ値が返されます。
            ユーザーにこのURLを案内してカード登録を促してください。
          example:
        purchase-token:
          oneOf:
          - "$ref": "#/components/schemas/PurchaseToken"
          - type: 'null'
          description: |
            購入実行時に必要なトークン情報。
            サーバーが署名した一時トークンで、ドメイン名・金額・有効期限を含みます。
            purchase-token.token を POST /api/v2/me/domain-purchase のリクエストボディに含めてください。
            availability が unavailable の場合は null が返されます。
    DomainPurchasePreviewResponse:
      type: object
      description: ドメイン購入見積もりレスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/DomainPurchasePreview"
    PurchaseToken:
      type: object
      description: |
        購入トークン情報。
        token は購入実行APIのリクエストボディに含めてください。
        expires-at はトークンの有効期限（発行から10分間）です。
      required:
      - token
      - expires-at
      properties:
        token:
          type: string
          description: |
            購入実行時に必要なトークン文字列。
            POST /api/v2/me/domain-purchase の purchase-token フィールドに指定してください。
            長さはドメイン名に比例して変わります（最長のドメイン名で約750文字）。
          minLength: 10
          maxLength: 2048
          example: tok_xxxxxxxxxxxxxxxxxxxxxxxx
        expires-at:
          type: string
          format: date-time
          description: トークンの有効期限（ISO 8601形式）。発行から10分間有効です。
          example: '2025-06-01T12:10:00+09:00'
    DomainPurchaseRequest:
      type: object
      description: |
        ドメイン購入の実行リクエスト。実行するとクレジットカードに課金が発生します。
        事前に見積もりAPIで金額を確認し、ユーザーの同意を得てから実行してください。
      required:
      - purchase-token
      properties:
        purchase-token:
          type: string
          description: |
            見積もりAPIで取得した購入トークン。
            ドメイン名・金額・有効期限がサーバー側で検証されます。
            有効期限（10分）を過ぎている場合はエラーになります。
          minLength: 10
          maxLength: 2048
          example: tok_xxxxxxxxxxxxxxxxxxxxxxxx
    DomainPurchaseResult:
      type: object
      description: |
        ドメイン購入セッションの作成結果。
        checkout-url をユーザーのブラウザで開いて購入確認を行ってください。
      required:
      - purchase-id
      - checkout-url
      - status
      - fqdn
      - term
      - expires-at
      properties:
        purchase-id:
          type: integer
          description: |
            購入セッションID。GET /api/v2/me/domain-purchase/{purchase_id}/status のポーリングに使用します。
            本 ID は checkout フロー（POST /api/v2/me/domain-purchase）専用の整数 ID で、
            直接購入API（POST /api/v2/me/domain-purchase/direct）が返す `TP########` 形式の ID とは
            別体系です。相互に読み替えることはできません。
          example: 1
        checkout-url:
          type: string
          format: uri
          description: |
            ブラウザチェックアウト画面のURL。
            ユーザーにこのURLを開いてもらい、購入確認と3DS認証を行います。
            有効期限は10分間です。
          example: https://muumuu-domain.com/checkout/mcp/abc123def456
        status:
          type: string
          description: 購入ステータス（作成直後は常に pending）
          enum:
          - pending
          - processing
          - completed
          - failed
          example: pending
        fqdn:
          type: string
          description: 購入対象のドメイン名
          example: example.com
        term:
          type: integer
          description: 契約期間（年）
          example: 1
        expires-at:
          type: string
          format: date-time
          description: チェックアウトURLの有効期限（ISO 8601形式）。作成から10分間有効です。
          example: '2025-06-01T12:10:00+09:00'
    DomainPurchaseResponse:
      type: object
      description: ドメイン購入レスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/DomainPurchaseResult"
    PaymentHistoryServiceType:
      type: string
      description: |
        サービス種別
        - domain: ドメイン
        - google_workspace: Google Workspace
        - wordpress: WordPress
        - domain_lock: ドメインロック
        - website_scan: ネットde診断
        - ai_site_builder: AIホームページ
        - muumuu_server: ムームーサーバー
        - mail: メールオプション
        - gws_addon: Google Workspace アドオン
      enum:
      - domain
      - google_workspace
      - gws_addon
      - wordpress
      - domain_lock
      - website_scan
      - ai_site_builder
      - muumuu_server
      - mail
      - auction
      - backorder
      - tmch
      - sunrise
      - land_rush
      - premium_domain
      - ssl
      - website_builder
      - ikazuchi_ms365
      example: domain
    PaymentHistoryAmountBreakdown:
      type: object
      description: 金額内訳
      required:
      - base-price
      - tax
      - surcharge
      - discount
      properties:
        base-price:
          type: integer
          description: 利用料金（税抜）
          example: 1480
        tax:
          type: integer
          description: 消費税
          example: 148
        surcharge:
          type: integer
          description: 調整費（ドメインのみ）
          example: 0
        discount:
          type: integer
          description: キャンペーン割引（ドメインのみ）
          example: 0
    PaymentHistoryItem:
      type: object
      description: 支払い履歴1件
      required:
      - id
      - paid-at
      - service-type
      - description
      - amount
      - amount-breakdown
      - status
      properties:
        id:
          type: string
          description: |
            支払い履歴ID。データソースの識別には `service-type` を使用してください。
            - ドメイン: bill_id（例: `MB00000001`）
            - オプション: opt_cont_id（例: `OC00000001`）
          example: MB00000001
        paid-at:
          type:
          - string
          - 'null'
          format: date
          description: |
            支払い日（YYYY-MM-DD形式）。
            入金確認済みでも入金日が記録されていない支払いがあり、その場合はnull。
          example: '2026-03-20'
        service-type:
          "$ref": "#/components/schemas/PaymentHistoryServiceType"
        target-name:
          type:
          - string
          - 'null'
          description: |
            対象名。ドメイン名またはオプションに紐づくドメイン名。
            ドメインと紐づかないオプション（ムームーサーバー等）の場合はnull。
          example: example.com
        description:
          type:
          - string
          - 'null'
          description: |
            支払い内容の説明。
            - ドメイン: 「取得（YYYY-MM-DD～YYYY-MM-DD）」「更新（YYYY-MM-DD～YYYY-MM-DD）」「移管（YYYY-MM-DD～YYYY-MM-DD）」
            - オプション（GWS含む）: 「利用料（YYYY-MM-DD～YYYY-MM-DD）」
            - オークション: 「落札」（期間表示なし）
            - バックオーダー: 「申込」（期間表示なし）
          example: 更新（2026-04-05～2027-04-05）
        amount:
          type: integer
          description: 支払い金額（税込合計）
          example: 1628
        amount-breakdown:
          "$ref": "#/components/schemas/PaymentHistoryAmountBreakdown"
        payment-method:
          type:
          - string
          - 'null'
          description: |
            決済方法
            - creditcard: クレジットカード
            - osaipo: おさいぽ!
            - bank: 銀行振込
            - convenience_store: コンビニ決済
            - amazon_pay: Amazon Pay
            - gws_card: GWSカード
          example: creditcard
        status:
          type: integer
          description: '入金ステータス（2: 入金確認済み）'
          example: 2
        refunded:
          type: boolean
          description: 返金済みかどうか
          example: false
        refunded-at:
          type:
          - string
          - 'null'
          format: date
          description: 返金日（YYYY-MM-DD形式）。返金がない場合はnull。
          example:
        contract-start-date:
          type:
          - string
          - 'null'
          format: date
          description: 契約開始日（YYYY-MM-DD形式）。契約に紐づかない支払い、または開始日が未記録の場合はnull。
          example: '2026-03-01'
        contract-end-date:
          type:
          - string
          - 'null'
          format: date
          description: 契約終了日（YYYY-MM-DD形式）。契約に紐づかない支払い、または終了日が未記録の場合はnull。
          example: '2027-03-01'
    PaymentHistoryListResponse:
      type: object
      description: 支払い履歴一覧レスポンス
      required:
      - data
      - meta
      properties:
        data:
          type: array
          items:
            "$ref": "#/components/schemas/PaymentHistoryItem"
        meta:
          "$ref": "#/components/schemas/PaginationMeta"
    NameserverSetupType:
      type: string
      description: |
        ネームサーバ設定タイプ
        - lolipop: ロリポップ
        - custom: 他のネームサーバ
        - acquired_domain: 取得したドメイン
        - muumuu_dns: ムームーDNS
        - parking: パーキング
        - other: 上記以外（サービス連携等で設定される、PATCHでは指定不可のレスポンス専用値）
      enum:
      - lolipop
      - custom
      - acquired_domain
      - muumuu_dns
      - parking
      - other
      example: muumuu_dns
    NameserverSettings:
      type: object
      required:
      - domain-id
      - setup-type
      - nameservers
      properties:
        domain-id:
          type: string
          example: MU00000001
        setup-type:
          "$ref": "#/components/schemas/NameserverSetupType"
        nameservers:
          type: array
          description: 設定されているネームサーバ一覧
          items:
            type: string
          example:
          - uns01.lolipop.jp
          - uns02.lolipop.jp
    NameserverSettingsResponse:
      type: object
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/NameserverSettings"
    NameserverUpdateRequest:
      type: object
      description: me API 専用のネームサーバ変更リクエスト。
      required:
      - setup-type
      properties:
        setup-type:
          "$ref": "#/components/schemas/NameserverSetupTypeRequest"
        nameservers:
          type: array
          description: |
            カスタムネームサーバ（setup-type=custom時、1-6個）。
            お名前.com 配下および org/info/co.uk/org.uk/bz/mobi の TLD は2個以上必須。
          items:
            type: string
            maxLength: 253
            pattern: "^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+(?:[a-zA-Z]{2,}|[xX][nN]--[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*)$"
          minItems: 1
          maxItems: 6
        confirm-existing-records:
          type: boolean
          default: false
          description: |
            muumuu_dns へ切り替える際、既存 mdns レコードを保持したまま切り替えることを
            明示的に承認する。他社/custom から muumuu_dns へ引き継ぐ場合に使う。
    NameserverSetupTypeRequest:
      type: string
      description: |
        ネームサーバ設定タイプ（更新リクエスト用）
        - lolipop: ロリポップ
        - custom: 他のネームサーバ
        - acquired_domain: 取得したドメイン
        - muumuu_dns: ムームーDNS
        - parking: パーキング
      enum:
      - lolipop
      - custom
      - acquired_domain
      - muumuu_dns
      - parking
      example: muumuu_dns
    DomainStatusGroup:
      type: string
      description: |
        コントロールパネルのドメイン一覧の区分（`status-group` 指定時のみ）
        - expired-recoverable: 期限切れで復旧可能
        - pending-payment: 新規申込の未入金
        - pending-transfer: 移管申請中
        - contracted: 契約中
        - transfer-unpaid: 移管の未払い
      enum:
      - expired-recoverable
      - pending-payment
      - pending-transfer
      - contracted
      - transfer-unpaid
      example: contracted
    DomainExpiredInfo:
      type: object
      description: 期限切れドメインの情報
      required:
      - recoverable-until
      - recovery-days
      - updating
      properties:
        discarded-at:
          type:
          - string
          - 'null'
          format: date
          description: 破棄日
          example: '2026-01-02'
        recoverable-until:
          type: string
          format: date
          description: 復旧できる最終日
          example: '2026-02-10'
        recovery-days:
          type: integer
          description: 契約終了日から復旧できる日数（`recoverable-until` = 契約終了日 + この日数）
          example: 30
        updating:
          type: boolean
          description: 更新手続き中か（今日が契約終了日の5日前より前）
          example: false
    PersonalAccessTokenSummary:
      type: object
      description: Personal Access Token のサマリー情報（トークン本体を含まない）
      required:
      - id
      - name
      - token-prefix
      - scopes
      - status
      properties:
        id:
          type: integer
          minimum: 1
          description: PAT の内部 ID
          example: 1
        name:
          type: string
          description: PAT の名前（アカウント内でユニーク）
          maxLength: 100
          example: My CI Token
        token-prefix:
          type: string
          description: トークンのプレフィックス表示（"muu_pat_" + 8文字 + "…"）。トークン本体は含まない
          example: muu_pat_abcdefgh…
        scopes:
          type: array
          description: PAT に付与されたスコープ一覧
          items:
            type: string
          example:
          - domains:read
        expires-at:
          oneOf:
          - type: string
            format: date-time
          - type: 'null'
          description: 有効期限（ISO 8601）。null の場合は無期限
          example: '2026-06-06T00:00:00Z'
        last-used-at:
          oneOf:
          - type: string
            format: date-time
          - type: 'null'
          description: 最終利用日時（ISO 8601）。未使用の場合は null
          example:
        status:
          type: string
          description: |
            PAT の状態
            - active: 有効
            - revoked: 失効済み
            - expired: 期限切れ
          enum:
          - active
          - revoked
          - expired
          example: active
    PersonalAccessTokenListResponse:
      type: object
      required:
      - data
      properties:
        data:
          type: array
          description: |
            PAT 一覧（created_at DESC 順）。
            1アカウントあたりの PAT 上限は 20 件（FR-205）のため、ページネーションは提供しない。
          items:
            "$ref": "#/components/schemas/PersonalAccessTokenSummary"
    DomainUpdateRequest:
      type: object
      description: |
        ドメイン更新リクエスト。
        クレジットカードによる自動更新の ON/OFF を変更します。
        少なくとも1つのフィールドを指定する必要があります。
      minProperties: 1
      properties:
        auto-renew-enabled:
          type: boolean
          description: |
            クレジットカードによる自動更新の有効/無効。
            - `true`: クレジットカード自動更新を有効化（クレジットカード登録済み・有効期限内が必須）
            - `false`: 自動更新を無効化

            おさいぽ!による自動更新は本 API の設定対象外です。
            既におさいぽ!で自動更新が有効なドメインに `true` を指定した場合は値を変更しません（冪等な no-op）。
          example: true
    DirectDomainPurchaseResult:
      type: object
      description: |
        ブラウザ画面遷移なしで決済とドメイン登録を 1 リクエストで完結するドメイン購入の結果。
        `POST /api/v2/me/domain-purchase/direct` のレスポンス到着時点で
        決済とドメイン登録の両方が完了している（status は常に completed）。
        failed の場合はエラーレスポンス（4xx/5xx）が返されるため、本データには出現しない。
      required:
      - purchase-id
      - status
      - fqdn
      - term
      - domain-id
      - contract-id
      - completed-at
      properties:
        purchase-id:
          type: string
          description: |
            直接購入の購入ID（`TP########` 形式）。
            本 ID は直接購入API専用の体系で、GET /api/v2/me/domain-purchase/{purchase_id}/status には
            指定できません（同 API は checkout フローの整数 ID のみを受け付けます）。
            直接購入はレスポンス到着時点で決済とドメイン登録が完了しているため、
            そもそもステータス照会は不要です。
          example: TP00000001
          pattern: "^TP[0-9]{8}$"
        status:
          type: string
          description: 同期決済の確定ステータス（常に completed）
          enum:
          - completed
          example: completed
        fqdn:
          type: string
          description: 購入したドメイン名
          example: example.com
        term:
          type: integer
          description: 契約期間（年）
          example: 1
        domain-id:
          type: string
          description: 登録完了したドメインのID
          example: MU00000001
          pattern: "^MU[0-9]{8}$"
        contract-id:
          type: string
          description: 契約ID
          example: MC00000001
          pattern: "^MC[0-9]{8}$"
        completed-at:
          type: string
          format: date
          description: 決済完了日（YYYY-MM-DD）。時刻は保持しないため日付のみを返します。
          example: '2025-06-01'
    DirectDomainPurchaseResponse:
      type: object
      description: 1 リクエストで完結するドメイン購入レスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/DirectDomainPurchaseResult"
    DomainPurchaseStatusDomain:
      type: object
      description: 個別ドメインの購入ステータス
      required:
      - domain-name
      - term
      - status
      properties:
        domain-name:
          type: string
          description: ドメイン名
          example: example.com
        term:
          type: integer
          description: 契約期間（年）
          example: 1
        status:
          type: string
          description: ドメイン個別のステータス
          enum:
          - pending
          - processing
          - completed
          - failed
          example: completed
        domain-id:
          type:
          - string
          - 'null'
          description: 取得したドメインのID（completed時のみ）
          example: MU00000001
          pattern: "^MU[0-9]{8}$"
        contract-id:
          type:
          - string
          - 'null'
          description: 作成された契約のID（completed時のみ）
          example: MC00000001
          pattern: "^MC[0-9]{8}$"
        failure-reason:
          type:
          - string
          - 'null'
          description: |
            失敗理由（failed時のみ）。
            - payment_failed: 決済処理失敗
            - domain_unavailable: ドメイン取得不可
            - price_mismatch: 金額変動（見積もり時と異なる）
            - external_service_error: 外部サービスエラー
            - checkout_expired: チェックアウト期限切れ
          enum:
          - payment_failed
          - domain_unavailable
          - price_mismatch
          - external_service_error
          - checkout_expired
          -
          example:
    DomainPurchaseStatus:
      type: object
      description: |
        ドメイン購入のステータス情報。
        AIエージェントがポーリングして購入完了を検知するために使用します。
      required:
      - purchase-id
      - status
      - fqdn
      - term
      - domains
      properties:
        purchase-id:
          type: integer
          description: |
            購入セッションID。
            checkout フロー（POST /api/v2/me/domain-purchase）で払い出される整数 ID で、
            直接購入API（POST /api/v2/me/domain-purchase/direct）が返す `TP########` 形式の ID とは
            別体系です。
          example: 1
        status:
          type: string
          description: |
            購入の集約ステータス。
            - pending: チェックアウト待ち（ユーザーがまだブラウザで確認していない）
            - processing: 3DS認証中または決済処理中
            - completed: 購入完了（domain-id, contract-id が確定）
            - failed: 購入失敗（failure-reason で原因を確認）
          enum:
          - pending
          - processing
          - completed
          - failed
          example: completed
        fqdn:
          type: string
          description: 購入対象のドメイン名
          example: example.com
        term:
          type: integer
          description: 契約期間（年）
          example: 1
        domains:
          type: array
          description: ドメイン明細（現在は常に1件）
          items:
            "$ref": "#/components/schemas/DomainPurchaseStatusDomain"
    DomainPurchaseStatusResponse:
      type: object
      description: ドメイン購入ステータスレスポンス
      required:
      - data
      properties:
        data:
          "$ref": "#/components/schemas/DomainPurchaseStatus"
    DomainUnavailableReason:
      type:
      - string
      - 'null'
      description: |
        取得不可（unavailable）の理由。リトライで結果が変わりうるかを判別するためのもので、
        取得できない原因を細分化するものではありません。

        - registered: メンテナンス以外の理由で取得できない。既に取得されている場合が大半ですが、
          商標保護期間（TMCH）、JPバックオーダー・オークションの対象、検索が判定に至らなかった
          場合も含みます。いずれも時間をおいても結果は変わりません
        - maintenance: レジストラ/レジストリのメンテナンス中で空き状況を判定できない。
          メンテナンス終了後は取得できる可能性があります

        取得可能（available）・プレミアム（premium）の場合は null です。
      enum:
      - registered
      - maintenance
      -
      example: registered
  parameters:
    DomainId:
      name: domain-id
      in: path
      required: true
      description: ドメインID（MU + 8桁の数字）
      schema:
        type: string
        pattern: "^MU[0-9]{8}$"
        maxLength: 10
      example: MU12345678
    IdempotencyKey:
      name: X-Idempotency-Key
      in: header
      required: false
      description: |
        再送時に同一の操作とみなすための冪等キー。UUID 形式（バージョンは問いません）で指定します。

        16 進数の大文字・小文字はどちらも受け付けますが、上流の Google Cloud Channel API は
        この値を不透明な文字列として比較します。再送では大小を含めて完全に同一の文字列を
        送ってください（`3f0d0c2e-...` と `3F0D0C2E-...` は別のキーとして扱われ、再送が
        新しい操作になります）。すべてゼロの UUID（`00000000-0000-0000-0000-000000000000`）は
        上流が受け付けないため指定できません。

        - ヘッダを送信しない場合は、リクエストごとにサーバー側で採番します（再送しても別の操作として扱われます）
        - 空値を送信した場合は 400 Bad Request を返します（冪等性が無いまま契約が作成・変更されるのを防ぐため）
        - UUID 形式でない場合は 400 Bad Request を返します

        この値は Google Cloud Channel API の `requestId` にそのまま渡されます。
        `requestId` を持たない顧客作成系のエンドポイントには適用されません。

        キーは 1 操作につき 1 つ採番してください。同じキーで内容の違うリクエストを送ると、
        上流は先に完了した操作の結果を返すため、後から送った変更は上流に反映されません。
      schema:
        type: string
        format: uuid
        pattern: "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
        not:
          const: 00000000-0000-0000-0000-000000000000
      example: 3f0d0c2e-9b7a-4f1e-8c6d-5a2b1e4f7c90
  responses:
    BadRequest:
      description: リクエストパラメータが不正
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: bad_request
              message: Invalid request parameters
    Unauthorized:
      description: |
        認証が必要または無効なトークン。
        - `unauthorized`: 認証が必要
        - `invalid_token`: アクセストークンが無効または期限切れ
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          examples:
            unauthorized:
              summary: 認証が必要
              value:
                error:
                  code: unauthorized
                  message: Authentication required
            invalid_token:
              summary: 無効なトークン
              value:
                error:
                  code: invalid_token
                  message: The access token is invalid or expired
    Forbidden:
      description: |
        権限不足。
        - `forbidden`: アクセスが禁止されている
        - `insufficient_scope`: トークンに必要なスコープがない
        - `context_mismatch`: 認証コンテキストが不正
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          examples:
            forbidden:
              summary: アクセス禁止
              value:
                error:
                  code: forbidden
                  message: Access forbidden
            insufficient_scope:
              summary: スコープ不足
              value:
                error:
                  code: insufficient_scope
                  message: Insufficient scope for this resource
            context_mismatch:
              summary: 認証コンテキスト不正
              value:
                error:
                  code: context_mismatch
                  message: Authentication context mismatch
    NotFound:
      description: リソースが見つからない
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: not_found
              message: The requested resource was not found
    Conflict:
      description: リソースの競合（既に存在する等）
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: conflict
              message: The resource already exists
    UnprocessableEntity:
      description: バリデーションエラー
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: validation_error
              message: Validation failed
              details:
              - field: domain-id
                message: is required
              - field: payment-method
                message: is not a valid payment method
    TooManyRequests:
      description: |
        レート制限超過。
        クライアントはRetry-Afterヘッダーに指定された秒数経過後にリトライしてください。

        ## レート制限
        - 認証済みリクエスト: 1,000リクエスト/時
        - 未認証リクエスト: 100リクエスト/時
      headers:
        Retry-After:
          description: リトライまでの待機時間（秒）
          schema:
            type: integer
            example: 60
        X-RateLimit-Limit:
          description: 制限値（リクエスト数/時）
          schema:
            type: integer
            example: 1000
        X-RateLimit-Remaining:
          description: 残りリクエスト数
          schema:
            type: integer
            example: 0
        X-RateLimit-Reset:
          description: レート制限リセット時刻（Unix timestamp）
          schema:
            type: integer
            example: 1705312800
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: rate_limit_exceeded
              message: Rate limit exceeded. Please retry after 60 seconds.
    InternalServerError:
      description: サーバー内部エラー
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: internal_error
              message: An internal server error occurred
    BadGateway:
      description: 外部サービスとの通信に失敗
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: external_service_error
              message: Failed to communicate with external service
    ServiceUnavailable:
      description: |
        一時的に処理を継続できない状態。外部サービスの障害・タイムアウト、
        レジストラ/レジストリのメンテナンスなどで安全に処理を完了できない場合に返します。
        クライアントは時間をおいてリトライしてください。
        Retry-After ヘッダが付いている場合は、その秒数が経過してからリトライしてください。
      headers:
        Retry-After:
          description: |
            リトライまでの待機時間（秒）。
            メンテナンス終了時刻が判明している場合にのみ付与されます。
          schema:
            type: integer
            example: 3600
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          examples:
            service-unavailable:
              summary: 外部サービスの障害・タイムアウト
              value:
                error:
                  code: service_unavailable
                  message: Service temporarily unavailable. Please try again later.
            registrar-maintenance:
              summary: レジストラ/レジストリのメンテナンス中
              value:
                error:
                  code: registrar_maintenance
                  message: The registrar for this domain is currently under maintenance.
                    Please try again later.
    KakebaraiBadGateway:
      description: |
        決済会社（GMO 掛け払い）との処理に失敗。`error.code` で次を区別する
        - `external_service_error`: 決済会社と通信できなかった、または応答・設定が不正
        - `payment_service_rejected`: 決済会社が要求を業務エラーとして受け付けなかった（入力内容の不備・取引状態の不整合など）。決済会社のエラーコードは返さない
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          examples:
            external-service-error:
              summary: 決済会社と通信できなかった
              value:
                error:
                  code: external_service_error
                  message: Failed to communicate with external service.
            payment-service-rejected:
              summary: 決済会社が業務エラーとして受け付けなかった
              value:
                error:
                  code: payment_service_rejected
                  message: The payment service rejected the request.
    BadRequestValidation:
      description: |
        リクエストパラメータが不正（必須項目の欠落・空値、文字数・形式の制約違反、メールアドレス形式の不正など）

        必須項目の欠落・空値は `details[].field` で対象フィールドを示します
        （`details[].code`: `missing_required_parameter`。ネストしたフィールドは `org-postal-address.postal-code` のように `.` 区切り）。
        これらの検証はサーバー側で完結するため、sandbox 環境でも本番と同じ 400 になります
        （それ以外の上流 API 側の受理条件は sandbox では検証されません）。
      content:
        application/json:
          schema:
            "$ref": "#/components/schemas/ErrorResponse"
          example:
            error:
              code: bad_request
              message: 'Missing required parameters: first-name, last-name'
              details:
              - code: missing_required_parameter
                field: first-name
                message: first-name is required
              - code: missing_required_parameter
                field: last-name
                message: last-name is required
