---
title: "Compose a markdown artifact into 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.

# Compose a markdown artifact into a PDF

Path: CloudRaker Paperwork API › Work Sessions

`POST /v1/work-sessions/{id}/artifacts/{artifactId}/compose`

Renders a `text/markdown` artifact into a PDF and files the PDF back onto the session as a new artifact, on the timeline, beside the markdown it came from.

Pass `configId` to render through one of your `/v1/compose` templates — the markdown arrives in the bundle as `body.typ`, which your template includes. Pass `styleProfileId` to render through one of your organization's style profiles instead — including the one marked default, which this route never applies on its own. With neither, the platform's own plain layout is used. Naming both answers `422 compose_target_ambiguous`.

The source must be `text/markdown`; anything else answers `422 artifact_not_markdown`.

Two rendering changes shipped with style profiles and apply to every call: CriticMarkup review comments and rejected suggestions (`{>> … <<}`, `{-- --}`) are stripped instead of printed, and GFM pipe tables render as tables instead of literal pipes.

**Learn more:** [Work sessions](https://docs.cloudraker.com/paperwork/api)

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `id` (`composeWorkSessionArtifact.path.id`; string, required)
  - minLength 1; maxLength 128
- `artifactId` (`composeWorkSessionArtifact.path.artifactId`; string, required)
  - minLength 1; maxLength 256

## Request body

_Required._

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

## Example request

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

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/v1/work-sessions/<id>/artifacts/<artifactId>/compose' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "configId": "string",
  "styleProfileId": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/work-sessions/<id>/artifacts/<artifactId>/compose';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({configId: 'string', 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/v1/work-sessions/<id>/artifacts/<artifactId>/compose"

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

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

print(response.text)
```

## Responses

### 201

The composed PDF artifact.

### 400

Validation Error

#### Example

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

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

### 401

Missing or invalid credential.

### 403

The credential may not use the /v1 API.

### 404

Unknown session, artifact, compose config or style profile.

### 422

`artifact_not_markdown` — the source artifact is not markdown; `compose_target_ambiguous` — both targets were named; `template_render_failed` — the template did not compile.

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


Source: https://docs.cloudraker.com/paperwork/api/work-sessions/compose-work-session-artifact/index.md
