# カスタムアトリビューションを追加する

> マーケティングのカスタムアトリビューションデータをプロファイルに追加します。

## OpenAPI

```yaml
/api-specs/web-api.yaml post /api/v2/web-api/attribution/
openapi: 3.1.0
info:
  title: Adapty Web API
  version: 1.0.0
  description: |
    Adapty Web API を使用すると、Adapty のサブスクリプション管理プラットフォームを
    Web アプリケーションに統合できます。この API は、ペイウォールの取得、
    ペイウォール表示の記録、アトリビューションデータの追加などのエンドポイントを提供します。
servers:
  - url: https://api.adapty.io
    description: 本番サーバー
security:
  - apikeyAuth: []
paths:
  /api/v2/web-api/attribution/:
    post:
      summary: カスタムアトリビューションを追加する
      description: マーケティングのカスタムアトリビューションデータをプロファイルに追加します。
      operationId: addAttribution
      security:
        - apikeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AddAttributionRequest"
            examples:
              basic:
                summary: Basic attribution data
                value:
                  status: organic
                  attribution_user_id: attribution_user_id_value
                  channel: marketing_channel_value
                  campaign: campaign_name_value
                  ad_group: ad_group_name_value
                  ad_set: ad_set_name_value
                  creative: creative_name_value
                  customer_user_id: user123
      responses:
        "201":
          description: アトリビューションがプロファイルに正常に追加されました。レスポンスボディは空です。
          content:
            application/json:
              schema:
                type: object
                description: レスポンスボディは空です
        "400":
          description: リクエストが不正です
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/InvalidEnumerationMemberError"
        "401":
          description: 認証されていません
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UnauthorizedError"
        "404":
          description: 見つかりません
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileNotFoundError"
components:
  schemas:
    AddAttributionRequest:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - organic
            - non_organic
            - unknown
          description: アトリビューションがオーガニックかノンオーガニックかを示します。
          example: organic
        attribution_user_id:
          type: string
          description: アトリビューションソースがユーザーに割り当てた ID。
          example: attribution_user_id_value
        channel:
          type: string
          description: マーケティングチャネル名。
          example: marketing_channel_value
        campaign:
          type: string
          description: マーケティングキャンペーン名。
          example: campaign_name_value
        ad_group:
          type: string
          description: アトリビューションの広告グループ。
          example: ad_group_name_value
        ad_set:
          type: string
          description: アトリビューションの広告セット。
          example: ad_set_name_value
        creative:
          type: string
          description: アトリビューションのクリエイティブキーワード。
          example: creative_name_value
        customer_user_id:
          type: string
          description: アプリでユーザーを識別するために使用するユーザー ID（例：ユーザーの UUID、メールアドレス、その他の ID）。設定していない場合は null。`customer_user_id` または `profile_id` のいずれかが必須です。
          example: user123
        profile_id:
          type: string
          description: Adapty におけるユーザーの識別子。Adapty ダッシュボードのプロファイルの **Adapty ID** フィールドで確認できます。`customer_user_id` または `profile_id` のいずれかが必須です。
          example: 3286abd3-48b0-4e9c-a5f6-ac0a006804a6
    InvalidEnumerationMemberError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    UnauthorizedError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
    ProfileNotFoundError:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
              errors:
                type: array
                items:
                  type: string
        error_code:
          type: string
        status_code:
          type: integer
  securitySchemes:
    apikeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: |
        API リクエストは、**Authorization** ヘッダーに公開 API キーを使用して認証する必要があります。
        値は `Api-Key {your_public_api_key}` の形式（例：`Api-Key public_live_...`）で指定します。
        このキーは Adapty ダッシュボード -> **App Settings** -> **General** タブ -> **API keys** セクションで確認できます。
```
