---
title: "Save a session back as a file"
---

> 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.

# Save a session back as a file

Path: CloudRaker Paperwork API › Redline

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

Exports the session as a `.docx` — tracked changes and all — and stores it as a new file next to the document it came from.

```json
{ "fileId": "msa.docx" }
```

`fileId` is the file the session was opened on, by id or by name. It must BE that file: a session that was opened on a different document answers `409 redline_file_mismatch`. The new file is named `<original>.redlined.docx` and carries `parentFileId` pointing back at it.

A NAME is resolved in the org API workspace only — there is no cross-space name index. A file that lives in an explicit space must be flushed by its id.

The session stays open: flush as often as you like, then let it expire or delete it.

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

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

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

## Request body

_Required._

- `fileId` (`flushRedlineSession.fileId`; string, required)
  - minLength 1; example `"msa.docx"`

## Example request

```json
{
  "fileId": "msa.docx"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/v1/redline/<sessionId>/flush' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "fileId": "msa.docx"
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/redline/<sessionId>/flush';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({fileId: 'msa.docx'})
};

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>/flush"

payload = { "fileId": "msa.docx" }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 201

The saved file.

#### Example

```json
{
  "object": "file",
  "id": "string",
  "name": "string",
  "mimeType": "string",
  "status": "uploading",
  "createdAt": "string",
  "parentFileId": "string",
  "metadata": {
    "property1": "string",
    "property2": "string"
  },
  "error": "string",
  "uploadUrl": "string",
  "uploadExpiresAt": "string",
  "urls": {
    "content": "string",
    "markdown": "string",
    "json": "string"
  }
}
```

- `object` (`flushRedlineSession.response.201.object`; string, required)
- `id` (`flushRedlineSession.response.201.id`; string, required)
- `name` (`flushRedlineSession.response.201.name`; string, required)
- `mimeType` (`flushRedlineSession.response.201.mimeType`; string, required)
- `status` (`flushRedlineSession.response.201.status`; string, required)
  - one of `"uploading"`, `"processing"`, `"ready"`, `"failed"`
- `createdAt` (`flushRedlineSession.response.201.createdAt`; string, required)
- `parentFileId` (`flushRedlineSession.response.201.parentFileId`; string, optional)
- `metadata` (`flushRedlineSession.response.201.metadata`; map<string>, optional)
- `error` (`flushRedlineSession.response.201.error`; string, optional)
- `uploadUrl` (`flushRedlineSession.response.201.uploadUrl`; string, optional)
- `uploadExpiresAt` (`flushRedlineSession.response.201.uploadExpiresAt`; string, optional)
- `urls` (`flushRedlineSession.response.201.urls`; object, optional)
  - `content` (`flushRedlineSession.response.201.urls.content`; string, optional)
  - `markdown` (`flushRedlineSession.response.201.urls.markdown`; string, optional)
  - `json` (`flushRedlineSession.response.201.urls.json`; string, optional)

### 400

Validation Error

#### Example

```json
{
  "success": false,
  "error": [
    null
  ],
  "data": null
}
```

- `success` (`flushRedlineSession.response.400.success`; boolean, required)
  - one of `false`
- `error` (`flushRedlineSession.response.400.error`; array<unknown>, required)
- `data` (`flushRedlineSession.response.400.data`; unknown, required)

### 404

Unknown session or file.

### 409

The session was opened on another file (`redline_file_mismatch`).

### 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` (`flushRedlineSession.response.429.code`; string, required)
  - one of `"rate_limited"`
- `message` (`flushRedlineSession.response.429.message`; string, required)
- `retryable` (`flushRedlineSession.response.429.retryable`; boolean, required)
  - one of `true`
- `requestId` (`flushRedlineSession.response.429.requestId`; string, required)
- `docUrl` (`flushRedlineSession.response.429.docUrl`; string, optional)


Source: https://docs.cloudraker.com/paperwork/api/redline/flush-redline-session/index.md
