Validate data
Run the same checks a render would run, without actually rendering — so you can surface problems to a user (or reject a submission) before spending a page credit. Validation consumes no render credit.
Endpoint
Section titled “Endpoint”POST /v1/render/{templateId}/validatePOST /v1/render/{templateId}/versions/{version}/validateValidate against the latest published version, or a specific one.
Example
Section titled “Example”curl -X POST "https://pagr-prd-api-public.azurewebsites.net/v1/render/8bec66ff-6f3d-4c1e-9a2b-1f0e5d7c4a90/validate" \ -H "Authorization: Bearer pagr_test_xxxxxxxx" \ -H "Content-Type: application/json" \ -d '{ "documents": [ { "Title": "Acme Q3 Invoice", "Amount": 42 } ] }'import asynciofrom pagr import PagrApiClient
async def main(): async with PagrApiClient("pagr_test_xxxxxxxx") as client: result = await client.validate( "8bec66ff-6f3d-4c1e-9a2b-1f0e5d7c4a90", {"Title": "Acme Q3 Invoice", "Amount": 42}, )
if result.is_valid: print("Looks good") else: for issue in result.errors: # blocking issues only print(issue) # "Error: MissingBinding [total] — …" for issue in result.warnings: # allowed in test, blocking in production print("warning:", issue)
asyncio.run(main())import { PagrApiClient } from 'pagr';
const client = new PagrApiClient('pagr_test_xxxxxxxx');
const result = await client.validate( '8bec66ff-6f3d-4c1e-9a2b-1f0e5d7c4a90', { Title: 'Acme Q3 Invoice', Amount: 42 },);
if (result.isValid) { console.log('Looks good');} else { for (const issue of result.errors) console.log(issue.description);}for (const issue of result.warnings) console.log('warning:', issue.description);import org.example.PagrApiClient;import org.example.models.ValidationResponse;import java.util.UUID;
try (PagrApiClient client = new PagrApiClient("pagr_test_xxxxxxxx")) {
ValidationResponse result = client.validate( UUID.fromString("8bec66ff-6f3d-4c1e-9a2b-1f0e5d7c4a90"), "{\"Title\": \"Acme Q3 Invoice\", \"Amount\": 42}");
if (result.isValid()) { System.out.println("Looks good"); } else { result.getErrors().forEach(System.out::println); } result.getWarnings().forEach(w -> System.out.println("warning: " + w));}using Pagr.Sdk;
using var client = new PagrApiClient("pagr_test_xxxxxxxx");
var result = await client.ValidateAsync( Guid.Parse("8bec66ff-6f3d-4c1e-9a2b-1f0e5d7c4a90"), new { Title = "Acme Q3 Invoice", Amount = 42 });
if (result.IsValid) Console.WriteLine("Looks good");else foreach (var issue in result.Errors) Console.WriteLine(issue);
foreach (var issue in result.Warnings) Console.WriteLine($"warning: {issue}");require "pagr"
client = Pagr::Client.new("pagr_test_xxxxxxxx")
result = client.validate( "8bec66ff-6f3d-4c1e-9a2b-1f0e5d7c4a90", { "Title" => "Acme Q3 Invoice", "Amount" => 42 },)
if result.valid? puts "Looks good"else result.errors.each { |issue| warn issue }endresult.warnings.each { |issue| warn "warning: #{issue}" }#include "pagr/PagrApiClient.hpp"
pagr::PagrApiClient client("pagr_test_xxxxxxxx");
auto result = client.validate( std::string("8bec66ff-6f3d-4c1e-9a2b-1f0e5d7c4a90"), R"({"Title": "Acme Q3 Invoice", "Amount": 42})");
if (result.is_valid()) { std::cout << "Looks good\n";} else { for (const auto& issue : result.errors()) { /* handle */ }}for (const auto& issue : result.warnings()) { /* handle */ }A validate_async form returning std::future<ValidationResponse> is also available.
Path parameters
Section titled “Path parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
templateId |
string (UUID) | Yes | The template to validate against. |
version |
integer | Only for the specific-version form | The version number. Omit the whole segment to validate against the latest published version. |
Query parameters
Section titled “Query parameters”None. Validation has no persist or language parameter — it never produces
output.
Request body
Section titled “Request body”| Field | Type | Required | Description |
|---|---|---|---|
documents |
array of objects | Yes | One object per document. Validate a batch in one call the same way you’d render one. |
{ "documents": [ { "Title": "Acme Q3 Invoice", "Amount": 42 } ]}Response
Section titled “Response”Every call returns HTTP 200 with a flat list of issues across the whole batch:
{ "issues": [ { "type": "MissingBinding", "severity": "Error", "description": "No value bound for 'total'.", "elementId": "total-amount", "documentIndex": 0 } ]}An empty issues array means every document is clean.
Issue fields
Section titled “Issue fields”| Field | Type | Description |
|---|---|---|
type |
string | The issue category — see Errors → Render issues for every value. |
severity |
string | Information, Warning, or Error. |
description |
string | Human-readable explanation. Don’t parse it; switch on type. |
elementId |
string or null | The template element the issue attaches to, when it maps to one. |
documentIndex |
number or null | Which document in the batch the issue belongs to. null for a batch-wide issue not scoped to one document. |
SDK reference
Section titled “SDK reference”| SDK | Method | Result accessors |
|---|---|---|
| Python | await client.validate(template_id, json_data, *, version=None) |
.is_valid, .errors, .warnings, .issues_for(i), iterable |
| TypeScript | await client.validate(templateId, data, { version }) |
.isValid, .errors, .warnings, .issuesFor(i), iterable |
| Java | client.validate(templateId, data[, version]) — data is a JSON String, JsonObject or Map |
.isValid(), .getErrors(), .getWarnings(), .issuesFor(i), iterable |
| C# | await client.ValidateAsync(templateId, data, version, cancellationToken) |
.IsValid, .Errors, .Warnings, .IssuesFor(i), IReadOnlyList<RenderIssue> |
| Ruby | client.validate(template_id, json_data, version:) |
.valid?, .errors, .warnings, .issues_for(i), Enumerable |
| C++ | client.validate(template_id, json_data, version) / validate_async(…) |
.is_valid(), .errors(), .warnings(), .issues_for(i) |
issues_for(i) returns the issues for document i plus every batch-wide
issue (those whose documentIndex is null) — so a per-document error report is
never missing a batch-level cause.
Errors
Section titled “Errors”| Status | code |
When |
|---|---|---|
404 |
TemplateNotFound, VersionNotFound, NoPublishedVersion |
The template or version doesn’t exist, or nothing is published yet. |
422 |
BindingError |
The request body couldn’t be parsed or bound. |
See Errors for the full table.
Related articles
Section titled “Related articles”- Validate before rendering — the validate-then-render pattern, step by step.
- Render a document — the endpoint this mirrors.
- Errors → Render issues — the full issue type table with severities.
- Templates & versions — fetch a version’s
sampleDataas a validation starting point.
