# Thumbnails

## Get Thumbnails

**get** `/print-mail/v1/thumbnails`

Gets the thumbnails of up to 100 resources.

IDs that have no thumbnail yet, and IDs of resources that are deleted,
don't exist, or belong to another organization or mode, are left out of
`data` without an error. Poll until an ID appears with `status` of
`generated`.

This endpoint is limited to 10 requests per minute.

### Query Parameters

- `resources: array of string`

  The IDs of the resources to get thumbnails for,
  comma separated (e.g. `resources=template_abc,template_def`). At least 1
  and at most 100. Only template IDs are accepted for now.

### Returns

- `data: array of Thumbnail`

  The thumbnails of the requested resources that have one, in no
  particular order.

  - `id: string`

    The ID of the resource this thumbnail is for. Only templates have
    thumbnails for now.

  - `object: "thumbnail"`

    Always `thumbnail`.

    - `"thumbnail"`

  - `status: "generating" or "generated" or "failed"`

    The status of a thumbnail.

    - `"generating"`

    - `"generated"`

    - `"failed"`

  - `medium: optional string`

    A signed URL to an 800 pixel wide JPEG of the resource's first page,
    keeping the page's aspect ratio. The URL expires after 15 minutes, and
    each response returns a fresh one. Absent until the first render has
    been published.

- `object: "list"`

  Always `list`.

  - `"list"`

### Example

```http
curl https://api.postgrid.com/print-mail/v1/thumbnails \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY"
```

#### Response

```json
{
  "object": "list",
  "data": [
    {
      "id": "template_pxd7wnnD1xY6H6etKNvjb4",
      "object": "thumbnail",
      "status": "generated",
      "medium": "https://pg-prod-bucket-1.s3.amazonaws.com/thumbnails/org_123/test/template_pxd7wnnD1xY6H6etKNvjb4_medium.jpg?X-Amz-Expires=900&X-Amz-Signature=..."
    },
    {
      "id": "template_7mhJUt25TnagyYzy1N81SJ",
      "object": "thumbnail",
      "status": "generating"
    }
  ]
}
```

## Domain Types

### Thumbnail

- `Thumbnail object { id, object, status, medium }`

  A preview image of the first page of a resource.

  - `id: string`

    The ID of the resource this thumbnail is for. Only templates have
    thumbnails for now.

  - `object: "thumbnail"`

    Always `thumbnail`.

    - `"thumbnail"`

  - `status: "generating" or "generated" or "failed"`

    The status of a thumbnail.

    - `"generating"`

    - `"generated"`

    - `"failed"`

  - `medium: optional string`

    A signed URL to an 800 pixel wide JPEG of the resource's first page,
    keeping the page's aspect ratio. The URL expires after 15 minutes, and
    each response returns a fresh one. Absent until the first render has
    been published.

### Thumbnail Get Response

- `ThumbnailGetResponse object { data, object }`

  - `data: array of Thumbnail`

    The thumbnails of the requested resources that have one, in no
    particular order.

    - `id: string`

      The ID of the resource this thumbnail is for. Only templates have
      thumbnails for now.

    - `object: "thumbnail"`

      Always `thumbnail`.

      - `"thumbnail"`

    - `status: "generating" or "generated" or "failed"`

      The status of a thumbnail.

      - `"generating"`

      - `"generated"`

      - `"failed"`

    - `medium: optional string`

      A signed URL to an 800 pixel wide JPEG of the resource's first page,
      keeping the page's aspect ratio. The URL expires after 15 minutes, and
      each response returns a fresh one. Absent until the first render has
      been published.

  - `object: "list"`

    Always `list`.

    - `"list"`
