> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.qonversion.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an identity

> Creates an identity. If `user_id` is not provided, a new Qonversion user is created automatically.




## OpenAPI

````yaml /api-reference/rest-api.yaml post /identities/{identity_id}
openapi: 3.1.0
info:
  title: Qonversion REST API
  version: '3.1'
  description: >
    Qonversion REST API follows REST standards. It has predictable
    resource-oriented URLs,

    accepts JSON-encoded request bodies, returns JSON-encoded responses, and
    uses standard

    HTTP response codes, authentication, and verbs.


    ## Where to find your keys


    1. Sign in to the Qonversion dashboard at https://dash.qonversion.io/.

    2. Open your project and go to **Project Settings** in the sidebar.

    3. The **Project Keys** section exposes three values:
       - **Project Key** - bearer token for the v3 REST endpoints documented here.
         A 32-character URL-safe random string (`A-Z`, `a-z`, `0-9`, `_`, `-`) with no fixed prefix
         (e.g. `JFPATc4VaaWYsfurml3qZ4zsmNw0VfWH`).
       - **API Key** - used in the URL path of the analytics API
         (`https://api.qonversion.io/v1/analytics/{API_KEY}/...`); do NOT use it as a v3 bearer.
       - **Secret Key** - bearer for the entitlement grant/revoke endpoints. Always prefixed with `sk_`.

    ## Sandbox vs production


    Project Keys with the `test_` prefix (e.g.
    `test_PV77YHL7qnGvsdmpTs7gimsxUvY-Znl2`) target the

    **sandbox** environment. Production keys have no prefix. The same prefix
    scheme applies to Secret

    Keys. Sandbox users do not affect production analytics.


    ## Errors


    All endpoints share the error envelope shown in `Error`. The
    `meta.reference` URL is set

    automatically for the documented machine-readable codes (`invalid_data`,
    `invalid_request`,

    `invalid_entitlement_data`); other errors omit `meta`. There is no
    `meta.fields[]` array.
servers:
  - url: https://api.qonversion.io/v3
    description: Production
security:
  - ProjectKey: []
paths:
  /identities/{identity_id}:
    post:
      tags:
        - Identity
      summary: Create an identity
      description: >
        Creates an identity. If `user_id` is not provided, a new Qonversion user
        is created automatically.
      operationId: createIdentity
      parameters:
        - name: identity_id
          in: path
          required: true
          schema:
            type: string
          description: User Identity ID
          example: new_identities_user
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                user_id:
                  type: string
                  description: Qonversion User ID. If omitted, a new user is created.
            example:
              user_id: QON_8968d347c4a24168b4885ee087fbd635
      responses:
        '201':
          description: Identity created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Identity'
              example:
                id: new_identities_user
                user_id: QON_8968d347c4a24168b4885ee087fbd635
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Identity already linked to another user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: invalid_request
                  message: 'identity already exists: it''s linked to another user'
                  type: request
      security:
        - ProjectKey: []
components:
  schemas:
    Identity:
      type: object
      properties:
        id:
          type: string
          description: User Identity ID
          example: awesome_user
        user_id:
          type: string
          description: Qonversion User ID
          example: QON_7791a27fc4e747412381842b36a
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - type
          properties:
            type:
              type: string
              enum:
                - request
                - resource
                - logical
                - internal
              description: Error category
            code:
              type: string
              description: Machine-readable error code
            message:
              type: string
              description: Human-readable error message
        meta:
          type: object
          description: >
            Optional metadata. Currently only contains a `reference` URL for a
            small subset

            of error codes (`invalid_data`, `invalid_request`,
            `invalid_entitlement_data`).
          properties:
            reference:
              type: string
              format: uri
              example: >-
                https://documentation.qonversion.io/reference/handling-api-errors
  securitySchemes:
    ProjectKey:
      type: http
      scheme: bearer
      description: >
        Use your **Project Key** from the Qonversion dashboard

        (Project Settings -> Project Keys -> Project Key).


        Production keys have no prefix; keys prefixed with `test_` target the
        sandbox environment.


        Example (sandbox): `Bearer test_PV77YHL7qnGvsdmpTs7gimsxUvY-Znl2`

        Example (production): `Bearer JFPATc4VaaWYsfurml3qZ4zsmNw0VfWH`

````