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

# Register a new user or create a user by admin

> Allows for user self-registration or user creation by an administrator.
  - If called without an admin token, a new user with the 'user' role is created and requires email confirmation. The 'role' field is ignored.
  - If called with an admin token, a new user (e.g., a manager) is created immediately with the specified role.




## OpenAPI

````yaml api-reference/openapi.json post /api/auth/register
openapi: 3.0.0
info:
  title: Tandem IT API
  version: 1.0.0
  description: API for tandem it backend
servers:
  - url: https://tandem.hlofiys.xyz
    description: Production server
security: []
tags:
  - name: Documentation
    description: API documentation endpoint
paths:
  /api/auth/register:
    post:
      tags:
        - Authentication
      summary: Register a new user or create a user by admin
      description: |
        Allows for user self-registration or user creation by an administrator.
          - If called without an admin token, a new user with the 'user' role is created and requires email confirmation. The 'role' field is ignored.
          - If called with an admin token, a new user (e.g., a manager) is created immediately with the specified role.
      operationId: register
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegisterRequest'
      responses:
        '201':
          description: >-
            Registration successful. For self-registration, a confirmation email
            has been sent. For admin creation, the user is created directly
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegisterResponse'
        '400':
          description: >-
            Bad Request. The request body is malformed or fails validation
            (e.g., empty fields, invalid role)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '403':
          description: >-
            Forbidden. The authenticated user does not have permission to create
            users with roles
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Conflict. A user with the provided email already exists
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    RegisterRequest:
      type: object
      description: >-
        Schema for user registration. Can be used by anonymous users or
        administrators.
      required:
        - email
        - phone_number
        - full_name
      properties:
        email:
          type: string
        phone_number:
          type: string
          description: >-
            User's phone number, preferably in international E.164 format (e.g.,
            +375291234567).
          example: '+375291234567'
        full_name:
          type: string
        password:
          type: string
        role:
          type: string
          description: >-
            For admins only. The role to assign to the new user. If omitted,
            defaults to 'user'
          enum:
            - user
            - manager
    RegisterResponse:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: >-
            Registration successful. Please check your email to verify your
            account
    ValidationError:
      type: object
      required:
        - message
      properties:
        message:
          type: string
          example: Validation failed
        errors:
          type: object
          description: A map of field names to their respective error messages.
          additionalProperties:
            type: string
          example:
            name: The name field is required.
            price: The price must be a valid number.
            hall_id: A valid hall_id is required.
    Error:
      type: object
      required:
        - message
      properties:
        message:
          type: string

````