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

# Register

> Register a new local-auth user and send an email-verification link.

The account is created immediately but login is blocked until the email
address is confirmed via ``/verify-email``. Registration failures due to
duplicate username / email return a 400 error.

Args:
    payload: Registration form data (username, email, password, captcha token).
    request: The raw HTTP request (used to extract the client IP for auditing).
    db:      Database session injected by FastAPI.

Returns:
    A ``RegisterResponse`` containing a confirmation message and the new user profile.

Raises:
    HTTPException 400: If the CAPTCHA fails or the username / email is taken.



## OpenAPI

````yaml /openapi.json post /api/auth/register
openapi: 3.1.0
info:
  title: HAI-Co² API
  description: Human-AI Co-Construction reference implementation.
  version: 0.1.0
servers:
  - url: https://haico.gr
    description: Production
  - url: https://dev.haico.gr
    description: Development
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /api/auth/register:
    post:
      tags:
        - Auth
      summary: Register
      description: |-
        Register a new local-auth user and send an email-verification link.

        The account is created immediately but login is blocked until the email
        address is confirmed via ``/verify-email``. Registration failures due to
        duplicate username / email return a 400 error.

        Args:
            payload: Registration form data (username, email, password, captcha token).
            request: The raw HTTP request (used to extract the client IP for auditing).
            db:      Database session injected by FastAPI.

        Returns:
            A ``RegisterResponse`` containing a confirmation message and the new user profile.

        Raises:
            HTTPException 400: If the CAPTCHA fails or the username / email is taken.
      operationId: register_api_auth_register_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserCreate'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegisterResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    UserCreate:
      properties:
        username:
          type: string
          maxLength: 50
          minLength: 3
          title: Username
        email:
          type: string
          format: email
          title: Email
        password:
          type: string
          maxLength: 128
          minLength: 6
          title: Password
        captcha_token:
          type: string
          title: Captcha Token
          description: reCAPTCHA v3 token from the frontend
          default: ''
      type: object
      required:
        - username
        - email
        - password
      title: UserCreate
      description: Registration request payload for new local-auth users.
    RegisterResponse:
      properties:
        message:
          type: string
          title: Message
        user:
          $ref: '#/components/schemas/UserResponse'
      type: object
      required:
        - message
        - user
      title: RegisterResponse
      description: Response returned after a successful registration.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UserResponse:
      properties:
        id:
          type: integer
          title: Id
        username:
          type: string
          title: Username
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
        role:
          type: string
          title: Role
        is_approved:
          type: boolean
          title: Is Approved
        auth_provider:
          type: string
          title: Auth Provider
        email_verified:
          type: boolean
          title: Email Verified
        created_at:
          type: string
          format: date-time
          title: Created At
        recording_consent_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Recording Consent At
        research_publish_consent_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Research Publish Consent At
        email_updates_opt_in:
          type: boolean
          title: Email Updates Opt In
          default: false
      type: object
      required:
        - id
        - username
        - role
        - is_approved
        - auth_provider
        - email_verified
        - created_at
      title: UserResponse
      description: Public user profile returned by auth endpoints.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````