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

# 注册账户

> 创建新用户账户。

## POST /auth/register

用于创建新用户账户。此为公开接口，无需认证。注册成功后会向用户发送验证邮件。

### 请求体

<ParamField body="email" type="string" required>
  用户邮箱，须为合法且唯一的邮箱地址。
</ParamField>

<ParamField body="password" type="string" required>
  用户密码，至少 8 位，并满足强度要求。
</ParamField>

<ParamField body="firstName" type="string" required>
  名字，最多 50 个字符。
</ParamField>

<ParamField body="lastName" type="string">
  姓氏，最多 50 个字符。
</ParamField>

<ParamField body="company" type="string">
  公司名称，最多 100 个字符。
</ParamField>

### 响应

<ResponseField name="success" type="boolean">
  注册是否成功。
</ResponseField>

<ResponseField name="message" type="string">
  可读的状态说明。
</ResponseField>

<ResponseField name="user" type="object">
  新创建用户的信息。

  <Expandable title="user 字段">
    <ResponseField name="id" type="string">
      用户唯一标识。
    </ResponseField>

    <ResponseField name="email" type="string">
      用户邮箱。
    </ResponseField>

    <ResponseField name="name" type="string">
      用户全名。
    </ResponseField>

    <ResponseField name="emailVerified" type="boolean">
      邮箱是否已验证（初始为 false）。
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      账户创建时间（ISO 8601）。
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="tokens" type="object">
  鉴权令牌对象。

  <Expandable title="tokens 字段">
    <ResponseField name="accessToken" type="string">
      用于后续请求的访问令牌，有效期 15 分钟。
    </ResponseField>

    <ResponseField name="refreshToken" type="string">
      刷新令牌，有效期 7 天。
    </ResponseField>

    <ResponseField name="expiresIn" type="number">
      令牌过期时间（秒）（900 = 15 分钟）。
    </ResponseField>

    <ResponseField name="tokenType" type="string">
      令牌类型（始终为 "Bearer"）。
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.llmgenerator.com/api/v1/auth/register \
    -H "Content-Type: application/json" \
    -d '{
          "email": "user@example.com",
          "password": "securePassword123!",
          "firstName": "John",
          "lastName": "Doe",
          "company": "Acme Inc"
        }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.llmgenerator.com/api/v1/auth/register', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      email: 'user@example.com',
      password: 'securePassword123!',
      firstName: 'John',
      lastName: 'Doe'
    })
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.llmgenerator.com/api/v1/auth/register',
      json={
          'email': 'user@example.com',
          'password': 'securePassword123!',
          'firstName': 'John',
          'lastName': 'Doe'
      }
  )

  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json Success (201) theme={null}
  {
    "success": true,
    "message": "Account created successfully",
    "user": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "email": "user@example.com",
      "name": "John Doe",
      "emailVerified": false,
      "createdAt": "2026-01-29T12:00:00.000Z"
    },
    "tokens": {
      "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "expiresIn": 900,
      "tokenType": "Bearer"
    }
  }
  ```

  ```json Email Already Exists (409) theme={null}
  {
    "message": "Email already registered"
  }
  ```

  ```json Weak Password (400) theme={null}
  {
    "message": "Weak password: Password must contain at least one uppercase letter, one number"
  }
  ```
</ResponseExample>
