# Template Editor Sessions

## Create Session

**post** `/print-mail/v1/template_editor_sessions`

Create a Template Editor Session.

Note that if no `backURL` is supplied, PostGrid removes the Back button
from the editor page. This is ideal for when you `iframe` the editor.

### Body Parameters

- `template: string`

  ID of the underlying template that this edits.

- `backURL: optional string`

  The URL supplied when this editor session was created.

- `styles: optional object { canvas, panelText, saveButton }`

  Style overrides for the template editor session.

  - `canvas: optional object { backgroundColor }`

    Style overrides for the template editor canvas.

    - `backgroundColor: optional string`

      The canvas background color.

  - `panelText: optional object { color }`

    Style overrides for template editor panel text.

    - `color: optional string`

      The panel text color.

  - `saveButton: optional object { backgroundColor, textColor }`

    Style overrides for the template editor save button.

    - `backgroundColor: optional string`

      The save button background color.

    - `textColor: optional string`

      The save button text color.

- `title: optional string`

  The title supplied when this editor session was created.

- `trackers: optional "all" or "none" or array of string`

  Controls which Trackers are displayed in the template editor session.

  - `"all" or "none"`

    - `"all"`

    - `"none"`

  - `array of string`

### Returns

- `id: string`

  A unique ID prefixed with `template_editor_session_`.

- `createdAt: string`

  The UTC time at which this session was created.

- `live: boolean`

  `true` if this is a live mode session else `false`.

- `object: "template_editor_session"`

  Always `template_editor_session`.

  - `"template_editor_session"`

- `template: string`

  ID of the underlying template that this edits.

- `url: string`

  A URL that can be iframed or redirected to for editing the template.

- `backURL: optional string`

  The URL supplied when this editor session was created.

- `styles: optional object { canvas, panelText, saveButton }`

  Style overrides for the template editor session.

  - `canvas: optional object { backgroundColor }`

    Style overrides for the template editor canvas.

    - `backgroundColor: optional string`

      The canvas background color.

  - `panelText: optional object { color }`

    Style overrides for template editor panel text.

    - `color: optional string`

      The panel text color.

  - `saveButton: optional object { backgroundColor, textColor }`

    Style overrides for the template editor save button.

    - `backgroundColor: optional string`

      The save button background color.

    - `textColor: optional string`

      The save button text color.

- `title: optional string`

  The title supplied when this editor session was created.

- `trackers: optional "all" or "none" or array of string`

  Controls which Trackers are displayed in the template editor session.

  - `"all" or "none"`

    - `"all"`

    - `"none"`

  - `array of string`

### Example

```http
curl https://api.postgrid.com/print-mail/v1/template_editor_sessions \
    -H 'Content-Type: application/json' \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY" \
    -d '{
          "template": "template_eYxcbMKPZEZPk71ZJPA6Yz"
        }'
```

#### Response

```json
{
  "id": "template_editor_session_bBYRQ5DKu3LJ5yNemoAQ7E3or6E7Yzd7FGNWJSXBRrAfcdoNXNGLvfZxAm2dJYiv9c",
  "object": "template_editor_session",
  "live": false,
  "template": "template_eYxcbMKPZEZPk71ZJPA6Yz",
  "backURL": "https://postgrid.com",
  "title": "My Editor Session",
  "trackers": [
    "tracker_123456789abcdefghijklmnopqrstuvwxyz"
  ],
  "url": "https://dashboard.postgrid.com/embed/template_editor_sessions/template_editor_session_bBYRQ5DKu3LJ5yNemoAQ7E3or6E7Yzd7FGNWJSXBRrAfcdoNXNGLvfZxAm2dJYiv9c",
  "createdAt": "2023-07-05T19:36:01.369Z"
}
```

## List Sessions

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

Retrieve a paginated list of Template Editor Sessions.

### Query Parameters

- `limit: optional number`

- `search: optional string`

  You can supply any string to help narrow down the list of resources. For example, if you pass `"New York"` (quoted), it will return resources that have that string present somewhere in their response. Alternatively, you can supply a structured search query. See the documentation on `StructuredSearchQuery` for more details.

- `skip: optional number`

### Returns

- `data: array of object { id, createdAt, live, 7 more }`

  - `id: string`

    A unique ID prefixed with `template_editor_session_`.

  - `createdAt: string`

    The UTC time at which this session was created.

  - `live: boolean`

    `true` if this is a live mode session else `false`.

  - `object: "template_editor_session"`

    Always `template_editor_session`.

    - `"template_editor_session"`

  - `template: string`

    ID of the underlying template that this edits.

  - `url: string`

    A URL that can be iframed or redirected to for editing the template.

  - `backURL: optional string`

    The URL supplied when this editor session was created.

  - `styles: optional object { canvas, panelText, saveButton }`

    Style overrides for the template editor session.

    - `canvas: optional object { backgroundColor }`

      Style overrides for the template editor canvas.

      - `backgroundColor: optional string`

        The canvas background color.

    - `panelText: optional object { color }`

      Style overrides for template editor panel text.

      - `color: optional string`

        The panel text color.

    - `saveButton: optional object { backgroundColor, textColor }`

      Style overrides for the template editor save button.

      - `backgroundColor: optional string`

        The save button background color.

      - `textColor: optional string`

        The save button text color.

  - `title: optional string`

    The title supplied when this editor session was created.

  - `trackers: optional "all" or "none" or array of string`

    Controls which Trackers are displayed in the template editor session.

    - `"all" or "none"`

      - `"all"`

      - `"none"`

    - `array of string`

- `limit: number`

- `object: "list"`

  - `"list"`

- `skip: number`

- `totalCount: number`

### Example

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

#### Response

```json
{
  "object": "list",
  "limit": 10,
  "skip": 0,
  "totalCount": 1,
  "data": [
    {
      "id": "template_editor_session_bBYRQ5DKu3LJ5yNemoAQ7E3or6E7Yzd7FGNWJSXBRrAfcdoNXNGLvfZxAm2dJYiv9c",
      "object": "template_editor_session",
      "live": false,
      "template": "template_eYxcbMKPZEZPk71ZJPA6Yz",
      "backURL": "https://postgrid.com",
      "title": "My Editor Session",
      "trackers": "none",
      "url": "https://dashboard.postgrid.com/embed/template_editor_sessions/template_editor_session_bBYRQ5DKu3LJ5yNemoAQ7E3or6E7Yzd7FGNWJSXBRrAfcdoNXNGLvfZxAm2dJYiv9c",
      "createdAt": "2023-07-05T19:36:01.369Z"
    }
  ]
}
```

## Delete Session

**delete** `/print-mail/v1/template_editor_sessions/{id}`

Delete a Template Editor Session by ID.

### Path Parameters

- `id: string`

### Returns

- `id: string`

  A unique ID prefixed with `template_editor_session_`.

- `deleted: true`

  - `true`

- `object: "template_editor_session"`

  Always `template_editor_session`.

  - `"template_editor_session"`

### Example

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

#### Response

```json
{
  "id": "template_editor_session_vmb3aXRJFzHb4oNRP2XMUZiTTBDtC91CSgQeqUrQfhSqq5P9wAGpmX5UkftueTubMN",
  "object": "template_editor_session",
  "deleted": true
}
```

## Domain Types

### Template Editor Session Create Response

- `TemplateEditorSessionCreateResponse object { id, createdAt, live, 7 more }`

  - `id: string`

    A unique ID prefixed with `template_editor_session_`.

  - `createdAt: string`

    The UTC time at which this session was created.

  - `live: boolean`

    `true` if this is a live mode session else `false`.

  - `object: "template_editor_session"`

    Always `template_editor_session`.

    - `"template_editor_session"`

  - `template: string`

    ID of the underlying template that this edits.

  - `url: string`

    A URL that can be iframed or redirected to for editing the template.

  - `backURL: optional string`

    The URL supplied when this editor session was created.

  - `styles: optional object { canvas, panelText, saveButton }`

    Style overrides for the template editor session.

    - `canvas: optional object { backgroundColor }`

      Style overrides for the template editor canvas.

      - `backgroundColor: optional string`

        The canvas background color.

    - `panelText: optional object { color }`

      Style overrides for template editor panel text.

      - `color: optional string`

        The panel text color.

    - `saveButton: optional object { backgroundColor, textColor }`

      Style overrides for the template editor save button.

      - `backgroundColor: optional string`

        The save button background color.

      - `textColor: optional string`

        The save button text color.

  - `title: optional string`

    The title supplied when this editor session was created.

  - `trackers: optional "all" or "none" or array of string`

    Controls which Trackers are displayed in the template editor session.

    - `"all" or "none"`

      - `"all"`

      - `"none"`

    - `array of string`

### Template Editor Session List Response

- `TemplateEditorSessionListResponse object { id, createdAt, live, 7 more }`

  - `id: string`

    A unique ID prefixed with `template_editor_session_`.

  - `createdAt: string`

    The UTC time at which this session was created.

  - `live: boolean`

    `true` if this is a live mode session else `false`.

  - `object: "template_editor_session"`

    Always `template_editor_session`.

    - `"template_editor_session"`

  - `template: string`

    ID of the underlying template that this edits.

  - `url: string`

    A URL that can be iframed or redirected to for editing the template.

  - `backURL: optional string`

    The URL supplied when this editor session was created.

  - `styles: optional object { canvas, panelText, saveButton }`

    Style overrides for the template editor session.

    - `canvas: optional object { backgroundColor }`

      Style overrides for the template editor canvas.

      - `backgroundColor: optional string`

        The canvas background color.

    - `panelText: optional object { color }`

      Style overrides for template editor panel text.

      - `color: optional string`

        The panel text color.

    - `saveButton: optional object { backgroundColor, textColor }`

      Style overrides for the template editor save button.

      - `backgroundColor: optional string`

        The save button background color.

      - `textColor: optional string`

        The save button text color.

  - `title: optional string`

    The title supplied when this editor session was created.

  - `trackers: optional "all" or "none" or array of string`

    Controls which Trackers are displayed in the template editor session.

    - `"all" or "none"`

      - `"all"`

      - `"none"`

    - `array of string`

### Template Editor Session Delete Response

- `TemplateEditorSessionDeleteResponse object { id, deleted, object }`

  - `id: string`

    A unique ID prefixed with `template_editor_session_`.

  - `deleted: true`

    - `true`

  - `object: "template_editor_session"`

    Always `template_editor_session`.

    - `"template_editor_session"`
