---
title: "Preview a document as a 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.

# Preview a document as a PDF

Path: CloudRaker Workspace API › Documents

`POST /workspace/sessions/{sessionId}/artifacts/{artifactId}/preview`

The same render as `compose`, streamed back as raw `application/pdf` bytes. It stores NOTHING: no file, no artifact, no timeline entry — the editor debounces this on every keystroke and a session must not fill up with drafts. **Authorization:** the same gate as every session route — `work_session:read` (or `comment` to write) on the session, OR `space:contribute` on one of its linked spaces; a desk session only for its owner. Any denial is 404.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `sessionId` (`previewWorkspaceDocument.path.sessionId`; string, required)
- `artifactId` (`previewWorkspaceDocument.path.artifactId`; string, required)

## Request body

_Required._

- `styleProfileId` (`previewWorkspaceDocument.styleProfileId`; string, optional)
  - minLength 1; maxLength 128

## Example request

```json
{
  "styleProfileId": "string"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/workspace/sessions/<sessionId>/artifacts/<artifactId>/preview' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "styleProfileId": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/workspace/sessions/<sessionId>/artifacts/<artifactId>/preview';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({styleProfileId: 'string'})
};

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/workspace/sessions/<sessionId>/artifacts/<artifactId>/preview"

payload = { "styleProfileId": "string" }
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

The rendered PDF.

### 400

Validation Error

#### Example

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

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

### 404

No such session or artifact, or the caller may not see it.

#### Example

```json
{
  "error": "string",
  "error_code": "string",
  "issues": [
    {
      "path": "string",
      "code": "string",
      "message": "string"
    }
  ]
}
```

- `error` (`previewWorkspaceDocument.response.404.error`; string, required) — The sentence a human reads.
- `error_code` (`previewWorkspaceDocument.response.404.error_code`; string, required) — The stable snake_case branch key.
- `issues` (`previewWorkspaceDocument.response.404.issues`; array<object>, optional) — Per-field detail, present only on a validation failure.
  - `path` (`previewWorkspaceDocument.response.404.issues.path`; string, required)
  - `code` (`previewWorkspaceDocument.response.404.issues.code`; string, required)
  - `message` (`previewWorkspaceDocument.response.404.issues.message`; string, required)

### 409

`artifact_not_ready` — the bytes are not stored or parsed yet (retryable); `document_version_conflict` — a save whose `baseVersion` is behind the current version.

#### Example

```json
{
  "error": "string",
  "error_code": "string",
  "issues": [
    {
      "path": "string",
      "code": "string",
      "message": "string"
    }
  ]
}
```

- `error` (`previewWorkspaceDocument.response.409.error`; string, required) — The sentence a human reads.
- `error_code` (`previewWorkspaceDocument.response.409.error_code`; string, required) — The stable snake_case branch key.
- `issues` (`previewWorkspaceDocument.response.409.issues`; array<object>, optional) — Per-field detail, present only on a validation failure.
  - `path` (`previewWorkspaceDocument.response.409.issues.path`; string, required)
  - `code` (`previewWorkspaceDocument.response.409.issues.code`; string, required)
  - `message` (`previewWorkspaceDocument.response.409.issues.message`; string, required)

### 422

`artifact_not_markdown` — the artifact is not a document.

#### Example

```json
{
  "error": "string",
  "error_code": "string",
  "issues": [
    {
      "path": "string",
      "code": "string",
      "message": "string"
    }
  ]
}
```

- `error` (`previewWorkspaceDocument.response.422.error`; string, required) — The sentence a human reads.
- `error_code` (`previewWorkspaceDocument.response.422.error_code`; string, required) — The stable snake_case branch key.
- `issues` (`previewWorkspaceDocument.response.422.issues`; array<object>, optional) — Per-field detail, present only on a validation failure.
  - `path` (`previewWorkspaceDocument.response.422.issues.path`; string, required)
  - `code` (`previewWorkspaceDocument.response.422.issues.code`; string, required)
  - `message` (`previewWorkspaceDocument.response.422.issues.message`; string, required)


Source: https://docs.cloudraker.com/workspace/api/documents/preview-workspace-document/index.md
