{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/pricklymails-com/json-schema/pricklymails-com-login-response-schema.json",
  "title": "LoginResponse",
  "description": "Response returned by the login endpoint.\n\nThe body is either a full authentication response or, when two-factor authentication is required, a\n`{ requires_2fa, temp_token }` object.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/pricklymails-com-auth-api-openapi.yml#/components/schemas/LoginResponse",
  "oneOf": [
    {
      "$ref": "#/$defs/AuthResponse",
      "description": "Standard authentication response (no 2FA required)."
    },
    {
      "type": "object",
      "description": "2FA is required; the client must call `/api/auth/2fa/verify` with the temp token.",
      "required": [
        "requires_2fa",
        "temp_token"
      ],
      "properties": {
        "requires_2fa": {
          "type": "boolean",
          "description": "Always `true` when this variant is returned."
        },
        "temp_token": {
          "type": "string",
          "description": "A short-lived token to send to `POST /api/auth/2fa/verify` with the code."
        }
      }
    }
  ],
  "$defs": {
    "AuthResponse": {
      "type": "object",
      "description": "Response body for authentication endpoints.\n\nThe refresh token is delivered in an httpOnly cookie, never in the JSON body.",
      "required": [
        "access_token",
        "expires_in",
        "user"
      ],
      "properties": {
        "access_token": {
          "type": "string",
          "description": "Access token (JWT), sent as a Bearer credential."
        },
        "expires_in": {
          "type": "integer",
          "format": "int64",
          "description": "Access token lifetime in seconds.",
          "minimum": 0
        },
        "user": {
          "$ref": "#/$defs/UserResponse",
          "description": "Authenticated user details."
        }
      }
    },
    "UserResponse": {
      "type": "object",
      "description": "Public representation of a user.",
      "required": [
        "uuid",
        "email",
        "role",
        "email_verified",
        "locale",
        "created_at"
      ],
      "properties": {
        "created_at": {
          "type": "string",
          "description": "Account creation timestamp (ISO 8601)."
        },
        "email": {
          "type": "string",
          "description": "Email address."
        },
        "email_verified": {
          "type": "boolean",
          "description": "Whether the email has been verified."
        },
        "locale": {
          "type": "string",
          "description": "Language of the account's emails (`\"en\"` or `\"fr\"`)."
        },
        "role": {
          "type": "string",
          "description": "User role (`\"user\"` or `\"admin\"`)."
        },
        "uuid": {
          "type": "string",
          "description": "Public UUID."
        }
      }
    }
  }
}