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

# 身份认证

> 用个人 API key 对 API 和 CLI 请求进行身份认证。

从你的 MapX 账号创建个人 API key：打开 `https://app.mapxagent.com?open=api-keys`（或应用内 Profile/账户 → API Keys）。原始 key（例如 `mkx_...`）只显示一次，请立即保存。

后端只存储 key 的 SHA-256 哈希。如果 key 泄露，请从账号中撤销并创建新的。

## API 请求

把 key 作为 Bearer token 发送：

```bash theme={null}
curl https://api.mapxagent.com/api/sessions \
  -H "Authorization: Bearer mkx_..."
```

## CLI 请求

本地保存一次 key，之后 CLI 自动复用：

```bash theme={null}
mapx auth login <mkx_...>
mapx auth status
```

`mapx auth login` 会把 key 存到 `~/.mapx/config.json`（0600 权限）；`mapx auth logout` 删除它。环境变量仍可作为备选：

```bash theme={null}
export MAPX_API_URL="https://api.mapxagent.com"
export MAPX_API_KEY="mkx_..."
mapx auth status
```

每个命令也接受 `--api-key` 和 `--url` 覆盖参数。所有操作都限定在拥有该 key 的账号范围内，项目所有权由后端强制校验。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.