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

# Create a new user



## OpenAPI

````yaml openapi-admin post /users
openapi: 3.0.3
info:
  version: 1.2.0
  title: Hanko Admin API
  description: >
    ## Introduction


    This is the OpenAPI specification for the [Hanko Admin
    API](https://github.com/teamhanko/hanko/blob/main/backend/README.md#start-private-api).


    ## Authentication


    The Admin API must be protected by an access management system.


    ---
  contact:
    email: developers@hanko.io
  license:
    name: AGPL-3.0-or-later
    url: https://www.gnu.org/licenses/agpl-3.0.txt
servers:
  - url: https://{tenant_id}.hanko.io/admin
    variables:
      tenant_id:
        default: ''
        description: The (UU)ID of a tenant. Replace the default value with your tenant ID.
security: []
externalDocs:
  description: More about Hanko
  url: https://github.com/teamhanko/hanko
paths:
  /users:
    post:
      tags:
        - User Management
      summary: Create a new user
      operationId: createUser
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  description: The ID of the new user
                  allOf:
                    - $ref: '#/components/schemas/UUID4'
                emails:
                  description: The email addresses of the new user
                  type: array
                  items:
                    type: object
                    properties:
                      address:
                        type: string
                      is_primary:
                        type: boolean
                      is_verified:
                        type: boolean
                    required:
                      - address
                      - is_primary
                username:
                  description: The username of the new user
                  type: string
                created_at:
                  description: Time of creation of the user
                  type: string
                  format: date-time
              required:
                - emails
      responses:
        '200':
          description: Details of the newly created user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '400':
          $ref: '#/components/responses/BadRequest'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerApiKeyAuth: []
components:
  schemas:
    UUID4:
      type: string
      format: uuid4
      example: c339547d-e17d-4ba7-8a1d-b3d5a4d17c1c
    User:
      allOf:
        - $ref: '#/components/schemas/UserBase'
        - type: object
          properties:
            otp:
              $ref: '#/components/schemas/OTP'
            password:
              $ref: '#/components/schemas/Password'
            identities:
              $ref: '#/components/schemas/Identities'
            metadata:
              $ref: '#/components/schemas/UserMetadata'
    UserBase:
      type: object
      required:
        - id
        - created_at
        - updated_at
      properties:
        id:
          description: The ID of the user
          allOf:
            - $ref: '#/components/schemas/UUID4'
        created_at:
          description: Time of creation of the user
          type: string
          format: date-time
        updated_at:
          description: Time of last update of the user
          type: string
          format: date-time
        webauthn_credentials:
          description: List of registered Webauthn credentials
          type: array
          items:
            $ref: '#/components/schemas/WebAuthnCredential'
        emails:
          description: List of emails associated to the user
          type: array
          items:
            $ref: '#/components/schemas/Email'
        username:
          $ref: '#/components/schemas/Username'
    OTP:
      type: object
      properties:
        id:
          type: string
          format: uuid
        created_at:
          type: string
          format: date-time
      required:
        - id
        - created_at
    Password:
      description: The password credential of a user
      type: object
      properties:
        id:
          allOf:
            - $ref: '#/components/schemas/UUID4'
          description: The ID of the password credential
          example: 28a7206b-e789-435a-b87c-108e034135c2
        created_at:
          description: Time of creation of the password credential
          type: string
          format: date-time
        updated_at:
          description: Time of last update of the password credential
          type: string
          format: date-time
    Identities:
      description: A list of third party provider identities
      type: array
      items:
        $ref: '#/components/schemas/Identity'
    UserMetadata:
      description: User metadata
      type: object
      properties:
        public_metadata:
          type: object
          additionalProperties: {}
          example:
            role: admin
        private_metadata:
          type: object
          additionalProperties: {}
          example:
            internal_id: e6c19cfb-09a2-41e5-a908-e33193b7ca0a
        unsafe_metadata:
          type: object
          additionalProperties: {}
          example:
            birthday: '2025-05-12'
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
    WebAuthnCredential:
      type: object
      required:
        - id
        - public_key
        - attestation_type
        - aaguid
        - created_at
        - backup_eligible
        - backup_state
        - mfa_only
      properties:
        id:
          description: The ID of the credential
          allOf:
            - $ref: '#/components/schemas/UUID4'
          example: f9bebc04-b894-4018-bdb8-8b520a532fef
        name:
          description: A name that the user choose
          type: string
        public_key:
          description: The public key of the credential
          type: string
        attestation_type:
          description: The attestation type the credential was registered with
          type: string
        aaguid:
          description: The AAGUID of the authenticator the credentials was created on
          type: string
        transports:
          description: The ways the authenticator is connected
          type: array
          items:
            type: string
        created_at:
          description: Time of creation of the credential
          type: string
          format: date-time
        last_used_at:
          description: The time when the credential was last used
          type: string
          format: date-time
        backup_eligible:
          description: Indicates if the credential can be backed up
          type: boolean
        backup_state:
          description: Indicates if the credential is backed up
          type: boolean
        mfa_only:
          description: Indicates if the credential can only be used as a MFA credential
          type: boolean
    Email:
      type: object
      required:
        - id
        - address
        - is_verified
        - is_primary
        - created_at
        - updated_at
      properties:
        id:
          description: The ID of the email
          allOf:
            - $ref: '#/components/schemas/UUID4'
          example: 802df042-1ac2-496d-af81-6ace729ed055
        address:
          description: The email address
          type: string
          format: email
        is_verified:
          description: Indicated the email has been verified.
          type: boolean
        is_primary:
          description: Indicates it's the primary email address.
          type: boolean
        created_at:
          description: Time of creation of the email
          type: string
          format: date-time
        updated_at:
          description: Time of last update of the email
          type: string
          format: date-time
    Username:
      description: The username of the user
      type: object
      properties:
        id:
          allOf:
            - $ref: '#/components/schemas/UUID4'
          description: The ID of the username
          example: 8cbed467-554b-4d17-b23f-bce1b4f1db92
        created_at:
          description: Time of creation of the username
          type: string
          format: date-time
        updated_at:
          description: Time of last update of the username
          type: string
          format: date-time
        username:
          description: The username of the user
          type: string
          example: john_doe_123
    Identity:
      description: A third party provider identity
      type: object
      properties:
        id:
          allOf:
            - $ref: '#/components/schemas/UUID4'
          description: The ID of the identity
          example: 77f8d594-9765-4891-ab2b-f31a797b531d
        email_id:
          allOf:
            - $ref: '#/components/schemas/UUID4'
          description: The ID of the email this identity is coupled with
          example: d4095586-8318-4a40-a840-b4260496f85a
        provider_id:
          description: The user's third party provider account/user ID
          type: string
        provider_name:
          description: The name of the third party provider this identity coupled with
          type: string
        created_at:
          description: Time of creation of the password credential
          type: string
          format: date-time
        updated_at:
          description: Time of last update of the password credential
          type: string
          format: date-time
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 400
            message: Bad Request
    Conflict:
      description: Conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 409
            message: Conflict
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: 500
            message: Internal Server Error
  securitySchemes:
    BearerApiKeyAuth:
      description: >-
        Bearer authentication header of the form `Bearer <token>`, where
        `<token>` is your API key. Must only be used when using Hanko Cloud.
      type: http
      scheme: bearer
      bearerFormat: API Key

````