> ## Documentation Index
> Fetch the complete documentation index at: https://help.draftable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exporting a comparison to PDF

> How to turn a completed Draftable API comparison into a downloadable PDF, including the four export kinds and how to retrieve the finished file.

The viewer is interactive, but sometimes you need a file: something to attach to an email, file against a matter, or send to someone who will not open a link.

The exports endpoint turns a completed comparison into a downloadable PDF.

```
POST https://api.draftable.com/v1/exports
```

> [!NOTE]
>
> You can only export a comparison that has finished processing. Confirm `ready` is `true` and `failed` is `false` before creating an export.

## Export kinds

Choose what the PDF should contain with the `kind` parameter.

| Kind | What the PDF contains |
| :- | :- |
| `single_page` | The right (revised) document only, with highlights and deletion markers showing the changes |
| `combined` | Both documents, left and right |
| `left` | The left (original) document only |
| `right` | The right (revised) document only |

> [!TIP]
>
> `single_page` is the one most people want. It reads as a single reviewable document, in the way a redline does, rather than as two documents side by side. Use `combined` when the reader needs to see both versions in full.

## Creating an export

```bash theme={null}
curl -X POST https://api.draftable.com/v1/exports \
  -H "Authorization: Token YOUR_AUTH_TOKEN" \
  -F "comparison=aBcDeFgH" \
  -F "kind=single_page"
```

| Parameter | Required | Description |
| :- | :-: | :- |
| `comparison` | Yes | The identifier of the comparison to export |
| `kind` | Yes | One of the four kinds above |
| `include_cover_page` | No | Whether a cover page is included for the `combined` export. Defaults to `true` |

The response is **201 Created**:

```json theme={null}
{
  "identifier": "xYzExPoRt",
  "comparison": "aBcDeFgH",
  "kind": "single_page",
  "ready": false,
  "failed": false
}
```

As with comparisons, exports are generated asynchronously. The response comes back immediately with `ready: false` and no `url`.

## Retrieving the finished PDF

Poll the export until it is ready:

```
GET https://api.draftable.com/v1/exports/{identifier}
```

```bash theme={null}
curl https://api.draftable.com/v1/exports/xYzExPoRt \
  -H "Authorization: Token YOUR_AUTH_TOKEN"
```

When it completes, a `url` appears:

```json theme={null}
{
  "identifier": "xYzExPoRt",
  "comparison": "aBcDeFgH",
  "kind": "single_page",
  "url": "https://...",
  "ready": true,
  "failed": false
}
```

Download the PDF from that URL.

> [!WARNING]
>
> The download URL is **signed and time-limited**. Fetch the file promptly rather than storing the URL for later use. If a stored URL has expired, create a new export to get a fresh one.

As with comparisons, `ready: true` means processing finished, not that it succeeded. Check `failed`, and read `error_message` when it is `true`.

## A complete flow

**1. Create the comparison**

`POST /comparisons` with both documents. Keep the returned identifier.

**2. Wait for the comparison to be ready**

Poll `GET /comparisons/{identifier}` until `ready` is `true`. Confirm `failed` is `false`.

**3. Create the export**

`POST /exports` with the comparison identifier and your chosen kind.

**4. Wait for the export to be ready**

Poll `GET /exports/{identifier}` until `ready` is `true`.

**5. Download the file**

Fetch the PDF from the `url` in the response, promptly.

Note the two separate waits. A common mistake is creating an export immediately after creating a comparison, before the comparison itself has finished.

## Related articles

> [card] [Creating a comparison](https://help.draftable.com/hc/en-us/articles/Draftable-API-creating-a-comparison.md)

> [card] [Viewing and sharing results](https://help.draftable.com/hc/en-us/articles/Draftable-API-viewing-and-sharing-results.md)

> [card] [Handling errors and failures](https://help.draftable.com/hc/en-us/articles/Draftable-API-handling-errors.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.