{
  "openapi": "3.0.0",
  "info": {
    "title": "單位系統",
    "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"
    },
    "description": "查詢您的點數明細與使用紀錄。請注意，Units 是 YouCam API 運作所用的計費單位；不同的 AI 功能會扣除不同數量的點數。在本文件中，Unit 的代號為「Credit」。\n"
  },
  "servers": [
    {
      "url": "https://yce-api-01.makeupar.com"
    }
  ],
  "paths": {
    "/s2s/v1.0/client/credit": {
      "get": {
        "summary": "取得點數資訊",
        "description": "以小數第二位顯示可用的 API 點數",
        "security": [
          {
            "BearerAuthentication": []
          }
        ],
        "responses": {
          "200": {
            "description": "成功取得點數資訊",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "description": "回應狀態",
                      "example": 200
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer",
                            "description": "這個點數的唯一識別碼",
                            "example": 13105541279084536
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "ApiSubsToken",
                              "ApiPaygToken"
                            ],
                            "description": "這個點數的類型"
                          },
                          "amount": {
                            "deprecated": true,
                            "type": "integer",
                            "description": "此參數已棄用。請改用 amount_dec。目前的點數餘額。",
                            "example": 10
                          },
                          "amount_dec": {
                            "type": "number",
                            "description": "以小數第二位顯示的剩餘點數。",
                            "example": 10.04
                          },
                          "expiry": {
                            "type": "integer",
                            "description": "這個點數到期日的 Unix 時間戳（毫秒）",
                            "example": 1704789135000
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/s2s/v1.0/client/credit/history": {
      "get": {
        "summary": "檢視點數紀錄",
        "security": [
          {
            "BearerAuthentication": []
          }
        ],
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer",
              "example": 20
            },
            "description": "每一頁要回傳的結果數量。有效值應介於 1 到 30 之間。預設為 20。"
          },
          {
            "name": "starting_token",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "73a3c9e69b89"
            },
            "description": "目前頁面的令牌。第一頁以 `null` 開始，並使用上一個回應中的 `next_token` 開始下一頁"
          }
        ],
        "responses": {
          "200": {
            "description": "成功取得點數使用紀錄",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "example": 200,
                      "description": "回應狀態"
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "next_token": {
                          "type": "string",
                          "example": "73a3c9e69b89",
                          "description": "查詢下一頁的令牌。"
                        },
                        "history": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "integer",
                                "example": 38173479337460984,
                                "description": "紀錄的唯一識別碼"
                              },
                              "timestamp": {
                                "type": "integer",
                                "example": 1703146067000,
                                "description": "紀錄的 Unix 時間戳（毫秒）"
                              },
                              "action": {
                                "type": "string",
                                "example": "photo_enhance",
                                "enum": [
                                  "photo_enhance",
                                  "api_photo_enhance",
                                  "object_removal",
                                  "api_object_removal",
                                  "background_removal",
                                  "api_background_removal",
                                  "colorize",
                                  "api_colorize",
                                  "text_to_image",
                                  "api_text_to_image",
                                  "hair_style",
                                  "api_hair_style",
                                  "blur_background",
                                  "change_background",
                                  "wig",
                                  "trial_gift_text_to_image",
                                  "sign_up_gift",
                                  "subscription_credits",
                                  "subscriber_gift",
                                  "permanent_credits",
                                  "compensation_from_customer_service",
                                  "renew",
                                  "expire"
                                ],
                                "description": "這個紀錄的動作"
                              },
                              "target_id": {
                                "type": "string",
                                "example": "7TWFkuE2Z9uR0NOxSmQ1rh4PJ5Zx7YJ5U9SAz51q0QHVwMP+Jb1XbjPsf7ZgUgLY",
                                "description": "這個點數的目標 id。例如，執行 AI 照片修復任務時，這條紀錄的 `target_id` 就是該 AI 照片修復任務的 `task_id`。購買點數時，這條紀錄的 `target_id` 就是 `order_id`"
                              },
                              "info": {
                                "type": "object",
                                "properties": {
                                  "credits": {
                                    "type": "array",
                                    "example": [
                                      {
                                        "id": 24409059381740548,
                                        "amount": -2
                                      },
                                      {
                                        "id": 27297116883780870,
                                        "amount": 0
                                      }
                                    ],
                                    "description": "每個點數的詳細資訊",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "id": {
                                          "type": "integer",
                                          "description": "點數的 id"
                                        },
                                        "amount": {
                                          "deprecated": true,
                                          "type": "integer",
                                          "description": "此參數已棄用。請改用 amount_dec。這個點數變更的總量。"
                                        },
                                        "amount_dec": {
                                          "type": "number",
                                          "description": "以小數第二位呈現的點數淨變動量。"
                                        }
                                      }
                                    }
                                  },
                                  "dst_actions": {
                                    "type": "array",
                                    "description": "肌膚檢測的 dst_actions",
                                    "items": {
                                      "type": "string"
                                    },
                                    "example": "[ \"hd_wrinkle\", \"hd_pore\", \"hd_texture\" ]"
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidParameters"
          },
          "401": {
            "$ref": "#/components/responses/InvalidAccessToken"
          }
        }
      }
    },
    "/s2s/v2.0/credit/feature-cost": {
      "get": {
        "summary": "取得功能費用",
        "description": "查詢每個 API 的點數消耗。這些數值與 https://yce.perfectcorp.com/ai-api/api-pricing 列出的內容一致。",
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "parameters": [
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer",
              "example": 20,
              "minimum": 1,
              "maximum": 20
            },
            "description": "每一頁要回傳的結果數量。預設為 20。值範圍：[1 - 20]"
          },
          {
            "name": "starting_token",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "MjA"
            },
            "description": "目前頁面的令牌。第一頁以 `null` 開始，並使用上一個回應中的 `next_token` 開始下一頁"
          }
        ],
        "responses": {
          "200": {
            "description": "成功取得各 sku 的功能費用",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer",
                      "example": 200,
                      "description": "回應狀態"
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "next_token": {
                          "type": "string",
                          "example": "MjA",
                          "description": "查詢下一頁的令牌。沒有更多頁面時為 `null`。"
                        },
                        "skus": {
                          "type": "array",
                          "description": "sku 清單",
                          "items": {
                            "type": "object",
                            "properties": {
                              "description": {
                                "type": "string",
                                "example": "AI Skin Analysis for SD 1~4 concerns",
                                "description": "sku 的說明"
                              },
                              "amount": {
                                "type": "number",
                                "example": 9,
                                "description": "每個 `proc_unit` 消耗的點數"
                              },
                              "unit": {
                                "type": "string",
                                "enum": [
                                  "result_image",
                                  "second"
                                ],
                                "example": "result_image",
                                "description": "費用的計量單位"
                              },
                              "proc_unit": {
                                "type": "integer",
                                "example": 1,
                                "description": "一次 `amount` 收費中包含的 `unit` 數量"
                              },
                              "run_task_url": {
                                "type": "string",
                                "example": "https://yce-api-01.makeupar.com/s2s/v2.0/task/skin-analysis",
                                "description": "消耗這個 sku 的任務端點完整網址"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "status": 200,
                  "result": {
                    "next_token": "MjA",
                    "skus": [
                      {
                        "description": "用於 SD 1~4 項目的 AI 肌膚檢測",
                        "amount": 9,
                        "unit": "result_image",
                        "proc_unit": 1,
                        "run_task_url": "https://yce-api-01.makeupar.com/s2s/v2.0/task/skin-analysis"
                      },
                      {
                        "description": "用於 SD 5~7 項目的 AI 肌膚檢測",
                        "amount": 12,
                        "unit": "result_image",
                        "proc_unit": 1,
                        "run_task_url": "https://yce-api-01.makeupar.com/s2s/v2.0/task/skin-analysis"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidParameters"
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuthentication": {
        "type": "http",
        "scheme": "bearer",
        "description": "使用從認證取得的 `access_token`，並放入標頭：`Authorization:Bearer <access_token>`"
      },
      "BearerAuthenticationV2": {
        "type": "http",
        "scheme": "bearer",
        "description": "使用標準的 'Bearer authentication'。請在標頭中放入您的 'API Key'：`Authorization:Bearer YOUR_API_KEY`。請注意 'Bearer' 與 'YOUR_API_KEY' 之間有一個空格。"
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "認證失敗，或使用者沒有必要的權限"
      },
      "InvalidParameters": {
        "description": "請求參數無效",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 400,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Invalid parameter value"
                },
                "error_code": {
                  "type": "string",
                  "example": "InvalidParameters"
                }
              }
            }
          }
        }
      },
      "InvalidAccessToken": {
        "description": "Access token 無效",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "回應狀態"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidAccessToken"
                  ],
                  "description": "錯誤代碼：\n* InvalidAccessToken - 未提供 access token 或無效\n"
                }
              }
            }
          }
        }
      },
      "InvalidApiKey": {
        "description": "API 金鑰無效或缺失",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "回應狀態"
                },
                "error": {
                  "type": "string",
                  "example": "Invalid API key"
                }
              }
            }
          }
        }
      }
    }
  }
}