# プロファイルを更新する

> ユーザープロファイル情報を更新します

## OpenAPI

```yaml
/api-specs/adapty-api.yaml patch /api/v2/server-side-api/profile/
openapi: 3.1.0
info:
  title: Adapty サーバーサイド API
  version: 1.0.0
servers:
  - url: https://api.adapty.io
    description: 本番サーバー
paths:
  /api/v2/server-side-api/profile/:
    patch:
      summary: プロファイルを更新する
      description: ユーザープロファイル情報を更新します
      operationId: updateProfile
      tags:
        - Profile
      security:
        - apikeyAuth: []
      parameters:
        - name: adapty-customer-user-id
          in: header
          required: false
          schema:
            type: string
          description: お客様のシステムにおける顧客の一意の ID です。`adapty-customer-user-id` または `adapty-profile-id` のいずれかが必須です。
        - name: adapty-profile-id
          in: header
          required: false
          schema:
            type: string
          description: お客様のシステムにおけるプロファイルの一意の ID です。匿名プロファイルを扱う場合に最適です。`adapty-customer-user-id` または `adapty-profile-id` のいずれかが必須です。
      responses:
        "200":
          description: プロファイルが正常に更新されました
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileResponse"
        "400":
          description: リクエストが不正です
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: 認証エラー
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: プロファイルが見つかりません
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: 内部サーバーエラー
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProfileRequest"
components:
  schemas:
    ProfileResponse:
      type: object
      properties:
        data:
          $ref: "#/components/schemas/Profile"
      required:
        - data
    ErrorResponse:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              source:
                type: string
                nullable: true
                description: エラーの発生源
              errors:
                type: array
                items:
                  type: string
                description: エラーメッセージの配列
        error_code:
          type: string
          description: エラーの短縮名
        status_code:
          type: integer
          description: HTTP ステータスコード
      required:
        - errors
        - error_code
        - status_code
    ProfileRequest:
      type: object
      properties:
        first_name:
          type: string
          nullable: true
          description: エンドユーザーの名
        last_name:
          type: string
          nullable: true
          description: エンドユーザーの姓
        gender:
          type: string
          nullable: true
          enum:
            - f
            - m
            - o
          description: エンドユーザーの性別
        email:
          type: string
          nullable: true
          format: email
          description: エンドユーザーのメールアドレス
        phone_number:
          type: string
          nullable: true
          description: エンドユーザーの電話番号
        birthday:
          type: string
          format: date
          nullable: true
          description: エンドユーザーの誕生日
        ip_country:
          type: string
          nullable: true
          description: ISO 3166-2 形式のエンドユーザーの国
        ip_v4_address:
          type: string
          nullable: true
          description: エンドユーザーの IPv4 アドレス
        store_country:
          type: string
          nullable: true
          description: エンドユーザーのアプリストアの国
        store:
          type: string
          nullable: true
          enum:
            - app_store
            - play_store
            - stripe
            - adapty
            - paddle
          description: ユーザーがアプリ内で購入に使用するプラットフォーム
        store_account_token:
          type: string
          format: uuid
          nullable: true
          description: ストアアカウントトークン
        att_status:
          type: integer
          nullable: true
          enum:
            - 0
            - 1
            - 2
            - 3
          description: Apple App Tracking Transparency ステータス（0=未確定、1=制限あり、2=拒否、3=許可）
        analytics_disabled:
          type: boolean
          nullable: true
          description: 外部アナリティクスをオプトアウトするオプション
        custom_attributes:
          type: array
          items:
            $ref: "#/components/schemas/CustomAttribute"
          description: プロファイルに最大 30 個のカスタム属性を設定できます
        installation_meta:
          $ref: "#/components/schemas/InstallationMeta"
      required:
        - installation_meta
      example:
        first_name: Jane
        last_name: Doe
        gender: f
        email: jane.doe@example.com
        phone_number: "+1234567890"
        birthday: "2000-12-31"
        ip_country: FR
        ip_v4_address: 192.168.1.1
        store_country: US
        store: app_store
        store_account_token: 3fa85f64-5717-4562-b3fc-2c963f66afa6
        att_status: 3
        analytics_disabled: true
        custom_attributes:
          - key: favourite_sport
            value: yoga
        installation_meta:
          device_id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
          device: iPhone 15 Pro
          locale: en
          os: iOS 17.1
          platform: iOS
          timezone: Europe/Rome
          user_agent: Mozilla/5.0 (iPhone; CPU iPhone OS 17_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Mobile/15E148 Safari/604.1
          app_build: 1.0.0
          app_version: 1.0.0
          adapty_sdk_version: 2.0.0
          idfa: EA7583CD-A667-48BC-B806-42ECB2B48333
          idfv: E9D48DA5-3930-4B41-8521-D953AECD2F33
          advertising_id: ""
          android_id: ""
          android_app_set_id: ""
    Profile:
      type: object
      properties:
        app_id:
          type: string
          format: uuid
          description: アプリの内部 ID
        profile_id:
          type: string
          format: uuid
          description: Adapty プロファイル ID
        customer_user_id:
          type: string
          nullable: true
          description: お客様のシステムにおけるユーザーの ID
        total_revenue_usd:
          type: number
          format: float
          description: プロファイルで獲得した USD 換算の総収益を表す浮動小数点値
        segment_hash:
          type: string
          description: 内部パラメータ
        timestamp:
          type: integer
          format: int64
          description: レスポンス時刻（ミリ秒）。競合状態の解決に使用します
        custom_attributes:
          type: array
          items:
            $ref: "#/components/schemas/CustomAttribute"
          description: プロファイルに設定できるカスタム属性は最大 30 個です
        access_levels:
          type: array
          items:
            $ref: "#/components/schemas/AccessLevel"
          description: アクセスレベルオブジェクトの配列。顧客がアクセスレベルを持たない場合は空配列
        subscriptions:
          type: array
          items:
            $ref: "#/components/schemas/Subscription"
          description: サブスクリプションオブジェクトの配列。顧客がサブスクリプションを持たない場合は空配列
        non_subscriptions:
          type: array
          items:
            $ref: "#/components/schemas/NonSubscription"
          description: 非サブスクリプションオブジェクトの配列。顧客が購入履歴を持たない場合は空配列
      required:
        - app_id
        - profile_id
        - customer_user_id
        - total_revenue_usd
        - segment_hash
        - timestamp
        - custom_attributes
        - access_levels
        - subscriptions
        - non_subscriptions
    CustomAttribute:
      type: object
      properties:
        key:
          type: string
          maxLength: 30
          description: キーは 30 文字以下の文字列である必要があります。英字、数字、ダッシュ、ピリオド、アンダースコアのみ使用できます
        value:
          oneOf:
            - type: string
            - type: number
          description: 属性値は 50 文字以下である必要があります。文字列と浮動小数点数のみ使用できます
      required:
        - key
        - value
    InstallationMeta:
      type: object
      properties:
        device_id:
          type: string
          format: uuid
          description: デバイスの一意の識別子
        device:
          type: string
          nullable: true
          description: デバイス情報
        locale:
          type: string
          nullable: true
          description: デバイスのロケール
        os:
          type: string
          nullable: true
          description: オペレーティングシステム情報
        platform:
          type: string
          nullable: true
          enum:
            - iOS
            - macOS
            - iPadOS
            - Android
            - visionOS
            - web
          description: プラットフォーム（iOS、Android など）
        timezone:
          type: string
          nullable: true
          description: デバイスのタイムゾーン
        user_agent:
          type: string
          nullable: true
          description: ユーザーエージェント文字列
        app_build:
          type: string
          nullable: true
          description: アプリのビルドバージョン
        app_version:
          type: string
          nullable: true
          description: アプリのバージョン
        adapty_sdk_version:
          type: string
          nullable: true
          description: Adapty SDK のバージョン
        idfa:
          type: string
          nullable: true
          description: iOS 広告識別子（IDFA）
        idfv:
          type: string
          nullable: true
          description: iOS ベンダー識別子（IDFV）
        advertising_id:
          type: string
          nullable: true
          description: Android 広告 ID
        android_id:
          type: string
          nullable: true
          description: Android デバイス ID
        android_app_set_id:
          type: string
          nullable: true
          description: Android アプリセット ID
      required:
        - device_id
    AccessLevel:
      type: object
      properties:
        access_level_id:
          type: string
          description: アクセスレベルの識別子
        store:
          type: string
          description: アクセスレベルが購入されたストア
        store_product_id:
          type: string
          description: ストアにおけるプロダクト ID
        store_base_plan_id:
          type: string
          nullable: true
          description: ストアにおけるベースプラン ID
        store_transaction_id:
          type: string
          description: ストアにおけるトランザクション ID
        store_original_transaction_id:
          type: string
          description: ストアにおける元のトランザクション ID
        offer:
          allOf:
            - $ref: "#/components/schemas/OfferDTO"
          nullable: true
          description: プロモーションオファーまたは初回オファーが適用された場合のオファー詳細
        starts_at:
          type: string
          format: date-time
          nullable: true
          description: アクセスレベルの開始日時
        purchased_at:
          type: string
          format: date-time
          description: アクセスレベルが購入された日時
        originally_purchased_at:
          type: string
          format: date-time
          description: アクセスレベルが最初に購入された日時
        expires_at:
          type: string
          format: date-time
          nullable: true
          description: アクセスレベルの有効期限
        renewal_cancelled_at:
          type: string
          format: date-time
          nullable: true
          description: 更新がキャンセルされた日時
        billing_issue_detected_at:
          type: string
          format: date-time
          nullable: true
          description: 請求問題が検出された日時
        is_in_grace_period:
          type: boolean
          description: アクセスレベルがグレース期間中かどうか
        cancellation_reason:
          type: string
          nullable: true
          description: キャンセルの理由
    Subscription:
      type: object
      properties:
        store:
          type: string
          description: サブスクリプションが購入されたストア
        store_product_id:
          type: string
          description: ストアにおけるプロダクト ID
        store_base_plan_id:
          type: string
          nullable: true
          description: ストアにおけるベースプラン ID
        store_transaction_id:
          type: string
          description: ストアにおけるトランザクション ID
        store_original_transaction_id:
          type: string
          description: ストアにおける元のトランザクション ID
        offer:
          allOf:
            - $ref: "#/components/schemas/OfferDTO"
          nullable: true
          description: プロモーションオファーまたは初回オファーが適用された場合のオファー詳細
        environment:
          type: string
          description: 環境（サンドボックス、本番）
        purchased_at:
          type: string
          format: date-time
          description: サブスクリプションが購入された日時
        originally_purchased_at:
          type: string
          format: date-time
          description: サブスクリプションが最初に購入された日時
        expires_at:
          type: string
          format: date-time
          nullable: true
          description: サブスクリプションの有効期限
        renewal_cancelled_at:
          type: string
          format: date-time
          nullable: true
          description: 更新がキャンセルされた日時
        billing_issue_detected_at:
          type: string
          format: date-time
          nullable: true
          description: 請求問題が検出された日時
        is_in_grace_period:
          type: boolean
          description: サブスクリプションがグレース期間中かどうか
        cancellation_reason:
          type: string
          nullable: true
          description: キャンセルの理由
    NonSubscription:
      type: object
      properties:
        purchase_id:
          type: string
          format: uuid
          description: 購入の一意の識別子
        store:
          type: string
          description: 購入が行われたストア
        store_product_id:
          type: string
          description: ストアにおけるプロダクト ID
        store_base_plan_id:
          type: string
          nullable: true
          description: ストアにおけるベースプラン ID
        store_transaction_id:
          type: string
          description: ストアにおけるトランザクション ID
        store_original_transaction_id:
          type: string
          description: ストアにおける元のトランザクション ID
        purchased_at:
          type: string
          format: date-time
          description: 購入が行われた日時
        environment:
          type: string
          description: 環境（サンドボックス、本番）
        is_refund:
          type: boolean
          description: 返金かどうか
        is_consumable:
          type: boolean
          description: 消耗型アイテムの購入かどうか
    OfferDTO:
      type: object
      properties:
        category:
          type: string
          enum:
            - introductory
            - promotional
            - offer_code
            - win_back
          description: オファーのカテゴリ
        type:
          type: string
          enum:
            - free_trial
            - pay_as_you_go
            - pay_up_front
          description: オファーの種別
        id:
          type: string
          nullable: true
          description: オファー ID
      required:
        - category
        - type
  securitySchemes:
    apikeyAuth:
      type: apiKey
      name: Authorization
      in: header
      default: Api-Key {Your secret API key}
      description: |
        API リクエストは、**Authorization** ヘッダーにシークレット API キーを `Api-Key {your_secret_api_key}` の形式（例: `Api-Key secret_live_...`）で指定して認証する必要があります。このキーは Adapty ダッシュボード → **App Settings** → **General** タブ → **API keys** セクションで確認できます。
```
