# Apply Exact Content Edits

`POST /pages/{pageId}/edits`

Replaces one or more exact passages without replacing the full page. Each old passage must occur exactly once, and missing or overlapping matches are rejected. Use `Idempotency-Key` when retrying the same request.
## Authentication

Use one of the following authentication alternatives:

- **API token** (`bearerToken`) : Send a named API token in the Authorization header. Send it in the `Authorization: Bearer <token>` header.
- **Better Auth browser session** (`browserSession`) : Use the Better Auth session cookie from a signed-in browser session. Send it in the `better-auth.session_token` cookie.
## Token permissions

API tokens must include `pages:write`.
## Parameters

- `pageId` (path, required): The UUID of the page.
- `Idempotency-Key` (header, optional): Use the same key to retry the same request. Completed responses are replayed for 24 hours; incomplete reservations expire after 5 minutes.
## Request Body

Required.

### `application/json`

```json
{
  "edits": [
    {
      "id": "rename-heading",
      "oldText": "# Draft",
      "newText": "# Notes"
    }
  ]
}
```
## Responses

### 200

One result for each requested edit and the new ETag.

#### Response headers

- `ETag`: Revision identifier for the returned page content. Type: `string`.

### `application/json`

```json
{
  "results": [
    null
  ],
  "etag": "string"
}
```

### 403

The API token is missing a required scope: pages:write.


### `application/json`

```json
{
  "error": {
    "code": "string",
    "message": "string"
  }
}
```
