# Update account preferences

<span id="更新账户偏好"></span>

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Partially update the display language or IANA time zone preference of the authenticated account and return the updated preference snapshot. Omitted fields remain unchanged.

```text
PATCH https://api.moi.matrixorigin.cn/v5/auth/preferences
```

<span id="调用前准备"></span>

## Before you begin

1. Prepare a personal access token or service account access token for the current account; see [Access credentials](../../../../../guides/billing/credentials.md#choose-credential-type). This endpoint updates preferences for the current account directly and does not require a workspace ID.
2. To inspect the current language and time zone before making changes, call [Get account preferences](get-account-preferences.md).

<span id="请求体"></span>

## Request body

Replace `$AI_STUDIO_API_KEY` with your credential. Authenticate with `X-API-Key`, `Authorization: Bearer`, or a browser session (which also requires `X-CSRF-Token`); credential types are mutually exclusive in a single request, and `X-Workspace-ID` is not required.

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl -X PATCH "https://api.moi.matrixorigin.cn/v5/auth/preferences" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "locale": "zh-CN",
    "timezone": "Asia/Shanghai"
  }'
```

:::::
:::::{tab-item} Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `locale` | string | No | Account display language tag. Supported values: `zh-CN`, `en-US`, `fr-FR`, `es-ES`, `ar`, `id-ID`. Omitting this field keeps the current language. |
| `timezone` | string | No | Account time zone as a valid IANA time zone name, such as `Asia/Shanghai`, `UTC`, or `America/New_York`. Fixed offsets such as `+08:00`, `UTC+08:00`, and `GMT+08:00` are rejected. Omitting this field keeps the current time zone. |

The request body is limited to 1 MiB (`1048576` bytes), and at least one of `locale` or `timezone` must be provided. An empty JSON object `{}`, unknown JSON fields, trailing JSON tokens after the first object, or unsupported `locale` or `timezone` values return HTTP `400` (`ErrParamInvalid`).

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

Returns HTTP `200` with `Cache-Control: no-store`. The top-level response object contains only `code` and `data`, with no `msg` field.

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "data": {
    "locale": "zh-CN",
    "timezone": "Asia/Shanghai",
    "updated_at": "2026-10-14T08:05:00Z"
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Always `OK` when the request succeeds. |
| `data` | object | Updated preferences for the current account. |
| `data.locale` | string | Effective account display language tag after the update: `zh-CN`, `en-US`, `fr-FR`, `es-ES`, `ar`, or `id-ID`. |
| `data.timezone` | string | Effective account IANA time zone name after the update, such as `Asia/Shanghai` or `UTC`. |
| `data.updated_at` | string | Last preference update timestamp in RFC 3339 format. |

:::::
::::::
:::::::

<span id="错误响应"></span>

## Error response

An empty JSON object `{}`, unknown fields, trailing JSON tokens, payloads exceeding 1 MiB, or unsupported `locale` or `timezone` values return HTTP `400` (`ErrParamInvalid`). Sending multiple authentication credentials in one request returns HTTP `400` (`ErrMultipleAuthCredentials`). Missing or invalid credentials return HTTP `401` (`Unauthorized` or `unauthenticated`), browser-session requests without a valid `X-CSRF-Token` return HTTP `403` (`ErrForbidden`), and upstream preference service failures return HTTP `502` (`ErrServiceUnavailable`). Error responses contain only `code` and `msg`, with no `data` field.

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "ErrParamInvalid",
  "msg": "Bad Request"
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Error code, such as `ErrParamInvalid`, `ErrMultipleAuthCredentials`, `Unauthorized`, `unauthenticated`, `ErrForbidden`, or `ErrServiceUnavailable`. |
| `msg` | string | Error message text. |

:::::
::::::
:::::::
