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

# Record Consent

> Record the user's consent to take part in the HAI-Co² research study.

HAI-Co² is a research study whose purpose is data collection, so agreeing
records BOTH the recording consent and the (required) publication consent,
each idempotently (the first grant's timestamp is preserved on repeated
calls). The optional request body carries only the e-mail opt-in; it is
optional so a body-less POST still records participation consent.

Args:
    user:    The authenticated user (injected by ``require_user``).
    payload: Optional consent-gate selection (the e-mail opt-in).
    db:      Database session.

Returns:
    The updated user profile as a ``UserResponse``.



## OpenAPI

````yaml /openapi.json post /api/auth/consent
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/consent:
    post:
      tags:
        - Auth
      summary: Record Consent
      description: >-
        Record the user's consent to take part in the HAI-Co² research study.


        HAI-Co² is a research study whose purpose is data collection, so
        agreeing

        records BOTH the recording consent and the (required) publication
        consent,

        each idempotently (the first grant's timestamp is preserved on repeated

        calls). The optional request body carries only the e-mail opt-in; it is

        optional so a body-less POST still records participation consent.


        Args:
            user:    The authenticated user (injected by ``require_user``).
            payload: Optional consent-gate selection (the e-mail opt-in).
            db:      Database session.

        Returns:
            The updated user profile as a ``UserResponse``.
      operationId: record_consent_api_auth_consent_post
      requestBody:
        content:
          application/json:
            schema:
              anyOf:
                - $ref: '#/components/schemas/ConsentRequest'
                - type: 'null'
              title: Payload
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ConsentRequest:
      properties:
        email_updates:
          type: boolean
          title: Email Updates
          default: false
      type: object
      title: ConsentRequest
      description: >-
        Study-participation consent submission.


        HAI-Co² is a research study whose purpose is data collection, so
        agreeing to

        take part records BOTH the recording consent and the (required)
        publication

        consent; the endpoint stamps them regardless of this body. The only
        optional

        choice is the e-mail opt-in, so it is the sole field here (defaults to
        false).
    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.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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
  securitySchemes:
    HTTPBearer:
      type: http
      description: >-
        A personal access token (`haico_pat_...`), created under Profile → API
        keys. Send it as `Authorization: Bearer <key>`. The browser session JWT
        is also accepted but is an internal mechanism and is not part of the
        public contract.
      scheme: bearer

````