---
title: "Convert a file to PDF"
---

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

# Convert a file to PDF

Path: CloudRaker Paperwork API › Tools

`POST /v1/files/{ref}/convert/pdf`

Turns a Word document, a spreadsheet, a presentation, an image or a plain-text file into a PDF, and stores the result as a new file next to the original.

`{ref}` is the file id or the file name. A file that is already a PDF answers `400` — there is nothing to convert.

The new file carries `parentFileId` pointing back at the original, and is never indexed for search: the original is the thing that gets indexed.

**Learn more:** [Working with files](https://docs.cloudraker.com/paperwork/developers/files)

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `ref` (`convertFileToPdf.path.ref`; string, required)
  - minLength 1

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/v1/files/<ref>/convert/pdf' \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/files/<ref>/convert/pdf';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

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/files/<ref>/convert/pdf"

headers = {"Authorization": "Bearer <token>"}

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

print(response.text)
```

## Responses

### 201

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

### 400

The file is already a PDF (`invalid_request`).

### 404

Unknown file.

### 422

The file type cannot be converted (`unsupported_file_type`).

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


Source: https://docs.cloudraker.com/paperwork/api/tools/convert-file-to-pdf/index.md
