> This page is for Paperwork API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.cloudraker.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.cloudraker.com/_mcp/server.

# Compose a markdown artifact into a PDF

POST https://api.cloudraker.com/v1/work-sessions/{id}/artifacts/{artifactId}/compose
Content-Type: application/json

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 (RKO-766): 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/overview)

Reference: https://docs.cloudraker.com/paperwork/api/work-sessions/compose-work-session-artifact

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `id` (string, required)
- `artifactId` (string, required)

### Body (application/json)

This endpoint expects a ComposeWorkSessionArtifactBody.

- `configId` (string, optional)
- `styleProfileId` (string, optional)

## Response

### 201

The composed PDF artifact.

## Errors

### 400 Bad Request Error

Validation Error

- `success` (boolean, required)
- `error` (list of any, required)
- `data` (any, required)

### 401 Unauthorized Error

Missing or invalid credential.

- `any`

### 403 Forbidden Error

The credential may not use the /v1 API.

- `any`

### 404 Not Found Error

Unknown session, artifact, compose config or style profile.

- `any`

### 422 Unprocessable Entity Error

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

- `any`

### 429 Too Many Requests Error

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

- `code` (enum, required)
  - Allowed values: `rate_limited`
- `message` (string, required)
- `retryable` (boolean, required)
- `requestId` (string, required)
- `docUrl` (string, optional)

## Examples

**Request**

```json
{}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose"

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

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

print(response.json())
```

```javascript
const url = 'https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.cloudraker.com/v1/work-sessions/id/artifacts/artifactId/compose")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```