---
title: "Edit a session"
---

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

# Edit a session

Path: CloudRaker Paperwork API › Redline

`POST /v1/redline/{sessionId}/edits`

Applies one edit to the document, as a tracked change by default.

```json
{ "op": "replace", "anchorText": "thirty (30) days", "replacement": "sixty (60) days" }
```

Four operations: `replace` and `deleteText` act on anchor text, `fill` applies a list of replacements in one pass, and `insertMarkdown` adds new paragraphs before or after an anchor (or at the end). Set `tracked: false` to write the change silently instead.

The response carries the new `revision` and the ids of the tracked changes the edit produced. Those ids are positional and only valid at that revision.

**Learn more:** [Redlining](https://docs.cloudraker.com/paperwork/developers/file-tools)

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `sessionId` (`applyRedlineEdits.path.sessionId`; string, required)
  - minLength 1

## Request body

_Required._

- `op` (`applyRedlineEdits.op`; string, required)
  - one of `"replace"`, `"insertMarkdown"`, `"fill"`, `"deleteText"`
- `anchorText` (`applyRedlineEdits.anchorText`; string, optional)
  - example `"thirty (30) days"`
- `occurrence` (`applyRedlineEdits.occurrence`; integer, optional)
  - max 9007199254740991
- `all` (`applyRedlineEdits.all`; boolean, optional)
- `replacement` (`applyRedlineEdits.replacement`; string, optional)
  - example `"sixty (60) days"`
- `markdown` (`applyRedlineEdits.markdown`; string, optional)
- `position` (`applyRedlineEdits.position`; string, optional)
  - one of `"before"`, `"after"`, `"end"`
- `fields` (`applyRedlineEdits.fields`; array<object>, optional)
  - `anchorText` (`applyRedlineEdits.fields.anchorText`; string, required)
  - `replacement` (`applyRedlineEdits.fields.replacement`; string, required)
  - `occurrence` (`applyRedlineEdits.fields.occurrence`; integer, optional)
    - max 9007199254740991
  - `all` (`applyRedlineEdits.fields.all`; boolean, optional)
- `tracked` (`applyRedlineEdits.tracked`; boolean, optional)
- `author` (`applyRedlineEdits.author`; string, optional)

## Example request

```json
{
  "op": "replace",
  "anchorText": "thirty (30) days",
  "occurrence": 9007199254740991,
  "all": true,
  "replacement": "sixty (60) days",
  "markdown": "string",
  "position": "before",
  "fields": [
    {
      "anchorText": "string",
      "replacement": "string",
      "occurrence": 9007199254740991,
      "all": true,
      "property1": null,
      "property2": null
    }
  ],
  "tracked": true,
  "author": "string",
  "property1": null,
  "property2": null
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/v1/redline/<sessionId>/edits' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "op": "replace",
  "anchorText": "thirty (30) days",
  "occurrence": 9007199254740991,
  "all": true,
  "replacement": "sixty (60) days",
  "markdown": "string",
  "position": "before",
  "fields": [
    {
      "anchorText": "string",
      "replacement": "string",
      "occurrence": 9007199254740991,
      "all": true,
      "property1": null,
      "property2": null
    }
  ],
  "tracked": true,
  "author": "string",
  "property1": null,
  "property2": null
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/redline/<sessionId>/edits';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    op: 'replace',
    anchorText: 'thirty (30) days',
    occurrence: 9007199254740991,
    all: true,
    replacement: 'sixty (60) days',
    markdown: 'string',
    position: 'before',
    fields: [
      {
        anchorText: 'string',
        replacement: 'string',
        occurrence: 9007199254740991,
        all: true,
        property1: null,
        property2: null
      }
    ],
    tracked: true,
    author: 'string',
    property1: null,
    property2: null
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/v1/redline/<sessionId>/edits"

payload = {
    "op": "replace",
    "anchorText": "thirty (30) days",
    "occurrence": 9007199254740991,
    "all": True,
    "replacement": "sixty (60) days",
    "markdown": "string",
    "position": "before",
    "fields": [
        {
            "anchorText": "string",
            "replacement": "string",
            "occurrence": 9007199254740991,
            "all": True,
            "property1": None,
            "property2": None
        }
    ],
    "tracked": True,
    "author": "string",
    "property1": None,
    "property2": None
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The edit outcome.

#### Example

```json
{
  "revision": -9007199254740991,
  "summary": {
    "paragraphCount": -9007199254740991,
    "comments": -9007199254740991,
    "trackedChanges": -9007199254740991
  }
}
```

- `revision` (`applyRedlineEdits.response.200.revision`; integer, required)
  - min -9007199254740991; max 9007199254740991
- `summary` (`applyRedlineEdits.response.200.summary`; object, required)
  - `paragraphCount` (`applyRedlineEdits.response.200.summary.paragraphCount`; integer, required)
    - min -9007199254740991; max 9007199254740991
  - `comments` (`applyRedlineEdits.response.200.summary.comments`; integer, required)
    - min -9007199254740991; max 9007199254740991
  - `trackedChanges` (`applyRedlineEdits.response.200.summary.trackedChanges`; integer, required)
    - min -9007199254740991; max 9007199254740991

### 400

The edit is malformed, or its anchor matched nothing.

### 404

Unknown or expired session.

### 429

Rate limited. The `/v1` API allows at least **67 requests per minute per organization** (about 1,000 requests per 15 minutes) — a guaranteed floor, enforced per edge location, so a geographically spread caller may get more. Wait for the `Retry-After` interval and retry — the error is `retryable`.

#### Example

```json
{
  "code": "rate_limited",
  "message": "string",
  "retryable": true,
  "requestId": "string",
  "docUrl": "string"
}
```

- `code` (`applyRedlineEdits.response.429.code`; string, required)
  - one of `"rate_limited"`
- `message` (`applyRedlineEdits.response.429.message`; string, required)
- `retryable` (`applyRedlineEdits.response.429.retryable`; boolean, required)
  - one of `true`
- `requestId` (`applyRedlineEdits.response.429.requestId`; string, required)
- `docUrl` (`applyRedlineEdits.response.429.docUrl`; string, optional)


Source: https://docs.cloudraker.com/paperwork/api/redline/apply-redline-edits/index.md
