# ChatGPT Session 管理 API

这是一个使用固定 Bearer Key 认证的 JSON 记录管理 API。

> `author` 是调用方自行声明的审计标签，不代表经过验证的身份。

## 认证

除本文档外，所有业务接口都需要以下请求头：

```http
Authorization: Bearer <key>
```

## 新增记录

`POST /v1/records`

```json
{
  "author": "调用方名称",
  "data": {
    "任意": "JSON 数据"
  }
}
```

- `author`：必填字符串，trim 后长度为 1 至 128 个字符。
- `data`：必填，可以是任意合法 JSON 值，包括 `null`。
- 成功状态：`201`。
- 返回字段：`id`、`author`、`data`、`created_at`。

## 分页查询

`GET /v1/records?limit=20&offset=0`

- 只返回未删除记录。
- `limit`：默认 20，范围 0 至 100。
- `offset`：默认 0，必须是非负整数。
- 按 `created_at DESC, id DESC` 排序。
- 分页字段：`limit`、`offset`、`count`、`total`、`has_more`。

## 软删除

`DELETE /v1/records/{id}`

```json
{
  "author": "执行删除的调用方"
}
```

- 只做软删除。
- 重复调用不会覆盖首次删除者和删除时间。
- 成功状态：`200`。
- 返回字段：`id`、`deleted_by`、`deleted_at`。

## 错误格式

```json
{
  "error": {
    "code": "error_code",
    "message": "Error description."
  }
}
```
