# Account

8 endpoints.

## Read the signed-in user's profile and preferences

```http
GET https://orbitwrite.com/api/v1/account
```

**Authentication:** session cookie.

### Responses

#### 200

The signed-in user

- `id` (string, required)
- `email` (string | null, required)
- `name` (string | null, required)
- `appearance` (string | null, required)
- `timezone` (string | null, required)
- `weekStartDay` (string | null, required)
- `timeFormat` (string | null, required, one of `auto`, `12h`, `24h`, `null`)
- `defaultLandingPage` (string | null, required)
- `defaultComposerPanel` (string, required, one of `none`, `info`, `assistant`, `ideas`, `hashtags`, `preview`, `comments`)
- `defaultOrganizationId` (string | null, required)
- `notifyMentionEmail` (boolean | null, required)
- `notifyCommentInApp` (boolean | null, required)
- `notifyCommentEmail` (boolean | null, required)
- `notifyPublishInApp` (boolean | null, required)
- `notifyPublishEmail` (boolean | null, required)
- `notifyPostErrorEmail` (boolean | null, required)
- `notifyApprovalRequestEmail` (boolean | null, required)
- `notifyApprovedInApp` (boolean | null, required)
- `notifyApprovedEmail` (boolean | null, required)
- `notifyRejectedInApp` (boolean | null, required)
- `notifyRejectedEmail` (boolean | null, required)
- `notifyReconnectEmail` (boolean | null, required)
- `notifyWeeklyDigestEmail` (boolean | null, required)

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

#### 404

The resource does not exist

- `error` (string, required)
- `issues` (any[], optional)

## Update the signed-in user's profile and preferences

```http
PATCH https://orbitwrite.com/api/v1/account
```

Partial update — only the fields present are written. Runs through Better Auth so its user-update hooks apply.

**Authentication:** session cookie.

### Request body (`application/json`)

- `name` (string, optional)
- `appearance` (string, optional, one of `light`, `dark`, `system`)
- `timezone` (string, optional)
- `weekStartDay` (string, optional, one of `saturday`, `sunday`, `monday`)
- `timeFormat` (string, optional, one of `auto`, `12h`, `24h`)
- `defaultLandingPage` (string, optional, one of `dashboard`, `planner`, `schedule`, `inbox`, `campaigns`, `activity`)
- `defaultComposerPanel` (string, optional, one of `none`, `info`, `assistant`, `ideas`, `hashtags`, `preview`, `comments`)
- `defaultOrganizationId` (string, optional)
- `notifyMentionEmail` (boolean, optional)
- `notifyCommentInApp` (boolean, optional)
- `notifyCommentEmail` (boolean, optional)
- `notifyPublishInApp` (boolean, optional)
- `notifyPublishEmail` (boolean, optional)
- `notifyPostErrorEmail` (boolean, optional)
- `notifyApprovalRequestEmail` (boolean, optional)
- `notifyApprovedInApp` (boolean, optional)
- `notifyApprovedEmail` (boolean, optional)
- `notifyRejectedInApp` (boolean, optional)
- `notifyRejectedEmail` (boolean, optional)
- `notifyReconnectEmail` (boolean, optional)
- `notifyWeeklyDigestEmail` (boolean, optional)

### Responses

#### 200

The user after the update

- `id` (string, required)
- `email` (string | null, required)
- `name` (string | null, required)
- `appearance` (string | null, required)
- `timezone` (string | null, required)
- `weekStartDay` (string | null, required)
- `timeFormat` (string | null, required, one of `auto`, `12h`, `24h`, `null`)
- `defaultLandingPage` (string | null, required)
- `defaultComposerPanel` (string, required, one of `none`, `info`, `assistant`, `ideas`, `hashtags`, `preview`, `comments`)
- `defaultOrganizationId` (string | null, required)
- `notifyMentionEmail` (boolean | null, required)
- `notifyCommentInApp` (boolean | null, required)
- `notifyCommentEmail` (boolean | null, required)
- `notifyPublishInApp` (boolean | null, required)
- `notifyPublishEmail` (boolean | null, required)
- `notifyPostErrorEmail` (boolean | null, required)
- `notifyApprovalRequestEmail` (boolean | null, required)
- `notifyApprovedInApp` (boolean | null, required)
- `notifyApprovedEmail` (boolean | null, required)
- `notifyRejectedInApp` (boolean | null, required)
- `notifyRejectedEmail` (boolean | null, required)
- `notifyReconnectEmail` (boolean | null, required)
- `notifyWeeklyDigestEmail` (boolean | null, required)

#### 400

Invalid request

- `error` (string, required)
- `issues` (any[], optional)

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

#### 404

The resource does not exist

- `error` (string, required)
- `issues` (any[], optional)

## List the signed-in user's email addresses

```http
GET https://orbitwrite.com/api/v1/account/emails
```

Session-only: an email address belongs to a person, and a workspace API key has no person to own one.

**Authentication:** session cookie.

### Responses

#### 200

Every address on the account, oldest first

- `emails` (UserEmail[], required)
  - `id` (string, required)
  - `email` (string, required)
  - `verified` (boolean, required)
  - `primary` (boolean, required) — The address the account signs in with and receives mail at. Exactly one per user.
  - `createdAt` (string, required) — ISO 8601.

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

## Add an email address to the signed-in user's account

```http
POST https://orbitwrite.com/api/v1/account/emails
```

The address starts unverified and a six-digit code is mailed to it. Verify it with `POST /account/emails/{emailId}/verify` within 10 minutes, or request a new code.

**Authentication:** session cookie.

### Request body (`application/json`)

- `email` (string, required)

### Responses

#### 200

The address was added and a code mailed to it

- `id` (string, required)
- `email` (string, required)
- `verified` (boolean, required)
- `primary` (boolean, required) — The address the account signs in with and receives mail at. Exactly one per user.
- `createdAt` (string, required) — ISO 8601.

#### 400

Invalid request

- `error` (string, required)
- `issues` (any[], optional)

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

#### 409

Conflicts with an existing resource

- `error` (string, required)
- `issues` (any[], optional)

#### 429

Rate limit exceeded

- `error` (string, required)
- `issues` (any[], optional)

## Mail a fresh verification code

```http
POST https://orbitwrite.com/api/v1/account/emails/{emailId}/resend
```

Replaces any code still outstanding for the address. Unlike the code sent when the address is added, this send is awaited: a provider failure is reported as a 502 rather than a false success.

**Authentication:** session cookie.

### Path parameters

- `emailId` (string, required)

### Responses

#### 200

The mutation was applied

- `ok` (boolean, required, one of `true`)

#### 400

Invalid request

- `error` (string, required)
- `issues` (any[], optional)

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

#### 404

The resource does not exist

- `error` (string, required)
- `issues` (any[], optional)

#### 429

Rate limit exceeded

- `error` (string, required)
- `issues` (any[], optional)

#### 502

An upstream provider failed

- `error` (string, required)
- `issues` (any[], optional)

## Verify an email address with its mailed code

```http
POST https://orbitwrite.com/api/v1/account/emails/{emailId}/verify
```

A code expires after 10 minutes and allows 5 wrong guesses; the fifth locks it (429) until a new one is requested.

**Authentication:** session cookie.

### Path parameters

- `emailId` (string, required)

### Request body (`application/json`)

- `otp` (string, required) — The six-digit code mailed to the address.

### Responses

#### 200

The address is verified

- `id` (string, required)
- `email` (string, required)
- `verified` (boolean, required)
- `primary` (boolean, required) — The address the account signs in with and receives mail at. Exactly one per user.
- `createdAt` (string, required) — ISO 8601.

#### 400

Invalid request

- `error` (string, required)
- `issues` (any[], optional)

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

#### 404

The resource does not exist

- `error` (string, required)
- `issues` (any[], optional)

#### 429

Rate limit exceeded

- `error` (string, required)
- `issues` (any[], optional)

## Make a verified address the account's primary one

```http
POST https://orbitwrite.com/api/v1/account/emails/{emailId}/primary
```

The primary address is what sign-in and account mail use, so it must be verified first. The previous primary stays on the account, demoted.

**Authentication:** session cookie.

### Path parameters

- `emailId` (string, required)

### Responses

#### 200

The address is now primary

- `id` (string, required)
- `email` (string, required)
- `verified` (boolean, required)
- `primary` (boolean, required) — The address the account signs in with and receives mail at. Exactly one per user.
- `createdAt` (string, required) — ISO 8601.

#### 400

Invalid request

- `error` (string, required)
- `issues` (any[], optional)

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

#### 404

The resource does not exist

- `error` (string, required)
- `issues` (any[], optional)

## Remove an email address from the account

```http
DELETE https://orbitwrite.com/api/v1/account/emails/{emailId}
```

The primary address cannot be removed — promote another verified address first.

**Authentication:** session cookie.

### Path parameters

- `emailId` (string, required)

### Responses

#### 200

The mutation was applied

- `ok` (boolean, required, one of `true`)

#### 400

Invalid request

- `error` (string, required)
- `issues` (any[], optional)

#### 401

Not signed in

- `error` (string, required)
- `issues` (any[], optional)

#### 404

The resource does not exist

- `error` (string, required)
- `issues` (any[], optional)
