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

# User

> User profile, BYOK API keys, onboarding, and account management

# User API

## Profile

### Get Profile

```http theme={null}
GET /api/user/profile
```

Returns user profile and preferences.

<CodeGroup>
  ```bash curl theme={null}
  curl https://app.thig.ai/api/user/profile \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/user/profile', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  });
  const profile = await res.json();
  ```
</CodeGroup>

### Update Profile

```http theme={null}
PATCH /api/user/profile
```

**Body:**

| Field            | Type   | Description               |
| ---------------- | ------ | ------------------------- |
| `name`           | string | Display name              |
| `jobTitle`       | string | Job title                 |
| `bio`            | string | Short bio                 |
| `avatar`         | string | Avatar URL                |
| `preferredStyle` | string | Document style preference |

<CodeGroup>
  ```bash curl theme={null}
  curl -X PATCH https://app.thig.ai/api/user/profile \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"name": "Jane Smith", "jobTitle": "Product Manager", "preferredStyle": "comprehensive"}'
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/user/profile', {
    method: 'PATCH',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: 'Jane Smith',
      jobTitle: 'Product Manager',
      preferredStyle: 'comprehensive'
    })
  });
  const data = await res.json();
  ```
</CodeGroup>

***

## BYOK API Keys

Manage personal AI provider keys (Bring Your Own Key).

### List Keys

```http theme={null}
GET /api/user/api-keys
```

Returns masked keys for all configured providers.

### Add Key

```http theme={null}
POST /api/user/api-keys
```

**Body:**

| Field      | Type   | Required | Description                        |
| ---------- | ------ | -------- | ---------------------------------- |
| `provider` | string | Yes      | `openai`, `anthropic`, or `gemini` |
| `key`      | string | Yes      | API key (encrypted before storage) |
| `name`     | string | No       | Display name                       |

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://app.thig.ai/api/user/api-keys \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"provider": "openai", "key": "sk-proj-abc123...", "name": "My OpenAI Key"}'
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/user/api-keys', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      provider: 'openai',
      key: 'sk-proj-abc123...',
      name: 'My OpenAI Key'
    })
  });
  const data = await res.json();
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "id": "key_123",
  "provider": "openai",
  "name": "My OpenAI Key",
  "createdAt": "2026-01-15T10:30:00Z"
}
```

### Remove Key

```http theme={null}
DELETE /api/user/api-keys/{keyId}
```

***

## Timezone

### Update Timezone

```http theme={null}
PATCH /api/user/timezone
```

**Body:**

```json theme={null}
{ "timezone": "America/New_York" }
```

Must be a valid IANA timezone string.

<CodeGroup>
  ```bash curl theme={null}
  curl -X PATCH https://app.thig.ai/api/user/timezone \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"timezone": "America/New_York"}'
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/user/timezone', {
    method: 'PATCH',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ timezone: 'America/New_York' })
  });
  const data = await res.json();
  ```
</CodeGroup>

***

## Onboarding

### Check Status

```http theme={null}
GET /api/user/onboarding
```

**Response:**

```json theme={null}
{
  "completed": true,
  "completedAt": "2026-01-15T10:30:00Z",
  "preferences": { ... }
}
```

### Complete Onboarding

```http theme={null}
POST /api/user/onboarding
```

**Body:**

| Field          | Type      | Required | Description          |
| -------------- | --------- | -------- | -------------------- |
| `fullName`     | string    | Yes      | Full name            |
| `jobTitle`     | string    | Yes      | Job title            |
| `company`      | string    | Yes      | Company name         |
| `useCase`      | string    | Yes      | Primary use case     |
| `teamSize`     | string    | Yes      | Team size            |
| `prdStyle`     | string    | Yes      | Preferred PRD style  |
| `interests`    | string\[] | Yes      | Features of interest |
| `createOrg`    | boolean   | No       | Create organization  |
| `orgName`      | string    | No       | Organization name    |
| `inviteEmails` | string\[] | No       | Emails to invite     |

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://app.thig.ai/api/user/onboarding \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "fullName": "Jane Smith",
      "jobTitle": "Product Manager",
      "company": "Acme Corp",
      "useCase": "Product requirements",
      "teamSize": "medium",
      "prdStyle": "comprehensive",
      "interests": ["ai-chat", "templates", "exports"]
    }'
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/user/onboarding', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      fullName: 'Jane Smith',
      jobTitle: 'Product Manager',
      company: 'Acme Corp',
      useCase: 'Product requirements',
      teamSize: 'medium',
      prdStyle: 'comprehensive',
      interests: ['ai-chat', 'templates', 'exports']
    })
  });
  const data = await res.json();
  ```
</CodeGroup>

### Onboarding Progress

```http theme={null}
GET /api/user/onboarding-progress
```

Returns a 5-step checklist with completion status.

***

## Activity

### Ping Activity

```http theme={null}
POST /api/user/activity
```

Records user activity. Server throttles to max once per 5 minutes.

***

## Account Management

### Data Export (GDPR)

```http theme={null}
GET /api/user/data-export
```

Downloads a JSON file containing all user data.

<CodeGroup>
  ```bash curl theme={null}
  curl https://app.thig.ai/api/user/data-export \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -o my-data.json
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://app.thig.ai/api/user/data-export', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  });
  const blob = await res.blob();
  const url = URL.createObjectURL(blob);
  const a = document.createElement('a');
  a.href = url;
  a.download = 'my-data.json';
  a.click();
  ```
</CodeGroup>

### Delete Account

```http theme={null}
DELETE /api/user/delete-account
```

**Body:**

```json theme={null}
{ "confirmEmail": "jane@example.com" }
```

Permanently deletes the account and all associated data.
