{
 "openapi": "3.1.0",
 "info": {
  "title": "智聞捷發 新聞稿發佈 API",
  "version": "1.0.0",
  "description": "把新聞稿送到智聞捷發，刊登到台灣 200+ 個新聞網站。流程：GET /me.php → GET /categories.php → GET /targets.php → POST /articles.php (dry_run:true 試審) → GET /articles.php?id= 直到 dry_run_passed → POST /articles.php 正式送出（帶 client_ref）→ 輪詢直到 published/rejected。完整說明：https://www.111.net.tw/member-system/api/v1/llms.txt",
  "contact": {
   "email": "service@111.net.tw"
  }
 },
 "servers": [
  {
   "url": "https://www.111.net.tw/member-system/api/v1"
  }
 ],
 "security": [
  {
   "bearerAuth": []
  }
 ],
 "paths": {
  "/me.php": {
   "get": {
    "operationId": "getAccount",
    "summary": "帳號、餘額、今日用量；gate_missing 必須為空才能發稿",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "success": {
           "type": "boolean"
          },
          "data": {
           "$ref": "#/components/schemas/Account"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "金鑰無效",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "請求太頻繁或超過每日上限",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "系統錯誤",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/categories.php": {
   "get": {
    "operationId": "listCategories",
    "summary": "文章分類（送稿 categories 用 id，1～5 個）",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "success": {
           "type": "boolean"
          },
          "data": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "id": {
              "type": "integer"
             },
             "name": {
              "type": "string"
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "金鑰無效",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "請求太頻繁或超過每日上限",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "系統錯誤",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/targets.php": {
   "get": {
    "operationId": "listTargets",
    "summary": "可選的網站與連稿群組，price 為此帳號價格（未稅）",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "success": {
           "type": "boolean"
          },
          "data": {
           "type": "object",
           "properties": {
            "websites": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "id": {
                "type": "integer"
               },
               "name": {
                "type": "string"
               },
               "url": {
                "type": "string"
               },
               "price": {
                "type": "number"
               },
               "tier": {
                "type": "string",
                "enum": [
                 "network",
                 "high_traffic"
                ],
                "description": "network=聯播網(規則較寬)；high_traffic=高流量主流媒體(規則較嚴)"
               }
              }
             }
            },
            "groups": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "id": {
                "type": "integer"
               },
               "name": {
                "type": "string"
               },
               "description": {
                "type": "string"
               },
               "site_count": {
                "type": "integer"
               },
               "price": {
                "type": "number"
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "金鑰無效",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "請求太頻繁或超過每日上限",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "系統錯誤",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/quote.php": {
   "post": {
    "operationId": "quote",
    "summary": "試算金額（不審稿、不扣款）",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "websites": {
          "type": "array",
          "items": {
           "type": "integer"
          }
         },
         "groups": {
          "type": "array",
          "items": {
           "type": "integer"
          }
         },
         "title": {
          "type": "string"
         },
         "content": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "success": {
           "type": "boolean"
          },
          "data": {
           "$ref": "#/components/schemas/Quote"
          }
         }
        }
       }
      }
     },
     "422": {
      "description": "欄位錯誤",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "金鑰無效",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "請求太頻繁或超過每日上限",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "系統錯誤",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  },
  "/articles.php": {
   "post": {
    "operationId": "submitArticle",
    "summary": "送稿（非同步）。dry_run=true 只試審不扣款。回 202 + submission_id，之後用 getArticle 查詢",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ArticleRequest"
       }
      }
     }
    },
    "responses": {
     "202": {
      "description": "已受理",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "success": {
           "type": "boolean"
          },
          "data": {
           "$ref": "#/components/schemas/Submission"
          },
          "message": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "200": {
      "description": "client_ref 重複，回傳原本那一筆（duplicate=true）",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "success": {
           "type": "boolean"
          },
          "duplicate": {
           "type": "boolean"
          },
          "data": {
           "$ref": "#/components/schemas/Submission"
          }
         }
        }
       }
      }
     },
     "402": {
      "description": "餘額不足",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "帳號必填資料未完成",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "413": {
      "description": "內容過大",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "欄位錯誤／目標無效／超過 max_total",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "金鑰無效",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "請求太頻繁或超過每日上限",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "系統錯誤",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   },
   "get": {
    "operationId": "getArticle",
    "summary": "查一筆（id 或 client_ref），或不帶參數列出最近送稿",
    "parameters": [
     {
      "name": "id",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "submission_id，例 sub_261126b46183805cbf"
     },
     {
      "name": "client_ref",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100,
       "default": 20
      }
     },
     {
      "name": "before_id",
      "in": "query",
      "schema": {
       "type": "string"
      },
      "description": "翻頁：上一頁的 next_before_id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "success": {
           "type": "boolean"
          },
          "data": {
           "oneOf": [
            {
             "$ref": "#/components/schemas/Submission"
            },
            {
             "type": "array",
             "items": {
              "$ref": "#/components/schemas/Submission"
             }
            }
           ]
          },
          "next_before_id": {
           "type": [
            "string",
            "null"
           ]
          }
         }
        }
       }
      }
     },
     "404": {
      "description": "查無",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "金鑰無效",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "請求太頻繁或超過每日上限",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "500": {
      "description": "系統錯誤",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "securitySchemes": {
   "bearerAuth": {
    "type": "http",
    "scheme": "bearer",
    "description": "zwj_ 開頭的 API 金鑰，在會員/B2B/經銷商後台「API 串接」頁產生"
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "success": {
      "type": "boolean",
      "const": false
     },
     "error": {
      "type": "object",
      "properties": {
       "code": {
        "type": "string",
        "enum": [
         "INVALID_JSON",
         "UNAUTHORIZED",
         "INSUFFICIENT_BALANCE",
         "PROFILE_INCOMPLETE",
         "NOT_FOUND",
         "METHOD_NOT_ALLOWED",
         "PAYLOAD_TOO_LARGE",
         "VALIDATION",
         "INVALID_TARGETS",
         "OVER_MAX_TOTAL",
         "RATE_LIMITED",
         "DAILY_LIMIT",
         "SERVER_ERROR"
        ]
       },
       "message": {
        "type": "string"
       },
       "details": {
        "type": "array",
        "items": {
         "type": "string"
        }
       }
      }
     }
    }
   },
   "Account": {
    "type": "object",
    "properties": {
     "member_id": {
      "type": "integer"
     },
     "username": {
      "type": "string"
     },
     "company": {
      "type": "string"
     },
     "channel": {
      "type": "string",
      "enum": [
       "member",
       "b2b",
       "dealer"
      ]
     },
     "balance": {
      "type": "number"
     },
     "unit": {
      "type": "string"
     },
     "gate_missing": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "token": {
      "type": "object",
      "properties": {
       "name": {
        "type": "string"
       },
       "daily_article_limit": {
        "type": "integer"
       },
       "daily_spend_limit": {
        "type": [
         "integer",
         "null"
        ]
       },
       "today_articles": {
        "type": "integer"
       },
       "today_spent": {
        "type": "number"
       },
       "webhook_url": {
        "type": [
         "string",
         "null"
        ]
       }
      }
     }
    }
   },
   "Quote": {
    "type": "object",
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "type": {
         "type": "string",
         "enum": [
          "website",
          "group",
          "surcharge"
         ]
        },
        "id": {
         "type": "integer"
        },
        "name": {
         "type": "string"
        },
        "price": {
         "type": "number"
        }
       }
      }
     },
     "subtotal": {
      "type": "number"
     },
     "tax": {
      "type": "number"
     },
     "total": {
      "type": "number",
      "description": "從餘額扣除的金額"
     },
     "balance": {
      "type": "number"
     },
     "enough_balance": {
      "type": "boolean"
     },
     "invalid_targets": {
      "type": "array",
      "items": {
       "type": "object"
      }
     }
    }
   },
   "ArticleRequest": {
    "type": "object",
    "required": [
     "title",
     "content",
     "categories"
    ],
    "properties": {
     "title": {
      "type": "string",
      "maxLength": 200
     },
     "content": {
      "type": "string",
      "description": "HTML。每張 <img> 下一段要是圖說 <p>圖說：…</p>；圖片可用公開網址或 data:image/...;base64；寬≥750px、橫式、至少一張真實照片。一般會員至少 300 字"
     },
     "categories": {
      "type": "array",
      "items": {
       "type": "integer"
      },
      "minItems": 1,
      "maxItems": 5
     },
     "websites": {
      "type": "array",
      "items": {
       "type": "integer"
      }
     },
     "groups": {
      "type": "array",
      "items": {
       "type": "integer"
      }
     },
     "dry_run": {
      "type": "boolean",
      "default": false,
      "description": "true=只試審，不建稿不扣款"
     },
     "client_ref": {
      "type": "string",
      "maxLength": 100,
      "description": "您的唯一編號；同金鑰同編號只受理一次（防重複扣款）"
     },
     "tags": {
      "type": "string"
     },
     "prefer_date": {
      "type": "string",
      "description": "YYYY-MM-DD 或 YYYY-MM-DD HH:MM（台灣時間）"
     },
     "max_total": {
      "type": "number",
      "description": "金額上限"
     },
     "political_surcharge_max": {
      "type": "number",
      "description": "選舉期間政治新聞願意加付的上限"
     }
    }
   },
   "Submission": {
    "type": "object",
    "properties": {
     "submission_id": {
      "type": "string"
     },
     "client_ref": {
      "type": [
       "string",
       "null"
      ]
     },
     "dry_run": {
      "type": "boolean"
     },
     "title": {
      "type": "string"
     },
     "created_at": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "enum": [
       "queued",
       "ai_reviewing",
       "ai_rejected",
       "dry_run_passed",
       "failed",
       "pending_review",
       "approved",
       "published",
       "rejected"
      ]
     },
     "status_text": {
      "type": "string"
     },
     "errors": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "notices": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "cost": {
      "type": [
       "number",
       "null"
      ]
     },
     "quote": {
      "type": [
       "object",
       "null"
      ]
     },
     "ai_review": {
      "type": [
       "object",
       "null"
      ],
      "properties": {
       "score": {
        "type": "integer"
       },
       "pass_score": {
        "type": "integer"
       },
       "summary": {
        "type": "string"
       },
       "issues": {
        "type": "array",
        "items": {
         "type": "object",
         "properties": {
          "severity": {
           "type": "string",
           "description": "illegal=必須修改；risk=建議修改"
          },
          "law": {
           "type": "string"
          },
          "title": {
           "type": "string"
          },
          "excerpt": {
           "type": "string"
          },
          "reason": {
           "type": "string"
          },
          "suggestion": {
           "type": "string"
          }
         }
        }
       }
      }
     },
     "case_no": {
      "type": [
       "string",
       "null"
      ]
     },
     "review": {
      "type": [
       "object",
       "null"
      ]
     },
     "published": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "section": {
         "type": "string"
        },
        "website_name": {
         "type": "string"
        },
        "status": {
         "type": "string",
         "enum": [
          "published",
          "waiting"
         ]
        },
        "url": {
         "type": [
          "string",
          "null"
         ]
        },
        "published_at": {
         "type": [
          "string",
          "null"
         ]
        }
       }
      }
     }
    }
   }
  }
 }
}