> For the complete documentation index, see [llms.txt](https://synap.ac/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://synap.ac/docs/api/reference/certificates/preview-a-template.md). Agents can also search and read this documentation through its [MCP server](https://synap.ac/docs/~gitbook/mcp).

# Preview a Template

Renders unsaved parts to a PDF with sample data and the branding of the portal, and stores nothing. The requester must be an admin of the main portal and not of a sub-portal. The template has to be a managed template of the portal: it tells the usage the parts are rendered for and which images they may use, and nothing of it is read or changed. Parts that do not compile are not an error: the answer is 200 with valid false and the errors to fix.

```json
{"openapi":"3.0.1","info":{"title":"Synap API","version":"3.0.0"},"tags":[{"name":"Certificates","description":"Endpoints related to Certificates."}],"servers":[{"url":"https://api.synap.ac/v3","description":"Production"},{"url":"https://api-stage.synap.ac/v3","description":"Staging"}],"security":[{"SessionAuth":[]},{"PATAuth":[]},{"AutomationAuth":[]},{"LegacySessionAuth":[]}],"components":{"securitySchemes":{"SessionAuth":{"type":"http","scheme":"bearer","description":"Authorize the request using a Session Token.","bearerFormat":"r:<token>"},"PATAuth":{"type":"http","scheme":"bearer","description":"Authorise the request using a personal access token.","bearerFormat":"p:"},"AutomationAuth":{"type":"http","scheme":"bearer","description":"Authorise the request with a short-lived token signed by the automations engine on behalf of a workflow owner.","bearerFormat":"a:<token>"},"LegacySessionAuth":{"type":"apiKey","description":"[Legacy] Authorize the request using a Session Token.","in":"header","name":"X-Syn-Session-Token"}},"schemas":{"ObjectId":{"type":"string","description":"The primary key for each resource."},"TemplatePreview":{"type":"object","required":["id","type"],"properties":{"id":{"$ref":"#/components/schemas/ObjectId"},"type":{"type":"string","description":"Identifies the Resource.","enum":["TemplatePreview"]},"attributes":{"type":"object","additionalProperties":false,"required":["valid","errors"],"properties":{"valid":{"type":"boolean","description":"false when the parts did not compile. That is not a failure of the request: the errors say what to fix."},"errors":{"type":"array","items":{"type":"object","required":["pane","code","message"],"properties":{"pane":{"type":"string","description":"Where the problem is: html (the body), css, settings, or background (the page background)."},"line":{"type":"integer","description":"Starting at 1, within the source of that pane. 0 for settings. Left out for the background."},"column":{"type":"integer","description":"Starting at 1, within the source of that pane. 0 for settings. Left out for the background."},"code":{"type":"string","description":"A stable, machine readable code such as template.parse_error."},"message":{"type":"string"}}}},"pdf":{"type":"string","description":"The rendered PDF, base64 encoded. Only when valid."},"pageCount":{"type":"integer"},"engine":{"type":"string","description":"The renderer that produced the PDF."},"scenario":{"type":"string","enum":["standard","long-text","no-qr"]},"shellVersion":{"type":"integer","description":"The version of the Synap-owned shell it was compiled with."}}},"relationships":{"type":"object","properties":{}}}},"BadRequestApiError":{"type":"object","description":"The request was invalid.","properties":{"id":{"type":"string","description":"Unique ID of this error occurrence."},"status":{"type":"string","description":"HTTP status code."},"code":{"type":"string","description":"Synap internal error code."},"title":{"type":"string"},"detail":{"type":"string"},"source":{"type":"object","properties":{"pointer":{"type":"string"},"parameter":{"type":"string"}}}}},"UnauthorizedApiError":{"type":"object","description":"Unauthorized request.","properties":{"id":{"type":"string","description":"Unique ID of this error occurrence."},"status":{"type":"string","description":"HTTP status code."},"code":{"type":"string","description":"Synap internal error code."},"title":{"type":"string"},"detail":{"type":"string"},"source":{"type":"object","properties":{"pointer":{"type":"string"},"parameter":{"type":"string"}}}}},"ForbiddenApiError":{"type":"object","description":"Forbidden request.","properties":{"id":{"type":"string","description":"Unique ID of this error occurrence."},"status":{"type":"string","description":"HTTP status code."},"code":{"type":"string","description":"Synap internal error code."},"title":{"type":"string"},"detail":{"type":"string"},"source":{"type":"object","properties":{"pointer":{"type":"string"},"parameter":{"type":"string"}}}}},"NotFoundApiError":{"type":"object","description":"The request resource could not be found.","properties":{"id":{"type":"string","description":"Unique ID of this error occurrence."},"status":{"type":"string","description":"HTTP status code."},"code":{"type":"string","description":"Synap internal error code."},"title":{"type":"string"},"detail":{"type":"string"},"source":{"type":"object","properties":{"pointer":{"type":"string"},"parameter":{"type":"string"}}}}}}},"paths":{"/templates/{object_id}/preview":{"post":{"summary":"Preview a Template","description":"Renders unsaved parts to a PDF with sample data and the branding of the portal, and stores nothing. The requester must be an admin of the main portal and not of a sub-portal. The template has to be a managed template of the portal: it tells the usage the parts are rendered for and which images they may use, and nothing of it is read or changed. Parts that do not compile are not an error: the answer is 200 with valid false and the errors to fix.","tags":["Certificates"],"parameters":[{"name":"object_id","in":"path","required":true,"schema":{"$ref":"#/components/schemas/ObjectId"}}],"requestBody":{"required":true,"content":{"application/vnd.api+json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"object","required":["type","attributes"],"properties":{"type":{"type":"string","description":"Identifies the Resource.","enum":["TemplatePreview"]},"attributes":{"type":"object","additionalProperties":false,"required":["orientation","parts"],"properties":{"orientation":{"type":"string","enum":["landscape","portrait"]},"parts":{"type":"object","required":["body","css"],"additionalProperties":false,"description":"The editable parts of a managed certificate template. Publishing compiles them, inside a shell owned by Synap, into the complete document.","properties":{"body":{"type":"string","maxLength":200000,"description":"An HTML fragment that may contain Go template actions."},"css":{"type":"string","maxLength":200000,"description":"CSS, scoped to the content box when compiled."},"contentInset":{"type":"integer","minimum":0,"maximum":30,"default":10,"description":"Safe area inside the A4 sheet, in millimetres. Defaults to 10."},"background":{"type":"object","nullable":true,"required":["url","fit"],"additionalProperties":false,"description":"The image that fills the whole page behind the content. It can only be set here, as the style of the template cannot reach it. Null or left out for no background. The url has to be the address of an image uploaded to this template, and publishing or previewing refuses any address of another place.","properties":{"url":{"type":"string","minLength":1,"maxLength":2048,"description":"The url of an image uploaded to this template."},"fit":{"type":"string","enum":["cover","contain","stretch"],"description":"How the image fills the page. Cover scales it until it covers the page and crops what does not fit, contain scales it until all of it fits in the page, and stretch fills the page whatever the proportions of the image."}}}}},"scenario":{"type":"string","enum":["standard","long-text","no-qr"],"default":"standard","description":"The sample data to render with. long-text uses very long names and titles to expose overflow, and no-qr leaves out the QR code and the expiry."}}},"relationships":{"type":"object","properties":{}}}}}}}}},"responses":{"200":{"description":"Success","content":{"application/vnd.api+json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/TemplatePreview"}}}}}},"400":{"description":"Bad Request","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"$ref":"#/components/schemas/BadRequestApiError"}}}}}}},"401":{"description":"Unauthorized","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"$ref":"#/components/schemas/UnauthorizedApiError"}}}}}}},"403":{"description":"Forbidden: the requester is not an admin of the main portal, or the template is a legacy template.","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"$ref":"#/components/schemas/ForbiddenApiError"}}}}}}},"404":{"description":"Not Found: the template is not in the portal of the requester.","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"$ref":"#/components/schemas/NotFoundApiError"}}}}}}}},"operationId":"templates.previewTemplate"}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://synap.ac/docs/api/reference/certificates/preview-a-template.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
