{
  "openapi": "3.0.0",
  "info": {
    "title": "AI 虛擬換裝 Mix & Match",
    "description": "# 概述 (Overview)\n一次呼叫試穿整套穿搭。送一張使用者照片加上 1 到 9 張單品參考圖，AI Outfit Virtual Try-On Mix & Match API 會一次為人物穿上所有單品，回傳一張完整造型照。\n\n* 一次呼叫、一套造型：單一任務就讓人物的身上出現全部參考單品，結果照片恰好一張。\n* 八種單品類別：`upper_body`、`lower_body`、`full_body`、`outer`、`shoes`、`bag`、`headwear`、`accessory`。\n* 穿法備註：可以指定怎麼穿，例如「外套敞開穿」「上衣紮進褲頭」。只影響穿法，不會動到單品本身、人物或姿勢。\n\n使用示例：\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2026-10-22/webp_23606d07-1943-449d-93d5-9ee8fa69dc38.webp)\n\n![](https://plugins-media.makeupar.com/smb/blog/post/2026-10-16/webp_972912f5-866d-4134-9347-45bde4991724.webp)\n\n---\n\n## 整合指南 (Integration Guide)\n\n* AI 虛擬換裝 Mix & Match 使用指南\n\n本指南說明如何上傳使用者照片與參考單品、建立試穿任務並解讀結果。任務採非同步：建立任務的回應會給任務 ID，您輪詢狀態端點取得結果。\n\n***\n\n   * 步驟 1. 用 File API 上傳照片\n\n用 **File API**（`/s2s/v2.0/file`）上傳一張使用者照片與 1 到 9 張參考圖，每張圖一個單品。回應會給每個檔案的 `file_id` 與 `requests.url`，把檔案內容上傳到該 URL 即可。您也可以把照片放在公開網址，直接傳 URL。\n\n請保持參考圖與單品類別的順序一致：第 n 張參考圖，對應 `garment_categories` 第 n 個類別的單品。\n\n***\n\n   * 步驟 2. 建立試穿任務\n\n用 **AI 任務 API**（`/s2s/v2.0/task/cloth-mix-v2`），傳入使用者照片、參考圖、每張圖的類別，以及選填的穿法備註：\n\n```bash\ncurl --request POST \\\n  --url https://yce-api-01.makeupar.com/s2s/v2.0/task/cloth-mix-v2 \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json' \\\n  --data '{\n    \"src_file_url\": \"https://example.com/selfie.jpg\",\n    \"ref_file_urls\": [\n      \"https://example.com/1.jpg\",\n      \"https://example.com/2.jpg\",\n      \"https://example.com/3.jpg\"\n    ],\n    \"garment_categories\": [\"upper_body\", \"lower_body\", \"shoes\"],\n    \"styling_note\": \"tuck the top in\"\n  }'\n```\n\n    > `garment_categories` 是必填，長度必須與參考圖陣列相同；長度不符會回傳 `invalid_parameter`。任務大約需要 40 到 50 秒，附穿法備註會多 3 到 4 秒。超過 400 秒仍未完成的任務會以 `unknown_internal_error` 失敗，可重試。\n\n***\n\n   * 步驟 3. 輪詢任務結果\n\n用建立任務回應裡的 `task_id` 查詢狀態，直到 `task_status` 變成 `success` 或 `error`：\n\n```bash\ncurl --request GET \\\n  --url https://yce-api-01.makeupar.com/s2s/v2.0/task/cloth-mix-v2/YOUR_TASK_ID \\\n  --header 'Authorization: Bearer YOUR_API_KEY' \\\n  --header 'content-type: application/json'\n```\n\n***\n\n   * 步驟 4. 取得結果\n\n成功的回應會回傳一張造型照。有附穿法備註時，`not_applied` 會列出沒照做的部分與原因；其餘一律照常套用。\n\n```json\n{\n  \"status\": 200,\n  \"data\": {\n    \"error\": null,\n    \"results\": {\n      \"url\": \"https://example.com/sample-result-url\",\n      \"not_applied\": \"bottom high-waisted: the trousers are already high-waisted\"\n    },\n    \"task_status\": \"success\"\n  }\n}\n```\n\n    > 只有回傳結果照片時才會消耗點數。以錯誤結束的任務不扣點。\n\n---\n\n## 輸入與輸出 (Inputs & Outputs)\n\n* 請求主體\n\n`src_file_url` / `src_file_id`：兩者取一。`ref_file_urls` / `ref_file_ids`：兩者取一。\n\n| 欄位 | 型別 | 必填 | 預設 | 說明 |\n|---|---|---|---|---|\n| src_file_url / src_file_id | string | 是* | - | 使用者照片，公開可取的 URL 或 File API 的檔案 ID |\n| ref_file_urls / ref_file_ids | string 陣列 | 是* | - | 1 到 9 張參考圖，每張一個單品，順序與 `garment_categories` 一致 |\n| garment_categories | string 陣列（enum） | 是 | - | 每張參考圖的類別，順序與長度和參考圖陣列一致：`upper_body`、`lower_body`、`full_body`、`outer`、`shoes`、`bag`、`headwear`、`accessory` |\n| styling_note | string | 否 | `\"\"` | 穿法備註，最多 300 字自由文字，例如 \"tuck the top in\"、\"wear the jacket open\"、\"carry the bag crossbody\" |\n\n* 單品類別\n\n| garment_category | 內容 | 上限 |\n|---|---|---|\n| upper_body | 上衣 | 1 |\n| lower_body | 下身單品 | 1 |\n| full_body | 連身款，例如洋裝 | 1，不可與 `upper_body` 或 `lower_body` 併用 |\n| outer | 外套、背心 | 1 |\n| shoes | 鞋子 | 1 |\n| bag | 包 | 1 |\n| headwear | 帽子、髮帶 | 1 |\n| accessory | 眼鏡、項鍊、耳環、手錶、腰帶、圍巾 | 3 |\n\n    > 您送來的類別會照原樣使用，引擎不會重新分類。配件擺放位置由引擎決定，新配件會取代人物身上同一位置的既有配件。\n\n* 結果（`data.results`）\n\n| 欄位 | 型別 | 說明 |\n|---|---|---|\n| url | string | 下載結果照片的 URL。有效 2 小時 |\n| not_applied | string | `styling_note` 中未套用的部分與原因。只在有給 `styling_note` 時回傳 |\n\n---\n\n## 檔案規格與錯誤 (File Specs & Errors)\n\n* 支援格式與尺寸\n\n| 項目 | 支援尺寸 | 支援檔案大小 | 支援格式 |\n|---|---|---|---|\n| 使用者照片 | 正面照片。最小 512 x 384，最長邊 4096 px。長寬比上限 3:1，超出部分從中央裁切 | < 10MB | JPEG, PNG, HEIC |\n| 參考圖 | 最小 512 x 384，最長邊 4096 px。不裁切（腰帶、項鍊類可超過 3:1） | < 10MB | JPEG, PNG, HEIC |\n| 結果照片 | 維持使用者照片的長寬比，上限約 1.5 MP（1024 x 1536）；最長邊低於 1024 會放大到 1024。例：3000 x 4000 -> 1072 x 1440、4000 x 1000 -> 2160 x 720 | - | JPEG |\n\n    > 透明背景的照片會以白底合成。結果照片附有 C2PA 簽章。\n\n* 錯誤碼\n\n| 錯誤碼 | 說明 |\n|---|---|\n| invalid_parameter | 參數缺少或無效；訊息會標明是哪個參數 |\n| error_download_image | 無法下載使用者照片或參考圖 |\n| error_invalid_src | 無法讀取使用者照片 |\n| error_invalid_ref | 無法讀取參考圖 |\n| error_analyze_failed | 單品分析失敗或逾時 |\n| error_ref_categories | 這些單品無法一起穿：類別重複、`full_body` 與 `upper_body`/`lower_body` 併用、`bag` 或 `headwear` 超過 1 個、`accessory` 超過 3 個 |\n| error_nsfw_content_detected | 偵測到不當內容，拒絕生成 |\n| unknown_internal_error | 其他錯誤，含 400 秒內未完成的任務 |\n\n---\n\n## 點數消耗 (Unit Consumption)\n\n| 參考單品數 | 消耗點數 |\n|---|---|\n| 1 件試穿 | 3 點 |\n| 2 件試穿 | 4 點 |\n| 3 件試穿 | 5 點 |\n| 4 件試穿 | 6 點 |\n| 5 件試穿 | 7 點 |\n| 6 件試穿 | 8 點 |\n| 7 件試穿 | 9 點 |\n| 8 件試穿 | 10 點 |\n| 9 件試穿 | 11 點 |\n\n    > 只有回傳結果照片時才會消耗點數；以錯誤結束的任務不扣點。\n\n---\n",
    "version": "",
    "termsOfService": "https://www.makeupar.com/perfectbeauty/youcam/terms-of-service-api",
    "contact": {
      "email": "YouCamOnlineEditor_API@perfectcorp.com"
    },
    "license": {
      "name": "Privacy policy",
      "url": "https://www.makeupar.com/perfectbeauty/youcam/privacy-policy-api"
    }
  },
  "servers": [
    {
      "url": "https://yce-api-01.makeupar.com"
    }
  ],
  "tags": [
    {
      "name": "V1.0",
      "description": "AI 虛擬換裝 Mix & Match API 在單一任務中，讓一張使用者照片穿上 1 到 9 張單品參考圖。每張參考圖附上單品類別，用穿法備註描述怎麼穿，就能拿到一張完整造型照。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/cloth-mix-v2": {
      "post": {
        "summary": "執行 AI 虛擬換裝 Mix & Match 任務。",
        "description": "AI 任務是非同步的。當功能支援 webhook 時，請優先使用以 webhook 為基礎的完成處理。設定您的 webhook 端點、驗證 webhook 簽章，並在收到 `success` 或 `error` 通知後，使用收到的 `task_id` 查詢任務結果。設定與驗證細節請見 [webhook 整合指南](/develop/webhook.md)。\n\n若您的整合不支援 webhook 或無法使用 webhook，請實作輪詢。送出 AI 任務後，以固定間隔（例如每 10 秒）輪詢狀態端點，直到任務狀態為 `success` 或 `error`。\n",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "allOf": [
                      {
                        "title": "用 src file url 與 ref file urls 執行任務",
                        "required": [
                          "ref_file_urls"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileUrls"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "title": "用 src file url 與 ref file IDs 執行任務",
                        "required": [
                          "ref_file_ids"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileUrl"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileIds"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "title": "用 src file ID 與 ref file urls 執行任務",
                        "required": [
                          "ref_file_urls"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileUrls"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  },
                  {
                    "allOf": [
                      {
                        "title": "用 src file ID 與 ref file IDs 執行任務",
                        "required": [
                          "ref_file_ids"
                        ]
                      },
                      {
                        "$ref": "#/components/schemas/BasicRunTaskV2SrcFileId"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixRefFileIds"
                      },
                      {
                        "$ref": "#/components/schemas/ClothMixTaskParams"
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "任務執行成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BasicRunTaskResponseV2"
                }
              }
            }
          },
          "400": {
            "description": "任務執行失敗",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/RunError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/s2s/v2.0/task/cloth-mix-v2/{task_id}": {
      "get": {
        "summary": "查詢 AI 虛擬換裝 Mix & Match 任務狀態。",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
            },
            "description": "要查詢的任務 ID"
          }
        ],
        "responses": {
          "200": {
            "description": "任務狀態查詢成功",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/TaskStatusResponseV2"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "data": {
                          "type": "object",
                          "properties": {
                            "results": {
                              "type": "object",
                              "properties": {
                                "not_applied": {
                                  "type": "string",
                                  "description": "styling_note 中未套用的部分與原因。只在有給 styling_note 時回傳"
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidTaskId"
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "500": {
            "$ref": "#/components/responses/TaskTimeout"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClothMixRefFileUrls": {
        "type": "object",
        "properties": {
          "ref_file_urls": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "description": "1 到 9 張參考圖的 URL，每張一個單品。第 n 張圖對應 garment_categories 第 n 個類別的單品。URL 必須可公開存取。",
            "example": [
              "https://example.com/full_body.jpg",
              "https://example.com/shoes.jpg"
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ClothMixRefFileIds": {
        "type": "object",
        "properties": {
          "ref_file_ids": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "description": "1 到 9 張參考圖的 ID，每張一個單品。第 n 張圖對應 garment_categories 第 n 個類別的單品。ID 取自上傳檔案 API。",
            "example": [
              "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ClothMixTaskParams": {
        "type": "object",
        "required": [
          "garment_categories"
        ],
        "properties": {
          "garment_categories": {
            "type": "array",
            "minItems": 1,
            "maxItems": 9,
            "description": "每張參考圖的類別，順序與長度和 ref_file_urls（或 ref_file_ids）一致。除 accessory 最多 3 個外，每個類別以一個單品為限；full_body 不可與 upper_body 或 lower_body 併用。",
            "example": [
              "full_body",
              "shoes"
            ],
            "items": {
              "type": "string",
              "enum": [
                "upper_body",
                "lower_body",
                "full_body",
                "outer",
                "shoes",
                "bag",
                "headwear",
                "accessory"
              ]
            }
          },
          "styling_note": {
            "type": "string",
            "maxLength": 300,
            "default": "",
            "description": "單品的穿法，例如 \"jacket open\"（外套敞開）、\"top tucked in\"（上衣紮進褲頭）、 \"bag cross body\"（包斜背）。只改變穿法，不會動到單品本身、人物或姿勢。無法套用的部分會被跳過， 並列在結果的 not_applied 中。",
            "example": "top tucked in"
          }
        }
      },
      "BasicRunTaskV2SrcFileUrl": {
        "type": "object",
        "required": [
          "src_file_url"
        ],
        "properties": {
          "src_file_url": {
            "type": "string",
            "description": "要執行任務的檔案網址。該網址應可公開存取。",
            "example": "https://example.com/selfie.jpg"
          }
        }
      },
      "BasicRunTaskV2SrcFileId": {
        "type": "object",
        "required": [
          "src_file_id"
        ],
        "properties": {
          "src_file_id": {
            "type": "string",
            "description": "要執行任務的檔案 ID。檔案 ID 來自上傳檔案 API。",
            "example": "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE="
          }
        }
      },
      "BasicRunTaskResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "回應狀態",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_id": {
                "type": "string",
                "description": "這個任務的 ID。任務結果可以此 ID 查詢，有效期限 30 天。",
                "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
              }
            }
          }
        }
      },
      "RunError": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "回應狀態",
            "example": 400
          },
          "error": {
            "type": "string",
            "description": "錯誤訊息",
            "example": "The operation could not be completed"
          },
          "error_code": {
            "type": "string",
            "enum": [
              "InvalidParameters",
              "CreditInsufficiency",
              "InvalidStyleGroup",
              "InvalidStyle",
              "BadRequest"
            ],
            "description": "錯誤代碼：\n* InvalidParameters - 請求參數無效\n* CreditInsufficiency - 點數不足，無法執行\n* BadRequest - 非預期的請求參數\n* InvalidStyleGroup - 風格群組 id 無效\n* InvalidStyle - 風格 id 無效\n"
          }
        }
      },
      "EngineErrorCode": {
        "type": "string",
        "nullable": true,
        "enum": [
          "error_exceed_max_image_size",
          "exceed_max_filesize",
          "invalid_parameter",
          "error_download_image",
          "error_download_mask",
          "error_decode_image",
          "error_decode_mask",
          "error_nsfw_content_detected",
          "error_no_face",
          "error_pose",
          "error_face_parsing",
          "error_inference",
          "exceed_nsfw_retry_limits",
          "error_upload",
          "unknown_internal_error"
        ],
        "description": "錯誤：\n- \\`error_exceed_max_image_size\\`  - 輸入圖片尺寸超過上限\n- \\`exceed_max_filesize\\` - 輸入檔案大小超過上限\n- \\`invalid_parameter\\` - 參數值無效\n- \\`error_download_image\\` - 下載來源圖片錯誤\n- \\`error_download_mask\\` - 下載遮罩圖片錯誤\n- \\`error_decode_image\\` - 解析來源圖片錯誤\n- \\`error_decode_mask\\` - 解析遮罩圖片錯誤\n- \\`error_nsfw_content_detected\\` - 在來源圖片中偵測到 NSFW 內容\n- \\`error_no_face\\` - 來源圖片未偵測到臉部\n- \\`error_pose\\` - 無法偵測來源圖片的姿势\n- \\`error_face_parsing\\` - 無法對來源圖片進行臉部分割\n- \\`error_inference\\` - 推論流程錯誤\n- \\`exceed_nsfw_retry_limits\\` - 超過重試上限以避免產生 NSFW 圖片\n- \\`error_upload\\` - 上傳結果圖片錯誤\n- \\`unknown_internal_error\\` - 其他"
      },
      "TaskStatusResponseBodySingleUrlResultsV2": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "下載這個結果的網址。有效期限 2 小時",
            "example": "https://example.com/sample-result-url"
          }
        }
      },
      "TaskStatusResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "回應狀態",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_status": {
                "type": "string",
                "enum": [
                  "running",
                  "success",
                  "error"
                ],
                "description": "這個任務的狀態"
              },
              "error": {
                "$ref": "#/components/schemas/EngineErrorCode"
              },
              "error_message": {
                "type": "string",
                "description": "錯誤的詳細說明"
              },
              "results": null
            }
          }
        },
        "$ref": "#/components/schemas/TaskStatusResponseBodySingleUrlResultsV2"
      }
    },
    "securitySchemes": {
      "BearerAuthenticationV2": {
        "type": "http",
        "scheme": "bearer",
        "description": "使用標準的 'Bearer authentication'。請在標頭中放入您的 'API Key'：`Authorization:Bearer YOUR_API_KEY`。請注意 'Bearer' 與 'YOUR_API_KEY' 之間有一個空格。"
      }
    },
    "responses": {
      "InvalidApiKey": {
        "description": "API 金鑰無效或缺失",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Invalid API key"
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "請求過多",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 429,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Too many requests"
                }
              }
            }
          }
        }
      },
      "InvalidTaskId": {
        "description": "任務 ID 無效",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 400,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Invalid task ID"
                }
              }
            }
          }
        }
      },
      "TaskTimeout": {
        "description": "任務執行逾時",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 500,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Task execution timed out"
                }
              }
            }
          }
        }
      }
    }
  }
}