{
  "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": "ユニットの詳細と使用履歴を確認します。ユニットは YouCam API 操作で使用される通貨であり、異なる AI 機能によって消費されるユニットの量は異なります。本ドキュメントでは、ユニットのコード名として \"Credit\" を使用しています。\n"
  },
  "servers": [
    {
      "url": "https://yce-api-01.makeupar.com"
    }
  ],
  "paths": {
    "/s2s/v1.0/client/credit": {
      "get": {
        "summary": "ユニット情報を取得",
        "description": "利用可能な API ユニットを小数点以下 2 桁まで表示します",
        "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": "小数点以下 2 桁まで表示される残りのユニット数。",
                            "example": 10.04
                          },
                          "expiry": {
                            "type": "integer",
                            "description": "このユニットの有効期限の Unix タイムスタンプ (ms)",
                            "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 ページあたりの返却結果数。有効な値は 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 タイムスタンプ（ms）"
                              },
                              "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": "記録されたユニットの正味変化量。小数点以下 2 桁で表示されます。"
                                        }
                                      }
                                    }
                                  },
                                  "dst_actions": {
                                    "type": "array",
                                    "description": "AI 肌分析の 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": "1 ページあたりに返される結果の数。初期値は 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` の 1 回の課金に含まれる `unit` の数"
                              },
                              "run_task_url": {
                                "type": "string",
                                "example": "https://yce-api-01.makeupar.com/s2s/v2.0/task/skin-analysis",
                                "description": "この SKU を消費するタスクエンドポイントの完全な URL"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "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 認証」を使用します。ヘッダーに「API キー」を指定します：`Authorization:Bearer YOUR_API_KEY`。「Bearer」と「YOUR_API_KEY」の間にスペースが 1 つあることに注意してください。"
      }
    },
    "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": "無効なアクセストークン",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "レスポンスステータス"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidAccessToken"
                  ],
                  "description": "エラーコード:\n  * InvalidAccessToken - アクセストークンが指定されていないか、有効ではありません"
                }
              }
            }
          }
        }
      },
      "InvalidApiKey": {
        "description": "無効または欠落している API キー",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "レスポンスステータス"
                },
                "error": {
                  "type": "string",
                  "example": "Invalid API key"
                }
              }
            }
          }
        }
      }
    }
  }
}