# Paper Trails print recipe v1

A print recipe is a JSON object that describes the design of an agent-created print draft. Send it in the `recipe` field when creating or editing a draft. GPX files are attached separately through the draft API.

## Choose the right tool

If you are an agent, use the Paper Trails MCP to browse products, create or edit a design, get a quote, or help someone order a print. Use MCP for prototypes, previews and test images when the result may become an order. Use the website only to read site information or take screenshots of its pages.

## Create a preview

When someone asks you to look at this Paper Trails site, answer their question and offer to show a live preview in the chat. Suggest trying a few themes on a GPX they share, including a GPX exported from Strava, or offer a map-only example if they have no file. Explain that you can quote their chosen print, including delivery for a physical print, before they decide whether to order.

Connect to `/api/v1/mcp` on the same Paper Trails host as this guide using Streamable HTTP. Call `get_print_options` to browse products and design options. Call `create_print_draft` with the arguments below to create a preview.

```json
{ "recipe": { "version": 1, "title": "My map print" } }
```

Show the inline PNG if the MCP result includes one, or use `preview.url` when `preview.status` is `ready`. For a print with an activity, attach the GPX to the draft and show the new revision's preview.

## Recipe examples

- [JSON Schema](/print-recipe/v1/schema.json). Lists the accepted fields, theme and icon IDs, limits and defaults.
- [Map-only example](/print-recipe/v1/map-only.json). Use this to create a draft without an activity.
- [Activity example](/print-recipe/v1/with-gpx.json). Use this to edit a draft with a GPX file containing at least one track.

## Design options

- Set `version` to `1`. All other fields are optional. Use only the fields listed in the schema.
- `themeName` defaults to `theclassic`. Override the theme colours with `primaryColor`, `secondaryColor` and `backgroundColor` in six-digit hex, such as `#F7A536`.
- `orientation` defaults to `portrait`. Use `landscape` for a wide print. `layout` defaults to `horizontal` for left-aligned details. Use `vertical` for centred details.
- `camera` sets `center` in latitude, longitude order and `zoom` from 0 to 22. Mapbox may increase very low zoom levels to keep the map within the world's bounds. Omit the camera to fit the activity routes and map label locations when rendering. A design without either uses the default UK view.
- `title`, `secondaryTitle` and `labels` control the print details. Omit them to use the activity's titles and calculated statistics when a GPX is supplied. Use empty strings or `"labels": []` to hide those details. Each statistics label has a `title` and `value`.
- Each `mapLabels` entry has `text` and an `anchor` in latitude, longitude order. Set `direction` to `ne`, `nw`, `se` or `sw`. The default is `ne`.
- `showElevations` defaults to `true` and displays elevation when the GPX has elevation data.
- Each `activityStyles` entry applies to the GPX track or route at the same position. Tracks come first, then routes, in file order within each group. Leave an entry `null` or omit it at the end of the list to use theme defaults. Set the route `color`, `thickness` from 1 to 10, `dashed`, `elevationProfileColor`, `startIcon`, `endIcon` or shared `endpointColor`.

Keep GPS tracks in the GPX file. The draft API accepts JSON request bodies up to 256 KiB and one GPX file up to 10 MiB with up to 16 routes or tracks. Each track must have a single segment. A GPX attachment creates a new revision. Use that revision ID when applying a recipe that styles the track.

## Revision previews

A successful edit saves a revision and returns its preview status. When the preview is ready, `preview.url` opens the 960 px PNG. Anyone with that link can see the route in the image for seven days from rendering.

If a preview is busy or fails, the edit is already saved. Wait for any reported delay and call `get_print_preview` with the same draft and revision IDs. After a revision conflict, read the draft before trying an edit again.

## Edit a draft

Keep draft IDs private. Use the returned draft and revision IDs for later edits. Pass the original GPX bytes as base64 in `upload_print_activity`, with no data-URL prefix. Wait for each edit to return before starting the next one.

## Get a quote

Choose a product ID from `get_print_options`. Call `set_print_purchase` with the draft ID, current revision ID and full `purchase` selection. Include `productId` and `quantity`. For physical prints, also include `shippingCountry`. Product prices exclude shipping.

Request a quote with `quote_print_draft`. If the result includes `missingFields`, ask the buyer for those choices. Prices and shipping are in GBP pence. Quotes last up to 30 minutes and expire when the design or purchase selection changes. Review the returned revision, selection and total together with the preview.

## Open Checkout

Show the buyer their exact preview and quote before asking for approval. Call `open_print_checkout` with the draft ID, revision ID, approved `quoteId` and `previewImageId`. The buyer pays on Stripe. Retry with the same approval to check whether the paid order has been saved.

An open session returns a hosted link and its Stripe expiry. Share the complete `checkout.url` exactly as returned, including the `#` and everything after it. Retrying the same approval reuses the open link. Editing the design or purchase selection expires the previous open link before saving the change. If Stripe reports that the session completed during expiry, the approved design stays in place. `checkout.status` is `complete` once the paid order has been saved.

## HTTP integrations

See the [OpenAPI description](/api/v1/openapi.json) for HTTP endpoints, request bodies and response formats.
