# Create profile

> Creates a new end user of your app in Adapty.

## OpenAPI

```yaml
/api-specs/adapty-api.yaml post /api/v2/server-side-api/profile/
openapi: 3.1.0
info:
  title: Adapty server-side API
  version: 1.0.0
servers:
  - url: https://api.adapty.io
    description: Production server
paths:
  /api/v2/server-side-api/profile/:
    post:
      summary: Create profile
      description: Creates a new end user of your app in Adapty.
      operationId: createProfile
      tags:
        - Profile
      security:
        - apikeyAuth: []
      parameters:
        - name: adapty-customer-user-id
          in: header
          required: false
          schema:
            type: string
          description: The unique ID of the customer in your system. Either `adapty-customer-user-id` or `adapty-profile-id` is required.
        - name: adapty-profile-id
          in: header
          required: false
          schema:
            type: string
          description: The unique ID of the profile in your system. Your best option if you are working with anonymous profiles. Either `adapty-customer-user-id` or `adapty-profile-id` is required.
        - name: adapty-platform
          in: header
          required: false
          schema:
            type: string
          description: The platform of the device where the user has your app installed
      responses:
        "200":
          description: Profile created successfully
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProfileResponse"
              example:
                data:
                  app_id: 14c3d623-2f3a-455a-aa86-ef83dff6913b
                  profile_id: 3286abd3-48b0-4e9c-a5f6-ac0a006804a6
                  customer_user_id: jane.doe@example.com
                  total_revenue_usd: 0
                  segment_hash: 8f45947bad31ab0c
                  timestamp: 1736425645861
                  custom_attributes:
                    - key: favourite_sport
                      value: yoga
                  access_levels: []
                  subscriptions: []
                  non_subscriptions: []
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
              example:
                errors:
                  - source: non_field_errors
                    errors:
                      - Authentication credentials were not provided.
                error_code: not_authenticated
                status_code: 401
        "500":
          description: Internal server error
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProfileRequest"
            example:
              first_name: Jane
              last_name: Doe
              gender: f
              email: jane.doe@example.com
              phone_number: "+1234567890"
              birthday: "2000-12-31"
              ip_country: FR
              store_country: US
              store: app_store
              analytics_disabled: true
              custom_attributes:
                - key: favourite_sport
                  value: yoga
              installation_meta:
                device_id: 3fa85f64-5717-4562-b3fc-2c963f66afa6
                device: string
                locale: en
                os: string
                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
                idfa: EA7583CD-A667-48BC-B806-42ECB2B48333
                idfv: E9D48DA5-3930-4B41-8521-D953AECD2F33
                advertising_id: ""
                android_id: ""
                android_app_set_id: ""
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: Source of the error
              errors:
                type: array
                items:
                  type: string
                description: Array of error messages
        error_code:
          type: string
          description: Short error name
        status_code:
          type: integer
          description: HTTP status code
      required:
        - errors
        - error_code
        - status_code
    ProfileRequest:
      type: object
      properties:
        first_name:
          type: string
          nullable: true
          description: Your end user's first name
        last_name:
          type: string
          nullable: true
          description: Your end user's last name
        gender:
          type: string
          nullable: true
          enum:
            - f
            - m
            - o
          description: Your end user's gender
        email:
          type: string
          nullable: true
          format: email
          description: Your end user's email
        phone_number:
          type: string
          nullable: true
          description: Your end user's phone number
        birthday:
          type: string
          format: date
          nullable: true
          description: Your end user's birthday
        ip_country:
          type: string
          nullable: true
          description: Country of the end user in ISO 3166-2 format
        ip_v4_address:
          type: string
          nullable: true
          description: IPv4 address of the end user
        store_country:
          type: string
          nullable: true
          description: Country of the end user's app store
        store:
          type: string
          nullable: true
          enum:
            - app_store
            - play_store
            - stripe
            - adapty
            - paddle
          description: The platform the user uses to make purchases in your app
        store_account_token:
          type: string
          format: uuid
          nullable: true
          description: Store account token
        att_status:
          type: integer
          nullable: true
          enum:
            - 0
            - 1
            - 2
            - 3
          description: Apple App Tracking Transparency status (0=not determined, 1=restricted, 2=denied, 3=authorized)
        analytics_disabled:
          type: boolean
          nullable: true
          description: Option to opt out of external analytics
        custom_attributes:
          type: array
          items:
            $ref: "#/components/schemas/CustomAttribute"
          description: Allows setting up to 30 custom attributes for the profile
        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: The internal ID of your app
        profile_id:
          type: string
          format: uuid
          description: Adapty profile ID
        customer_user_id:
          type: string
          nullable: true
          description: The ID of your user in your system
        total_revenue_usd:
          type: number
          format: float
          description: A float value representing the total revenue in USD earned in the profile
        segment_hash:
          type: string
          description: Internal parameter
        timestamp:
          type: integer
          format: int64
          description: Response time in milliseconds, needs for resolve a race condition
        custom_attributes:
          type: array
          items:
            $ref: "#/components/schemas/CustomAttribute"
          description: A maximum of 30 custom attributes to the profile are allowed to be set
        access_levels:
          type: array
          items:
            $ref: "#/components/schemas/AccessLevel"
          description: Array of Access level objects. Empty array if the customer has no access levels
        subscriptions:
          type: array
          items:
            $ref: "#/components/schemas/Subscription"
          description: Array of Subscription objects. Empty array if the customer has no subscriptions
        non_subscriptions:
          type: array
          items:
            $ref: "#/components/schemas/NonSubscription"
          description: Array of Non-Subscription objects. Empty array if the customer has no purchases
      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: The key must be a string with no more than 30 characters. Only letters, numbers, dashes, points, and underscores allowed
        value:
          oneOf:
            - type: string
            - type: number
          description: The attribute value must be no more than 50 characters. Only strings and floats are allowed as values
      required:
        - key
        - value
    InstallationMeta:
      type: object
      properties:
        device_id:
          type: string
          format: uuid
          description: Unique device identifier
        device:
          type: string
          nullable: true
          description: Device information
        locale:
          type: string
          nullable: true
          description: Device locale
        os:
          type: string
          nullable: true
          description: Operating system information
        platform:
          type: string
          nullable: true
          enum:
            - iOS
            - macOS
            - iPadOS
            - Android
            - visionOS
            - web
          description: Platform (iOS, Android, etc.)
        timezone:
          type: string
          nullable: true
          description: Device timezone
        user_agent:
          type: string
          nullable: true
          description: User agent string
        app_build:
          type: string
          nullable: true
          description: App build version
        app_version:
          type: string
          nullable: true
          description: App version
        adapty_sdk_version:
          type: string
          nullable: true
          description: Adapty SDK version
        idfa:
          type: string
          nullable: true
          description: iOS Identifier for Advertisers
        idfv:
          type: string
          nullable: true
          description: iOS Identifier for Vendor
        advertising_id:
          type: string
          nullable: true
          description: Android advertising ID
        android_id:
          type: string
          nullable: true
          description: Android device ID
        android_app_set_id:
          type: string
          nullable: true
          description: Android app set ID
      required:
        - device_id
    AccessLevel:
      type: object
      properties:
        access_level_id:
          type: string
          description: Access level identifier
        store:
          type: string
          description: Store where the access level was purchased
        store_product_id:
          type: string
          description: Product ID in the store
        store_base_plan_id:
          type: string
          nullable: true
          description: Base plan ID in the store
        store_transaction_id:
          type: string
          description: Transaction ID in the store
        store_original_transaction_id:
          type: string
          description: Original transaction ID in the store
        offer:
          allOf:
            - $ref: "#/components/schemas/OfferDTO"
          nullable: true
          description: Offer details, if a promotional or introductory offer was applied
        starts_at:
          type: string
          format: date-time
          nullable: true
          description: When the access level starts
        purchased_at:
          type: string
          format: date-time
          description: When the access level was purchased
        originally_purchased_at:
          type: string
          format: date-time
          description: When the access level was originally purchased
        expires_at:
          type: string
          format: date-time
          nullable: true
          description: When the access level expires
        renewal_cancelled_at:
          type: string
          format: date-time
          nullable: true
          description: When renewal was cancelled
        billing_issue_detected_at:
          type: string
          format: date-time
          nullable: true
          description: When billing issue was detected
        is_in_grace_period:
          type: boolean
          description: Whether the access level is in grace period
        cancellation_reason:
          type: string
          nullable: true
          description: Reason for cancellation
    Subscription:
      type: object
      properties:
        store:
          type: string
          description: Store where the subscription was purchased
        store_product_id:
          type: string
          description: Product ID in the store
        store_base_plan_id:
          type: string
          nullable: true
          description: Base plan ID in the store
        store_transaction_id:
          type: string
          description: Transaction ID in the store
        store_original_transaction_id:
          type: string
          description: Original transaction ID in the store
        offer:
          allOf:
            - $ref: "#/components/schemas/OfferDTO"
          nullable: true
          description: Offer details, if a promotional or introductory offer was applied
        environment:
          type: string
          description: Environment (Sandbox, Production)
        purchased_at:
          type: string
          format: date-time
          description: When the subscription was purchased
        originally_purchased_at:
          type: string
          format: date-time
          description: When the subscription was originally purchased
        expires_at:
          type: string
          format: date-time
          nullable: true
          description: When the subscription expires
        renewal_cancelled_at:
          type: string
          format: date-time
          nullable: true
          description: When renewal was cancelled
        billing_issue_detected_at:
          type: string
          format: date-time
          nullable: true
          description: When billing issue was detected
        is_in_grace_period:
          type: boolean
          description: Whether the subscription is in grace period
        cancellation_reason:
          type: string
          nullable: true
          description: Reason for cancellation
    NonSubscription:
      type: object
      properties:
        purchase_id:
          type: string
          format: uuid
          description: Unique purchase identifier
        store:
          type: string
          description: Store where the purchase was made
        store_product_id:
          type: string
          description: Product ID in the store
        store_base_plan_id:
          type: string
          nullable: true
          description: Base plan ID in the store
        store_transaction_id:
          type: string
          description: Transaction ID in the store
        store_original_transaction_id:
          type: string
          description: Original transaction ID in the store
        purchased_at:
          type: string
          format: date-time
          description: When the purchase was made
        environment:
          type: string
          description: Environment (Sandbox, Production)
        is_refund:
          type: boolean
          description: Whether this is a refund
        is_consumable:
          type: boolean
          description: Whether this is a consumable purchase
    OfferDTO:
      type: object
      properties:
        category:
          type: string
          enum:
            - introductory
            - promotional
            - offer_code
            - win_back
          description: Offer category
        type:
          type: string
          enum:
            - free_trial
            - pay_as_you_go
            - pay_up_front
          description: Offer type
        id:
          type: string
          nullable: true
          description: Offer ID
      required:
        - category
        - type
  securitySchemes:
    apikeyAuth:
      type: apiKey
      name: Authorization
      in: header
      default: Api-Key {Your secret API key}
      description: |
        API requests must be authenticated by your secret API key as the **Authorization** 
        header with the value `Api-Key {your_secret_api_key}`, for example, 
        `Api-Key secret_live_...`. Find this key in the Adapty Dashboard -> 
        **App Settings** -> **General** tab -> **API keys** section.
```
