Skip to content
Get startedDashboardSupport
Print & Mail
API

Thumbnails

Get preview images of the first page of your resources through the Print & Mail API, generated automatically whenever a resource is saved.

A thumbnail is a JPEG preview of the first page of a resource, so you can show your users what it looks like without rendering it yourself. PostGrid generates thumbnails automatically.

Note: Thumbnails are in early access and must be enabled for your organization. Contact [email protected] to request access. Until they are enabled, requests return a template_thumbnails_disabled_error.

Thumbnails are currently generated for templates only, so resources and id take template IDs (template_...). Other resources will be added to the same endpoint and object.


Once thumbnails are enabled for your organization, PostGrid checks every minute for resources that need a new thumbnail:

  • Existing resources all get a thumbnail on the first check after the feature is enabled. For an organization with many resources this backfill can take several minutes.
  • New and updated resources get a new thumbnail within about a minute of being created or saved. A resource saved several times within a minute is rendered once.
  • Archived and deleted resources are not rendered. Deleting a resource removes its thumbnail.

Resources are rendered in both live and test mode.

  • The first page of the resource.
  • An image 800 pixels wide. The height follows the page’s aspect ratio, so a US Letter page is 800 x 1035 pixels.
  • The design only. No merge variables are filled in, so placeholders such as {{to.firstName}} appear as written.

Because merge variables are left empty, anything whose URL depends on one won’t load. For example, an image with src="https://cdn.example.com/{{logo}}.png" shows as a missing image, and a stylesheet or font loaded from such a URL falls back to the default styling. The rest of the thumbnail is still generated, and orders created from the resource are not affected.


To use the Thumbnails API, you will need your PostGrid API key. You can find your API key on your PostGrid dashboard settings page.

Requests are made to:

https://api.postgrid.com/print-mail/v1/thumbnails

Authenticate by passing your API key in the x-api-key header.

Thumbnails are scoped to the mode of your API key: a test-mode key only returns thumbnails of test-mode resources, and a live-mode key only returns thumbnails of live-mode resources.


FieldTypeDescription
idstringThe ID of the resource this thumbnail is for. See Supported Resources.
objectstringAlways thumbnail.
statusstringThe status of the latest render: generating, generated, or failed. See Statuses below.
mediumstringOptional. A signed, temporary URL to the JPEG. Absent until the resource’s first render has finished. The link expires after 15 minutes — see Image URLs.
StatusMeaning
generatingA render is queued or running. If the resource had a thumbnail before, medium still points to the previous image until the new one is ready.
generatedThe latest version of the resource has been rendered and medium points to it.
failedThe latest render failed. It is not retried until the resource is saved again. If an earlier render succeeded, medium still points to that image, which may be out of date.

Send a GET request to /thumbnails with the IDs of up to 100 resources in the resources query parameter, separated by commas. See the API Reference for the full request and response schema.

Terminal window
curl "https://api.postgrid.com/print-mail/v1/thumbnails?resources=template_pxd7wnnD1xY6H6etKNvjb4,template_7mhJUt25TnagyYzy1N81SJ" \
-H "x-api-key: <your-api-key>"
ParameterTypeDescription
resourcesstringRequired. Between 1 and 100 resource IDs, separated by commas. Spaces and empty items are ignored. The array forms (resources[]=...) are not accepted. See Supported Resources.
{
"object": "list",
"data": [
{
"id": "template_pxd7wnnD1xY6H6etKNvjb4",
"object": "thumbnail",
"status": "generated",
"medium": "https://pg-prod-bucket-1.s3.amazonaws.com/thumbnails/...medium.jpg?X-Amz-Expires=900&X-Amz-Signature=..."
},
{
"id": "template_7mhJUt25TnagyYzy1N81SJ",
"object": "thumbnail",
"status": "generating"
}
]
}

data holds the thumbnails of the requested resources that have one, in no particular order, so match them to your resources by id. An ID is left out of data, without an error, when:

  • the resource doesn’t have a thumbnail yet (for example, it was created less than a minute ago), or
  • the resource is deleted, doesn’t exist, or belongs to another organization or mode.

This endpoint isn’t paginated: the response has no skip, limit or totalCount, and every thumbnail found is returned at once.


medium is a signed URL that expires 15 minutes after the request. Each response returns a fresh URL.


This endpoint is limited to 10 requests per minute. Requests above the limit return a 429 with a rate_limit_exceeded_error.

To stay within the limit:

  • Request the thumbnails for a whole page of resources (up to 100) in one call, instead of one call per resource.
  • After saving a resource, wait about a minute before checking for its new thumbnail, then poll no more than every 10–15 seconds until its status is generated or failed.

StatusTypeWhen
400validation_errorresources is missing, has more than 100 IDs, uses the array form, or contains an ID of a resource that isn’t supported yet.
401missing_auth_errorThe API key is missing or invalid.
403template_thumbnails_disabled_errorThumbnails are not enabled for your organization. Contact [email protected].
403permission_missing_errorThe API key’s user doesn’t have the thumbnails:read permission.
429rate_limit_exceeded_errorMore than 10 requests in a minute. See Rate Limits and Polling.

See Errors for the shape of error responses.