{
  "openapi": "3.0.3",
  "info": {
    "title": "roguemobile API 文檔",
    "version": "0.28.0",
    "description": "**介面地址**：`https://rogue.gcsl.ai/v1`\n\n**認證方式**：每次請求同時發送 `X-Partner-Id`（渠道帳戶）和 `X-API-Key`（固定金鑰），無需臨時 token。可在「設定授權」中填寫。\n\n**基本流程**：開卡先從目錄選擇套餐和地址；提交業務後，查詢任務或接收回呼。\n\n自動補救結束後，已確認的失敗按原批次、原明細回呼並記錄異常，無需員工批准。已成功的明細照常回呼並按受理報價結算一次。內部 Wi-Fi Calling 補救獨立執行，不會延遲成功回呼，也沒有單獨的渠道回呼。 辦理前補資料每條最多查一次。無法核實時，該明細按本次錯誤結束並回呼，費用為零，其他明細繼續。已提交且結果未明的辦理仍保持處理中，只核對原任務。\n\n時間輸出口徑：API 查詢及新建立的回呼統一使用美東時間（America/New_York），明確帶 -04:00（EDT）或 -05:00（EST）。上游已有時區偏移時優先按該偏移換算；已知上游套餐／帳戶時間未標偏移時，按已核對的 America/New_York 冬夏令時換算。上游純日期、缺失值、無效時間及夏令時切換時無法唯一確定的時刻保留原值，不補造時間。套餐週期只使用本次已核實身份的上游即時回包或對應歷史業務回執。當期與下期分別保留；未提供的日期為 null，不再估算到期日。已建立的舊回呼重試時保持原簽名正文；留存的上游原文及請求回顯保持原值。日期篩選仍使用各接口原有時區。"
  },
  "servers": [
    {
      "url": "https://rogue.gcsl.ai/v1",
      "description": "渠道統一入口"
    }
  ],
  "tags": [
    {
      "name": "業務辦理"
    },
    {
      "name": "任務"
    },
    {
      "name": "庫存與地區"
    },
    {
      "name": "查詢"
    },
    {
      "name": "帳戶與帳單"
    },
    {
      "name": "相容接入"
    }
  ],
  "components": {
    "securitySchemes": {
      "channelAccount": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Partner-Id",
        "description": "渠道帳戶，即平台分配的渠道代碼；與 X-API-Key 同時發送。"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "平台發放的固定 API Key，直接填寫原值，不加 Bearer 前綴。不會定時到期；重置金鑰後舊值立即失效。"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "bad_request",
                  "unauthorized",
                  "insufficient_balance",
                  "forbidden",
                  "not_found",
                  "conflict",
                  "rate_limited",
                  "internal_error",
                  "upstream_error",
                  "unavailable"
                ]
              },
              "message": {
                "type": "string",
                "description": "介面回應及回呼的系統說明統一為英文，不返回中文解釋或非英文錯誤原文。保留原始業務錯誤碼和英文原因，過濾敏感憑證；非英文原因按已知錯誤碼提供英文說明，無法識別時提供英文提示並保留原文供後台排查。文件語言不改變執行時回應。"
              },
              "details": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/ErrorContext"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "business_code": {
                        "type": "string"
                      },
                      "next_action": {
                        "$ref": "#/components/schemas/NextAction"
                      },
                      "upstream_status": {
                        "type": "integer"
                      },
                      "upstream_code": {
                        "type": "string"
                      },
                      "upstream_request_id": {
                        "type": "string"
                      }
                    }
                  }
                ]
              }
            },
            "required": [
              "code",
              "message",
              "details"
            ]
          },
          "meta": {
            "$ref": "#/components/schemas/Meta"
          }
        },
        "required": [
          "error",
          "meta"
        ]
      },
      "Meta": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string",
            "description": "請求追蹤號，排障時提供。"
          },
          "job_id": {
            "type": "string"
          },
          "txid": {
            "type": "string",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          }
        },
        "required": [
          "request_id"
        ]
      },
      "ServiceStatus": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "operational"
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "mode": {
            "type": "string",
            "enum": [
              "mock",
              "live"
            ]
          }
        }
      },
      "Token": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "存取權杖，後續請求發送 `Authorization: Bearer <token>`。"
          },
          "expires_in": {
            "type": "integer",
            "example": 1800,
            "description": "權杖有效秒數，目前為 1800。"
          },
          "token_type": {
            "type": "string",
            "example": "Bearer",
            "description": "Bearer"
          }
        }
      },
      "CustomerLine": {
        "type": "object",
        "properties": {
          "found": {
            "type": "boolean",
            "description": "是否找到目標線路。僅 found=true 且返回標識匹配時，才按線路 status 選擇續費或重新啟用；false 不等於 Inactive。"
          },
          "mdn": {
            "type": "string",
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          },
          "esn": {
            "type": "string",
            "nullable": true,
            "description": "ICCID，18–22 位數字字串。請保留前導零，不要使用數字類型或科學記號。"
          },
          "sim": {
            "type": "string",
            "nullable": true
          },
          "customer_id": {
            "type": "string",
            "nullable": true
          },
          "enrollment_id": {
            "type": "string",
            "nullable": true,
            "description": "已登記線路的 Enrollment ID，可單獨用於識別線路；若同時提供 ICCID 或手機號碼，必須指向同一線路。"
          },
          "account_number": {
            "type": "string",
            "nullable": true
          },
          "plan_id": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐 ID，從目錄讀取。續費換套餐時與 plan_change=true 配合。"
          },
          "plan_code": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐代碼，供查詢及結果展示；開卡請求不接受此欄位，套餐由 catalog_entry_id 決定。"
          },
          "plan_name": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true,
            "description": "五位美國郵政編碼字串，保留前導 0。"
          },
          "city": {
            "type": "string",
            "nullable": true,
            "description": "城市。"
          },
          "state": {
            "type": "string",
            "nullable": true,
            "description": "美國州的兩位字母代碼。"
          },
          "address": {
            "type": "string",
            "nullable": true,
            "description": "真實街道地址。"
          },
          "address_two": {
            "type": "string",
            "nullable": true,
            "description": "地址補充資訊。"
          },
          "wfc_address": {
            "type": "string",
            "nullable": true
          },
          "wfc_address_two": {
            "type": "string",
            "nullable": true
          },
          "wfc_city": {
            "type": "string",
            "nullable": true
          },
          "wfc_state": {
            "type": "string",
            "nullable": true
          },
          "wfc_zip": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "nullable": true,
            "description": "線路狀態：Active 為目前啟用，渠道選擇續費 POST /jobs/renewals；Inactive 為既有線路目前停用，渠道選擇重新啟用 POST /jobs/reactivations，不代表 SIM 從未激活。僅忽略大小寫和首尾空白後完整比對；未知、缺失、null 或空值須先核實。不同於 SIM 庫存的 ACTIVE，也不代表訂單成功。",
            "example": "Active"
          },
          "first_name": {
            "type": "string",
            "nullable": true,
            "description": "名（可選）。"
          },
          "last_name": {
            "type": "string",
            "nullable": true,
            "description": "姓（可選）。"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "電子郵件（可選）。"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "service_period": {
            "$ref": "#/components/schemas/ServicePeriod"
          },
          "wifi_calling_enabled": {
            "type": "boolean",
            "nullable": true,
            "description": "線路的 Wi-Fi Calling／E911 登記標記。true 表示記錄包含 Active WFC 功能或完整 WFC 地址；false 表示找到線路但未偵測到上述登記；null 表示未找到線路。欄位缺省時不能按 false 處理。這不是手機端的即時開關狀態。\n\n業務成功與 WFC 登記結果須分開判讀。回執的 wifi_calling.status=enabled 或 already_enabled 可能與尚未更新的 line.wifi_calling_enabled=false 同時出現，不能據此重辦激活、續費或重新激活。需自動確認或補開時，平台獨立查詢同卡目前資料：完整匹配且 WFC=true 時不再補開，Active 且明確 false 時才申請補開並再次確認；資料未核實不補開。臨時查詢失敗按原任務等待重查，無法處理時交由人工。WFC 處理不改變主業務的成功或扣款，也不延後主業務回呼；以最新有效線路查詢確認登記狀態。明確提交的 WFC 任務仍依請求地址辦理，請查該任務結果。"
          },
          "queried_at": {
            "type": "string",
            "format": "date-time",
            "description": "本次查詢時間，不是到期時間；狀態反映本次查詢報告，不保證之後仍不變。"
          },
          "plan_start_date": {
            "type": "string",
            "nullable": true,
            "description": "上游當期開始時間。 可唯一確定時輸出 YYYY-MM-DDTHH:mm:ss[.小數]，帶 -04:00 或 -05:00。選填；純日期、未知值及歧義時間保持原值。",
            "example": "2026-12-03T01:38:50-05:00"
          },
          "plan_expiry_date": {
            "type": "string",
            "nullable": true,
            "description": "上游當期到期時間，不是全部已購週期的最終到期時間。 可唯一確定時輸出 YYYY-MM-DDTHH:mm:ss[.小數]，帶 -04:00 或 -05:00。選填；純日期、未知值及歧義時間保持原值。",
            "example": "2026-12-03T01:38:50-05:00"
          },
          "plan_grace_expiry_date": {
            "type": "string",
            "nullable": true,
            "description": "上游寬限期結束時間。 可唯一確定時輸出 YYYY-MM-DDTHH:mm:ss[.小數]，帶 -04:00 或 -05:00。選填；純日期、未知值及歧義時間保持原值。",
            "example": "2026-12-03T01:38:50-05:00"
          },
          "next_plan_change_renew_date": {
            "type": "string",
            "nullable": true,
            "description": "上游下期生效時間，不覆蓋當期開始時間。 可唯一確定時輸出 YYYY-MM-DDTHH:mm:ss[.小數]，帶 -04:00 或 -05:00。選填；純日期、未知值及歧義時間保持原值。",
            "example": "2026-12-03T01:38:50-05:00"
          },
          "next_plan_expiry_date": {
            "type": "string",
            "nullable": true,
            "description": "上游下期到期時間，不覆蓋當期到期時間。 可唯一確定時輸出 YYYY-MM-DDTHH:mm:ss[.小數]，帶 -04:00 或 -05:00。選填；純日期、未知值及歧義時間保持原值。",
            "example": "2027-01-03T01:38:50-05:00"
          },
          "created_at": {
            "type": "string",
            "nullable": true,
            "description": "線路記錄中上游提供的帳戶建立時間。 可唯一確定時輸出 YYYY-MM-DDTHH:mm:ss[.小數]，帶 -04:00 或 -05:00。選填；純日期、未知值及歧義時間保持原值。",
            "example": "2026-12-03T01:38:50-05:00"
          },
          "approved_at": {
            "type": "string",
            "nullable": true,
            "description": "線路記錄中上游提供的帳戶核准時間。 可唯一確定時輸出 YYYY-MM-DDTHH:mm:ss[.小數]，帶 -04:00 或 -05:00。選填；純日期、未知值及歧義時間保持原值。",
            "example": "2026-12-03T01:38:50-05:00"
          },
          "next_service_period": {
            "$ref": "#/components/schemas/ServicePeriod"
          },
          "service_periods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ServicePeriod"
            },
            "description": "依時間返回當期與已核實的後續週期。中間週期以匹配的原續費及上游日期證據為準；缺失或衝突時不推算。"
          }
        }
      },
      "InventoryStatus": {
        "type": "object",
        "properties": {
          "esn": {
            "type": "string",
            "description": "ICCID，18–22 位數字字串。請保留前導零，不要使用數字類型或科學記號。"
          },
          "status": {
            "type": "string",
            "enum": [
              "FREE",
              "NOTFOUND",
              "ACTIVE",
              "ERROR"
            ],
            "description": "SIM 庫存狀態：FREE 僅表示庫存標記為 Free，不代表 SIM 從未激活；曾使用且原線路已停機的 SIM 也可能返回 FREE。ACTIVE 表示庫存中的已激活或已佔用標記，不保證線路目前啟用；NOTFOUND 表示庫存未找到；ERROR 表示庫存查詢失敗。結合 provision_status 和 message 理解庫存結果；續費或重新啟用須依據客戶／線路查詢的 data.status，不能只看庫存狀態。"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "nullable": true
          },
          "esn_status": {
            "type": "string",
            "nullable": true
          },
          "provision_status": {
            "type": "string",
            "nullable": true
          },
          "mdn": {
            "type": "string",
            "nullable": true,
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          },
          "enrollment_id": {
            "type": "string",
            "nullable": true,
            "description": "已登記線路的 Enrollment ID，可單獨用於識別線路；若同時提供 ICCID 或手機號碼，必須指向同一線路。"
          },
          "zip": {
            "type": "string",
            "nullable": true,
            "description": "五位美國郵政編碼字串，保留前導 0。"
          },
          "plan_code": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐代碼，供查詢及結果展示；開卡請求不接受此欄位，套餐由 catalog_entry_id 決定。"
          },
          "plan_name": {
            "type": "string",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "service_period": {
            "type": "object",
            "nullable": true,
            "enum": [
              null
            ],
            "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。"
          },
          "queried_at": {
            "type": "string",
            "format": "date-time",
            "description": "本次查詢時間，不是到期時間；狀態反映本次查詢報告，不保證之後仍不變。"
          },
          "next_service_period": {
            "type": "object",
            "nullable": true,
            "enum": [
              null
            ],
            "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。"
          }
        }
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "ord_example"
          },
          "txid": {
            "type": "string",
            "example": "order-99",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          },
          "partner_id": {
            "type": "string",
            "description": "平台分配的渠道代碼。"
          },
          "type": {
            "type": "string",
            "enum": [
              "activation",
              "renewal",
              "reactivation",
              "wifi_calling",
              "auto_handling"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed",
              "partial"
            ]
          },
          "totals": {
            "type": "object",
            "properties": {
              "total": {
                "type": "integer",
                "minimum": 0
              },
              "succeeded": {
                "type": "integer",
                "minimum": 0
              },
              "failed": {
                "type": "integer",
                "minimum": 0
              },
              "pending": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "total",
              "succeeded",
              "failed",
              "pending"
            ]
          },
          "defaults": {
            "type": "object",
            "description": "重新啟用和 WFC 的可選批次地址，明細 customer、zip 可覆蓋。優先本次明確欄位，再使用本地號卡已登記地址、同卡最近成功開卡地址；本地無有效地址時由線路目前 WFC 或服務記錄補齊，不按城市或郵編從目錄任選地址。可選 address_two 的空字串按未填處理。開卡不接受 defaults。"
          },
          "webhook_url": {
            "type": "string",
            "nullable": true,
            "description": "可選，本任務的渠道 HTTPS 回呼地址，覆蓋已登記地址。省略且未登記時由平台接收及留存結果，不會主動通知渠道；請查詢原任務。不要填 API 地址。"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "billing": {
            "type": "object",
            "description": "批次報價與已扣款金額。\n\n資料完整的明細校驗報價後正常受理辦理；缺少必要線路資料的明細先保存為 pending，再單獨非同步補查，不阻塞其餘明細。補查階段不發送業務、不扣款。billing.quote_pending=true 表示報價尚未確定，price 暫為 0.00，批次 amount 僅含已確定的報價，不代表免費。補齊後保存當時渠道售價並進入辦理，餘額可為負數。補資料最多查一次。不能核實線路或帳號時返回該明細錯誤，不發送辦理。\n\n手機號與卡號資料衝突時，僅對應明細保持處理中，等待平台核實，不發送辦理或扣款；其餘明細正常處理，請勿重複提交。",
            "properties": {
              "amount": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "2.60"
              },
              "quote_pending": {
                "type": "boolean",
                "description": "true 表示仍需補充資料以確定可辦理報價；0.00 不代表免費。"
              },
              "charged_amount": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "2.60",
                "description": "實際已扣金額；受理、排隊、結果未確認及失敗均不扣款。按約定僅記帳的成功業務保留報價，已扣金額為 0。"
              },
              "currency": {
                "type": "string",
                "enum": [
                  "USD"
                ]
              }
            }
          },
          "paused": {
            "type": "boolean",
            "description": "相容暫停標記，僅在 paused=true 時查看 reason。"
          },
          "attention_required": {
            "type": "boolean",
            "description": "原任務需要關注。已發送但結果未明時，只核對原任務。"
          },
          "reason": {
            "type": "string",
            "enum": [
              "INSUFFICIENT_BALANCE",
              "UPSTREAM_ACCOUNT_UNCONFIRMED",
              "LINE_IDENTITY_CONFLICT"
            ]
          }
        },
        "required": [
          "id",
          "txid",
          "partner_id",
          "type",
          "status",
          "totals",
          "billing"
        ]
      },
      "JobItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "item_example"
          },
          "job_id": {
            "type": "string"
          },
          "txid": {
            "type": "string",
            "example": "order-99_56789012",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。 自動辦理單一明細使用批次號，多條按輸入順序附加 _line1、_line2。"
          },
          "job_txid": {
            "type": "string",
            "example": "order-99",
            "description": "批次的渠道交易號。"
          },
          "esn": {
            "type": "string",
            "nullable": true,
            "description": "已確認的 ICCID。補查中或補查失敗且無法確定卡號時返回 null；用逐條 txid 對應原請求，失敗時另有 error_details.item_index。補齊後返回實際 ICCID，明細 id 和 txid 不變，不生成虛構卡號。"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "succeeded",
              "failed"
            ]
          },
          "plan_code": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐代碼，供查詢及結果展示；開卡請求不接受此欄位，套餐由 catalog_entry_id 決定。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。"
          },
          "plan_id": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐 ID，從目錄讀取。續費換套餐時與 plan_change=true 配合。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。"
          },
          "zip": {
            "type": "string",
            "nullable": true,
            "description": "五位美國郵政編碼字串，保留前導 0。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。",
            "pattern": "^[0-9]{5}$"
          },
          "request": {
            "type": "object",
            "nullable": true
          },
          "result": {
            "type": "object",
            "nullable": true,
            "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。",
            "properties": {
              "error": {
                "type": "string",
                "description": "介面回應及回呼的系統說明統一為英文，不返回中文解釋或非英文錯誤原文。保留原始業務錯誤碼和英文原因，過濾敏感憑證；非英文原因按已知錯誤碼提供英文說明，無法識別時提供英文提示並保留原文供後台排查。文件語言不改變執行時回應。"
              },
              "error_code": {
                "type": "string",
                "description": "穩定的業務錯誤碼。"
              },
              "retryable": {
                "type": "boolean",
                "description": "true 表示允許重試，不要求渠道重提。新受理開卡的明確限流失敗依開卡說明自動補救最多兩次；其他明確 failed 的明細保留失敗結果、不扣款，核實後再決定是否手動重試。"
              },
              "next_action": {
                "$ref": "#/components/schemas/NextAction"
              },
              "error_details": {
                "$ref": "#/components/schemas/ErrorContext"
              },
              "service_period": {
                "$ref": "#/components/schemas/ServicePeriod"
              },
              "plan_code": {
                "type": "string",
                "nullable": true,
                "description": "介面套餐代碼，供查詢及結果展示；開卡請求不接受此欄位，套餐由 catalog_entry_id 決定。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。"
              },
              "plan_id": {
                "type": "string",
                "nullable": true,
                "description": "介面套餐 ID，從目錄讀取。續費換套餐時與 plan_change=true 配合。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。"
              },
              "zip": {
                "type": "string",
                "nullable": true,
                "description": "五位美國郵政編碼字串，保留前導 0。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。",
                "pattern": "^[0-9]{5}$"
              }
            },
            "additionalProperties": true
          },
          "last_error": {
            "type": "string",
            "nullable": true,
            "description": "介面回應及回呼的系統說明統一為英文，不返回中文解釋或非英文錯誤原文。保留原始業務錯誤碼和英文原因，過濾敏感憑證；非英文原因按已知錯誤碼提供英文說明，無法識別時提供英文提示並保留原文供後台排查。文件語言不改變執行時回應。"
          },
          "attempt_count": {
            "type": "integer",
            "description": "該明細的處理嘗試次數。"
          },
          "started_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "finished_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "處理完成時間；可能為 null。這不是服務到期日。"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "next_action": {
            "$ref": "#/components/schemas/NextAction"
          },
          "result_revision": {
            "type": "integer",
            "minimum": 1,
            "nullable": true,
            "description": "逐卡結果版本。首次通知為 1，後補結果或開卡延遲成功更正時遞增；未完成或沒有版本化通知的歷史結果為 null。"
          },
          "billing": {
            "type": "object",
            "description": "本條報價及成功扣款金額。",
            "properties": {
              "price": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "2.60"
              },
              "quote_pending": {
                "type": "boolean",
                "description": "true 表示仍需補充資料以確定可辦理報價；0.00 不代表免費。"
              },
              "charged_amount": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "2.60",
                "description": "實際已扣金額；受理、排隊、結果未確認及失敗均不扣款。按約定僅記帳的成功業務保留報價，已扣金額為 0。"
              },
              "currency": {
                "type": "string",
                "enum": [
                  "USD"
                ]
              }
            }
          },
          "operation": {
            "type": "string",
            "nullable": true,
            "enum": [
              "renewal",
              "reactivation",
              null
            ],
            "description": "此號碼實際受理的業務。尚未判定或受理前拒絕時為 null。"
          },
          "change_type": {
            "type": "string",
            "nullable": true,
            "enum": [
              "ONEXPIRY",
              null
            ]
          },
          "mdn": {
            "type": "string",
            "nullable": true
          },
          "cycle": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "index",
              "quantity"
            ],
            "properties": {
              "index": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12
              },
              "quantity": {
                "type": "integer",
                "minimum": 2,
                "maximum": 12
              }
            },
            "description": "此明細在同一號碼原請求的辦理期次。多期辦理時提供。"
          },
          "confirmed_through_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "同一號碼在原任務內由上游核實的最後到期日，採美東日期。單期取本期已核實到期日。多期從第 1 期起累計至連續核實的最後一期。尚無已核實到期日為 null。適用於自動辦理、續費及重新啟用明細與新建的逐筆回呼。"
          }
        },
        "required": [
          "id",
          "job_id",
          "job_txid",
          "txid",
          "esn",
          "status",
          "result",
          "billing"
        ]
      },
      "JobDetail": {
        "type": "object",
        "properties": {
          "job": {
            "$ref": "#/components/schemas/Job"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JobItem"
            }
          },
          "match": {
            "type": "string",
            "enum": [
              "job_id",
              "txid",
              "item_txid"
            ],
            "description": "匹配方式為任務 ID 或交易號；交易號可對應批次或逐卡明細。"
          }
        },
        "required": [
          "job",
          "items"
        ]
      },
      "ActivationItem": {
        "type": "object",
        "required": [
          "esn",
          "catalog_entry_id"
        ],
        "properties": {
          "esn": {
            "type": "string",
            "minLength": 18,
            "description": "ICCID（必填），18–22 位數字字串。請保留前導零，不使用數字類型；與 catalog_entry_id 一起提交，不能用手機號碼或 Enrollment ID 替代。",
            "pattern": "^[0-9]{18,22}$",
            "maxLength": 22
          },
          "catalog_entry_id": {
            "type": "string",
            "description": "必填：首次辦理使用所選地區套餐目錄的唯一編碼，平台據此補齊套餐代碼及地址；僅明確限流後的自動補救可依開卡說明隨機更換目錄。",
            "minLength": 1,
            "maxLength": 250
          },
          "catalog_revision": {
            "type": "string",
            "deprecated": true,
            "description": "相容欄位，無需傳入，不再按版本號拒絕請求；仍按 catalog_entry_id 校驗目前可辦理目錄及報價，並保存受理快照。",
            "minLength": 1,
            "maxLength": 250
          },
          "service_address": {
            "$ref": "#/components/schemas/HandlingServiceAddress"
          }
        },
        "additionalProperties": false
      },
      "ActivationRequest": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "txid": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9._:-]{1,64}$",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ActivationItem"
            },
            "minItems": 1
          },
          "mode": {
            "type": "string",
            "enum": [
              "sync",
              "async"
            ],
            "description": "辦理統一非同步排隊。mode 可省略或傳 async；相容舊值 sync，但同樣非同步處理，不等待辦理結果。任務保存後返回 202 和原任務號；若全部明細在本地校驗時已失敗，返回 200 及失敗明細。200 不代表業務成功。",
            "default": "async",
            "deprecated": true
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "可選，本任務的渠道 HTTPS 回呼地址，覆蓋已登記地址。省略且未登記時由平台接收及留存結果，不會主動通知渠道；請查詢原任務。不要填 API 地址。"
          },
          "service_address": {
            "$ref": "#/components/schemas/HandlingServiceAddress"
          }
        },
        "example": {
          "txid": "channel-activation-001",
          "items": [
            {
              "esn": "89000000000000000001",
              "catalog_entry_id": "CATALOG_ENTRY_ID"
            }
          ]
        },
        "additionalProperties": false
      },
      "ReactivationRequest": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "txid": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9._:-]{1,64}$",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "esn": {
                  "type": "string",
                  "description": "ICCID（推薦），18–22 位數字字串。可直接識別目標 SIM，不必同傳手機號碼。亦支援已登記的 mdn 或 enrollment_id；同傳多個標識時必須對應同一張卡。",
                  "pattern": "^[0-9]{18,22}$",
                  "minLength": 18,
                  "maxLength": 22
                },
                "mdn": {
                  "type": "string",
                  "description": "10 位美國手機號碼，不帶 +1、空格或連字符。",
                  "pattern": "^[0-9]{10}$"
                },
                "enrollment_id": {
                  "type": "string",
                  "description": "已登記線路的 Enrollment ID，可單獨用於識別線路；若同時提供 ICCID 或手機號碼，必須指向同一線路。",
                  "minLength": 1,
                  "maxLength": 100
                },
                "zip": {
                  "type": "string",
                  "pattern": "^\\d{5}$",
                  "description": "本地卡檔地址的選填郵編。"
                },
                "customer": {
                  "type": "object",
                  "properties": {
                    "address": {
                      "type": "string",
                      "description": "真實街道地址。",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "address_two": {
                      "type": "string",
                      "description": "地址補充資訊。",
                      "maxLength": 250
                    },
                    "city": {
                      "type": "string",
                      "description": "城市。",
                      "minLength": 1,
                      "maxLength": 100
                    },
                    "state": {
                      "type": "string",
                      "description": "美國州的兩位字母代碼。",
                      "minLength": 1,
                      "maxLength": 2,
                      "pattern": "^[A-Za-z]{2}$"
                    },
                    "zip": {
                      "type": "string",
                      "pattern": "^\\d{5}$",
                      "description": "五位美國郵政編碼字串，保留前導 0。",
                      "minLength": 1,
                      "maxLength": 5
                    }
                  },
                  "description": "重新啟用的本地卡檔地址，可省略。完整新址在成功後存檔，辦理時每筆只傳核實過的三項標識。",
                  "additionalProperties": false
                },
                "service_address": {
                  "$ref": "#/components/schemas/HandlingServiceAddress"
                }
              },
              "additionalProperties": false,
              "anyOf": [
                {
                  "required": [
                    "esn"
                  ]
                },
                {
                  "required": [
                    "mdn"
                  ]
                },
                {
                  "required": [
                    "enrollment_id"
                  ]
                }
              ]
            },
            "minItems": 1
          },
          "defaults": {
            "type": "object",
            "properties": {
              "address": {
                "type": "string",
                "description": "真實街道地址。",
                "minLength": 1,
                "maxLength": 200
              },
              "address_two": {
                "type": "string",
                "description": "地址補充資訊。",
                "maxLength": 250
              },
              "city": {
                "type": "string",
                "description": "城市。",
                "minLength": 1,
                "maxLength": 100
              },
              "state": {
                "type": "string",
                "description": "美國州的兩位字母代碼。",
                "minLength": 1,
                "maxLength": 2,
                "pattern": "^[A-Za-z]{2}$"
              },
              "zip": {
                "type": "string",
                "pattern": "^\\d{5}$",
                "description": "五位美國郵政編碼字串，保留前導 0。",
                "minLength": 1,
                "maxLength": 5
              }
            },
            "description": "重新啟用的本地卡檔地址，可省略。完整新址在成功後存檔，辦理時每筆只傳核實過的三項標識。",
            "additionalProperties": false
          },
          "mode": {
            "type": "string",
            "enum": [
              "sync",
              "async"
            ],
            "description": "辦理統一非同步排隊。mode 可省略或傳 async；相容舊值 sync，但同樣非同步處理，不等待辦理結果。任務保存後返回 202 和原任務號；若全部明細在本地校驗時已失敗，返回 200 及失敗明細。200 不代表業務成功。",
            "default": "async",
            "deprecated": true
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "可選，本任務的渠道 HTTPS 回呼地址，覆蓋已登記地址。省略且未登記時由平台接收及留存結果，不會主動通知渠道；請查詢原任務。不要填 API 地址。"
          },
          "service_address": {
            "$ref": "#/components/schemas/HandlingServiceAddress"
          }
        },
        "example": {
          "txid": "channel-reactivation-001",
          "items": [
            {
              "esn": "89000000000000000001"
            }
          ]
        },
        "additionalProperties": false
      },
      "WifiCallingRequest": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "txid": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9._:-]{1,64}$",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "esn": {
                  "type": "string",
                  "description": "ICCID，18–22 位數字字串。請保留前導零，不要使用數字類型或科學記號。",
                  "pattern": "^[0-9]{18,22}$",
                  "minLength": 18,
                  "maxLength": 22
                },
                "mdn": {
                  "type": "string",
                  "description": "10 位美國手機號碼，不帶 +1、空格或連字符。",
                  "pattern": "^[0-9]{10}$"
                },
                "enrollment_id": {
                  "type": "string",
                  "description": "已登記線路的 Enrollment ID，可單獨用於識別線路；若同時提供 ICCID 或手機號碼，必須指向同一線路。",
                  "minLength": 1,
                  "maxLength": 100
                },
                "zip": {
                  "type": "string",
                  "pattern": "^\\d{5}$",
                  "description": "五位美國郵政編碼字串，保留前導 0。"
                },
                "feature_action": {
                  "type": "string",
                  "enum": [
                    "Active"
                  ],
                  "default": "Active",
                  "deprecated": true,
                  "description": "相容欄位，無需傳入；此介面僅開啟 Wi-Fi Calling，舊請求仍可傳 Active，不支援 Inactive。"
                },
                "customer": {
                  "type": "object",
                  "properties": {
                    "address": {
                      "type": "string",
                      "description": "真實街道地址。",
                      "minLength": 1,
                      "maxLength": 200
                    },
                    "address_two": {
                      "type": "string",
                      "description": "地址補充資訊。",
                      "maxLength": 250
                    },
                    "city": {
                      "type": "string",
                      "description": "城市。",
                      "minLength": 1,
                      "maxLength": 100
                    },
                    "state": {
                      "type": "string",
                      "description": "美國州的兩位字母代碼。",
                      "minLength": 1,
                      "maxLength": 2,
                      "pattern": "^[A-Za-z]{2}$"
                    },
                    "zip": {
                      "type": "string",
                      "pattern": "^\\d{5}$",
                      "description": "五位美國郵政編碼字串，保留前導 0。",
                      "minLength": 1,
                      "maxLength": 5
                    }
                  },
                  "description": "目前明細的客戶資料或地址，覆蓋批次 defaults。",
                  "additionalProperties": false
                },
                "catalog_entry_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 250,
                  "description": "選填，使用本渠道可用目錄的唯一編碼選擇 WFC 地址；僅使用地址，不變更套餐。不能與該條 customer 或 zip 同傳；批次 defaults 地址不作用於這條。"
                },
                "service_address": {
                  "$ref": "#/components/schemas/HandlingServiceAddress"
                }
              },
              "additionalProperties": false,
              "anyOf": [
                {
                  "required": [
                    "esn"
                  ]
                },
                {
                  "required": [
                    "mdn"
                  ]
                },
                {
                  "required": [
                    "enrollment_id"
                  ]
                }
              ]
            },
            "minItems": 1
          },
          "defaults": {
            "type": "object",
            "properties": {
              "address": {
                "type": "string",
                "description": "真實街道地址。",
                "minLength": 1,
                "maxLength": 200
              },
              "address_two": {
                "type": "string",
                "description": "地址補充資訊。",
                "maxLength": 250
              },
              "city": {
                "type": "string",
                "description": "城市。",
                "minLength": 1,
                "maxLength": 100
              },
              "state": {
                "type": "string",
                "description": "美國州的兩位字母代碼。",
                "minLength": 1,
                "maxLength": 2,
                "pattern": "^[A-Za-z]{2}$"
              },
              "zip": {
                "type": "string",
                "pattern": "^\\d{5}$",
                "description": "五位美國郵政編碼字串，保留前導 0。",
                "minLength": 1,
                "maxLength": 5
              },
              "feature_action": {
                "type": "string",
                "enum": [
                  "Active"
                ],
                "default": "Active",
                "deprecated": true,
                "description": "相容欄位，無需傳入；此介面僅開啟 Wi-Fi Calling，舊請求仍可傳 Active，不支援 Inactive。",
                "minLength": 1,
                "maxLength": 250
              }
            },
            "description": "重新啟用和 WFC 的可選批次地址，明細 customer、zip 可覆蓋。優先本次明確欄位，再使用本地號卡已登記地址、同卡最近成功開卡地址；本地無有效地址時由線路目前 WFC 或服務記錄補齊，不按城市或郵編從目錄任選地址。可選 address_two 的空字串按未填處理。開卡不接受 defaults。",
            "additionalProperties": false
          },
          "feature_action": {
            "type": "string",
            "enum": [
              "Active"
            ],
            "default": "Active",
            "deprecated": true,
            "description": "相容欄位，無需傳入；此介面僅開啟 Wi-Fi Calling，舊請求仍可傳 Active，不支援 Inactive。"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sync",
              "async"
            ],
            "description": "辦理統一非同步排隊。mode 可省略或傳 async；相容舊值 sync，但同樣非同步處理，不等待辦理結果。任務保存後返回 202 和原任務號；若全部明細在本地校驗時已失敗，返回 200 及失敗明細。200 不代表業務成功。",
            "default": "async",
            "deprecated": true
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "可選，本任務的渠道 HTTPS 回呼地址，覆蓋已登記地址。省略且未登記時由平台接收及留存結果，不會主動通知渠道；請查詢原任務。不要填 API 地址。"
          },
          "service_address": {
            "$ref": "#/components/schemas/HandlingServiceAddress"
          }
        },
        "example": {
          "txid": "channel-wfc-001",
          "items": [
            {
              "mdn": "2025550100"
            }
          ]
        },
        "additionalProperties": false
      },
      "RenewalRequest": {
        "type": "object",
        "required": [
          "items"
        ],
        "properties": {
          "txid": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9._:-]{1,64}$",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "esn": {
                  "type": "string",
                  "description": "ICCID（推薦），18–22 位數字字串。可直接識別目標 SIM，不必同傳手機號碼。亦支援已登記的 mdn 或 enrollment_id；同傳多個標識時必須對應同一張卡。",
                  "pattern": "^[0-9]{18,22}$",
                  "minLength": 18,
                  "maxLength": 22
                },
                "mdn": {
                  "type": "string",
                  "description": "10 位美國手機號碼，不帶 +1、空格或連字符。",
                  "pattern": "^[0-9]{10}$"
                },
                "enrollment_id": {
                  "type": "string",
                  "description": "已登記線路的 Enrollment ID，可單獨用於識別線路；若同時提供 ICCID 或手機號碼，必須指向同一線路。",
                  "minLength": 1,
                  "maxLength": 100
                },
                "renewal_catalog_entry_id": {
                  "type": "string",
                  "maxLength": 250,
                  "description": "續費換套餐的已核實地址匹配；只用於選擇目標套餐 ID，不修改號碼或線路地址。"
                },
                "renewal_catalog_revision": {
                  "type": "string",
                  "maxLength": 100,
                  "description": "續費換套餐的已核實地址匹配；只用於選擇目標套餐 ID，不修改號碼或線路地址。"
                },
                "service_address": {
                  "$ref": "#/components/schemas/HandlingServiceAddress"
                }
              },
              "additionalProperties": false,
              "anyOf": [
                {
                  "required": [
                    "esn"
                  ]
                },
                {
                  "required": [
                    "mdn"
                  ]
                },
                {
                  "required": [
                    "enrollment_id"
                  ]
                }
              ]
            },
            "minItems": 1
          },
          "plan_change": {
            "type": "boolean",
            "default": false,
            "description": "false（預設）：續費目前套餐；true：按 plan_id 指定的已開放套餐續費。存在尚未核實生效的到期套餐變更時，預設續費明細返回 PLAN_CONFIRMATION_REQUIRED，不繼續辦理、不扣款；核實後明確 plan_change=true 和 plan_id，或透過獨立資料同步確認目標套餐已生效。"
          },
          "plan_id": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐 ID，從目錄讀取。續費換套餐時與 plan_change=true 配合。",
            "minLength": 1,
            "maxLength": 100
          },
          "change_type": {
            "type": "string",
            "enum": [
              "IMMEDIATE",
              "ONEXPIRY"
            ],
            "description": "IMMEDIATE（預設，可省略）：即日續費，從辦理當日重新開始一個套餐週期，並提供新的資源量。ONEXPIRY：到期續費，保留目前週期，在原到期日追加一個週期。兩種均可現在提交，確認成功後立即記帳；ONEXPIRY 不會等到到期日才發單或扣款。",
            "default": "IMMEDIATE"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sync",
              "async"
            ],
            "description": "辦理統一非同步排隊。mode 可省略或傳 async；相容舊值 sync，但同樣非同步處理，不等待辦理結果。任務保存後返回 202 和原任務號；若全部明細在本地校驗時已失敗，返回 200 及失敗明細。200 不代表業務成功。",
            "default": "async",
            "deprecated": true
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "可選，本任務的渠道 HTTPS 回呼地址，覆蓋已登記地址。省略且未登記時由平台接收及留存結果，不會主動通知渠道；請查詢原任務。不要填 API 地址。"
          },
          "service_address": {
            "$ref": "#/components/schemas/HandlingServiceAddress"
          }
        },
        "example": {
          "txid": "channel-renewal-001",
          "change_type": "ONEXPIRY",
          "items": [
            {
              "esn": "89000000000000000001"
            }
          ]
        },
        "additionalProperties": false
      },
      "Usage": {
        "type": "object",
        "properties": {
          "mdn": {
            "type": "string",
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          },
          "summary": {
            "type": "boolean"
          },
          "from": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "to": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "data_used": {
            "type": "string",
            "nullable": true
          },
          "data_remaining": {
            "type": "string",
            "nullable": true
          },
          "data_limit": {
            "type": "string",
            "nullable": true
          },
          "talk_used": {
            "type": "string",
            "nullable": true
          },
          "talk_remaining": {
            "type": "string",
            "nullable": true
          },
          "text_used": {
            "type": "string",
            "nullable": true
          },
          "text_remaining": {
            "type": "string",
            "nullable": true
          },
          "records": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "line_status": {
            "type": "string",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "talk_limit": {
            "type": "string",
            "nullable": true,
            "description": "當期套餐通話總額度，單位分鐘。"
          },
          "text_limit": {
            "type": "string",
            "nullable": true,
            "description": "當期套餐短訊總額度，接收和發送共用。"
          },
          "data_unlimited": {
            "type": "boolean",
            "nullable": true,
            "description": "true 表示不限量；null 表示未知。"
          },
          "talk_unlimited": {
            "type": "boolean",
            "nullable": true,
            "description": "true 表示不限量；null 表示未知。"
          },
          "text_unlimited": {
            "type": "boolean",
            "nullable": true,
            "description": "true 表示不限量；null 表示未知。"
          },
          "usage_units": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "data": {
                "type": "string",
                "enum": [
                  "MB"
                ]
              },
              "talk": {
                "type": "string",
                "enum": [
                  "minute"
                ]
              },
              "text": {
                "type": "string",
                "enum": [
                  "message"
                ]
              }
            },
            "required": [
              "data",
              "talk",
              "text"
            ],
            "description": "無單位數值分別按 MB、分鐘、條讀取；原有帶單位字串保留原樣。"
          },
          "service_period": {
            "$ref": "#/components/schemas/ServicePeriod"
          },
          "current_usage": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "properties": {
              "from": {
                "type": "string",
                "format": "date"
              },
              "to": {
                "type": "string",
                "format": "date"
              },
              "data_used": {
                "type": "string",
                "nullable": true
              },
              "talk_used": {
                "type": "string",
                "nullable": true
              },
              "text_used": {
                "type": "string",
                "nullable": true
              },
              "timestamp": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            },
            "required": [
              "from",
              "to",
              "data_used",
              "talk_used",
              "text_used",
              "timestamp"
            ],
            "description": "本期起始日至所列查詢日期的計費用量，單位見 usage_units。不可取得時為 null；原有頂層已用量欄位仍對應原請求區間。"
          }
        }
      },
      "WebhookItemData": {
        "type": "object",
        "required": [
          "job_id",
          "item_id",
          "status"
        ],
        "properties": {
          "txid": {
            "type": "string",
            "nullable": true,
            "example": "order-99_56789012",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。 自動辦理單一明細使用批次號，多條按輸入順序附加 _line1、_line2。"
          },
          "job_txid": {
            "type": "string",
            "nullable": true,
            "example": "order-99",
            "description": "批次的渠道交易號。"
          },
          "job_id": {
            "type": "string",
            "example": "ord_example"
          },
          "item_id": {
            "type": "string",
            "example": "item_example"
          },
          "esn": {
            "type": "string",
            "nullable": true,
            "description": "已確認的 ICCID。補查中或補查失敗且無法確定卡號時返回 null；用逐條 txid 對應原請求，失敗時另有 error_details.item_index。補齊後返回實際 ICCID，明細 id 和 txid 不變，不生成虛構卡號。"
          },
          "status": {
            "type": "string",
            "enum": [
              "succeeded",
              "failed"
            ]
          },
          "customer_id": {
            "type": "string",
            "nullable": true
          },
          "mdn": {
            "type": "string",
            "nullable": true,
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          },
          "enrollment_id": {
            "type": "string",
            "nullable": true,
            "description": "已登記線路的 Enrollment ID，可單獨用於識別線路；若同時提供 ICCID 或手機號碼，必須指向同一線路。"
          },
          "error": {
            "type": "string",
            "description": "介面回應及回呼的系統說明統一為英文，不返回中文解釋或非英文錯誤原文。保留原始業務錯誤碼和英文原因，過濾敏感憑證；非英文原因按已知錯誤碼提供英文說明，無法識別時提供英文提示並保留原文供後台排查。文件語言不改變執行時回應。"
          },
          "error_code": {
            "type": "string",
            "description": "穩定的業務錯誤碼。"
          },
          "retryable": {
            "type": "boolean",
            "description": "true 表示允許重試，不要求渠道重提。新受理開卡的明確限流失敗依開卡說明自動補救最多兩次；其他明確 failed 的明細保留失敗結果、不扣款，核實後再決定是否手動重試。"
          },
          "details": {},
          "next_action": {
            "$ref": "#/components/schemas/NextAction"
          },
          "error_details": {
            "$ref": "#/components/schemas/ErrorContext"
          },
          "service_period": {
            "$ref": "#/components/schemas/ServicePeriod"
          },
          "result_revision": {
            "type": "integer",
            "minimum": 1,
            "nullable": false,
            "description": "逐卡結果版本。首次通知為 1，後補結果或開卡延遲成功更正時遞增；未完成或沒有版本化通知的歷史結果為 null。"
          },
          "started_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "處理開始時間，沿用已返回的時間戳；未返回時為 null，不用事件時間代替。"
          },
          "finished_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "處理完成時間，沿用已返回的時間戳；未返回時為 null，不用事件時間代替。"
          },
          "attempt_count": {
            "type": "integer",
            "minimum": 0,
            "nullable": true,
            "description": "業務處理嘗試次數，不是回呼投遞次數。缺失時為 null；已記錄的 0 保留，不推算。"
          },
          "plan_code": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐代碼，供查詢及結果展示；開卡請求不接受此欄位，套餐由 catalog_entry_id 決定。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。"
          },
          "plan_id": {
            "type": "string",
            "nullable": true,
            "description": "介面套餐 ID，從目錄讀取。續費換套餐時與 plan_change=true 配合。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。"
          },
          "zip": {
            "type": "string",
            "nullable": true,
            "description": "五位美國郵政編碼字串，保留前導 0。\n\n統一的套餐代碼、套餐 ID 或五位郵遞區號。優先已保存結果的同名欄位，其次 result.line，再取受理時快照；缺失為 null。查單外層明細、result 和逐卡回呼 data 保持一致；原始 line 保留原文。",
            "pattern": "^[0-9]{5}$"
          },
          "sim_type": {
            "type": "string",
            "nullable": true,
            "enum": [
              "esim",
              "physical",
              null
            ],
            "description": "首次開卡受理時的庫存卡型。新建的 activation.item.succeeded、activation.item.failed、activation.item.updated 提供 esim 或 physical；卡型未確認為 null。已建立的舊事件重送時沿用原文。"
          },
          "cycle": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "index",
              "quantity"
            ],
            "properties": {
              "index": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12
              },
              "quantity": {
                "type": "integer",
                "minimum": 2,
                "maximum": 12
              }
            },
            "description": "此明細在同一號碼原請求的辦理期次。多期辦理時提供。"
          },
          "operation": {
            "type": "string",
            "nullable": true,
            "enum": [
              "renewal",
              "reactivation",
              null
            ],
            "description": "此號碼實際受理的業務。尚未判定或受理前拒絕時為 null。"
          },
          "request": {
            "type": "object",
            "properties": {
              "esn": {
                "type": "string"
              },
              "mdn": {
                "type": "string"
              },
              "quantity": {
                "type": "integer",
                "minimum": 1,
                "maximum": 12
              }
            }
          },
          "billing": {
            "type": "object",
            "description": "本條報價及成功扣款金額。",
            "properties": {
              "price": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "2.60"
              },
              "quote_pending": {
                "type": "boolean",
                "description": "true 表示仍需補充資料以確定可辦理報價；0.00 不代表免費。"
              },
              "charged_amount": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "2.60",
                "description": "實際已扣金額；受理、排隊、結果未確認及失敗均不扣款。按約定僅記帳的成功業務保留報價，已扣金額為 0。"
              },
              "currency": {
                "type": "string",
                "enum": [
                  "USD"
                ]
              }
            }
          },
          "confirmed_through_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "同一號碼在原任務內由上游核實的最後到期日，採美東日期。單期取本期已核實到期日。多期從第 1 期起累計至連續核實的最後一期。尚無已核實到期日為 null。適用於自動辦理、續費及重新啟用明細與新建的逐筆回呼。"
          }
        },
        "additionalProperties": true
      },
      "WebhookJobData": {
        "type": "object",
        "required": [
          "job_id",
          "status",
          "total",
          "succeeded",
          "failed"
        ],
        "properties": {
          "txid": {
            "type": "string",
            "nullable": true,
            "example": "order-99",
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          },
          "job_txid": {
            "type": "string",
            "nullable": true,
            "example": "order-99",
            "description": "批次的渠道交易號。"
          },
          "job_id": {
            "type": "string",
            "example": "ord_example"
          },
          "status": {
            "type": "string",
            "enum": [
              "succeeded",
              "failed",
              "partial"
            ]
          },
          "total": {
            "type": "integer",
            "example": 2
          },
          "succeeded": {
            "type": "integer",
            "example": 1
          },
          "failed": {
            "type": "integer",
            "example": 1
          },
          "pending": {
            "type": "integer",
            "minimum": 0,
            "example": 0
          }
        }
      },
      "WebhookItemEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "evt_01hxyz"
          },
          "type": {
            "type": "string",
            "enum": [
              "activation.item.succeeded",
              "activation.item.failed",
              "renewal.item.succeeded",
              "renewal.item.failed",
              "reactivation.item.succeeded",
              "reactivation.item.failed",
              "wifi_calling.item.succeeded",
              "wifi_calling.item.failed",
              "activation.item.updated",
              "renewal.item.updated",
              "reactivation.item.updated",
              "wifi_calling.item.updated",
              "auto_handling.item.succeeded",
              "auto_handling.item.failed",
              "auto_handling.item.updated"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/WebhookItemData"
          }
        }
      },
      "WebhookJobEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created_at",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "evt_01hjob"
          },
          "type": {
            "type": "string",
            "enum": [
              "activation.job.completed",
              "renewal.job.completed",
              "reactivation.job.completed",
              "wifi_calling.job.completed",
              "auto_handling.job.completed"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/WebhookJobData"
          }
        }
      },
      "WebhookEvent": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/WebhookItemEvent"
          },
          {
            "$ref": "#/components/schemas/WebhookJobEvent"
          }
        ]
      },
      "ErrorContext": {
        "type": "object",
        "description": "僅返回可安全公開的錯誤上下文，不包含憑證或完整原始請求。",
        "properties": {
          "field": {
            "type": "string",
            "description": "出錯欄位；僅在可確定時返回。"
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "item_index": {
            "type": "integer",
            "minimum": 0,
            "description": "原渠道請求 items 陣列中的位置，從 0 開始；僅在可確定時返回。"
          },
          "item_indexes": {
            "type": "array",
            "items": {
              "type": "integer",
              "minimum": 0
            },
            "uniqueItems": true,
            "description": "受影響明細在原 items 陣列中的序號，從 0 開始；僅在能確定時返回，不包含內部帳戶資料。"
          },
          "balance": {
            "type": "string"
          },
          "required": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          }
        }
      },
      "NextAction": {
        "type": "string",
        "enum": [
          "correct_and_resubmit",
          "query_original",
          "retry_original",
          "recharge_and_resubmit",
          "recharge_and_resume",
          "wait",
          "contact_support"
        ],
        "description": "建議下一步，不是自動執行或無條件重提許可。correct_and_resubmit：修正明確失敗的明細後以新 txid 提交；未建單時可使用未佔用的 txid。query_original：只查原任務。retry_original：按原參數主動重試，仍須符合重試資格。wait：等待恢復或 Retry-After。contact_support：聯絡平台。recharge_and_resubmit 和 recharge_and_resume 僅保留舊記錄相容，新請求不因平台餘額不足拒絕或暫停。"
      },
      "ServicePeriod": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。",
        "required": [
          "status",
          "source",
          "period_kind",
          "date_timezone",
          "effective_date",
          "expiry_date"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "confirmed",
              "unknown",
              "needs_review"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "upstream"
            ]
          },
          "period_kind": {
            "type": "string",
            "enum": [
              "current",
              "next"
            ]
          },
          "date_timezone": {
            "type": "string",
            "enum": [
              "America/New_York"
            ]
          },
          "effective_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "上游明確開始日；未提供為 null。"
          },
          "expiry_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "上游明確到期日；未提供為 null。"
          },
          "current_cycle_end_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "上游明確當期到期日，與下期分開。"
          },
          "effective_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "明確生效時刻與偏移；僅有日期時為 null。"
          },
          "expiry_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "明確到期時刻與偏移；僅有日期時為 null。"
          },
          "current_cycle_end_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "明確當期到期時刻。"
          },
          "success_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "實際完成或確認成功日期，不以此推算套餐週期。"
          },
          "success_date_basis": {
            "type": "string",
            "nullable": true,
            "enum": [
              "upstream_finished_at",
              "first_success_confirmed_at",
              null
            ]
          },
          "as_of_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "觀察日期。"
          },
          "observed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "觀察或回執時刻。"
          },
          "reason": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ExtensionPagination": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer"
          },
          "per_page": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          },
          "has_more": {
            "type": "boolean"
          }
        },
        "required": [
          "page",
          "per_page",
          "total",
          "has_more"
        ]
      },
      "ExtensionWallet": {
        "type": "object",
        "properties": {
          "business_funds": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              },
              "opened_at": {
                "type": "string"
              },
              "currency": {
                "type": "string"
              },
              "amount_unit": {
                "type": "string"
              },
              "total_balance": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$",
                "example": "15.00",
                "description": "USD，兩位小數字串"
              },
              "classification_required": {
                "type": "boolean"
              },
              "accounts": {
                "type": "object",
                "properties": {
                  "physical": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      },
                      "opening_balance": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "balance": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "recharge": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "card_fees": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "package_fees": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "refunds": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "adjustments": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "unsettled_amount": {
                        "type": "string",
                        "pattern": "^\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      }
                    },
                    "required": [
                      "label",
                      "opening_balance",
                      "balance",
                      "recharge",
                      "card_fees",
                      "package_fees",
                      "refunds",
                      "adjustments",
                      "unsettled_amount"
                    ]
                  },
                  "esim": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      },
                      "opening_balance": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "balance": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "recharge": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "card_fees": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "package_fees": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "refunds": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "adjustments": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "unsettled_amount": {
                        "type": "string",
                        "pattern": "^\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      }
                    },
                    "required": [
                      "label",
                      "opening_balance",
                      "balance",
                      "recharge",
                      "card_fees",
                      "package_fees",
                      "refunds",
                      "adjustments",
                      "unsettled_amount"
                    ]
                  },
                  "unclassified": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string"
                      },
                      "opening_balance": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "balance": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "recharge": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "card_fees": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "package_fees": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "refunds": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "adjustments": {
                        "type": "string",
                        "pattern": "^-?\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      },
                      "unsettled_amount": {
                        "type": "string",
                        "pattern": "^\\d+\\.\\d{2}$",
                        "example": "15.00",
                        "description": "USD，兩位小數字串"
                      }
                    },
                    "required": [
                      "label",
                      "opening_balance",
                      "balance",
                      "recharge",
                      "card_fees",
                      "package_fees",
                      "refunds",
                      "adjustments",
                      "unsettled_amount"
                    ]
                  }
                },
                "required": [
                  "physical",
                  "esim",
                  "unclassified"
                ]
              }
            },
            "required": [
              "enabled",
              "opened_at",
              "currency",
              "amount_unit",
              "total_balance",
              "classification_required",
              "accounts"
            ]
          },
          "balance": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "available": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "相容返回欄位，與 balance 相同，可為負數。",
            "deprecated": true
          },
          "unsettled_amount": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "available_for_orders": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串",
            "nullable": true
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          }
        },
        "required": [
          "balance",
          "available",
          "currency"
        ]
      },
      "ExtensionHuiWallet": {
        "type": "object",
        "properties": {
          "snail_balance": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "gcsl_balance": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          }
        },
        "required": [
          "snail_balance",
          "gcsl_balance",
          "currency"
        ],
        "additionalProperties": false
      },
      "ExtensionLedgerEntry": {
        "type": "object",
        "properties": {
          "business_fund": {
            "type": "string",
            "enum": [
              "physical",
              "esim",
              "unclassified"
            ]
          },
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "recharge",
              "debit",
              "record",
              "record_adjustment",
              "card_fee_refund"
            ]
          },
          "recorded_amount": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "僅記帳的餘額變動為負數，不代表實際收款；歷史零變動記錄使用 record_adjustment 追加調整。"
          },
          "reference": {
            "type": "string"
          },
          "change": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "本次變動金額，儲值及卡費退差為正數，扣費為負數。"
          },
          "balance_after": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "order_id": {
            "type": "string",
            "nullable": true
          },
          "item_id": {
            "type": "string",
            "nullable": true
          },
          "txid": {
            "type": "string",
            "nullable": true
          },
          "iccid": {
            "type": "string",
            "nullable": true
          },
          "operation": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "data_scope": {
            "type": "string",
            "enum": [
              "wallet_ledger"
            ]
          },
          "entry_type": {
            "type": "string",
            "enum": [
              "opening_transfer",
              "recharge",
              "debit",
              "record",
              "record_adjustment",
              "card_fee_refund"
            ]
          }
        },
        "required": [
          "id",
          "kind",
          "reference",
          "change",
          "balance_after",
          "order_id",
          "item_id",
          "txid",
          "iccid",
          "operation",
          "created_at",
          "currency"
        ]
      },
      "ExtensionLedgerSummary": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "recharge_count": {
            "type": "integer"
          },
          "consumption_count": {
            "type": "integer"
          },
          "opening_balance": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "recharge": {
            "type": "string",
            "pattern": "^\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "consumption": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "closing_balance": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "current_balance": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "USD，兩位小數字串"
          },
          "recorded_amount": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$",
            "example": "15.00",
            "description": "期間僅記帳變動合計，為負數；不計入實際消耗金額。"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "timezone": {
            "type": "string",
            "enum": [
              "America/New_York"
            ]
          },
          "data_scope": {
            "type": "string",
            "enum": [
              "wallet_ledger"
            ]
          },
          "ledger_started_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "opening_transfer": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$"
          },
          "new_deposits": {
            "type": "string",
            "pattern": "^-?\\d+\\.\\d{2}$"
          },
          "history": {
            "type": "object",
            "nullable": true,
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "verified",
                  "needs_review"
                ]
              },
              "included_in_period": {
                "type": "boolean",
                "enum": [
                  false
                ]
              },
              "initial_deposit": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "additional_deposits": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "funds": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "consumption": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "opening_balance": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "item_count": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "lifetime": {
            "type": "object",
            "nullable": true,
            "properties": {
              "funds": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "consumption": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "recorded_amount": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              },
              "balance": {
                "type": "string",
                "pattern": "^-?\\d+\\.\\d{2}$"
              }
            }
          }
        },
        "required": [
          "total",
          "recharge_count",
          "consumption_count",
          "opening_balance",
          "recharge",
          "consumption",
          "closing_balance",
          "current_balance",
          "currency",
          "timezone"
        ]
      },
      "ExtensionCard": {
        "type": "object",
        "properties": {
          "iccid": {
            "type": "string"
          },
          "sim_type": {
            "type": "string",
            "nullable": true,
            "enum": [
              "physical",
              "esim",
              null
            ],
            "description": "卡類型尚未確認時回傳 null，不能據此判斷為實體 SIM 或 eSIM。"
          },
          "status": {
            "type": "string",
            "enum": [
              "unassigned",
              "free",
              "used"
            ],
            "description": "庫存使用事實：未分配、未使用、已使用；不表示線路 Active/Inactive。線路狀態和當期日期請即時查詢綜合介面。"
          },
          "mdn": {
            "type": "string",
            "nullable": true
          },
          "enrollment_id": {
            "type": "string",
            "nullable": true
          },
          "plan_code": {
            "type": "string",
            "nullable": true
          },
          "scheduled_plan_code": {
            "type": "string",
            "nullable": true
          },
          "last_synced_at": {
            "type": "string",
            "nullable": true
          },
          "service_address": {
            "type": "object",
            "nullable": true
          },
          "catalog_entry_id": {
            "type": "string",
            "nullable": true
          },
          "catalog_snapshot": {
            "type": "object",
            "nullable": true
          },
          "service_period": {
            "type": "object",
            "nullable": true,
            "enum": [
              null
            ],
            "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。"
          },
          "latest_handling": {
            "$ref": "#/components/schemas/ExtensionLatestHandling"
          },
          "next_service_period": {
            "type": "object",
            "nullable": true,
            "enum": [
              null
            ],
            "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。"
          },
          "expiry_info": {
            "$ref": "#/components/schemas/LocalInventoryExpiry"
          },
          "binding_status": {
            "type": "string",
            "enum": [
              "current",
              "historical",
              "unconfirmed"
            ]
          },
          "pending_handling": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "count": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "count"
            ]
          },
          "allocated_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          }
        },
        "required": [
          "iccid",
          "sim_type",
          "status",
          "mdn",
          "enrollment_id",
          "plan_code",
          "scheduled_plan_code",
          "last_synced_at",
          "service_address",
          "catalog_entry_id",
          "catalog_snapshot"
        ]
      },
      "ExtensionServiceAddress": {
        "type": "object",
        "properties": {
          "address": {
            "type": "string",
            "maxLength": 200
          },
          "city": {
            "type": "string",
            "maxLength": 100
          },
          "state": {
            "type": "string",
            "pattern": "^[A-Za-z]{2}$"
          },
          "zip": {
            "type": "string",
            "pattern": "^\\d{5}$"
          }
        },
        "required": [
          "address",
          "city",
          "state",
          "zip"
        ]
      },
      "ExtensionRegionalCatalog": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "deprecated": true,
            "description": "相容返回欄位，與 catalog_entry_id 相同；新接入使用 catalog_entry_id。"
          },
          "revision": {
            "type": "string",
            "deprecated": true,
            "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
          },
          "plan_code": {
            "type": "string",
            "nullable": true
          },
          "plan_name": {
            "type": "string"
          },
          "service_address": {
            "$ref": "#/components/schemas/ExtensionServiceAddress"
          },
          "zip_region": {
            "type": "object",
            "properties": {
              "zip": {
                "type": "string",
                "pattern": "^\\d{5}$"
              },
              "city": {
                "type": "string"
              },
              "state": {
                "type": "string",
                "pattern": "^[A-Z]{2}$"
              },
              "state_name": {
                "type": "string"
              },
              "city_source": {
                "type": "string",
                "enum": [
                  "activation_history",
                  "address_reference",
                  "verified_reference"
                ],
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "reference_cities": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "location_note": {
                "type": "string"
              },
              "area_codes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[2-9]\\d{2}$",
                  "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                },
                "readOnly": true,
                "description": "通用展示及區號篩選欄位：合併同城市同州的歷史區號和已確認實開區號；兩類記錄均為空才回退地區參考。僅展示已確認實開區號時使用 city_issued_area_codes。"
              },
              "area_code_source": {
                "type": "string",
                "enum": [
                  "city_activation_history",
                  "geographic_reference",
                  "none"
                ],
                "readOnly": true
              },
              "city_issued_area_codes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[2-9]\\d{2}$",
                  "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                },
                "readOnly": true,
                "description": "渠道下拉列表專用：同城市同州已確認的實開區號，不分套餐。按核實過的開卡記錄歸集，不混入未核實歷史或地理參考；無記錄為 []。並非實時庫存，不能保證或指定區號。"
              },
              "city_issued_area_code_samples": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "area_code": {
                      "type": "string",
                      "pattern": "^[2-9]\\d{2}$",
                      "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                    },
                    "sample_count": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "area_code",
                    "sample_count"
                  ]
                },
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "city_issued_sample_count": {
                "type": "integer",
                "minimum": 0,
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "city_issued_history_zips": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^\\d{5}$"
                },
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "city_issued_last_observed_on": {
                "type": "string",
                "format": "date",
                "nullable": true,
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "city_issued_sources": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "rogue_activation_report",
                    "rogue_api"
                  ]
                },
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "issued_sample_count": {
                "type": "integer",
                "minimum": 0,
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "issued_last_observed_on": {
                "type": "string",
                "format": "date",
                "nullable": true,
                "readOnly": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "city_historical_area_codes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[2-9]\\d{2}$",
                  "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                },
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "city_area_code_samples": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "area_code": {
                      "type": "string",
                      "pattern": "^[2-9]\\d{2}$",
                      "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                    },
                    "sample_count": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "area_code",
                    "sample_count"
                  ]
                },
                "readOnly": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "city_sample_count": {
                "type": "integer",
                "minimum": 0,
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "city_history_zips": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^\\d{5}$"
                },
                "readOnly": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。",
                "deprecated": true
              },
              "city_last_observed_on": {
                "type": "string",
                "format": "date",
                "nullable": true,
                "readOnly": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "historical_area_codes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[2-9]\\d{2}$",
                  "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                },
                "readOnly": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "area_code_samples": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "area_code": {
                      "type": "string",
                      "pattern": "^[2-9]\\d{2}$",
                      "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                    },
                    "sample_count": {
                      "type": "integer",
                      "minimum": 1
                    }
                  },
                  "required": [
                    "area_code",
                    "sample_count"
                  ]
                },
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "reference_area_codes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "pattern": "^[2-9]\\d{2}$",
                  "description": "地區或歷史號碼的三位區號，僅供查詢參考"
                },
                "readOnly": true,
                "description": "獨立保留的地理核驗資料。展示及篩選使用area_codes，本欄位不覆蓋城市實開區號；空陣列表示尚未補充"
              },
              "reference_sources": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "title": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "title",
                    "url"
                  ]
                },
                "readOnly": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "reference_checked_on": {
                "type": "string",
                "format": "date",
                "nullable": true,
                "readOnly": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "reference_scope": {
                "type": "string",
                "nullable": true,
                "readOnly": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "sample_count": {
                "type": "integer",
                "minimum": 0,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "history_status": {
                "type": "string",
                "enum": [
                  "observed",
                  "no_samples"
                ],
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "last_observed_on": {
                "type": "string",
                "format": "date",
                "nullable": true,
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              },
              "area_code_guaranteed": {
                "type": "boolean",
                "enum": [
                  false
                ],
                "readOnly": true
              },
              "notice": {
                "type": "string"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time",
                "deprecated": true,
                "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
              }
            },
            "required": [
              "zip",
              "city",
              "state",
              "state_name",
              "city_source",
              "reference_cities",
              "location_note",
              "area_codes",
              "area_code_source",
              "city_issued_area_codes",
              "city_issued_area_code_samples",
              "city_issued_sample_count",
              "city_issued_history_zips",
              "city_issued_last_observed_on",
              "city_issued_sources",
              "issued_sample_count",
              "issued_last_observed_on",
              "city_historical_area_codes",
              "city_area_code_samples",
              "city_sample_count",
              "city_history_zips",
              "city_last_observed_on",
              "historical_area_codes",
              "area_code_samples",
              "reference_area_codes",
              "reference_sources",
              "reference_checked_on",
              "reference_scope",
              "sample_count",
              "history_status",
              "last_observed_on",
              "area_code_guaranteed",
              "notice",
              "updated_at"
            ],
            "nullable": true,
            "readOnly": true,
            "description": "按ZIP關聯的只讀參考資料；未導入時為null。更新此資料不改變目錄id或revision。"
          },
          "verification_status": {
            "type": "string",
            "enum": [
              "matched",
              "updated",
              "supplemented",
              "not_found",
              "query_failed",
              "ambiguous",
              "retired"
            ],
            "deprecated": true,
            "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
          },
          "available": {
            "type": "boolean",
            "deprecated": true,
            "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
          },
          "orderable": {
            "type": "boolean",
            "deprecated": true,
            "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
          },
          "currency": {
            "type": "string",
            "enum": [
              "USD"
            ]
          },
          "prices": {
            "type": "object",
            "properties": {
              "activate_physical": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "15.00",
                "description": "USD，兩位小數字串",
                "nullable": true
              },
              "activate_esim": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "15.00",
                "description": "USD，兩位小數字串",
                "nullable": true
              },
              "renew": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "15.00",
                "description": "USD，兩位小數字串",
                "nullable": true
              },
              "reactivate": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "15.00",
                "description": "USD，兩位小數字串",
                "nullable": true
              },
              "plan_change": {
                "type": "string",
                "pattern": "^\\d+\\.\\d{2}$",
                "example": "15.00",
                "description": "相容返回欄位，不代表已開放獨立換套餐；續費換套餐使用 plan_change=true 和 plan_id。",
                "nullable": true,
                "deprecated": true
              }
            },
            "required": [
              "activate_physical",
              "activate_esim",
              "renew",
              "reactivate",
              "plan_change"
            ],
            "description": "本渠道目前售價（USD 字串），不是平台採購成本；null 表示未設定。使用 activate_physical、activate_esim、renew、reactivate；已建訂單以 billing 報價及扣款為準，辦理前無需先查價。"
          },
          "unavailable_reason": {
            "type": "string",
            "nullable": true,
            "deprecated": true,
            "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
          },
          "checked_at": {
            "type": "string",
            "nullable": true,
            "deprecated": true,
            "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
          },
          "product_code": {
            "type": "string",
            "nullable": true
          },
          "plan_id": {
            "type": "string",
            "nullable": true
          },
          "catalog_entry_id": {
            "type": "string",
            "description": "唯一地區套餐目錄 ID，可直接用於開卡。"
          },
          "benefits": {
            "type": "object",
            "additionalProperties": false,
            "description": "套餐每週期總額度，不是即時餘量。0 表示不包含；null 表示未知，或對應 unlimited=true 時表示不限量。有效天數是設定週期，不是號碼實際到期日。",
            "properties": {
              "data_mb": {
                "type": "integer",
                "minimum": 0,
                "nullable": true,
                "description": "每週期包含的數據流量，單位 MB；不包含流量時為 0。"
              },
              "data_unlimited": {
                "type": "boolean",
                "nullable": true,
                "description": "數據流量是否不限量；null 表示未知。"
              },
              "voice_minutes": {
                "type": "integer",
                "minimum": 0,
                "nullable": true,
                "description": "每週期包含的通話分鐘數；不限量時為 null，並以 voice_unlimited=true 標識。"
              },
              "voice_unlimited": {
                "type": "boolean",
                "nullable": true,
                "description": "通話是否不限量；null 表示未知。"
              },
              "sms": {
                "type": "integer",
                "minimum": 0,
                "nullable": true,
                "description": "每週期包含的短訊總條數，接收和發送共用此額度；不限量時為 null，並以 sms_unlimited=true 標識。"
              },
              "sms_unlimited": {
                "type": "boolean",
                "nullable": true,
                "description": "短訊是否不限量；null 表示未知。"
              },
              "sms_scope": {
                "type": "string",
                "enum": [
                  "shared_inbound_outbound",
                  null
                ],
                "nullable": true,
                "description": "shared_inbound_outbound 表示接收和發送共用短訊額度，不是收發各一份；未知為 null。"
              },
              "validity_days": {
                "type": "integer",
                "minimum": 1,
                "nullable": true,
                "description": "已設定的單週期有效天數；未知為 null。不能用來替代實際到期日或續費生效日。"
              }
            },
            "required": [
              "data_mb",
              "data_unlimited",
              "voice_minutes",
              "voice_unlimited",
              "sms",
              "sms_unlimited",
              "sms_scope",
              "validity_days"
            ],
            "example": {
              "data_mb": 0,
              "data_unlimited": false,
              "voice_minutes": 50,
              "voice_unlimited": false,
              "sms": 100,
              "sms_unlimited": false,
              "sms_scope": "shared_inbound_outbound",
              "validity_days": 30
            }
          }
        },
        "required": [
          "id",
          "revision",
          "plan_code",
          "plan_name",
          "service_address",
          "zip_region",
          "verification_status",
          "available",
          "orderable",
          "currency",
          "prices",
          "unavailable_reason",
          "checked_at",
          "product_code",
          "plan_id",
          "catalog_entry_id",
          "benefits"
        ]
      },
      "ExtensionInventoryServicePeriod": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。",
        "required": [
          "status",
          "source",
          "period_kind",
          "date_timezone",
          "effective_date",
          "expiry_date"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "confirmed",
              "unknown",
              "needs_review"
            ]
          },
          "source": {
            "type": "string",
            "enum": [
              "upstream"
            ]
          },
          "period_kind": {
            "type": "string",
            "enum": [
              "current",
              "next"
            ]
          },
          "date_timezone": {
            "type": "string",
            "enum": [
              "America/New_York"
            ]
          },
          "effective_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "上游明確開始日；未提供為 null。"
          },
          "expiry_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "上游明確到期日；未提供為 null。"
          },
          "current_cycle_end_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "上游明確當期到期日，與下期分開。"
          },
          "effective_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "明確生效時刻與偏移；僅有日期時為 null。"
          },
          "expiry_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "明確到期時刻與偏移；僅有日期時為 null。"
          },
          "current_cycle_end_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "明確當期到期時刻。"
          },
          "success_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "實際完成或確認成功日期，不以此推算套餐週期。"
          },
          "success_date_basis": {
            "type": "string",
            "nullable": true,
            "enum": [
              "upstream_finished_at",
              "first_success_confirmed_at",
              null
            ]
          },
          "as_of_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "觀察日期。"
          },
          "observed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "觀察或回執時刻。"
          },
          "reason": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "ExtensionLatestHandling": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "required": [
          "operation",
          "date",
          "date_range",
          "date_kind",
          "date_basis",
          "date_timezone"
        ],
        "properties": {
          "operation": {
            "type": "string",
            "enum": [
              "activate",
              "renew",
              "reactivate"
            ]
          },
          "date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "date_range": {
            "type": "array",
            "nullable": true,
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "string",
              "format": "date"
            }
          },
          "date_kind": {
            "type": "string",
            "enum": [
              "handled"
            ]
          },
          "date_basis": {
            "type": "string",
            "enum": [
              "recorded"
            ]
          },
          "date_timezone": {
            "type": "string",
            "enum": [
              "America/New_York"
            ]
          },
          "handled_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "time_basis": {
            "type": "string",
            "nullable": true
          },
          "source": {
            "type": "string",
            "enum": [
              "order",
              "history"
            ]
          },
          "job_id": {
            "type": "string",
            "nullable": true
          },
          "txid": {
            "type": "string",
            "nullable": true
          },
          "effective_date": {
            "type": "string",
            "nullable": true,
            "format": "date"
          }
        },
        "description": "最新成功的本地辦理。date/date_range 保留日期精度，沒有確切時刻時 handled_at 為 null。time_basis 區分上游完成、首次成功確認與歷史依據。待辦、失敗、僅排期不延長週期。"
      },
      "RenewalCatalog": {
        "type": "object",
        "required": [
          "catalog_entry_id",
          "revision",
          "product_code",
          "plan_name",
          "plan_id",
          "plan_code",
          "service_address",
          "prices",
          "orderable",
          "scope",
          "checked_at"
        ],
        "properties": {
          "catalog_entry_id": {
            "type": "string",
            "description": "續費選擇標識，不可用於啟用；換套餐提交 plan_id。"
          },
          "revision": {
            "type": "string"
          },
          "product_code": {
            "type": "string"
          },
          "plan_name": {
            "type": "string"
          },
          "plan_id": {
            "type": "string"
          },
          "plan_code": {
            "type": "string"
          },
          "service_address": {
            "type": "object",
            "required": [
              "zip"
            ],
            "properties": {
              "zip": {
                "type": "string",
                "pattern": "^[0-9]{5}$"
              }
            },
            "description": "僅說明套餐所屬郵編，不提供或修改線路地址。"
          },
          "prices": {
            "type": "object",
            "required": [
              "renew"
            ],
            "properties": {
              "renew": {
                "type": "string",
                "pattern": "^[0-9]+\\.[0-9]{2}$"
              }
            }
          },
          "orderable": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "scope": {
            "type": "string",
            "enum": [
              "renewal"
            ]
          },
          "checked_at": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "PlanChangeOptions": {
        "type": "object",
        "required": [
          "plans",
          "retained_plans",
          "current_product_code"
        ],
        "properties": {
          "plans": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "product_code",
                "orderable",
                "selection"
              ],
              "properties": {
                "product_code": {
                  "type": "string"
                },
                "plan_name": {
                  "type": "string"
                },
                "orderable": {
                  "type": "boolean"
                },
                "reason": {
                  "type": "string"
                },
                "prices": {
                  "type": "object"
                },
                "selection": {
                  "type": "object",
                  "nullable": true,
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "revision": {
                      "type": "string"
                    },
                    "product_code": {
                      "type": "string"
                    },
                    "plan_id": {
                      "type": "string"
                    },
                    "plan_code": {
                      "type": "string"
                    },
                    "zip": {
                      "type": "string"
                    },
                    "match_tier": {
                      "type": "string",
                      "enum": [
                        "original",
                        "city",
                        "state",
                        "other"
                      ]
                    },
                    "service_address": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "retained_plans": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "current_product_code": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "QueryIdentifiers": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "esn": {
            "type": "string",
            "pattern": "^\\d{18,22}$"
          },
          "mdn": {
            "type": "string",
            "pattern": "^\\d{10}$"
          },
          "enrollment_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        },
        "description": "至少提供一個已登記標識；同傳多個時必須屬於同一張卡。"
      },
      "QueryJobItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "index": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "accepted",
              "processing",
              "pending",
              "succeeded",
              "review"
            ]
          },
          "identifiers": {
            "$ref": "#/components/schemas/QueryIdentifiers"
          },
          "attempt_count": {
            "type": "integer"
          },
          "next_check_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "result": {
            "type": "object",
            "properties": {
              "found": {
                "type": "boolean",
                "description": "是否找到目標線路。僅 found=true 且返回標識匹配時，才按線路 status 選擇續費或重新啟用；false 不等於 Inactive。"
              },
              "mdn": {
                "type": "string",
                "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
              },
              "esn": {
                "type": "string",
                "nullable": true,
                "description": "ICCID，18–22 位數字字串。請保留前導零，不要使用數字類型或科學記號。"
              },
              "sim": {
                "type": "string",
                "nullable": true
              },
              "customer_id": {
                "type": "string",
                "nullable": true
              },
              "enrollment_id": {
                "type": "string",
                "nullable": true,
                "description": "已登記線路的 Enrollment ID，可單獨用於識別線路；若同時提供 ICCID 或手機號碼，必須指向同一線路。"
              },
              "account_number": {
                "type": "string",
                "nullable": true
              },
              "plan_id": {
                "type": "string",
                "nullable": true,
                "description": "介面套餐 ID，從目錄讀取。續費換套餐時與 plan_change=true 配合。"
              },
              "plan_code": {
                "type": "string",
                "nullable": true,
                "description": "介面套餐代碼，供查詢及結果展示；開卡請求不接受此欄位，套餐由 catalog_entry_id 決定。"
              },
              "plan_name": {
                "type": "string",
                "nullable": true
              },
              "zip": {
                "type": "string",
                "nullable": true,
                "description": "五位美國郵政編碼字串，保留前導 0。"
              },
              "city": {
                "type": "string",
                "nullable": true,
                "description": "城市。"
              },
              "state": {
                "type": "string",
                "nullable": true,
                "description": "美國州的兩位字母代碼。"
              },
              "address": {
                "type": "string",
                "nullable": true,
                "description": "真實街道地址。"
              },
              "address_two": {
                "type": "string",
                "nullable": true,
                "description": "地址補充資訊。"
              },
              "wfc_address": {
                "type": "string",
                "nullable": true
              },
              "wfc_address_two": {
                "type": "string",
                "nullable": true
              },
              "wfc_city": {
                "type": "string",
                "nullable": true
              },
              "wfc_state": {
                "type": "string",
                "nullable": true
              },
              "wfc_zip": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string",
                "nullable": true,
                "description": "線路狀態：Active 為目前啟用，渠道選擇續費 POST /jobs/renewals；Inactive 為既有線路目前停用，渠道選擇重新啟用 POST /jobs/reactivations，不代表 SIM 從未激活。僅忽略大小寫和首尾空白後完整比對；未知、缺失、null 或空值須先核實。不同於 SIM 庫存的 ACTIVE，也不代表訂單成功。",
                "example": "Active"
              },
              "first_name": {
                "type": "string",
                "nullable": true,
                "description": "名（可選）。"
              },
              "last_name": {
                "type": "string",
                "nullable": true,
                "description": "姓（可選）。"
              },
              "email": {
                "type": "string",
                "nullable": true,
                "description": "電子郵件（可選）。"
              },
              "message": {
                "type": "string",
                "nullable": true
              },
              "timestamp": {
                "type": "string",
                "format": "date-time"
              },
              "service_period": {
                "$ref": "#/components/schemas/ServicePeriod"
              },
              "wifi_calling_enabled": {
                "type": "boolean",
                "nullable": true,
                "description": "線路的 Wi-Fi Calling／E911 登記標記。true 表示記錄包含 Active WFC 功能或完整 WFC 地址；false 表示找到線路但未偵測到上述登記；null 表示未找到線路。欄位缺省時不能按 false 處理。這不是手機端的即時開關狀態。\n\n業務成功與 WFC 登記結果須分開判讀。回執的 wifi_calling.status=enabled 或 already_enabled 可能與尚未更新的 line.wifi_calling_enabled=false 同時出現，不能據此重辦激活、續費或重新激活。需自動確認或補開時，平台獨立查詢同卡目前資料：完整匹配且 WFC=true 時不再補開，Active 且明確 false 時才申請補開並再次確認；資料未核實不補開。臨時查詢失敗按原任務等待重查，無法處理時交由人工。WFC 處理不改變主業務的成功或扣款，也不延後主業務回呼；以最新有效線路查詢確認登記狀態。明確提交的 WFC 任務仍依請求地址辦理，請查該任務結果。"
              },
              "queried_at": {
                "type": "string",
                "format": "date-time",
                "description": "本次查詢時間，不是到期時間；狀態反映本次查詢報告，不保證之後仍不變。"
              },
              "service_periods": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ServicePeriod"
                },
                "description": "依時間返回當期與已核實的後續週期。中間週期以匹配的原續費及上游日期證據為準；缺失或衝突時不推算。"
              }
            },
            "nullable": true
          },
          "error_code": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "QueryJobResult": {
        "type": "object",
        "properties": {
          "job": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "txid": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "query"
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "succeeded",
                  "partial",
                  "review"
                ]
              },
              "revision": {
                "type": "integer",
                "minimum": 1
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              },
              "finished_at": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/QueryJobItem"
            }
          }
        }
      },
      "QueryCompletedEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "query.job.completed"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "$ref": "#/components/schemas/QueryJobResult"
          }
        }
      },
      "QueryCallback": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivering",
              "delivered",
              "failed"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "cycle_attempts": {
            "type": "integer"
          },
          "next_attempt": {
            "type": "string",
            "format": "date-time"
          },
          "last_error": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AutoHandlingRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items"
        ],
        "properties": {
          "txid": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,64}$",
            "description": "同一渠道每批使用一個交易號。省略時依次讀取 Idempotency-Key 標頭、txid 標頭，最後由平台產生。回應不明時依原號查單。"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "description": "可選，本任務的渠道 HTTPS 回呼地址，覆蓋已登記地址。省略且未登記時由平台接收及留存結果，不會主動通知渠道；請查詢原任務。不要填 API 地址。"
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "anyOf": [
                {
                  "required": [
                    "esn"
                  ]
                },
                {
                  "required": [
                    "mdn"
                  ]
                }
              ],
              "properties": {
                "esn": {
                  "type": "string",
                  "maxLength": 100
                },
                "mdn": {
                  "type": "string",
                  "maxLength": 100
                },
                "quantity": {
                  "type": "integer",
                  "default": 1,
                  "minimum": 1,
                  "maximum": 12,
                  "description": "此號碼的辦理期數。需要重新啟用時，重新啟用計入第一期。"
                },
                "service_address": {
                  "$ref": "#/components/schemas/HandlingServiceAddress"
                }
              }
            }
          },
          "service_address": {
            "$ref": "#/components/schemas/HandlingServiceAddress"
          }
        },
        "example": {
          "txid": "FW-1028",
          "items": [
            {
              "mdn": "2025550140",
              "quantity": 2
            },
            {
              "esn": "89000000000000000049"
            }
          ]
        }
      },
      "HandlingServiceAddress": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "address",
          "city",
          "state",
          "zip"
        ],
        "properties": {
          "address": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "address_two": {
            "type": "string",
            "maxLength": 250
          },
          "city": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "state": {
            "type": "string",
            "pattern": "^[a-zA-Z]{2}$"
          },
          "zip": {
            "type": "string",
            "pattern": "^[0-9]{5}$"
          }
        },
        "description": "明確指定的服務地址優先於卡檔，逐行地址優先於整批地址。成功後寫回同一張卡。重新啟用僅傳經核實的 esn、mdn 和 enrollment_id。續費請求僅傳送線路和套餐參數。首次啟用須選同郵編的目錄。WFC 緊急地址獨立留存。"
      },
      "NumberOverview": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "mdn",
          "line",
          "usage",
          "partial",
          "usage_error"
        ],
        "properties": {
          "mdn": {
            "type": "string",
            "pattern": "^\\d{10}$"
          },
          "line": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "found",
              "service_period",
              "next_service_period"
            ],
            "properties": {
              "found": {
                "type": "boolean"
              },
              "mdn": {
                "type": "string",
                "nullable": true
              },
              "esn": {
                "type": "string",
                "nullable": true
              },
              "sim": {
                "type": "string",
                "nullable": true
              },
              "enrollment_id": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string",
                "nullable": true
              },
              "plan_id": {
                "type": "string",
                "nullable": true
              },
              "plan_code": {
                "type": "string",
                "nullable": true
              },
              "plan_name": {
                "type": "string",
                "nullable": true
              },
              "timestamp": {
                "type": "string",
                "nullable": true
              },
              "queried_at": {
                "type": "string",
                "nullable": true
              },
              "plan_start_date": {
                "type": "string",
                "nullable": true
              },
              "plan_expiry_date": {
                "type": "string",
                "nullable": true
              },
              "plan_grace_expiry_date": {
                "type": "string",
                "nullable": true
              },
              "next_plan_change_renew_date": {
                "type": "string",
                "nullable": true
              },
              "next_plan_expiry_date": {
                "type": "string",
                "nullable": true
              },
              "wifi_calling_enabled": {
                "type": "boolean",
                "nullable": true
              },
              "service_period": {
                "type": "object",
                "nullable": true,
                "additionalProperties": false,
                "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。",
                "required": [
                  "status",
                  "source",
                  "period_kind",
                  "date_timezone",
                  "effective_date",
                  "expiry_date"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "confirmed",
                      "unknown",
                      "needs_review"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "upstream"
                    ]
                  },
                  "period_kind": {
                    "type": "string",
                    "enum": [
                      "current",
                      "next"
                    ]
                  },
                  "date_timezone": {
                    "type": "string",
                    "enum": [
                      "America/New_York"
                    ]
                  },
                  "effective_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "上游明確開始日；未提供為 null。"
                  },
                  "expiry_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "上游明確到期日；未提供為 null。"
                  },
                  "current_cycle_end_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "上游明確當期到期日，與下期分開。"
                  },
                  "effective_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "明確生效時刻與偏移；僅有日期時為 null。"
                  },
                  "expiry_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "明確到期時刻與偏移；僅有日期時為 null。"
                  },
                  "current_cycle_end_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "明確當期到期時刻。"
                  },
                  "success_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "實際完成或確認成功日期，不以此推算套餐週期。"
                  },
                  "success_date_basis": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      "upstream_finished_at",
                      "first_success_confirmed_at",
                      null
                    ]
                  },
                  "as_of_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "觀察日期。"
                  },
                  "observed_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "觀察或回執時刻。"
                  },
                  "reason": {
                    "type": "string",
                    "nullable": true
                  }
                }
              },
              "next_service_period": {
                "type": "object",
                "nullable": true,
                "additionalProperties": false,
                "description": "線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。",
                "required": [
                  "status",
                  "source",
                  "period_kind",
                  "date_timezone",
                  "effective_date",
                  "expiry_date"
                ],
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "confirmed",
                      "unknown",
                      "needs_review"
                    ]
                  },
                  "source": {
                    "type": "string",
                    "enum": [
                      "upstream"
                    ]
                  },
                  "period_kind": {
                    "type": "string",
                    "enum": [
                      "current",
                      "next"
                    ]
                  },
                  "date_timezone": {
                    "type": "string",
                    "enum": [
                      "America/New_York"
                    ]
                  },
                  "effective_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "上游明確開始日；未提供為 null。"
                  },
                  "expiry_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "上游明確到期日；未提供為 null。"
                  },
                  "current_cycle_end_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "上游明確當期到期日，與下期分開。"
                  },
                  "effective_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "明確生效時刻與偏移；僅有日期時為 null。"
                  },
                  "expiry_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "明確到期時刻與偏移；僅有日期時為 null。"
                  },
                  "current_cycle_end_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "明確當期到期時刻。"
                  },
                  "success_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "實際完成或確認成功日期，不以此推算套餐週期。"
                  },
                  "success_date_basis": {
                    "type": "string",
                    "nullable": true,
                    "enum": [
                      "upstream_finished_at",
                      "first_success_confirmed_at",
                      null
                    ]
                  },
                  "as_of_date": {
                    "type": "string",
                    "format": "date",
                    "nullable": true,
                    "description": "觀察日期。"
                  },
                  "observed_at": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true,
                    "description": "觀察或回執時刻。"
                  },
                  "reason": {
                    "type": "string",
                    "nullable": true
                  }
                }
              },
              "service_periods": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ServicePeriod"
                },
                "description": "依時間返回當期與已核實的後續週期。中間週期以匹配的原續費及上游日期證據為準；缺失或衝突時不推算。"
              }
            },
            "description": "本次即時核實的線路資料；線路狀態、當期／下期週期及查詢時刻獨立於餘量。"
          },
          "usage": {
            "type": "object",
            "properties": {
              "mdn": {
                "type": "string",
                "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
              },
              "summary": {
                "type": "boolean"
              },
              "from": {
                "type": "string",
                "format": "date",
                "nullable": true
              },
              "to": {
                "type": "string",
                "format": "date",
                "nullable": true
              },
              "data_used": {
                "type": "string",
                "nullable": true
              },
              "data_remaining": {
                "type": "string",
                "nullable": true
              },
              "data_limit": {
                "type": "string",
                "nullable": true
              },
              "talk_used": {
                "type": "string",
                "nullable": true
              },
              "talk_remaining": {
                "type": "string",
                "nullable": true
              },
              "text_used": {
                "type": "string",
                "nullable": true
              },
              "text_remaining": {
                "type": "string",
                "nullable": true
              },
              "records": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "line_status": {
                "type": "string",
                "nullable": true,
                "description": "用量回包中的狀態；本次核實的線路狀態請讀取 line.status。"
              },
              "timestamp": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              },
              "talk_limit": {
                "type": "string",
                "nullable": true,
                "description": "當期套餐通話總額度，單位分鐘。"
              },
              "text_limit": {
                "type": "string",
                "nullable": true,
                "description": "當期套餐短訊總額度，接收和發送共用。"
              },
              "data_unlimited": {
                "type": "boolean",
                "nullable": true,
                "description": "true 表示不限量；null 表示未知。"
              },
              "talk_unlimited": {
                "type": "boolean",
                "nullable": true,
                "description": "true 表示不限量；null 表示未知。"
              },
              "text_unlimited": {
                "type": "boolean",
                "nullable": true,
                "description": "true 表示不限量；null 表示未知。"
              },
              "usage_units": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "data": {
                    "type": "string",
                    "enum": [
                      "MB"
                    ]
                  },
                  "talk": {
                    "type": "string",
                    "enum": [
                      "minute"
                    ]
                  },
                  "text": {
                    "type": "string",
                    "enum": [
                      "message"
                    ]
                  }
                },
                "required": [
                  "data",
                  "talk",
                  "text"
                ],
                "description": "無單位數值分別按 MB、分鐘、條讀取；原有帶單位字串保留原樣。"
              },
              "service_period": {
                "$ref": "#/components/schemas/ServicePeriod"
              },
              "current_usage": {
                "type": "object",
                "nullable": true,
                "additionalProperties": false,
                "properties": {
                  "from": {
                    "type": "string",
                    "format": "date"
                  },
                  "to": {
                    "type": "string",
                    "format": "date"
                  },
                  "data_used": {
                    "type": "string",
                    "nullable": true
                  },
                  "talk_used": {
                    "type": "string",
                    "nullable": true
                  },
                  "text_used": {
                    "type": "string",
                    "nullable": true
                  },
                  "timestamp": {
                    "type": "string",
                    "format": "date-time",
                    "nullable": true
                  }
                },
                "required": [
                  "from",
                  "to",
                  "data_used",
                  "talk_used",
                  "text_used",
                  "timestamp"
                ],
                "description": "當期計費用量；頂層 *_used 使用相同數值。未知或混入週期開始前用量的項目保留 null。"
              }
            },
            "nullable": true,
            "description": "本期起始日至美東今天的用量，不使用預設 90 天彙總。整份用量無法取得時為 null。"
          },
          "partial": {
            "type": "boolean",
            "description": "線路結果已取得、整份用量未取得時為 true，原因見 usage_error。partial=false 時個別未知數值仍可能為 null。"
          },
          "usage_error": {
            "type": "object",
            "nullable": true,
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "LocalInventoryExpiry": {
        "type": "object",
        "additionalProperties": false,
        "description": "僅查本地庫，不呼叫上游、不提交業務、不扣款。同一身份與週期已有確認日期時優先採用；expiry_info 是歷史／推算的已購週期截止，不代表目前線路狀態或即時 service_period。當期查詢不抹去已成功購買的後續週期。依據不足或衝突保持未知。未使用空卡仍僅提供數量。",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "confirmed",
              "estimated",
              "unknown"
            ]
          },
          "expiry_date": {
            "type": "string",
            "nullable": true,
            "format": "date"
          },
          "expiry_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "expiry_date_range": {
            "type": "array",
            "nullable": true,
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "string",
              "format": "date"
            }
          },
          "source": {
            "type": "string",
            "nullable": true,
            "enum": [
              "saved_query",
              "receipt",
              "handling_history",
              null
            ]
          },
          "basis": {
            "type": "string",
            "nullable": true
          },
          "confirmed_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "current_cycle_end_date": {
            "type": "string",
            "nullable": true,
            "format": "date"
          },
          "current_cycle_status": {
            "type": "string",
            "enum": [
              "confirmed",
              "estimated",
              "unknown"
            ]
          },
          "date_timezone": {
            "type": "string",
            "enum": [
              "America/New_York"
            ]
          },
          "as_of_date": {
            "type": "string",
            "nullable": true,
            "format": "date"
          },
          "last_observed_at": {
            "type": "string",
            "nullable": true,
            "format": "date-time"
          },
          "identity_current": {
            "type": "boolean",
            "nullable": true
          },
          "reason": {
            "type": "string",
            "nullable": true
          }
        },
        "required": [
          "status",
          "expiry_date",
          "expiry_at",
          "expiry_date_range",
          "source",
          "basis",
          "confirmed_at",
          "current_cycle_end_date",
          "current_cycle_status",
          "date_timezone",
          "as_of_date",
          "last_observed_at",
          "identity_current",
          "reason"
        ]
      }
    }
  },
  "paths": {
    "/status": {
      "get": {
        "tags": [
          "查詢"
        ],
        "summary": "服務狀態",
        "security": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ServiceStatus"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "status": "operational",
                    "timestamp": "2026-10-03T20:00:00-04:00",
                    "mode": "live"
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "查詢完成",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__status",
        "description": "檢查平台入口是否運行，不代表每個業務請求都會成功。"
      }
    },
    "/auth": {
      "post": {
        "tags": [
          "相容接入"
        ],
        "summary": "取得存取權杖（可選相容）",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "partner_id",
                  "api_key"
                ],
                "properties": {
                  "partner_id": {
                    "type": "string",
                    "example": "your_partner_id",
                    "description": "平台分配的渠道代碼。",
                    "minLength": 1,
                    "maxLength": 32
                  },
                  "api_key": {
                    "type": "string",
                    "description": "平台發放的固定 API Key；日常請求放在 X-API-Key 標頭，無需換取權杖。",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Token"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "已簽發存取權杖",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "post__auth",
        "description": "僅供已使用臨時 token 的接入繼續相容；新接入直接使用帳戶和固定 Key，不需要呼叫此介面。相容 token 有效期 30 分鐘，使用 `Authorization: Bearer <token>`，不要與固定 Key 標頭同時發送。此介面按來源位址與渠道帳戶組合限流，每分鐘最多 20 次；未知帳戶按來源位址合併限流。"
      }
    },
    "/customers": {
      "get": {
        "tags": [
          "查詢"
        ],
        "summary": "按 ICCID、手機號碼或 Enrollment ID 查詢線路",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mdn",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            },
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          },
          {
            "name": "esn",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "ICCID（推薦），18–22 位數字字串。esn、mdn、enrollment_id 必須且只能提供一個查詢鍵。"
          },
          {
            "name": "enrollment_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "已登記線路的 Enrollment ID；本查詢只能從 enrollment_id、esn、mdn 中選擇一個標識，不可同時傳入。先找到對應 ICCID 再查詢；回傳的 Enrollment ID 必須與請求一致，否則返回標識不一致錯誤。"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CustomerLine"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "查詢完成",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "多筆記錄符合識別資料，但無法確定目前的 SIM，請核實號碼與卡號對應記錄。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__customers",
        "description": "esn、mdn、enrollment_id 必須且只能提供一個查詢鍵，並且線路必須已歸屬本渠道。\n\n先確認 data.found=true，且返回號碼和 ICCID 與目標線路一致，再讀取 data.status：Active 表示線路目前啟用，選擇 POST /jobs/renewals；Inactive 表示既有線路目前停用，選擇 POST /jobs/reactivations。僅忽略大小寫和首尾空白後完整比對，不用 active 子字串比對。未找到、未知或缺失狀態、查詢失敗及標識衝突時先核實，不自動下單。渠道按需查詢並選擇業務，平台不自動改換介面；不要求定時查詢。此處是線路狀態，不是 SIM 庫存狀態。區分業務不要求先取得到期日；查詢不保證返回到期日，日期缺失不代表已過期，timestamp 或 finished_at 不能當作到期日。\n\n按 mdn 查詢時，平台先以本渠道已確認的手機號碼對應記錄取得 ICCID，再查詢該 ICCID 的線路資料，不會按手機號碼改查其他 SIM。沒有對應記錄或無法唯一確定 ICCID 時，先核實或使用明確的 esn。回傳 ICCID 與手機號碼仍須一致；查詢不改寫綁定或歷史訂單。\n\n線路及庫存狀態查詢預設即時執行並保存本次有效結果。ICCID、渠道歸屬、目錄地址等已確認基礎資料從本地讀取；狀態、WFC 及到期欄位使用本次查詢回應，不從舊記錄補值。\n\n依據客戶／線路查詢的 data.status 選擇續費或重新啟用。WFC 及到期欄位可能缺省或為 null，以本次回應為準，不依據舊記錄或日期推算。庫存 ACTIVE 不能代替線路 Active。\n\n推薦使用 esn（ICCID）查詢目標 SIM 的線路資料。亦支援已登記的 mdn 或 enrollment_id，三個查詢鍵必須且只能提供一個；預設即時查詢。 平台先核實渠道歸屬，使用原登記帳號按 ICCID 查詢。若未找到線路、資料不完整或身份不符，再依序使用已登記的原登記編號、原手機號碼。缺少的標識會跳過。每次只傳一個標識，每個標識最多查一次。取得完整且符合原卡的資料即停止。遇到限流、逾時或暫時網路錯誤立即返回並記錄，不通知員工。身份衝突仍未解決、帳號或平台故障時記錄異常。\n\n依時間返回當期與已核實的後續週期。中間週期以匹配的原續費及上游日期證據為準；缺失或衝突時不推算。"
      }
    },
    "/mdns/{mdn}": {
      "get": {
        "tags": [
          "查詢"
        ],
        "summary": "按手機號碼查詢線路",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mdn",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            },
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CustomerLine"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "查詢完成",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "多筆記錄符合識別資料，但無法確定目前的 SIM，請核實號碼與卡號對應記錄。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__mdns_mdn_",
        "description": "先確認 data.found=true，且返回號碼和 ICCID 與目標線路一致，再讀取 data.status：Active 表示線路目前啟用，選擇 POST /jobs/renewals；Inactive 表示既有線路目前停用，選擇 POST /jobs/reactivations。僅忽略大小寫和首尾空白後完整比對，不用 active 子字串比對。未找到、未知或缺失狀態、查詢失敗及標識衝突時先核實，不自動下單。渠道按需查詢並選擇業務，平台不自動改換介面；不要求定時查詢。此處是線路狀態，不是 SIM 庫存狀態。區分業務不要求先取得到期日；查詢不保證返回到期日，日期缺失不代表已過期，timestamp 或 finished_at 不能當作到期日。\n\n按 mdn 查詢時，平台先以本渠道已確認的手機號碼對應記錄取得 ICCID，再查詢該 ICCID 的線路資料，不會按手機號碼改查其他 SIM。沒有對應記錄或無法唯一確定 ICCID 時，先核實或使用明確的 esn。回傳 ICCID 與手機號碼仍須一致；查詢不改寫綁定或歷史訂單。\n\n線路及庫存狀態查詢預設即時執行並保存本次有效結果。ICCID、渠道歸屬、目錄地址等已確認基礎資料從本地讀取；狀態、WFC 及到期欄位使用本次查詢回應，不從舊記錄補值。\n\n依據客戶／線路查詢的 data.status 選擇續費或重新啟用。WFC 及到期欄位可能缺省或為 null，以本次回應為準，不依據舊記錄或日期推算。庫存 ACTIVE 不能代替線路 Active。 平台先核實渠道歸屬，使用原登記帳號按 ICCID 查詢。若未找到線路、資料不完整或身份不符，再依序使用已登記的原登記編號、原手機號碼。缺少的標識會跳過。每次只傳一個標識，每個標識最多查一次。取得完整且符合原卡的資料即停止。遇到限流、逾時或暫時網路錯誤立即返回並記錄，不通知員工。身份衝突仍未解決、帳號或平台故障時記錄異常。\n\n依時間返回當期與已核實的後續週期。中間週期以匹配的原續費及上游日期證據為準；缺失或衝突時不推算。"
      }
    },
    "/mdns/{mdn}/usage": {
      "get": {
        "tags": [
          "查詢"
        ],
        "summary": "查詢用量",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mdn",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            },
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          },
          {
            "name": "summary",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Usage"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "查詢完成",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "未找到本渠道的資料",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "多筆記錄符合識別資料，但無法確定目前的 SIM，請核實號碼與卡號對應記錄。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__mdns_mdn_usage",
        "description": "查詢最近 90 天用量，預設 summary=true。先按本渠道對應 ICCID 核對手機號碼，一致後才查詢該號碼用量；標識不一致或線路未找到時不查詢用量。按日查詢時同時提供 from、to，不能與 summary=true 同用。缺失欄位或 null 不代表零用量。\n\n用量始終即時查詢。剛完成的一分鐘內同帳號、同 ICCID、同號碼身分核驗可複用；發生新辦理、標識變化或衝突則重新核驗。此限制只用於用量前的身分核驗，不會觸發定時刷新。\n\n當期額度：data_limit／talk_limit／text_limit 採用已核實線路的當期 plan_data／plan_talk／plan_sms。有效的上游餘量（包括 0）優先採用；未提供時按 max(總額度－本期計費用量, 0) 返回餘量。不限量以 *_unlimited=true 表示，不使用數字額度。單位、用量或週期邊界不明時保持 null。短訊收發共用額度，通話已用量包含計費語音信箱分鐘。預設 summary=true 保留原有 90 天用量和明細；缺少餘量時，同次同步請求最多補查一次本期用量並放在 current_usage。補查失敗時該餘量保持未知，原成功查詢仍正常返回。指定日期查詢只有在覆蓋美東當期起始日至今天時補齊額度；歷史和部分區間保留原值。下期已購資源不加入本期總量。這些數值不用於判定線路狀態或觸發辦理。"
      }
    },
    "/esns/{esn}/status": {
      "get": {
        "tags": [
          "查詢"
        ],
        "summary": "查詢 SIM 庫存狀態",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "esn",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ICCID，18–22 位數字字串。請保留前導零，不要使用數字類型或科學記號。"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/InventoryStatus"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "查詢完成",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__esns_esn_status",
        "description": "查詢 SIM 庫存狀態，不是線路的目前啟用狀態。FREE 只表示庫存標記為 Free；例如 FREE 與 provision_status=Used 可以同時出現，表示該卡有使用記錄，原線路可能已停機，不代表新卡或可直接首次激活。data.status=ACTIVE 也不等於線路 Active。判斷續費或重新啟用，請使用 GET /customers?esn={ICCID}（推薦）或 GET /mdns/{mdn} 的線路 data.status，並確認 found=true 及返回識別資料匹配；庫存狀態及 message 都不能代替該線路結果。NOTFOUND 和 ERROR 也不能當作線路 Inactive。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n線路及庫存狀態查詢預設即時執行並保存本次有效結果。ICCID、渠道歸屬、目錄地址等已確認基礎資料從本地讀取；狀態、WFC 及到期欄位使用本次查詢回應，不從舊記錄補值。\n\n依據客戶／線路查詢的 data.status 選擇續費或重新啟用。WFC 及到期欄位可能缺省或為 null，以本次回應為準，不依據舊記錄或日期推算。庫存 ACTIVE 不能代替線路 Active。"
      }
    },
    "/jobs/activations": {
      "post": {
        "tags": [
          "業務辦理"
        ],
        "summary": "提交開卡",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "僅在請求體未傳 txid 時使用；優先使用 JSON txid。"
          },
          {
            "name": "txid",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActivationRequest"
              },
              "examples": {
                "single": {
                  "value": {
                    "txid": "channel-activation-001",
                    "items": [
                      {
                        "esn": "89000000000000000001",
                        "catalog_entry_id": "CATALOG_ENTRY_ID"
                      }
                    ]
                  }
                },
                "batch": {
                  "value": {
                    "txid": "channel-activation-002",
                    "items": [
                      {
                        "esn": "89000000000000000001",
                        "catalog_entry_id": "CATALOG_ENTRY_ID"
                      },
                      {
                        "esn": "89000000000000000002",
                        "catalog_entry_id": "CATALOG_ENTRY_ID"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-activation-001",
                      "partner_id": "your_channel",
                      "type": "activation",
                      "status": "failed",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 1,
                        "pending": 0
                      },
                      "billing": {
                        "amount": "0.00",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-activation-001",
                        "txid": "channel-activation-001",
                        "esn": "89000000000000000001",
                        "status": "failed",
                        "result": {
                          "error_code": "CATALOG_ENTRY_NOT_FOUND",
                          "error": "Catalog entry was not found.",
                          "retryable": false
                        },
                        "billing": {
                          "price": "0.00",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        }
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-activation-001"
                  }
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-activation-001",
                      "partner_id": "your_channel",
                      "type": "activation",
                      "status": "queued",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 0,
                        "pending": 1
                      },
                      "billing": {
                        "amount": "2.60",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-activation-001",
                        "txid": "channel-activation-001",
                        "esn": "89000000000000000001",
                        "status": "pending",
                        "result": null,
                        "billing": {
                          "price": "2.60",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        }
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-activation-001"
                  }
                }
              }
            },
            "description": "任務已受理，等待最終結果",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放 渠道已關閉套餐時返回 PLAN_DISABLED，受理前整批拒絕，不建立訂單、不扣款、不辦理激活。已受理任務繼續；續費、重新激活及 Wi-Fi Calling 不受此開關影響。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "交易號衝突或狀態衝突",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "post__jobs_activations",
        "description": "校驗當前業務條件、可辦理明細的總報價後受理；逐卡業務錯誤只影響該卡，其餘明細繼續同批辦理。同一 txid 重複返回 409，請查詢原任務。所有辦理統一非同步排隊，任務保存後返回 202；全部明細本地校驗失敗時返回 200 及失敗結果。200 不代表業務成功，須檢查逐卡狀態。已驗簽並關聯目前辦理的逐卡最終回呼直接更新結果；未確認結果缺失、不完整或衝突時補查原批次，不重複辦理。開卡限流補救的已核驗延遲成功按開卡說明更正；其他終態衝突保留結算並記錄異常待核實。\n\n系統更新或處理程序中斷後，已保存的未完成任務自動恢復，無需重提或呼叫 resume。尚未發送的繼續排隊；已經發送但結果未確認的只查詢原任務；已完成業務不重新辦理或扣款，未確認送達的回呼按原事件繼續投遞。需人工確認及明確業務失敗仍按相應錯誤處理，不會因重啟繞過。查詢介面和資料同步介面直接返回查詢結果，不創建辦理任務。\n\n每條明細必須傳 esn（ICCID）和 catalog_entry_id。僅支援目錄開卡，不接受 plan_code、mdn、zip、customer 或批次 defaults；多傳欄位返回參數錯誤，不會忽略。每張卡可選擇不同目錄記錄，受理時保存目前套餐、地址和報價。\n\n首次激活不要求預先匯入庫存或分配渠道。通過本次目錄、狀態和報價校驗的明細，歸屬到認證憑證對應的提交渠道；無效明細不改變原歸屬。已激活或仍在辦理的卡不能透過首次激活轉移歸屬。續費、重新啟用和查詢仍校驗已登記的渠道歸屬。\n\n資料完整的明細校驗報價後正常受理辦理；缺少必要線路資料的明細先保存為 pending，再單獨非同步補查，不阻塞其餘明細。補查階段不發送業務、不扣款。billing.quote_pending=true 表示報價尚未確定，price 暫為 0.00，批次 amount 僅含已確定的報價，不代表免費。補齊後保存當時渠道售價並進入辦理，餘額可為負數。補資料最多查一次。不能核實線路或帳號時返回該明細錯誤，不發送辦理。\n\n批次中的單條線路查詢或資料校驗失敗時，該條保留失敗原因和原始序號，其餘有效明細繼續處理。只有成功明細扣款，允許負數餘額。認證、整批參數、交易號重複、重複卡號仍拒絕整批。未找到卡號的失敗明細 esn=null，多條請求的逐條 txid 後綴為 _line加原始序號（從1開始）；已確認卡號仍使用卡號後8位後綴。\n\n僅適用於新受理的開卡明細：辦理結果明確返回 failed、error_code=rate_limited 且 retryable=true 時，平台依據已確認的失敗回執在原渠道批次內直接更換目錄補救，最多兩次；不設補救冷卻，不重複首次受理的查重或 SIM 空閒檢查，不額外查詢原任務或 SIM 庫存。已明確失敗的卡直接進入下一輪，不等待同批其他卡的結果；原帳號、歸屬、目錄和報價保持有效。每次優先從最近有成功記錄的開卡批次中，隨機選擇一筆可用且尚未嘗試的同套餐目錄及地址；不限渠道、可跨日期，該批次沒有合適目錄時再依序查找前面的批次；報價、ICCID 與渠道任務編號保持。無候選或兩次仍失敗時，回呼最後已確認結果並記錄異常。補救中返回 running/pending、next_action=wait，暫不發送最終失敗回呼；確認成功只扣款一次。收到原任務或任一補救輪次已核驗的成功回執，立即停止該卡後續補救，按原渠道批次和明細編號通知成功；若此前已通知失敗，再發送成功更正，整批結束時彙總最終結果。重複回執不重複結算；已發出的請求無法撤回，其他輪次後到結果不覆蓋已確認成功。本規則不繞過介面實際 HTTP 429 的 Retry-After 及通用請求排程。逾時或結果未明只查原任務，不更換目錄；渠道請勿重複提交。\n\n批次提交使用一個外層 txid，items 中每張卡或每個手機號碼一個物件，逐卡交易號由平台產生。選擇 batch 範例查看多條請求。每批至少一條，不設固定條數上限，整個 JSON 不超過 200,000 字節。保存返回的 data.job.id；GET /jobs/{id} 可用任務號或原批次 txid 一次查詢整批。HTTP 200 或 202 都不能代替逐條狀態判斷；提交逾時或重複 txid 時查原單，不換交易號重送整批。\n\n業務確認成功後才按受理報價扣款，每條明細只扣一次；失敗不扣款，受理及排隊時不凍結或提前扣款。帳戶餘額可以為負數，餘額不足不阻擋受理或辦理；儲值增加餘額。渠道被人工暫停或停用時不能繼續發送新業務。WFC 免費，僅記帳帳戶保留既有計費約定。\n\n自動補救結束後，已確認的失敗按原批次、原明細回呼並記錄異常，無需員工批准。已成功的明細照常回呼並按受理報價結算一次。內部 Wi-Fi Calling 補救獨立執行，不會延遲成功回呼，也沒有單獨的渠道回呼。 辦理前補資料每條最多查一次。無法核實時，該明細按本次錯誤結束並回呼，費用為零，其他明細繼續。已提交且結果未明的辦理仍保持處理中，只核對原任務。",
        "callbacks": {
          "businessResult": {
            "{$request.body#/webhook_url}": {
              "post": {
                "summary": "接收業務事件（由平台發送）",
                "security": [],
                "description": "回呼使用獨立 Webhook Secret 驗簽，不發送渠道帳戶或 API Key。對原始請求體計算 HMAC-SHA256，不拼接時間戳；created_at 為事件建立時間。平台在事件落庫後立即觸發投遞，待發通知連續發送，不設每秒或每輪固定條數限制；實際投遞時間取決於接收方與網路。首次投遞失敗後，平台最多自動重試 5 次，間隔為 30、60、120、240、480 秒，指數退避上限為 15 分鐘，包括首次在內最多投遞 6 次。平台重投原事件，不重新辦理業務或扣款。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。",
                "parameters": [
                  {
                    "name": "X-RM-Event",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "enum": [
                        "activation.item.succeeded",
                        "activation.item.failed",
                        "activation.item.updated",
                        "activation.job.completed"
                      ]
                    },
                    "description": "與 JSON type 一致。"
                  },
                  {
                    "name": "X-RM-Delivery-Id",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "example": "delivery_example"
                    },
                    "description": "本次投遞嘗試編號，重投時改變；使用 JSON id 作為穩定事件去重鍵。"
                  },
                  {
                    "name": "X-RM-Signature",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "pattern": "^sha256=[a-f0-9]{64}$"
                    },
                    "description": "sha256= 加原始請求體的 HMAC-SHA256 十六進制簽名；密鑰為渠道 Webhook Secret。"
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "已驗簽、持久化並去重"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/jobs/reactivations": {
      "post": {
        "tags": [
          "業務辦理"
        ],
        "summary": "提交重新啟用",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "僅在請求體未傳 txid 時使用；優先使用 JSON txid。"
          },
          {
            "name": "txid",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReactivationRequest"
              },
              "examples": {
                "single": {
                  "value": {
                    "txid": "channel-reactivation-001",
                    "items": [
                      {
                        "esn": "89000000000000000001"
                      }
                    ]
                  }
                },
                "batch": {
                  "value": {
                    "txid": "channel-reactivation-002",
                    "items": [
                      {
                        "mdn": "2025550100"
                      },
                      {
                        "mdn": "2025550101"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-reactivation-001",
                      "partner_id": "your_channel",
                      "type": "reactivation",
                      "status": "failed",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 1,
                        "pending": 0
                      },
                      "billing": {
                        "amount": "0.00",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-reactivation-001",
                        "txid": "channel-reactivation-001",
                        "esn": "89000000000000000001",
                        "status": "failed",
                        "result": {
                          "error_code": "INVALID_ADDRESS",
                          "error": "Invalid address.",
                          "retryable": false
                        },
                        "billing": {
                          "price": "0.00",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        },
                        "confirmed_through_date": null
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-reactivation-001"
                  }
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-reactivation-001",
                      "partner_id": "your_channel",
                      "type": "reactivation",
                      "status": "queued",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 0,
                        "pending": 1
                      },
                      "billing": {
                        "amount": "2.60",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-reactivation-001",
                        "txid": "channel-reactivation-001",
                        "esn": "89000000000000000001",
                        "status": "pending",
                        "result": null,
                        "billing": {
                          "price": "2.60",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        },
                        "confirmed_through_date": null
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-reactivation-001"
                  }
                }
              }
            },
            "description": "任務已受理，等待最終結果",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "交易號衝突或狀態衝突",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "post__jobs_reactivations",
        "description": "恢復曾經激活、目前已停用的線路。渠道按線路查詢結果選擇業務時，data.status=Inactive 呼叫本介面，Active 選擇 POST /jobs/renewals。Inactive 不代表 SIM 從未激活，也不保證一定能恢復。本介面不使用 change_type；平台不會自動改換已提交的業務類型，最終以逐卡結果為準。\n\n校驗當前業務條件、可辦理明細的總報價後受理；逐卡業務錯誤只影響該卡，其餘明細繼續同批辦理。同一 txid 重複返回 409，請查詢原任務。所有辦理統一非同步排隊，任務保存後返回 202；全部明細本地校驗失敗時返回 200 及失敗結果。200 不代表業務成功，須檢查逐卡狀態。已驗簽並關聯目前辦理的逐卡最終回呼直接更新結果；未確認結果缺失、不完整或衝突時補查原批次，不重複辦理。開卡限流補救的已核驗延遲成功按開卡說明更正；其他終態衝突保留結算並記錄異常待核實。\n\n系統更新或處理程序中斷後，已保存的未完成任務自動恢復，無需重提或呼叫 resume。尚未發送的繼續排隊；已經發送但結果未確認的只查詢原任務；已完成業務不重新辦理或扣款，未確認送達的回呼按原事件繼續投遞。需人工確認及明確業務失敗仍按相應錯誤處理，不會因重啟繞過。查詢介面和資料同步介面直接返回查詢結果，不創建辦理任務。\n\n資料完整的明細校驗報價後正常受理辦理；缺少必要線路資料的明細先保存為 pending，再單獨非同步補查，不阻塞其餘明細。補查階段不發送業務、不扣款。billing.quote_pending=true 表示報價尚未確定，price 暫為 0.00，批次 amount 僅含已確定的報價，不代表免費。補齊後保存當時渠道售價並進入辦理，餘額可為負數。補資料最多查一次。不能核實線路或帳號時返回該明細錯誤，不發送辦理。\n\n僅傳 mdn 時，平台從已有線路及成功訂單定位 ICCID。沒有唯一對應關係時返回 LINE_IDENTITY_CONFLICT，不會搜尋或使用另一張 SIM；其餘有效明細繼續。\n\n批次中的單條線路查詢或資料校驗失敗時，該條保留失敗原因和原始序號，其餘有效明細繼續處理。只有成功明細扣款，允許負數餘額。認證、整批參數、交易號重複、重複卡號仍拒絕整批。未找到卡號的失敗明細 esn=null，多條請求的逐條 txid 後綴為 _line加原始序號（從1開始）；已確認卡號仍使用卡號後8位後綴。\n\n辦理前補資料每條最多查一次。無法核實時，該明細按本次錯誤結束並回呼，費用為零，其他明細繼續。已提交且結果未明的辦理仍保持處理中，只核對原任務。\n\n批次提交使用一個外層 txid，items 中每張卡或每個手機號碼一個物件，逐卡交易號由平台產生。選擇 batch 範例查看多條請求。每批至少一條，不設固定條數上限，整個 JSON 不超過 200,000 字節。保存返回的 data.job.id；GET /jobs/{id} 可用任務號或原批次 txid 一次查詢整批。HTTP 200 或 202 都不能代替逐條狀態判斷；提交逾時或重複 txid 時查原單，不換交易號重送整批。\n\n業務確認成功後才按受理報價扣款，每條明細只扣一次；失敗不扣款，受理及排隊時不凍結或提前扣款。帳戶餘額可以為負數，餘額不足不阻擋受理或辦理；儲值增加餘額。渠道被人工暫停或停用時不能繼續發送新業務。WFC 免費，僅記帳帳戶保留既有計費約定。\n\n推薦每條 items 使用 esn（ICCID）識別線路。亦可使用已登記的 mdn 或 enrollment_id，不要求同時傳多個標識；同傳時必須對應同一張卡。\n\n自動補救結束後，已確認的失敗按原批次、原明細回呼並記錄異常，無需員工批准。已成功的明細照常回呼並按受理報價結算一次。內部 Wi-Fi Calling 補救獨立執行，不會延遲成功回呼，也沒有單獨的渠道回呼。 辦理前補資料每條最多查一次。無法核實時，該明細按本次錯誤結束並回呼，費用為零，其他明細繼續。已提交且結果未明的辦理仍保持處理中，只核對原任務。\n\n重新啟用每筆只傳經核實的 esn、mdn 和 enrollment_id。地址與郵編為選填卡檔資料。明確指定的完整 service_address 會在成功後存入卡檔。\n\n續費、重新啟用及自動辦理的 confirmed_through_date 位於查單的 data.items[]、明細介面的 data[] 及逐筆回呼的 data。後續 item.updated 可補上日期，最新結果可查原任務。",
        "callbacks": {
          "businessResult": {
            "{$request.body#/webhook_url}": {
              "post": {
                "summary": "接收業務事件（由平台發送）",
                "security": [],
                "description": "回呼使用獨立 Webhook Secret 驗簽，不發送渠道帳戶或 API Key。對原始請求體計算 HMAC-SHA256，不拼接時間戳；created_at 為事件建立時間。平台在事件落庫後立即觸發投遞，待發通知連續發送，不設每秒或每輪固定條數限制；實際投遞時間取決於接收方與網路。首次投遞失敗後，平台最多自動重試 5 次，間隔為 30、60、120、240、480 秒，指數退避上限為 15 分鐘，包括首次在內最多投遞 6 次。平台重投原事件，不重新辦理業務或扣款。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。",
                "parameters": [
                  {
                    "name": "X-RM-Event",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "enum": [
                        "reactivation.item.succeeded",
                        "reactivation.item.failed",
                        "reactivation.item.updated",
                        "reactivation.job.completed"
                      ]
                    },
                    "description": "與 JSON type 一致。"
                  },
                  {
                    "name": "X-RM-Delivery-Id",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "example": "delivery_example"
                    },
                    "description": "本次投遞嘗試編號，重投時改變；使用 JSON id 作為穩定事件去重鍵。"
                  },
                  {
                    "name": "X-RM-Signature",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "pattern": "^sha256=[a-f0-9]{64}$"
                    },
                    "description": "sha256= 加原始請求體的 HMAC-SHA256 十六進制簽名；密鑰為渠道 Webhook Secret。"
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      },
                      "examples": {
                        "reactivation_without_date": {
                          "value": {
                            "id": "evt_reactivation_example",
                            "type": "reactivation.item.succeeded",
                            "created_at": "2026-10-17T02:00:00-04:00",
                            "data": {
                              "job_id": "ord_reactivation_example",
                              "item_id": "item_reactivation_example",
                              "txid": "channel-reactivation-001",
                              "job_txid": "channel-reactivation-001",
                              "esn": "89000000000000000001",
                              "status": "succeeded",
                              "result_revision": 1,
                              "confirmed_through_date": null,
                              "service_period": {
                                "status": "unknown",
                                "source": "upstream",
                                "period_kind": "current",
                                "date_timezone": "America/New_York",
                                "effective_date": null,
                                "expiry_date": null,
                                "current_cycle_end_date": null
                              }
                            }
                          }
                        },
                        "reactivation_result_updated": {
                          "value": {
                            "id": "evt_reactivation_update",
                            "type": "reactivation.item.updated",
                            "created_at": "2026-10-17T02:00:10-04:00",
                            "data": {
                              "job_id": "ord_reactivation_example",
                              "item_id": "item_reactivation_example",
                              "txid": "channel-reactivation-001",
                              "job_txid": "channel-reactivation-001",
                              "esn": "89000000000000000001",
                              "status": "succeeded",
                              "result_revision": 2,
                              "confirmed_through_date": "2026-11-17",
                              "service_period": {
                                "status": "confirmed",
                                "source": "upstream",
                                "period_kind": "current",
                                "date_timezone": "America/New_York",
                                "effective_date": "2026-10-17",
                                "expiry_date": "2026-11-17",
                                "current_cycle_end_date": "2026-11-17"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "已驗簽、持久化並去重"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/jobs/renewals": {
      "post": {
        "tags": [
          "業務辦理"
        ],
        "summary": "提交續費",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "僅在請求體未傳 txid 時使用；優先使用 JSON txid。"
          },
          {
            "name": "txid",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenewalRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-renewal-001",
                      "partner_id": "your_channel",
                      "type": "renewal",
                      "status": "failed",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 1,
                        "pending": 0
                      },
                      "billing": {
                        "amount": "0.00",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-renewal-001",
                        "txid": "channel-renewal-001",
                        "esn": "89000000000000000001",
                        "status": "failed",
                        "result": {
                          "error_code": "CURRENT_PLAN_UNKNOWN",
                          "error": "Current plan is unknown.",
                          "retryable": false,
                          "service_period": null
                        },
                        "billing": {
                          "price": "0.00",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        },
                        "confirmed_through_date": null
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-renewal-001"
                  }
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-renewal-001",
                      "partner_id": "your_channel",
                      "type": "renewal",
                      "status": "queued",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 0,
                        "pending": 1
                      },
                      "billing": {
                        "amount": "2.60",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-renewal-001",
                        "txid": "channel-renewal-001",
                        "esn": "89000000000000000001",
                        "status": "pending",
                        "result": null,
                        "billing": {
                          "price": "2.60",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        },
                        "confirmed_through_date": null
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-renewal-001"
                  }
                }
              }
            },
            "description": "任務已受理，等待最終結果",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "交易號衝突或狀態衝突",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "post__jobs_renewals",
        "description": "續套餐週期。渠道按線路查詢結果選擇業務時，data.status=Active 呼叫本介面，Inactive 選擇 POST /jobs/reactivations。change_type=IMMEDIATE 為即日續費，ONEXPIRY 為到期續費，兩者均不代替重新啟用。平台不會自動改換已提交的業務類型；最終以逐卡結果為準。\n\n校驗當前業務條件、可辦理明細的總報價後受理；逐卡業務錯誤只影響該卡，其餘明細繼續同批辦理。同一 txid 重複返回 409，請查詢原任務。所有辦理統一非同步排隊，任務保存後返回 202；全部明細本地校驗失敗時返回 200 及失敗結果。200 不代表業務成功，須檢查逐卡狀態。已驗簽並關聯目前辦理的逐卡最終回呼直接更新結果；未確認結果缺失、不完整或衝突時補查原批次，不重複辦理。開卡限流補救的已核驗延遲成功按開卡說明更正；其他終態衝突保留結算並記錄異常待核實。\n\n系統更新或處理程序中斷後，已保存的未完成任務自動恢復，無需重提或呼叫 resume。尚未發送的繼續排隊；已經發送但結果未確認的只查詢原任務；已完成業務不重新辦理或扣款，未確認送達的回呼按原事件繼續投遞。需人工確認及明確業務失敗仍按相應錯誤處理，不會因重啟繞過。查詢介面和資料同步介面直接返回查詢結果，不創建辦理任務。\n\n資料完整的明細校驗報價後正常受理辦理；缺少必要線路資料的明細先保存為 pending，再單獨非同步補查，不阻塞其餘明細。補查階段不發送業務、不扣款。billing.quote_pending=true 表示報價尚未確定，price 暫為 0.00，批次 amount 僅含已確定的報價，不代表免費。補齊後保存當時渠道售價並進入辦理，餘額可為負數。補資料最多查一次。不能核實線路或帳號時返回該明細錯誤，不發送辦理。\n\n每次續費只辦理一個套餐週期，不接受月數或指定日期。連續到期續費由渠道依次提交多筆 ONEXPIRY，每筆使用新的 txid；同一號碼必須確認上一筆 succeeded 且實際到期日延長後再提交，失敗即停止。結果未明只查詢原任務；到期日缺失或未延長時先核實，不並發或更換交易號重發原業務。每筆請求保存實際報價，餘額不足不阻止辦理；按實際成功明細扣款，不凍結資金。不需計算 30 天。\n\n僅傳 mdn 時，平台從已有線路及成功訂單定位 ICCID。沒有唯一對應關係時返回 LINE_IDENTITY_CONFLICT，不會搜尋或使用另一張 SIM；其餘有效明細繼續。\n\n批次中的單條線路查詢或資料校驗失敗時，該條保留失敗原因和原始序號，其餘有效明細繼續處理。只有成功明細扣款，允許負數餘額。認證、整批參數、交易號重複、重複卡號仍拒絕整批。未找到卡號的失敗明細 esn=null，多條請求的逐條 txid 後綴為 _line加原始序號（從1開始）；已確認卡號仍使用卡號後8位後綴。\n\n辦理前補資料每條最多查一次。無法核實時，該明細按本次錯誤結束並回呼，費用為零，其他明細繼續。已提交且結果未明的辦理仍保持處理中，只核對原任務。\n\n業務確認成功後才按受理報價扣款，每條明細只扣一次；失敗不扣款，受理及排隊時不凍結或提前扣款。帳戶餘額可以為負數，餘額不足不阻擋受理或辦理；儲值增加餘額。渠道被人工暫停或停用時不能繼續發送新業務。WFC 免費，僅記帳帳戶保留既有計費約定。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n推薦每條 items 使用 esn（ICCID）識別線路。亦可使用已登記的 mdn 或 enrollment_id，不要求同時傳多個標識；同傳時必須對應同一張卡。\n\n自動補救結束後，已確認的失敗按原批次、原明細回呼並記錄異常，無需員工批准。已成功的明細照常回呼並按受理報價結算一次。內部 Wi-Fi Calling 補救獨立執行，不會延遲成功回呼，也沒有單獨的渠道回呼。 辦理前補資料每條最多查一次。無法核實時，該明細按本次錯誤結束並回呼，費用為零，其他明細繼續。已提交且結果未明的辦理仍保持處理中，只核對原任務。\n\n續費、重新啟用及自動辦理的 confirmed_through_date 位於查單的 data.items[]、明細介面的 data[] 及逐筆回呼的 data。後續 item.updated 可補上日期，最新結果可查原任務。",
        "callbacks": {
          "businessResult": {
            "{$request.body#/webhook_url}": {
              "post": {
                "summary": "接收業務事件（由平台發送）",
                "security": [],
                "description": "回呼使用獨立 Webhook Secret 驗簽，不發送渠道帳戶或 API Key。對原始請求體計算 HMAC-SHA256，不拼接時間戳；created_at 為事件建立時間。平台在事件落庫後立即觸發投遞，待發通知連續發送，不設每秒或每輪固定條數限制；實際投遞時間取決於接收方與網路。首次投遞失敗後，平台最多自動重試 5 次，間隔為 30、60、120、240、480 秒，指數退避上限為 15 分鐘，包括首次在內最多投遞 6 次。平台重投原事件，不重新辦理業務或扣款。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。",
                "parameters": [
                  {
                    "name": "X-RM-Event",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "enum": [
                        "renewal.item.succeeded",
                        "renewal.item.failed",
                        "renewal.item.updated",
                        "renewal.job.completed"
                      ]
                    },
                    "description": "與 JSON type 一致。"
                  },
                  {
                    "name": "X-RM-Delivery-Id",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "example": "delivery_example"
                    },
                    "description": "本次投遞嘗試編號，重投時改變；使用 JSON id 作為穩定事件去重鍵。"
                  },
                  {
                    "name": "X-RM-Signature",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "pattern": "^sha256=[a-f0-9]{64}$"
                    },
                    "description": "sha256= 加原始請求體的 HMAC-SHA256 十六進制簽名；密鑰為渠道 Webhook Secret。"
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      },
                      "examples": {
                        "renewal_success": {
                          "value": {
                            "id": "evt_renewal_example",
                            "type": "renewal.item.succeeded",
                            "created_at": "2026-10-17T02:00:00-04:00",
                            "data": {
                              "service_period": {
                                "status": "confirmed",
                                "date_timezone": "America/New_York",
                                "success_date": null,
                                "success_date_basis": null,
                                "effective_date": "2026-11-16",
                                "current_cycle_end_date": "2026-11-16",
                                "expiry_date": "2026-12-16",
                                "as_of_date": "2026-10-17",
                                "reason": null,
                                "source": "upstream",
                                "period_kind": "current"
                              },
                              "change_type": "ONEXPIRY",
                              "retryable": false,
                              "job_id": "ord_renewal_example",
                              "item_id": "item_renewal_example",
                              "job_txid": "channel-renewal-001",
                              "txid": "channel-renewal-001",
                              "esn": "89000000000000000001",
                              "status": "succeeded",
                              "plan_code": "97",
                              "plan_id": "6641",
                              "zip": "90034",
                              "started_at": "2026-10-17T01:59:58-04:00",
                              "finished_at": "2026-10-17T02:00:00-04:00",
                              "attempt_count": 1,
                              "result_revision": 1,
                              "confirmed_through_date": "2026-12-16"
                            }
                          }
                        },
                        "renewal_result_updated": {
                          "value": {
                            "id": "evt_renewal_update",
                            "type": "renewal.item.updated",
                            "created_at": "2026-10-17T02:00:10-04:00",
                            "data": {
                              "service_period": {
                                "status": "confirmed",
                                "date_timezone": "America/New_York",
                                "success_date": null,
                                "success_date_basis": null,
                                "effective_date": "2026-11-16",
                                "current_cycle_end_date": "2026-11-16",
                                "expiry_date": "2026-12-16",
                                "as_of_date": "2026-10-17",
                                "reason": null,
                                "source": "upstream",
                                "period_kind": "current"
                              },
                              "change_type": "ONEXPIRY",
                              "retryable": false,
                              "job_id": "ord_renewal_example",
                              "item_id": "item_renewal_example",
                              "job_txid": "channel-renewal-001",
                              "txid": "channel-renewal-001",
                              "esn": "89000000000000000001",
                              "status": "succeeded",
                              "plan_code": "97",
                              "plan_id": "6641",
                              "zip": "90034",
                              "started_at": "2026-10-17T01:59:58-04:00",
                              "finished_at": "2026-10-17T02:00:00-04:00",
                              "attempt_count": 1,
                              "result_revision": 2,
                              "confirmed_through_date": "2026-12-16"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "已驗簽、持久化並去重"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/jobs/wifi-calling": {
      "post": {
        "tags": [
          "業務辦理"
        ],
        "summary": "免費開啟 Wi-Fi Calling",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "僅在請求體未傳 txid 時使用；優先使用 JSON txid。"
          },
          {
            "name": "txid",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WifiCallingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-wfc-001",
                      "partner_id": "your_channel",
                      "type": "wifi_calling",
                      "status": "failed",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 1,
                        "pending": 0
                      },
                      "billing": {
                        "amount": "0.00",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-wfc-001",
                        "txid": "channel-wfc-001",
                        "esn": "89000000000000000001",
                        "status": "failed",
                        "result": {
                          "error_code": "INVALID_ADDRESS",
                          "error": "Invalid address.",
                          "retryable": false
                        },
                        "billing": {
                          "price": "0.00",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        }
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-wfc-001"
                  }
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "example": {
                  "data": {
                    "job": {
                      "id": "ord_example",
                      "txid": "channel-wfc-001",
                      "partner_id": "your_channel",
                      "type": "wifi_calling",
                      "status": "queued",
                      "totals": {
                        "total": 1,
                        "succeeded": 0,
                        "failed": 0,
                        "pending": 1
                      },
                      "billing": {
                        "amount": "0.00",
                        "charged_amount": "0.00",
                        "currency": "USD"
                      }
                    },
                    "items": [
                      {
                        "id": "item_example",
                        "job_id": "ord_example",
                        "job_txid": "channel-wfc-001",
                        "txid": "channel-wfc-001",
                        "esn": "89000000000000000001",
                        "status": "pending",
                        "result": null,
                        "billing": {
                          "price": "0.00",
                          "charged_amount": "0.00",
                          "currency": "USD"
                        }
                      }
                    ]
                  },
                  "meta": {
                    "request_id": "req_example",
                    "job_id": "ord_example",
                    "txid": "channel-wfc-001"
                  }
                }
              }
            },
            "description": "任務已受理，等待最終結果",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "交易號衝突或狀態衝突",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "post__jobs_wifi_calling",
        "description": "獨立開啟 WFC，僅支援 Active，不單獨收費，不扣渠道餘額。地址可省略，優先本次明確欄位、本地號卡已登記地址、同卡最近成功開卡地址；本地無有效地址時使用線路目前 WFC 或服務記錄。結果透過任務和回呼返回。\n\n傳 catalog_entry_id 時，平台校驗本渠道可用目錄，保存受理時的完整地址並用於 WFC 辦理；只使用所選地址，不改變號碼套餐，也不按目錄價格收費。目錄後續修改不影響已受理任務，包括補資料等待及重試。目錄不存在或不可用時該條失敗；不能與同條 customer 或 zip 同傳，批次 defaults 地址只作用於未傳目錄編碼的明細。不傳編碼時地址補齊規則保持不變。仍為非同步免費 WFC 辦理，以任務結果及回呼確認成功。\n\n資料完整的明細校驗報價後正常受理辦理；缺少必要線路資料的明細先保存為 pending，再單獨非同步補查，不阻塞其餘明細。補查階段不發送業務、不扣款。billing.quote_pending=true 表示報價尚未確定，price 暫為 0.00，批次 amount 僅含已確定的報價，不代表免費。補齊後保存當時渠道售價並進入辦理，餘額可為負數。補資料最多查一次。不能核實線路或帳號時返回該明細錯誤，不發送辦理。\n\n僅傳 mdn 時，平台從已有線路及成功訂單定位 ICCID。沒有唯一對應關係時返回 LINE_IDENTITY_CONFLICT，不會搜尋或使用另一張 SIM；其餘有效明細繼續。\n\nWFC 報價與扣款均為 0.00。每條返回其實際結果或錯誤，同批其他有效明細繼續。\n\n業務確認成功後才按受理報價扣款，每條明細只扣一次；失敗不扣款，受理及排隊時不凍結或提前扣款。帳戶餘額可以為負數，餘額不足不阻擋受理或辦理；儲值增加餘額。渠道被人工暫停或停用時不能繼續發送新業務。WFC 免費，僅記帳帳戶保留既有計費約定。\n\n自動補救結束後，已確認的失敗按原批次、原明細回呼並記錄異常，無需員工批准。已成功的明細照常回呼並按受理報價結算一次。內部 Wi-Fi Calling 補救獨立執行，不會延遲成功回呼，也沒有單獨的渠道回呼。 辦理前補資料每條最多查一次。無法核實時，該明細按本次錯誤結束並回呼，費用為零，其他明細繼續。已提交且結果未明的辦理仍保持處理中，只核對原任務。",
        "callbacks": {
          "businessResult": {
            "{$request.body#/webhook_url}": {
              "post": {
                "summary": "接收業務事件（由平台發送）",
                "security": [],
                "description": "回呼使用獨立 Webhook Secret 驗簽，不發送渠道帳戶或 API Key。對原始請求體計算 HMAC-SHA256，不拼接時間戳；created_at 為事件建立時間。平台在事件落庫後立即觸發投遞，待發通知連續發送，不設每秒或每輪固定條數限制；實際投遞時間取決於接收方與網路。首次投遞失敗後，平台最多自動重試 5 次，間隔為 30、60、120、240、480 秒，指數退避上限為 15 分鐘，包括首次在內最多投遞 6 次。平台重投原事件，不重新辦理業務或扣款。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。",
                "parameters": [
                  {
                    "name": "X-RM-Event",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "enum": [
                        "wifi_calling.item.succeeded",
                        "wifi_calling.item.failed",
                        "wifi_calling.item.updated",
                        "wifi_calling.job.completed"
                      ]
                    },
                    "description": "與 JSON type 一致。"
                  },
                  {
                    "name": "X-RM-Delivery-Id",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "example": "delivery_example"
                    },
                    "description": "本次投遞嘗試編號，重投時改變；使用 JSON id 作為穩定事件去重鍵。"
                  },
                  {
                    "name": "X-RM-Signature",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "pattern": "^sha256=[a-f0-9]{64}$"
                    },
                    "description": "sha256= 加原始請求體的 HMAC-SHA256 十六進制簽名；密鑰為渠道 Webhook Secret。"
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "已驗簽、持久化並去重"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/jobs": {
      "get": {
        "tags": [
          "任務"
        ],
        "summary": "查詢任務列表或按交易號查單",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "running",
                "succeeded",
                "failed",
                "partial"
              ]
            }
          },
          {
            "name": "txid",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。 自動辦理單一明細使用批次號，多條按輸入順序附加 _line1、_line2。"
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1,
              "minimum": 1,
              "maximum": 1000000
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 100,
              "minimum": 1,
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Job"
                          }
                        },
                        {
                          "$ref": "#/components/schemas/JobDetail"
                        }
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/ExtensionPagination"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "未找到本渠道的資料",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "交易號衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__jobs",
        "description": "列表回應附帶 pagination（page、per_page、total、has_more）。批次 txid 返回整批；逐條 txid 只返回該條明細。所有 GET 查單直接返回本地最新結果，不觸發額外服務查詢或辦理；背景處理程序及回呼持續更新結果。需要提前核實時呼叫原任務 recheck。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。\n\n續費、重新啟用及自動辦理的 confirmed_through_date 位於查單的 data.items[]、明細介面的 data[] 及逐筆回呼的 data。後續 item.updated 可補上日期，最新結果可查原任務。"
      }
    },
    "/jobs/{id}": {
      "get": {
        "tags": [
          "任務"
        ],
        "summary": "讀取任務及逐卡結果",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                },
                "examples": {
                  "batch_pending": {
                    "value": {
                      "data": {
                        "job": {
                          "id": "ord_batch_example",
                          "txid": "channel-reactivation-002",
                          "partner_id": "your_channel",
                          "type": "reactivation",
                          "status": "running",
                          "totals": {
                            "total": 2,
                            "succeeded": 1,
                            "failed": 0,
                            "pending": 1
                          },
                          "billing": {
                            "amount": "2.60",
                            "charged_amount": "2.60",
                            "currency": "USD",
                            "quote_pending": true
                          },
                          "attention_required": false
                        },
                        "items": [
                          {
                            "id": "item_batch_1",
                            "job_id": "ord_batch_example",
                            "job_txid": "channel-reactivation-002",
                            "txid": "channel-reactivation-002_00000001",
                            "esn": "89000000000000000001",
                            "request": {
                              "mdn": "2025550100"
                            },
                            "status": "succeeded",
                            "result": {
                              "mdn": "2025550100",
                              "retryable": false
                            },
                            "billing": {
                              "price": "2.60",
                              "charged_amount": "2.60",
                              "currency": "USD",
                              "quote_pending": false
                            }
                          },
                          {
                            "id": "item_batch_2",
                            "job_id": "ord_batch_example",
                            "job_txid": "channel-reactivation-002",
                            "txid": "channel-reactivation-002_00000002",
                            "esn": "89000000000000000002",
                            "request": {
                              "mdn": "2025550101"
                            },
                            "status": "pending",
                            "result": null,
                            "billing": {
                              "price": "0.00",
                              "charged_amount": "0.00",
                              "currency": "USD",
                              "quote_pending": true
                            },
                            "last_error": null
                          }
                        ]
                      },
                      "meta": {
                        "request_id": "req_batch_example",
                        "job_id": "ord_batch_example",
                        "txid": "channel-reactivation-002"
                      }
                    }
                  },
                  "renewal_success": {
                    "value": {
                      "data": {
                        "job": {
                          "id": "ord_renewal_example",
                          "txid": "channel-renewal-001",
                          "partner_id": "your_channel",
                          "type": "renewal",
                          "status": "succeeded",
                          "totals": {
                            "total": 1,
                            "succeeded": 1,
                            "failed": 0,
                            "pending": 0
                          },
                          "billing": {
                            "amount": "2.85",
                            "charged_amount": "2.85",
                            "currency": "USD"
                          }
                        },
                        "items": [
                          {
                            "id": "item_renewal_example",
                            "job_id": "ord_renewal_example",
                            "job_txid": "channel-renewal-001",
                            "txid": "channel-renewal-001",
                            "esn": "89000000000000000001",
                            "status": "succeeded",
                            "result": {
                              "service_period": {
                                "status": "confirmed",
                                "date_timezone": "America/New_York",
                                "success_date": null,
                                "success_date_basis": null,
                                "effective_date": "2026-11-16",
                                "current_cycle_end_date": "2026-11-16",
                                "expiry_date": "2026-12-16",
                                "as_of_date": "2026-10-17",
                                "reason": null,
                                "source": "upstream",
                                "period_kind": "current"
                              },
                              "change_type": "ONEXPIRY",
                              "retryable": false,
                              "plan_code": "97",
                              "plan_id": "6641",
                              "zip": "90034"
                            },
                            "billing": {
                              "price": "2.85",
                              "charged_amount": "2.85",
                              "currency": "USD"
                            },
                            "plan_code": "97",
                            "plan_id": "6641",
                            "zip": "90034",
                            "started_at": "2026-10-17T01:59:58-04:00",
                            "finished_at": "2026-10-17T02:00:00-04:00",
                            "attempt_count": 1,
                            "result_revision": 1,
                            "confirmed_through_date": "2026-12-16"
                          }
                        ]
                      },
                      "meta": {
                        "request_id": "req_example"
                      }
                    }
                  },
                  "renewal_without_date": {
                    "value": {
                      "data": {
                        "job": {
                          "id": "ord_renewal_example",
                          "txid": "channel-renewal-001",
                          "partner_id": "your_channel",
                          "type": "renewal",
                          "status": "succeeded",
                          "totals": {
                            "total": 1,
                            "succeeded": 1,
                            "failed": 0,
                            "pending": 0
                          },
                          "billing": {
                            "amount": "2.85",
                            "charged_amount": "2.85",
                            "currency": "USD"
                          }
                        },
                        "items": [
                          {
                            "id": "item_renewal_example",
                            "job_id": "ord_renewal_example",
                            "job_txid": "channel-renewal-001",
                            "txid": "channel-renewal-001",
                            "esn": "89000000000000000001",
                            "status": "succeeded",
                            "result": {
                              "service_period": {
                                "status": "unknown",
                                "date_timezone": "America/New_York",
                                "success_date": null,
                                "success_date_basis": null,
                                "effective_date": null,
                                "current_cycle_end_date": null,
                                "expiry_date": null,
                                "as_of_date": "2026-10-17",
                                "reason": "missing_anchor",
                                "source": "upstream",
                                "period_kind": "current"
                              },
                              "change_type": "ONEXPIRY",
                              "retryable": false,
                              "plan_code": "97",
                              "plan_id": "6641",
                              "zip": "90034"
                            },
                            "billing": {
                              "price": "2.85",
                              "charged_amount": "2.85",
                              "currency": "USD"
                            },
                            "plan_code": "97",
                            "plan_id": "6641",
                            "zip": "90034",
                            "started_at": "2026-10-17T01:59:58-04:00",
                            "finished_at": "2026-10-17T02:00:00-04:00",
                            "attempt_count": 1,
                            "result_revision": 1,
                            "confirmed_through_date": null
                          }
                        ]
                      },
                      "meta": {
                        "request_id": "req_example"
                      }
                    }
                  }
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "未找到本渠道的資料",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "405": {
            "description": "請求方法不支援",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Method not allowed.",
                    "details": {
                      "business_code": "METHOD_NOT_ALLOWED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Allow": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "GET"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "交易號衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__jobs_id_",
        "description": "按任務 ID 或批次 txid 查詢整批；按逐條 txid 只返回匹配明細，match=item_txid。直接讀取本地最新結果，包括處理中任務；GET 不觸發額外服務查詢或發單。背景補查及回呼繼續更新結果；需要提前核實時對原任務呼叫 recheck。\n\ndata.job.totals 為批次計數。範例有一條成功、另一條正在依已登記 ICCID 補查資料。所有明細結束後才返回最終批次匯總。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。\n\n續費、重新啟用及自動辦理的 confirmed_through_date 位於查單的 data.items[]、明細介面的 data[] 及逐筆回呼的 data。後續 item.updated 可補上日期，最新結果可查原任務。"
      }
    },
    "/jobs/{id}/items": {
      "get": {
        "tags": [
          "任務"
        ],
        "summary": "讀取逐卡結果",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "processing",
                "succeeded",
                "failed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/JobItem"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "未找到本渠道的資料",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "405": {
            "description": "請求方法不支援",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Method not allowed.",
                    "details": {
                      "business_code": "METHOD_NOT_ALLOWED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Allow": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "GET"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "交易號衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "get__jobs_id_items",
        "description": "返回該批次本地最新的逐條結果，可按 status 篩選；返回全部匹配明細，不分頁。GET 不觸發額外服務查詢，無需逐條補查。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。\n\n續費、重新啟用及自動辦理的 confirmed_through_date 位於查單的 data.items[]、明細介面的 data[] 及逐筆回呼的 data。後續 item.updated 可補上日期，最新結果可查原任務。"
      }
    },
    "/jobs/{id}/items/{itemId}/retry": {
      "post": {
        "tags": [
          "任務"
        ],
        "summary": "重試可重試的失敗明細",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "retried": {
                          "type": "string"
                        },
                        "txid": {
                          "type": "string",
                          "description": "提交的批次交易號為 1–64 位字母、數字、點、底線、冒號或連字符，渠道內唯一。重複提交返回 409，請查詢原任務。返回的逐卡交易號：單條與批次相同，多條為批次 txid_卡號後八位，最長 73 位。"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "已安排重試，不代表業務成功",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "未找到本渠道的資料",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "405": {
            "description": "請求方法不支援",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Method not allowed.",
                    "details": {
                      "business_code": "METHOD_NOT_ALLOWED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Allow": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "POST"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "交易號衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "post__jobs_id_items_itemId_retry",
        "description": "最終 failed 明細須核實後主動呼叫本介面，且 retryable=true、有原任務及明細編號，才依原參數及報價排隊重試；不要求 attempt_count 必返。200 表示已安排，最終結果須查詢或等待回呼。開卡限流自動補救期間無需呼叫本介面；處理中及結果未明只查原任務。渠道主動修改參數仍須建立新請求。\n\n業務確認成功後才按受理報價扣款，每條明細只扣一次；失敗不扣款，受理及排隊時不凍結或提前扣款。帳戶餘額可以為負數，餘額不足不阻擋受理或辦理；儲值增加餘額。渠道被人工暫停或停用時不能繼續發送新業務。WFC 免費，僅記帳帳戶保留既有計費約定。",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              },
              "example": {}
            }
          }
        }
      }
    },
    "/jobs/{id}/resume": {
      "post": {
        "tags": [
          "任務"
        ],
        "summary": "儲值後恢復暫停任務",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "已安排處理",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "405": {
            "description": "請求方法不支援",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Method not allowed.",
                    "details": {
                      "business_code": "METHOD_NOT_ALLOWED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Allow": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "POST"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "狀態不允許",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "僅供舊版因餘額不足暫停的未完成任務恢復，沿用原任務及報價，不再校驗餘額。正常新任務不需要呼叫；已完成或失敗業務不因此重辦。",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              },
              "example": {}
            }
          }
        }
      }
    },
    "/jobs/{id}/recheck": {
      "post": {
        "tags": [
          "任務"
        ],
        "summary": "補查結果待確認任務",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "已安排處理",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "405": {
            "description": "請求方法不支援",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Method not allowed.",
                    "details": {
                      "business_code": "METHOD_NOT_ALLOWED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Allow": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "POST"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "狀態不允許",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "只查詢原任務，不重新提交辦理請求。首次確認成功時正常記帳，重複查詢不重複扣款。",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              },
              "example": {}
            }
          }
        }
      }
    },
    "/cards/{iccid}/esim": {
      "get": {
        "summary": "讀取本渠道 eSIM 安裝資料",
        "parameters": [
          {
            "name": "iccid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{18,22}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "iccid": {
                          "type": "string"
                        },
                        "activation_string": {
                          "type": "string"
                        },
                        "created_at": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "iccid",
                        "activation_string",
                        "created_at"
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "返回本渠道已提供的 LPA 安裝字串，不生成新的安裝碼；未提供為 404。資料敏感，不要公開緩存或記錄完整值。",
        "tags": [
          "庫存與地區"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/cards/{iccid}/sync": {
      "post": {
        "summary": "同步已歸屬卡的號碼和套餐資料",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "required": [],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "iccid": {
                          "type": "string"
                        },
                        "mdn": {
                          "type": "string",
                          "nullable": true
                        },
                        "enrollment_id": {
                          "type": "string",
                          "nullable": true
                        },
                        "plan_code": {
                          "type": "string",
                          "nullable": true
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "unassigned",
                            "free",
                            "used"
                          ],
                          "description": "庫存使用事實：未分配、未使用、已使用；不表示線路 Active/Inactive。線路狀態和當期日期請即時查詢綜合介面。"
                        },
                        "last_synced_at": {
                          "type": "string",
                          "nullable": true
                        }
                      },
                      "required": [
                        "iccid",
                        "mdn",
                        "enrollment_id",
                        "plan_code",
                        "status",
                        "last_synced_at"
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "iccid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{18,22}$"
            }
          }
        ],
        "description": "即時核對卡與線路標識後更新已登記資料；不儲存線路狀態或到期日，不建立業務訂單、不扣款。每次一張，傳空 JSON 物件；辦理中的卡、無法唯一匹配的套餐或號碼衝突拒絕同步。",
        "tags": [
          "庫存與地區"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/balance": {
      "get": {
        "summary": "渠道預存款餘額",
        "parameters": [],
        "responses": {
          "200": {
            "description": "查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/ExtensionWallet"
                        },
                        {
                          "$ref": "#/components/schemas/ExtensionHuiWallet"
                        }
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "tags": [
          "帳戶與帳單"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "description": "balance 與 available 均為帳戶餘額，可為負數。unsettled_amount 是已受理、尚未結算的收費明細報價合計，僅供參考，不限制接單。available_for_orders 保留相容並固定返回 null，表示不設餘額接單上限。金額均為 USD 字串；僅成功明細扣款。\n\n資料完整的明細校驗報價後正常受理辦理；缺少必要線路資料的明細先保存為 pending，再單獨非同步補查，不阻塞其餘明細。補查階段不發送業務、不扣款。billing.quote_pending=true 表示報價尚未確定，price 暫為 0.00，批次 amount 僅含已確定的報價，不代表免費。補齊後保存當時渠道售價並進入辦理，餘額可為負數。補資料最多查一次。不能核實線路或帳號時返回該明細錯誤，不發送辦理。\n\nHUIYINBI 啟用 Snail/GCSL 分流後只返回 snail_balance、gcsl_balance、currency，不返回 balance、available 或其他合計餘額欄位。兩個 USD 字串均可為負數，繼續辦理且不互相挪用。其他渠道維持原返回，包括既有卡型分帳的可選 business_funds。"
      }
    },
    "/cards": {
      "get": {
        "summary": "本渠道卡號",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "stock_state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "activated",
                "unused"
              ],
              "default": "activated"
            }
          },
          {
            "name": "mdn",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            }
          },
          {
            "name": "iccid",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^\\d{18,22}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ExtensionCard"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/ExtensionPagination"
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "activated": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "unused": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "by_type": {
                          "type": "object",
                          "properties": {
                            "physical": {
                              "type": "object",
                              "properties": {
                                "total": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "activated": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "unused": {
                                  "type": "integer",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "total",
                                "activated",
                                "unused"
                              ]
                            },
                            "esim": {
                              "type": "object",
                              "properties": {
                                "total": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "activated": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "unused": {
                                  "type": "integer",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "total",
                                "activated",
                                "unused"
                              ]
                            },
                            "unknown": {
                              "type": "object",
                              "properties": {
                                "total": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "activated": {
                                  "type": "integer",
                                  "minimum": 0
                                },
                                "unused": {
                                  "type": "integer",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "total",
                                "activated",
                                "unused"
                              ]
                            }
                          },
                          "required": [
                            "physical",
                            "esim",
                            "unknown"
                          ]
                        }
                      },
                      "required": [
                        "total",
                        "activated",
                        "unused",
                        "by_type"
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "pagination",
                    "summary",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "本介面返回本地號卡庫存記錄，其狀態不能代替目前線路狀態。渠道選擇續費或重新啟用時，按需使用 GET /mdns/{mdn} 或 GET /customers 的 data.status。\n\nsummary 的 total、activated、unused 為本渠道實體卡的總數、已啟用數和未啟用數。by_type 分列實體卡、eSIM 和未確認卡型。空卡僅提供數量。預設列出已辦理卡，stock_state=unused 回傳空陣列。pagination.total 只計算可列出的明細。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不返回權威的當前線路狀態或即時週期，service_period 欄位為 null；另以 expiry_info 提供歷史確認／推算的已購週期截止。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n僅查本地庫，不呼叫上游、不提交業務、不扣款。同一身份與週期已有確認日期時優先採用；expiry_info 是歷史／推算的已購週期截止，不代表目前線路狀態或即時 service_period。當期查詢不抹去已成功購買的後續週期。依據不足或衝突保持未知。未使用空卡仍僅提供數量。\n\n單查傳 mdn 或 iccid，兩者只能選一個；均省略則分頁列出可見卡片。單查保留陣列與分頁結構。手機號碼採用最新已確認的本地激活綁定；未找到或不屬於本渠道返回空陣列。重查舊卡不改變已確認的目前綁定。",
        "tags": [
          "庫存與地區"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/ledger": {
      "get": {
        "summary": "本渠道儲值和消耗明細",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "開始日期，按 America/New_York（華盛頓特區）計算，含當天，自動處理夏令時"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "結束日期，按 America/New_York（華盛頓特區）計算，含當天，自動處理夏令時"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ExtensionLedgerEntry"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/ExtensionPagination"
                    },
                    "summary": {
                      "$ref": "#/components/schemas/ExtensionLedgerSummary"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "pagination",
                    "summary",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "日期為資金實際入帳 / 扣款時間；不傳日期查詢全部。summary 覆蓋全部篩選結果，不受分頁影響。金額均為 USD 字串。\n\ndata_scope=wallet_ledger：明細與期間匯總只含錢包啟用後的流水。ledger_started_at 為可查詢流水的起點，無流水時為 null。recharge 保留全部入帳金額，包含期初結餘轉入；opening_transfer 為期間結餘轉入，new_deposits 為期間新增入帳，兩者相加等於 recharge。entry_type=opening_transfer 標記原結餘轉入，kind 仍為 recharge，不代表新的付款。history 為已核對的導入前資金與消費摘要，未納入期間值；無歷史資料時為 null，核對不符時 status=needs_review，不提供未核實金額。lifetime 不受日期篩選，合併已核對歷史及錢包流水並去除重複結餘；包含累計 funds、consumption、recorded_amount 和目前 balance，歷史待核時為 null。所有金額為 USD 字串；歷史摘要與轉入流水不可再相加入帳。",
        "tags": [
          "帳戶與帳單"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/ledger/summary": {
      "get": {
        "summary": "本渠道資金期間匯總",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "開始日期，按 America/New_York（華盛頓特區）計算，含當天，自動處理夏令時"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "結束日期，按 America/New_York（華盛頓特區）計算，含當天，自動處理夏令時"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ExtensionLedgerSummary"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "期初餘額為 from 之前的餘額；期末 = 期初 + 期間儲值 - 實際消耗 + recorded_amount（如有）；current_balance 為目前餘額。僅記帳帳戶餘額允許為負，不代表已收款。無 from 時期初為 0。\n\ndata_scope=wallet_ledger：明細與期間匯總只含錢包啟用後的流水。ledger_started_at 為可查詢流水的起點，無流水時為 null。recharge 保留全部入帳金額，包含期初結餘轉入；opening_transfer 為期間結餘轉入，new_deposits 為期間新增入帳，兩者相加等於 recharge。entry_type=opening_transfer 標記原結餘轉入，kind 仍為 recharge，不代表新的付款。history 為已核對的導入前資金與消費摘要，未納入期間值；無歷史資料時為 null，核對不符時 status=needs_review，不提供未核實金額。lifetime 不受日期篩選，合併已核對歷史及錢包流水並去除重複結餘；包含累計 funds、consumption、recorded_amount 和目前 balance，歷史待核時為 null。所有金額為 USD 字串；歷史摘要與轉入流水不可再相加入帳。",
        "tags": [
          "帳戶與帳單"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/ledger/export": {
      "get": {
        "summary": "導出本渠道完整帳單 CSV",
        "description": "UTF-8 BOM，按入帳時間升序；覆蓋全部日期篩選結果，忽略 page/per_page。長編號前加單引號避免表格軟體截斷。\n\nCSV 保留既有欄位與順序。資金範圍與結餘轉入標記請讀取 /ledger 的 data_scope、entry_type；歷史及累計摘要請讀取 /ledger/summary。不生成歷史虛擬流水。",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "開始日期，按 America/New_York（華盛頓特區）計算，含當天，自動處理夏令時"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "description": "結束日期，按 America/New_York（華盛頓特區）計算，含當天，自動處理夏令時"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "完整帳單",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "tags": [
          "帳戶與帳單"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/regional-catalog": {
      "get": {
        "summary": "已保存的地區套餐目錄",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "catalog_entry_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 250,
              "pattern": "\\S",
              "description": "按目錄唯一編碼讀取記錄；仍返回 data 陣列，無符合記錄時為空陣列。"
            }
          },
          {
            "name": "zip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^\\d{5}$"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "area_code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[2-9]\\d{2}$",
              "description": "地區或歷史號碼的三位區號，僅供查詢參考"
            }
          },
          {
            "name": "product_code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "verification_status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "deprecated": true,
            "description": "相容篩選項，舊請求繼續按原含義篩選；新接入無需傳入，按套餐、城市、州或區號選擇可辦理目錄。"
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "spreadsheet",
                "supplemented"
              ]
            },
            "deprecated": true,
            "description": "相容篩選項，舊請求繼續按原含義篩選；新接入無需傳入，按套餐、城市、州或區號選擇可辦理目錄。"
          },
          {
            "name": "orderable",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": true
            },
            "description": "僅保留相容：省略、true 或 false 均只返回可下單記錄，不返回停用或不可下單的編碼。",
            "deprecated": true
          }
        ],
        "responses": {
          "200": {
            "description": "查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ExtensionRegionalCatalog"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/ExtensionPagination"
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "matched": {
                          "type": "integer",
                          "deprecated": true,
                          "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
                        },
                        "updated": {
                          "type": "integer",
                          "deprecated": true,
                          "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
                        },
                        "supplemented": {
                          "type": "integer",
                          "deprecated": true,
                          "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
                        },
                        "unresolved": {
                          "type": "integer",
                          "deprecated": true,
                          "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
                        }
                      }
                    },
                    "sync": {
                      "type": "object",
                      "nullable": true,
                      "deprecated": true,
                      "description": "相容返回欄位，仍保留原值；新接入無需依賴。"
                    },
                    "card_fees": {
                      "type": "object",
                      "properties": {
                        "physical": {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$",
                          "example": "1.25",
                          "description": "實體卡單價，未設定為 null。",
                          "nullable": true
                        },
                        "esim": {
                          "type": "string",
                          "pattern": "^\\d+\\.\\d{2}$",
                          "example": "1.75",
                          "description": "eSIM 卡單價，未設定為 null。",
                          "nullable": true
                        }
                      },
                      "required": [
                        "physical",
                        "esim"
                      ],
                      "additionalProperties": false,
                      "description": "目前渠道在售價設定中儲存的卡費單價，單位 USD。每頁均回傳，獨立於套餐報價。"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "pagination",
                    "card_fees",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "description": "一次讀取套餐、完整服務地址、城市與參考區號、本渠道售價及目錄唯一編碼。只返回可下單記錄；可用 catalog_entry_id 篩選記錄，停用或不可下單的編碼返回空陣列。仍須檢查對應業務報價，summary 為全部篩選結果的匯總。",
        "tags": [
          "庫存與地區"
        ],
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/renewal-catalog": {
      "get": {
        "tags": [
          "庫存與地區"
        ],
        "summary": "已有號碼的續費及續費換套餐目錄",
        "description": "按號碼目前五位郵編讀取本渠道可續費套餐。包含新購地址表之外、已由營運商核實的續費映射；不擴展新購地址或啟用資格。使用 plan_id 與 plan_change=true 提交 /jobs/renewals，仍核對實際線路、售價和業務狀態。",
        "parameters": [
          {
            "name": "zip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{5}$"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000000,
              "default": 1
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "本渠道可續費的套餐映射",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RenewalCatalog"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "integer"
                        },
                        "per_page": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        },
                        "has_more": {
                          "type": "boolean"
                        }
                      }
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "total": {
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "查詢參數無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/plan-change-options": {
      "get": {
        "tags": [
          "庫存與地區"
        ],
        "summary": "續費換套餐的已核實地址匹配；只用於選擇目標套餐 ID，不修改號碼或線路地址。",
        "description": "僅按原號碼歸屬讀取換套餐選項。依原地址、同城市、同州、其他可用地址匹配，返回目標套餐 ID 與凍結版本；原套餐續費沿用已有映射。",
        "parameters": [
          {
            "name": "mdn",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9]{10}$"
            }
          },
          {
            "name": "esn",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          },
          {
            "name": "current_plan_id",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          },
          {
            "name": "current_plan_code",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "套餐匹配結果",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/PlanChangeOptions"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "查詢參數無效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/query-jobs": {
      "post": {
        "tags": [
          "查詢"
        ],
        "operationId": "post_query_jobs",
        "summary": "獨立非同步批次查詢",
        "description": "POST /query-jobs 保存 1–100 條查詢後返回 202。每條線路均按同步查詢的順序核對 ICCID、原登記編號及原手機號碼。錯誤明細以 review、error_code 和 message 返回，result 為 null。所有明細結束後發送 query.job.completed。查詢不收費。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "txid",
                  "items"
                ],
                "properties": {
                  "txid": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9._:-]{1,64}$"
                  },
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "$ref": "#/components/schemas/QueryIdentifiers"
                    }
                  },
                  "webhook_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "可選的本任務 HTTPS 回呼地址。省略時採用已登記地址；未登記時由平台接收，渠道需查詢原任務。不填 API 地址。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "已保存查詢任務；最終結果以明細為準",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QueryJobResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON 請求體超過 200,000 位元組。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "有請求體時須使用 application/json。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁；依 Retry-After 等待後查詢原任務。",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              },
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "callbacks": {
          "queryResult": {
            "{$request.body#/webhook_url}": {
              "post": {
                "summary": "接收批次查詢結果",
                "description": "使用 X-RM-Event、X-RM-Delivery-Id 和 X-RM-Signature；對原始 JSON 位元組計算 HMAC-SHA256。依事件 id 去重，回傳 2xx 確認。投遞重試保持相同事件與內容。每個查詢任務只保存最大的 revision，較舊有效事件仍以 2xx 確認，不覆蓋新結果。",
                "security": [],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/QueryCompletedEvent"
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "已接收"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/query-jobs/{id}": {
      "get": {
        "tags": [
          "查詢"
        ],
        "operationId": "get_query_job",
        "summary": "讀取原查詢批次",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "本渠道的查詢任務 ID 或原 txid"
          }
        ],
        "responses": {
          "200": {
            "description": "查詢任務資料",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QueryJobResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁；依 Retry-After 等待後查詢原任務。",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              },
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/query-jobs/{id}/recheck": {
      "post": {
        "tags": [
          "查詢"
        ],
        "operationId": "recheck_query_job",
        "summary": "重查已結案 review 明細",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "本渠道的查詢任務 ID 或原 txid"
          }
        ],
        "description": "批次結束後，確認資料已修正才呼叫；進行中的明細不可重啟。只重查 review 明細，保留成功明細與原任務號；完成後以新 revision 和新事件 id 回呼。原登記身份有衝突時仍需處理，不能藉此改綁。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "查詢任務資料",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/QueryJobResult"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON 請求體超過 200,000 位元組。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "有請求體時須使用 application/json。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁；依 Retry-After 等待後查詢原任務。",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              },
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/query-jobs/{id}/callbacks": {
      "get": {
        "tags": [
          "查詢"
        ],
        "operationId": "get_query_callbacks",
        "summary": "查詢批次結果的回呼投遞狀態",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "本渠道的查詢任務 ID 或原 txid"
          }
        ],
        "responses": {
          "200": {
            "description": "查詢任務資料",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/QueryCallback"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁；依 Retry-After 等待後查詢原任務。",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              },
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/query-jobs/{id}/callbacks/retry": {
      "post": {
        "tags": [
          "查詢"
        ],
        "operationId": "retry_query_callbacks",
        "summary": "重新投遞失敗的查詢回呼",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "本渠道的查詢任務 ID 或原 txid"
          }
        ],
        "description": "自動投遞六次失敗後進入異常。確認接收端恢復後，重新排入原事件，保留投遞次數與記錄；不重查線路，也不重辦業務。",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "查詢任務資料",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "job_id": {
                          "type": "string"
                        },
                        "requeued": {
                          "type": "integer"
                        }
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "參數、權限或任務狀態錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "JSON 請求體超過 200,000 位元組。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "415": {
            "description": "有請求體時須使用 application/json。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁；依 Retry-After 等待後查詢原任務。",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              },
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ]
      }
    },
    "/jobs/auto-handling": {
      "post": {
        "tags": [
          "業務辦理"
        ],
        "summary": "已啟用號碼自動辦理",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "僅在請求體未傳 txid 時使用；優先使用 JSON txid。"
          },
          {
            "name": "txid",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "同一渠道每批使用一個交易號。省略時依次讀取 Idempotency-Key 標頭、txid 標頭，最後由平台產生。回應不明時依原號查單。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AutoHandlingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "請求完成；業務結果以逐卡狀態為準",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/JobDetail"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "任務已受理，等待最終結果",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "交易號衝突或狀態衝突",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "請求內容過大",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Request body too large.",
                    "details": {
                      "business_code": "BODY_TOO_LARGE",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "415": {
            "description": "需要 JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Content-Type must be application/json.",
                    "details": {
                      "business_code": "JSON_REQUIRED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "submitAutoHandling",
        "description": "提交本渠道已啟用庫存的號碼或 ICCID，每批最多 1,000 條。同一批可含到期續費與重新啟用，逐號回傳實際業務及結果，個別失敗的號碼獨立處理。即日續費使用獨立續費介面。\n\n自動辦理依同一線路、帳號及套餐的已購到期日分流。月套餐也可按過往成功啟用、重新啟用或續費記錄，以美東自然月計算到期日。尚未到期走到期續費，已到期走重新啟用。只有日期時，到期當天先查線路。有可靠日期的明細先送出，日期缺失或資料衝突的明細查詢後再送。兩組沿用原渠道批次與明細編號。確認失敗後，如回執或複查證實應辦另一項業務，同一明細最多轉辦一次。提交結果未明時繼續核對原任務。\n\n同一號碼只提交一條，以 items[].quantity 指定期數（1–12 的整數，預設 1），一批最多 1,000 期。在用號碼逐期到期續費；停用號碼先重新啟用，核實恢復後再辦 quantity 減 1 期續費。結果未明依原任務查詢；明確失敗停止該號碼後續期次。每個受理期次對應一條明細，用 cycle.index、cycle.quantity 辨識，後續期次交易號附加 _p2、_p3 等。僅成功期次扣費。\n\n重新啟用每筆只傳經核實的 esn、mdn 和 enrollment_id。地址與郵編為選填卡檔資料。明確指定的完整 service_address 會在成功後存入卡檔。\n\n續費、重新啟用及自動辦理的 confirmed_through_date 位於查單的 data.items[]、明細介面的 data[] 及逐筆回呼的 data。後續 item.updated 可補上日期，最新結果可查原任務。",
        "callbacks": {
          "businessResult": {
            "{$request.body#/webhook_url}": {
              "post": {
                "summary": "接收業務事件（由平台發送）",
                "security": [],
                "description": "回呼使用獨立 Webhook Secret 驗簽，不發送渠道帳戶或 API Key。對原始請求體計算 HMAC-SHA256，不拼接時間戳；created_at 為事件建立時間。平台在事件落庫後立即觸發投遞，待發通知連續發送，不設每秒或每輪固定條數限制；實際投遞時間取決於接收方與網路。首次投遞失敗後，平台最多自動重試 5 次，間隔為 30、60、120、240、480 秒，指數退避上限為 15 分鐘，包括首次在內最多投遞 6 次。平台重投原事件，不重新辦理業務或扣款。\n\n線路 service_period 與 next_service_period 只取本次核實身份的上游即時回包，當期與下期分開；缺失日期為 null。庫存列表不儲存或返回當前線路狀態和到期日，週期欄位為 null。查單週期僅為當次業務歷史憑據。直接辦理會核實線路。自動辦理先按相符的已購日期分流，必要時查詢線路。原始查詢和業務回執保留供核對。\n\n後補結果透過同一業務前綴的 item.updated 通知，data.status 保留原終態，data.result_revision 遞增，data 是完整的最新逐卡結果快照。首次逐卡通知版本為 1；後補通知至少為 2。同一事件重投保留 id 和版本，不同補充使用新 id。按 item_id 保存最高版本，舊版本仍驗簽並返回 2xx，但不覆蓋新結果；沒有版本時查詢原任務核實。補充不重新辦理、不再次扣款、不重發 job.completed。只有已生成版本化逐卡通知的結果參與補充；上線前歷史回呼不修改或補發。",
                "parameters": [
                  {
                    "name": "X-RM-Event",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "enum": [
                        "renewal.item.succeeded",
                        "renewal.item.failed",
                        "renewal.item.updated",
                        "renewal.job.completed"
                      ]
                    },
                    "description": "與 JSON type 一致。"
                  },
                  {
                    "name": "X-RM-Delivery-Id",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "example": "delivery_example"
                    },
                    "description": "本次投遞嘗試編號，重投時改變；使用 JSON id 作為穩定事件去重鍵。"
                  },
                  {
                    "name": "X-RM-Signature",
                    "in": "header",
                    "required": true,
                    "schema": {
                      "type": "string",
                      "pattern": "^sha256=[a-f0-9]{64}$"
                    },
                    "description": "sha256= 加原始請求體的 HMAC-SHA256 十六進制簽名；密鑰為渠道 Webhook Secret。"
                  }
                ],
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "$ref": "#/components/schemas/WebhookEvent"
                      },
                      "examples": {
                        "auto_item_success": {
                          "value": {
                            "id": "evt_auto_example",
                            "type": "auto_handling.item.succeeded",
                            "created_at": "2026-10-17T02:00:00-04:00",
                            "data": {
                              "service_period": {
                                "status": "confirmed",
                                "date_timezone": "America/New_York",
                                "success_date": null,
                                "success_date_basis": null,
                                "effective_date": "2026-11-16",
                                "current_cycle_end_date": "2026-11-16",
                                "expiry_date": "2026-12-16",
                                "as_of_date": "2026-10-17",
                                "reason": null,
                                "source": "upstream",
                                "period_kind": "current"
                              },
                              "change_type": "ONEXPIRY",
                              "retryable": false,
                              "job_id": "ord_auto_example",
                              "item_id": "item_renewal_example",
                              "job_txid": "FW-1028",
                              "txid": "FW-1028_line1",
                              "esn": "89000000000000000001",
                              "status": "succeeded",
                              "plan_code": "97",
                              "plan_id": "6641",
                              "zip": "90034",
                              "started_at": "2026-10-17T01:59:58-04:00",
                              "finished_at": "2026-10-17T02:00:00-04:00",
                              "attempt_count": 1,
                              "result_revision": 1,
                              "mdn": "2025550140",
                              "operation": "renewal",
                              "cycle": {
                                "index": 1,
                                "quantity": 2
                              },
                              "confirmed_through_date": "2026-12-16"
                            }
                          }
                        },
                        "auto_batch_completed": {
                          "value": {
                            "id": "evt_auto_complete",
                            "type": "auto_handling.job.completed",
                            "created_at": "2026-10-17T02:00:00-04:00",
                            "data": {
                              "job_id": "ord_auto_example",
                              "txid": "FW-1028",
                              "job_txid": "FW-1028",
                              "status": "succeeded",
                              "total": 3,
                              "succeeded": 3,
                              "failed": 0,
                              "pending": 0
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "已驗簽、持久化並去重"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mdns/{mdn}/overview": {
      "get": {
        "tags": [
          "查詢"
        ],
        "summary": "查詢號碼狀態及當期用量餘量",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "mdn",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{10}$"
            },
            "description": "10 位美國手機號碼，不帶 +1、空格或連字符。"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/NumberOverview"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    }
                  },
                  "required": [
                    "data",
                    "meta"
                  ]
                }
              }
            },
            "description": "查詢完成",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "參數錯誤",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道或能力未開放",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "未找到本渠道的資料",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "多筆記錄符合識別資料，但無法確定目前的 SIM，請核實號碼與卡號對應記錄。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "請求過於頻繁，請參考 Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "查詢服務異常；收費請求結果不明時先查原交易號",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "operationId": "getNumberOverview",
        "description": "同步綜合查詢。不接受查詢參數，請勿傳 from、to、summary 或 mode。先按本渠道登記身份及原帳號核實線路，再以同次線路的當期日期和套餐資源查一次當期用量。line 與 usage 分別保留各自時刻，不代表上游同一瞬間快照。當期與下期分開；有效上游餘量（包括 0）優先，其餘沿用現有當期餘量規則。未知值為 null，不限量以 *_unlimited=true 表示。當期缺失、已到期、未生效或超出可查範圍時，HTTP 200 返回 partial=true、usage=null、USAGE_PERIOD_UNCONFIRMED。未找到線路時保留 found=false，不繼續查用量。上游用量暫不可用時保留線路並返回 usage_error；回包無效／身份或區間不符、歸屬變更、無查詢權限仍按原規則拒絕。不建立非同步查詢任務、訂單、扣款或回呼。原線路及用量介面保持原有行為。"
      }
    },
    "/cards/lookup": {
      "post": {
        "tags": [
          "庫存與地區"
        ],
        "summary": "批次本地查庫",
        "description": "僅查本地庫，不呼叫上游、不提交業務、不扣款。同一身份與週期已有確認日期時優先採用；expiry_info 是歷史／推算的已購週期截止，不代表目前線路狀態或即時 service_period。當期查詢不抹去已成功購買的後續週期。依據不足或衝突保持未知。未使用空卡仍僅提供數量。\n\n每批 1–200 個標識，結果保持輸入順序及重複項。未找到或綁定待確認不影響其他條目；格式錯誤拒絕整個請求。不建立查詢任務、回呼或訂單；暫停辦理的唯讀渠道也可使用此 POST。",
        "security": [
          {
            "channelAccount": [],
            "apiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 200,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "mdn": {
                          "type": "string",
                          "pattern": "^\\d{10}$"
                        },
                        "iccid": {
                          "type": "string",
                          "pattern": "^\\d{18,22}$"
                        }
                      },
                      "oneOf": [
                        {
                          "required": [
                            "mdn"
                          ],
                          "not": {
                            "required": [
                              "iccid"
                            ]
                          }
                        },
                        {
                          "required": [
                            "iccid"
                          ],
                          "not": {
                            "required": [
                              "mdn"
                            ]
                          }
                        }
                      ]
                    }
                  }
                }
              },
              "example": {
                "items": [
                  {
                    "mdn": "2025550100"
                  },
                  {
                    "iccid": "89000000000000000001"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "本地查詢完成",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "request": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "mdn": {
                                "type": "string",
                                "pattern": "^\\d{10}$"
                              },
                              "iccid": {
                                "type": "string",
                                "pattern": "^\\d{18,22}$"
                              }
                            },
                            "oneOf": [
                              {
                                "required": [
                                  "mdn"
                                ],
                                "not": {
                                  "required": [
                                    "iccid"
                                  ]
                                }
                              },
                              {
                                "required": [
                                  "iccid"
                                ],
                                "not": {
                                  "required": [
                                    "mdn"
                                  ]
                                }
                              }
                            ]
                          },
                          "found": {
                            "type": "boolean"
                          },
                          "card": {
                            "oneOf": [
                              {
                                "$ref": "#/components/schemas/ExtensionCard"
                              },
                              {
                                "type": "object",
                                "nullable": true,
                                "enum": [
                                  null
                                ]
                              }
                            ]
                          },
                          "error": {
                            "type": "object",
                            "nullable": true,
                            "additionalProperties": false,
                            "properties": {
                              "code": {
                                "type": "string",
                                "enum": [
                                  "LOCAL_IDENTITY_UNCONFIRMED"
                                ]
                              },
                              "message": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "code",
                              "message"
                            ]
                          }
                        },
                        "required": [
                          "request",
                          "found",
                          "card",
                          "error"
                        ]
                      }
                    },
                    "summary": {
                      "type": "object",
                      "properties": {
                        "requested": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "found": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "not_found": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "needs_review": {
                          "type": "integer",
                          "minimum": 0
                        }
                      },
                      "required": [
                        "requested",
                        "found",
                        "not_found",
                        "needs_review"
                      ]
                    },
                    "meta": {
                      "$ref": "#/components/schemas/Meta"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "data",
                    "summary"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "參數錯誤",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "bad_request",
                    "message": "Invalid field value or type.",
                    "details": {
                      "business_code": "INVALID_INPUT",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "渠道帳戶或 API Key 無效；請檢查設定或金鑰是否已重置。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "unauthorized",
                    "message": "Invalid account or API key.",
                    "details": {
                      "business_code": "UNAUTHORIZED",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "渠道停用",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "forbidden",
                    "message": "Service unavailable.",
                    "details": {
                      "business_code": "CAPABILITY_DISABLED",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "目前渠道無此資源",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_found",
                    "message": "Resource or endpoint not found.",
                    "details": {
                      "business_code": "NOT_FOUND",
                      "next_action": "correct_and_resubmit"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "description": "重複編號內容衝突或狀態衝突",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "conflict",
                    "message": "Transaction ID already exists.",
                    "details": {
                      "business_code": "DUPLICATE_TXID",
                      "next_action": "query_original"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "限流；按 Retry-After 秒數重試",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Too many requests.",
                    "details": {
                      "business_code": "RATE_LIMITED",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[0-9]+$"
                }
              }
            }
          },
          "500": {
            "description": "內部異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "internal_error",
                    "message": "Internal error.",
                    "details": {
                      "business_code": "INTERNAL_ERROR",
                      "next_action": "contact_support"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "業務服務異常",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "upstream_error",
                    "message": "Service temporarily unavailable.",
                    "details": {
                      "business_code": "UPSTREAM_UNAVAILABLE",
                      "next_action": "wait"
                    }
                  },
                  "meta": {
                    "request_id": "req_example"
                  }
                }
              }
            },
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "channelAccount": [],
      "apiKeyAuth": []
    }
  ],
  "externalDocs": {
    "description": "接入說明",
    "url": "https://rogue.gcsl.ai/docs/guide.html?lang=zh-Hant"
  },
  "x-documentation-language": "zh-Hant"
}
