{
  "openapi": "3.0.0",
  "info": {
    "title": "髪のうねり分析",
    "description": "# 概要\n180° フルビュー髪のうねり分析\n\nAI 髪のうねり分析ツールでは、髪の正面、左側、右側の 3 枚の写真をアップロードして髪のうねりレベルを分析します。\n\n企業は、髪のうねりレベルに基づいたヘアソリューションやアンチフラジー製品を提供できます。\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/hair_frizzy_S_02_enu_b80c238858.jpg)\n\n## 統合ガイド\n\n1. **セルフィーのアップロード**\n  ソース画像は以下の 2 通りの方法で提供できます。\n\n  - **既存の公開画像 URL の使用**\n    アップロードの代わりに、AI タスクを開始する際に公開アクセス可能な画像 URL を直接指定できます。\n\n  - **File API によるアップロード**\n    エンドポイントを使用します。\n    ```\n    POST /s2s/v2.0/file\n    ```\n    これにより、後続のタスク実行用の `file_id` が返されます。\n\n    - ***重要***: File API を呼び出すだけではファイルはアップロードされません。File API のレスポンスで提供された **URL に手動でファイルをアップロード** する必要があります。その URL がアップロード先です。次に進む前に、ファイルが正常に転送されたことを確認してください。\n\n    AI API を呼び出す前に、ファイルが正常にアップロードされていることを確認してください。File API を使用してアップロード URL を取得し、その場所にファイルをアップロードします。アップロードが完了すると、レスポンスに ***file_id*** が含まれます。この ID は、そのファイルに関連する AI 機能にアクセスするために使用します。\n\n      > **警告:** File API のレスポンスで提供された URL にファイルをアップロードしない場合、AI API の使用時に 500 Server Error / unknown_internal_error または 404 Not Found エラーが発生します。\n\n2.  **AI タスクの実行とタスク ID の取得**\n    /s2s/v2.0/task/hair-frizziness-detection を使用して AI タスクを実行します。対象ユーザー画像には、``src_file_url`` または ``src_file_id`` のいずれかを指定します。また、適用するスタイルの ``template_id`` を指定し、``task_id`` を取得します。\n\n3.  **タスクのステータス確認のためのポーリング（成功または失敗まで）**\n    ``task_id`` を使用して、GET /s2s/v2.0/task/hair-frizziness-detection をポーリングし、現在のエンジンステータスを取得してタスクのステータスを監視します。エンジンがタスクを完了するまで、ステータスは running のままとなり、この段階ではユニットは消費されません。\n    AI タスクが成功または失敗した際に通知を受け取るために Webhook を実装することもできます。詳細は **[Webhook](../../../../develop/webhook)** セクションを参照してください。\n\n    > **警告:** 保持期間内にタスクのステータスを確認するためにポーリングを行うことが必須です。保持期間内にポーリングリクエストがない場合、タスクが正常に処理されていてもタイムアウトします。ユニットは消費されます。\n\n    > **警告:** タイムアウトしたタスクのステータスを確認すると、InvalidTaskId エラーが発生します。したがって、AI タスクを実行した後は、ステータスが success または error になるまで、保持期間内にステータスを確認するためにポーリングを行う必要があります。\n\n4.  **成功後の AI タスク結果の取得**\n    エンジンが入力ファイルを処理し、結果画像を生成すると、タスクのステータスは success に変わります。処理済み画像の URL が返されます。\n\n## 入力と出力\n* 入力形式\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/hair_frizzy_step_01_ac5c651ea4.png)\n髪の正面、左側、右側の 3 枚の写真をアップロードします。\nJS Camera Kit を使用して、3 枚の適格な写真を撮影するための Javascript カメラモジュールを実装できます。\n\n\n* 出力形式\nAI 髪のうねり分析ツールでは髪質を評価し、滑らかな髪から非常にうねった髪まで、4 つの異なる髪のうねり度を識別します。\n\n| **マッピング (0–3)** | **用語**            | **説明**                                           |\n| ----------------- | ------------------- | --------------------------------------------------------- |\n| 0             | Not Frizzy      | 髪は滑らかで、目立つうねりはほとんどまたは全く見られません。     |\n| 1            | Slightly Frizzy | 軽いうねりが見られます。表面の質感にわずかな不規則性があります。 |\n| 2             | Frizzy         | 髪全体に目立つうねりがあります。質感の乱れが明確です。   |\n| 3             | Extreme Frizzy  | 強いうねりが広範囲に見られます。髪の質感が非常に不規則です。  |\n\n![](https://bcw-media.s3.ap-northeast-1.amazonaws.com/hair_frizzy_S_01_enu_fcd10905ff.jpg)\n\n* サンプル出力\n```json\n{\n  \"mapping\": 1, // number; the key to map of result, alternatives: [0, 1, 2, 3]\n  \"term\": \"Slightly Frizzy\" // string; 1-1 map to the \"mapping\", alternatives: [\"Not Frizzy\", \"Slightly Frizzy\", \"Frizzy\", \"Extreme Frizzy\"]\n}\n```\n\n## ファイル仕様とエラー\n* サポートされる形式と寸法\n\n|タイプ|サポートされる寸法|サポートされるファイルサイズ|サポートされる形式|\n|  ----  | ----  | ----  | ----  |\n|AI 髪のうねり分析|画像は幅と高さともに少なくとも 320 ピクセル、いずれかの次元で最大 4096 ピクセルである必要があります。画像の片側の長さが 1080 ピクセルを超える場合、分析のためにその制限内に自動的にリサイズされます。|< 10MB|jpg/png|\n\n* エラーコード\n\n|エラーコード|説明|\n|  ----  | ----  |\n|error_mismatch_image_size|すべての顔写真（正面、左側、右側）が同じサイズであることを確認してください|\n|error_below_min_image_size|画像の幅または高さが 320 ピクセル未満の場合、使用するには小さすぎます|\n|error_face_position_invalid|画像内で顔全体が完全に視認可能であり、一部が切れていない必要があります|\n|error_face_position_too_small|写真内の顔が小さすぎて適切に分析できません|\n|error_face_position_out_of_boundary|顔が大きすぎるか、写真の端の一部が外れています|\n|error_insufficient_lighting|照明が暗すぎて、分析が困難です|\n|error_face_angle_invalid|顔の角度が正しくありません。正面を向いたショットでは、頭を正面から 10 度以内に保ってください。横を向いたショットでは、角度は 15 度以上である必要があります|\n\n* 環境と依存関係\n\n| サンプルコード言語 / ツール | 推奨ランタイムバージョン |\n|---|---|\n| cURL | - bash >= 3.2</br>   - curl >= 7.58 (モダンな TLS/HTTP サポート)</br>   - jq >= 1.6 (堅牢な JSON パーシング) |\n| Node.js (JavaScript) | Node >= 18 (グローバル fetch 用) |\n| JavaScript | - Chrome / Edge >= 80</br>   - Firefox >= 74</br>   - Safari >= 13.1 |\n| PHP | PHP >= 7.4 (モダンな TLS/互換性用), ext-curl (推奨) または allow_url_fopen=On + ext-openssl, ext-json |\n| Python | Python >= 3.10 (f-strings 用), requests >= 2.20.0 |\n| Java | Java 11+ (HttpClient 用), Jackson Databind >= 2.12.0 |\n\n---\n\n## JS Camera Kit\n{% partial file=\"/_partials/js-camera-kit.md\" /%}\n\n---\n\n## ユニット消費\n\n| AI 機能 | 消費ユニット |\n|---|---|\n| AI 髪のうねり分析 V1.0 | 2 |\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": "髪のうねり分析 API では、3 つの角度（正面、右、左）の入力を使用して、画像内の髪のうねりを検出できます。"
    }
  ],
  "paths": {
    "/s2s/v2.0/task/hair-frizziness-detection": {
      "post": {
        "summary": "髪のうねり分析タスクを実行します。",
        "description": "タスクステータスの確認については、ポーリングガイドを参照してください。",
        "tags": [
          "V1.0"
        ],
        "security": [
          {
            "BearerAuthenticationV2": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BasicFaceAttrReqFaceThreeAngle"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "タスクの実行に成功しました",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BasicRunTaskResponseV2"
                }
              }
            }
          },
          "400": {
            "description": "タスクの実行に失敗しました",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/responses/RunError"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "429": {
            "description": "一定時間内にリクエストが多すぎます",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/s2s/v2.0/task/hair-frizziness-detection/{task_id}": {
      "get": {
        "summary": "髪のうねり分析タスクのステータスを確認します。",
        "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": {
                  "$ref": "#/components/schemas/TaskStatusResponseHairFrizz"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/InvalidTaskId"
          },
          "401": {
            "$ref": "#/components/responses/InvalidApiKey"
          },
          "500": {
            "$ref": "#/components/responses/TaskTimeout"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "FileV1.1": {
        "title": "File V1.1",
        "description": "このオブジェクトはファイルを表します。",
        "type": "object",
        "required": [
          "files"
        ],
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "content_type",
                "file_name",
                "file_size"
              ],
              "properties": {
                "content_type": {
                  "type": "string",
                  "example": "image/jpg",
                  "description": "このファイルのコンテンツ MIME タイプ。現在利用可能な値は enum に記載されています。"
                },
                "file_name": {
                  "type": "string",
                  "example": "my-selfie.jpg",
                  "description": "このファイルの名前"
                },
                "file_size": {
                  "type": "integer",
                  "example": 50000,
                  "description": "このファイルのコンテンツ長（バイト単位）。10MB を超えてはいけません。"
                }
              }
            }
          }
        }
      },
      "BasicFileResponse": {
        "type": "object",
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "content_type": {
                  "type": "string",
                  "example": "image/jpg",
                  "description": "このファイルのコンテンツ MIME タイプ。"
                },
                "file_name": {
                  "type": "string",
                  "example": "my-selfie.jpg",
                  "description": "このファイルの名前"
                },
                "file_id": {
                  "type": "string",
                  "example": "U8aqJbsXGT537jtGnEDFHqxdDXqh8+oTF/cSkLimzuvVwMP+Jb1XbjPsf7ZgUgLY",
                  "description": "このファイルの ID。他のタスク実行 API ではこの `file_id` が必要です。"
                },
                "requests": {
                  "type": "array",
                  "description": "以下の `url`、`headers`、`method` を使用してファイルをアップロードします。完了後、タスク実行 API の呼び出しに進むために `file_id` を使用します。",
                  "items": {
                    "type": "object",
                    "properties": {
                      "headers": {
                        "type": "object",
                        "example": {
                          "Content-Type": "image/jpg",
                          "Content-Length": 50000
                        },
                        "description": "ファイルのアップロード時に含めるヘッダー"
                      },
                      "url": {
                        "type": "string",
                        "example": "https://example.com/presigned-upload-url",
                        "description": "このファイルをアップロードする URL"
                      },
                      "method": {
                        "type": "string",
                        "example": "PUT",
                        "description": "このファイルをアップロードするための HTTP メソッド"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "FileResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "example": 200,
            "description": "レスポンスステータス"
          },
          "data": {
            "$ref": "#/components/schemas/BasicFileResponse"
          }
        }
      },
      "BasicFaceAttrReqFaceThreeAngleWithSrcFileUrls": {
        "title": "3 方向のソースファイル URL を使用したタスク実行",
        "type": "object",
        "required": [
          "src_file_urls"
        ],
        "properties": {
          "src_file_urls": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "description": "ファイルアップロード API からのファイル URL。ソース画像のシーケンスに対するファイル ID は 'frontFace'、'rightFace'、'leftFace' です。'src_file_urls' または 'src_file_ids' のいずれかを指定する必要があります。",
            "example": [
              "https://example.com/selfie.jpg",
              "https://example.com/selfie.jpg",
              "https://example.com/selfie.jpg"
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "BasicFaceAttrReqFaceThreeAngleWithSrcFileIds": {
        "title": "3 方向のソースファイル ID を使用したタスク実行",
        "type": "object",
        "required": [
          "src_file_ids"
        ],
        "properties": {
          "src_file_ids": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "description": "ファイルアップロード API からのファイル ID。ソース画像のシーケンスに対するファイル ID は 'frontFace'、'rightFace'、'leftFace' です。'src_file_urls' または 'src_file_ids' のいずれかを指定する必要があります。",
            "example": [
              "pfNK5PuRe0MrwLHcGA3DOmB1ahwfXTbYHjv+KoBIxbE=",
              "pkVzplMv8Y1QPgHbqtKfyJmg+xJDUbTP16YijZ3qARNf",
              "B5LNohvvO+7d/78Ymuhp6vMiSooN/5DX9oVuupzkKctf"
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "BasicFaceAttrReqFaceThreeAngle": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/BasicFaceAttrReqFaceThreeAngleWithSrcFileUrls"
          },
          {
            "$ref": "#/components/schemas/BasicFaceAttrReqFaceThreeAngleWithSrcFileIds"
          }
        ]
      },
      "BasicRunTaskResponseV2": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "description": "レスポンスステータス",
            "example": 200
          },
          "data": {
            "type": "object",
            "properties": {
              "task_id": {
                "type": "string",
                "description": "このタスクの ID。タスク結果はこの ID で 24 時間以内にクエリ可能です。",
                "example": "grH0CvsgXuAIHLUzD0V1Ol34hoet3R1tvdbtiVHrDb6_UqCLKIejAIajwxrhOAfe"
              }
            }
          }
        }
      },
      "EngineErrorCode": {
        "type": "string",
        "nullable": true,
        "enum": [
          "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- `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` - その他\n"
      },
      "BasicFaceAttrRespHairFrizziness": {
        "type": "object",
        "properties": {
          "mapping": {
            "type": "number",
            "description": "結果のマッピングキー",
            "enum": [
              0,
              1,
              2,
              3
            ]
          },
          "term": {
            "type": "string",
            "description": "\"mapping\" との 1 対 1 対応",
            "enum": [
              "Not Frizzy",
              "Slightly Frizzy",
              "Frizzy",
              "Extreme Frizzy"
            ]
          }
        }
      },
      "TaskStatusResponseHairFrizz": {
        "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": {
                "allOf": [
                  {
                    "type": "object",
                    "properties": {
                      "hair_frizziness": {
                        "$ref": "#/components/schemas/BasicFaceAttrRespHairFrizziness"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }
    },
    "responses": {
      "InvalidParameters": {
        "description": "無効なリクエストパラメータ",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 400,
                  "description": "レスポンスステータス"
                },
                "error": {
                  "type": "string",
                  "description": "エラーメッセージ",
                  "example": "The operation could not be completed"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidParameters"
                  ],
                  "description": "エラーコード:\n  * InvalidParameters - 無効なリクエストパラメータまたはボディ\n"
                }
              }
            }
          }
        }
      },
      "InvalidApiKey": {
        "description": "無効な API キー、非アクティブな API キー、または期限切れの API キー",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "example": 401,
                  "description": "レスポンスステータス"
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidApiKey",
                    "InactiveApiKey",
                    "ExpiredApiKey"
                  ],
                  "description": "エラーコード:\n  * InvalidApiKey - API キーが指定されていないか、有効ではありません\n  * InactiveApiKey - API キーが非アクティブ化されています\n  * ExpiredApiKey - API キーが期限切れです\n"
                }
              }
            }
          }
        }
      },
      "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": [
              "CreditInsufficiency",
              "InvalidStyleGroup",
              "InvalidStyle",
              "BadRequest",
              "InvalidParameters"
            ],
            "description": "エラーコード:\n  * CreditInsufficiency - 実行に必要なユニットが不足しています\n  * BadRequest - 予期しないリクエストパラメータ\n  * InvalidStyleGroup - 無効なスタイルグループ ID\n  * InvalidStyle - 無効なスタイル ID\n  * InvalidParameters - 無効なリクエストパラメータ\n"
          }
        }
      },
      "InvalidTaskId": {
        "description": "無効なタスク ID",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "description": "レスポンスステータス",
                  "example": 400
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "InvalidTaskId"
                  ],
                  "description": "エラーコード:\n  * InvalidTaskId - 無効なタスク ID\n"
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "一定時間内にリクエストが多すぎます"
      },
      "TaskTimeout": {
        "description": "タスクが期待される時間内にレスポンスがありません",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "integer",
                  "description": "レスポンスステータス",
                  "example": 500
                },
                "error_code": {
                  "type": "string",
                  "enum": [
                    "TaskTimeout"
                  ],
                  "description": "エラーコード:\n  * TaskTimeout - タスクが期待される時間内にレスポンスがありません\n"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuthenticationV2": {
        "type": "http",
        "scheme": "bearer",
        "description": "標準の「Bearer 認証」を使用します。ヘッダーに `API Key` を設定します: `Authorization:Bearer YOUR_API_KEY`。`Bearer` と `YOUR_API_KEY` の間にスペースがあることに注意してください。"
      }
    }
  }
}