Skip to content

Validate a payload

POST
/v2/validate

Reports syntax and semantic problems in a payload without rendering it. A 200 response does not mean the payload is valid — read valid. Takes the same body and content types as POST /v2/pdf.

Authorizations

BearerAuth

Your Papermill API key, sent as Authorization: Bearer <key>.

Type
HTTP (bearer)
or
ApiKeyHeader

Your Papermill API key. Equivalent to the bearer form.

Type
API Key (header: x-api-key)

Parameters

Query Parameters

template_id

The template to render or validate against. Required when the body is JSON, CSV, or Markdown; optional when the body is a complete Press document.

Type
string
Examples
"papermill-invoice""papermill-modern-invoice""papermill-modern-letter""papermill-modern-report""papermill-simple-report"
flow

With Content-Type: text/markdown, the template flow the body replaces. Defaults to body. Supplying it with any other content type is rejected rather than silently ignored.

Type
string

Request Body

XML

Responses

Validation findings, split by severity.

application/json
JSON
{
  
"valid": true,
  
"errors": [
  
  
{
  
  
  
"message": "string",
  
  
  
"source": {
  
  
  
  
"tagName": "string",
  
  
  
  
"origin": "string",
  
  
  
  
"lineStart": 0,
  
  
  
  
"lineEnd": 0,
  
  
  
  
"columnStart": 0,
  
  
  
  
"columnEnd": 0
  
  
  
}
  
  
}
  
],
  
"warnings": [
  
  
{
  
  
  
"message": "string",
  
  
  
"source": {
  
  
  
  
"tagName": "string",
  
  
  
  
"origin": "string",
  
  
  
  
"lineStart": 0,
  
  
  
  
"lineEnd": 0,
  
  
  
  
"columnStart": 0,
  
  
  
  
"columnEnd": 0
  
  
  
}
  
  
}
  
]
}

Playground

Authorization
Variables
Key
Value
Body

Samples

Example

A 200 does not mean the payload is valid — read valid, and branch on the findings.

shell
curl -X POST https://api.papermill.io/v2/validate \
  -H "Authorization: Bearer $PAPERMILL_API_KEY" \
  -H "Content-Type: application/xml" \
  --data-binary @template.press
python
import os
import requests

with open("template.press", "rb") as f:
    response = requests.post(
        "https://api.papermill.io/v2/validate",
        headers={
            "Authorization": f"Bearer {os.environ['PAPERMILL_API_KEY']}",
            "Content-Type": "application/xml",
        },
        data=f.read(),
    )

findings = response.json()
if not findings["valid"]:
    for error in findings["errors"]:
        print(error["message"])
javascript
import fs from 'node:fs/promises'

const response = await fetch('https://api.papermill.io/v2/validate', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PAPERMILL_API_KEY}`,
    'Content-Type': 'application/xml',
  },
  body: await fs.readFile('template.press'),
})

const findings = await response.json()
if (!findings.valid) findings.errors.forEach((e) => console.error(e.message))