# List templates (/api-reference/templates/listTemplates)

`GET /templates`

Base URL: `https://next-api.useplunk.com`

Get a paginated list of email templates.

This endpoint uses **offset pagination** (`page` / `pageSize`), not the cursor pagination used by `GET /contacts`.

## Query parameters

- `page`: integer — 1-based page number.
- `pageSize`: integer — Items per page.
- `type`: enum ("TRANSACTIONAL" | "MARKETING" | "HEADLESS") — Filter by template type.
- `search`: string — Case-insensitive match on name, description, or subject.
- `sort`: enum ("name" | "createdAt" | "updatedAt") — Column to sort by. Unrecognised values fall back to `createdAt`.
- `dir`: enum ("asc" | "desc") — Sort direction. Unrecognised values fall back to the default.

## Responses

### `200` — List of templates

- `data`: array<object>
  items:
    - `id`: string
    - `name`: string
    - `description`: string
    - `subject`: string
    - `body`: string — HTML content with `{{variable}}` placeholders.
    - `from`: string (email) — Sender address. Must belong to a verified domain.
    - `fromName`: string
    - `replyTo`: string (email)
    - `type`: enum ("TRANSACTIONAL" | "MARKETING" | "HEADLESS")
    - `projectId`: string
    - `createdAt`: string (date-time)
    - `updatedAt`: string (date-time)
- `total`: integer — Total templates matching the filters, across all pages.
- `page`: integer
- `pageSize`: integer
- `totalPages`: integer

```json
{
  "data": [
    {
      "id": "string",
      "name": "string",
      "description": "string",
      "subject": "string",
      "body": "string",
      "from": "user@example.com",
      "fromName": "string",
      "replyTo": "user@example.com",
      "type": "TRANSACTIONAL",
      "projectId": "string",
      "createdAt": "2026-08-09T17:56:20.171Z",
      "updatedAt": "2026-08-09T17:56:20.171Z"
    }
  ],
  "total": 0,
  "page": 0,
  "pageSize": 0,
  "totalPages": 0
}
```

### `401` — Missing or invalid API key.

- `success`: enum (false)
- `error`: object
  - `code`: string — Machine-readable error code, e.g. `VALIDATION_ERROR`, `INVALID_API_KEY`, `IDEMPOTENCY_KEY_REUSED`.
  - `message`: string
  - `statusCode`: integer
  - `requestId`: string — Correlation ID for this request. Include it when contacting support.
  - `errors`: array<object> — Field-level detail, present on validation failures.
    items:
      - `field`: string — Dot-path of the offending field, e.g. `attachments.0.filename`.
      - `message`: string
      - `code`: string — Validation issue code, e.g. `invalid_type`, `too_big`, `reserved_event`.
      - `received`: object — The value that was received, when available.
  - `details`: object — Additional error context.
  - `suggestion`: string — Hint for fixing the request.
- `timestamp`: string (date-time)

```json
{
  "success": false,
  "error": {
    "code": "string",
    "message": "string",
    "statusCode": 0,
    "requestId": "string",
    "errors": [
      {
        "field": "string",
        "message": "string",
        "code": "string",
        "received": null
      }
    ],
    "details": null,
    "suggestion": "string"
  },
  "timestamp": "2026-08-09T17:56:20.171Z"
}
```

## Example request

```bash
curl -X GET 'https://next-api.useplunk.com/templates' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```
