# Template Editor Sessions

## Create Session

`print_mail.template_editor_sessions.create(TemplateEditorSessionCreateParams**kwargs)  -> TemplateEditorSessionCreateResponse`

**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.

### Parameters

- `template: str`

  ID of the underlying template that this edits.

- `back_url: Optional[str]`

  The URL supplied when this editor session was created.

- `styles: Optional[Styles]`

  Style overrides for the template editor session.

  - `canvas: Optional[StylesCanvas]`

    Style overrides for the template editor canvas.

    - `background_color: Optional[str]`

      The canvas background color.

  - `panel_text: Optional[StylesPanelText]`

    Style overrides for template editor panel text.

    - `color: Optional[str]`

      The panel text color.

  - `save_button: Optional[StylesSaveButton]`

    Style overrides for the template editor save button.

    - `background_color: Optional[str]`

      The save button background color.

    - `text_color: Optional[str]`

      The save button text color.

- `title: Optional[str]`

  The title supplied when this editor session was created.

- `trackers: Optional[Union[Literal["all", "none"], Sequence[str]]]`

  Controls which Trackers are displayed in the template editor session.

  - `Literal["all", "none"]`

    - `"all"`

    - `"none"`

  - `Sequence[str]`

### Returns

- `class TemplateEditorSessionCreateResponse: …`

  - `id: str`

    A unique ID prefixed with `template_editor_session_`.

  - `created_at: datetime`

    The UTC time at which this session was created.

  - `live: bool`

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

  - `object: Literal["template_editor_session"]`

    Always `template_editor_session`.

    - `"template_editor_session"`

  - `template: str`

    ID of the underlying template that this edits.

  - `url: str`

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

  - `back_url: Optional[str]`

    The URL supplied when this editor session was created.

  - `styles: Optional[Styles]`

    Style overrides for the template editor session.

    - `canvas: Optional[StylesCanvas]`

      Style overrides for the template editor canvas.

      - `background_color: Optional[str]`

        The canvas background color.

    - `panel_text: Optional[StylesPanelText]`

      Style overrides for template editor panel text.

      - `color: Optional[str]`

        The panel text color.

    - `save_button: Optional[StylesSaveButton]`

      Style overrides for the template editor save button.

      - `background_color: Optional[str]`

        The save button background color.

      - `text_color: Optional[str]`

        The save button text color.

  - `title: Optional[str]`

    The title supplied when this editor session was created.

  - `trackers: Optional[Union[Literal["all", "none"], List[str], null]]`

    Controls which Trackers are displayed in the template editor session.

    - `Literal["all", "none"]`

      - `"all"`

      - `"none"`

    - `List[str]`

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
template_editor_session = client.print_mail.template_editor_sessions.create(
    template="template_eYxcbMKPZEZPk71ZJPA6Yz",
    back_url="https://postgrid.com",
    title="My Editor Session",
    trackers=["tracker_123456789abcdefghijklmnopqrstuvwxyz"],
)
print(template_editor_session.id)
```

#### 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

`print_mail.template_editor_sessions.list(TemplateEditorSessionListParams**kwargs)  -> SyncSkipLimit[TemplateEditorSessionListResponse]`

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

Retrieve a paginated list of Template Editor Sessions.

### Parameters

- `limit: Optional[int]`

- `search: Optional[str]`

  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[int]`

### Returns

- `class TemplateEditorSessionListResponse: …`

  - `id: str`

    A unique ID prefixed with `template_editor_session_`.

  - `created_at: datetime`

    The UTC time at which this session was created.

  - `live: bool`

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

  - `object: Literal["template_editor_session"]`

    Always `template_editor_session`.

    - `"template_editor_session"`

  - `template: str`

    ID of the underlying template that this edits.

  - `url: str`

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

  - `back_url: Optional[str]`

    The URL supplied when this editor session was created.

  - `styles: Optional[Styles]`

    Style overrides for the template editor session.

    - `canvas: Optional[StylesCanvas]`

      Style overrides for the template editor canvas.

      - `background_color: Optional[str]`

        The canvas background color.

    - `panel_text: Optional[StylesPanelText]`

      Style overrides for template editor panel text.

      - `color: Optional[str]`

        The panel text color.

    - `save_button: Optional[StylesSaveButton]`

      Style overrides for the template editor save button.

      - `background_color: Optional[str]`

        The save button background color.

      - `text_color: Optional[str]`

        The save button text color.

  - `title: Optional[str]`

    The title supplied when this editor session was created.

  - `trackers: Optional[Union[Literal["all", "none"], List[str], null]]`

    Controls which Trackers are displayed in the template editor session.

    - `Literal["all", "none"]`

      - `"all"`

      - `"none"`

    - `List[str]`

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
page = client.print_mail.template_editor_sessions.list()
page = page.data[0]
print(page.id)
```

#### 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

`print_mail.template_editor_sessions.delete(strid)  -> TemplateEditorSessionDeleteResponse`

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

Delete a Template Editor Session by ID.

### Parameters

- `id: str`

### Returns

- `class TemplateEditorSessionDeleteResponse: …`

  - `id: str`

    A unique ID prefixed with `template_editor_session_`.

  - `deleted: Literal[true]`

    - `true`

  - `object: Literal["template_editor_session"]`

    Always `template_editor_session`.

    - `"template_editor_session"`

### Example

```python
import os
from postgrid import PostGrid

client = PostGrid(
    print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"),  # This is the default and can be omitted
)
template_editor_session = client.print_mail.template_editor_sessions.delete(
    "id",
)
print(template_editor_session.id)
```

#### Response

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

## Domain Types

### Template Editor Session Create Response

- `class TemplateEditorSessionCreateResponse: …`

  - `id: str`

    A unique ID prefixed with `template_editor_session_`.

  - `created_at: datetime`

    The UTC time at which this session was created.

  - `live: bool`

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

  - `object: Literal["template_editor_session"]`

    Always `template_editor_session`.

    - `"template_editor_session"`

  - `template: str`

    ID of the underlying template that this edits.

  - `url: str`

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

  - `back_url: Optional[str]`

    The URL supplied when this editor session was created.

  - `styles: Optional[Styles]`

    Style overrides for the template editor session.

    - `canvas: Optional[StylesCanvas]`

      Style overrides for the template editor canvas.

      - `background_color: Optional[str]`

        The canvas background color.

    - `panel_text: Optional[StylesPanelText]`

      Style overrides for template editor panel text.

      - `color: Optional[str]`

        The panel text color.

    - `save_button: Optional[StylesSaveButton]`

      Style overrides for the template editor save button.

      - `background_color: Optional[str]`

        The save button background color.

      - `text_color: Optional[str]`

        The save button text color.

  - `title: Optional[str]`

    The title supplied when this editor session was created.

  - `trackers: Optional[Union[Literal["all", "none"], List[str], null]]`

    Controls which Trackers are displayed in the template editor session.

    - `Literal["all", "none"]`

      - `"all"`

      - `"none"`

    - `List[str]`

### Template Editor Session List Response

- `class TemplateEditorSessionListResponse: …`

  - `id: str`

    A unique ID prefixed with `template_editor_session_`.

  - `created_at: datetime`

    The UTC time at which this session was created.

  - `live: bool`

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

  - `object: Literal["template_editor_session"]`

    Always `template_editor_session`.

    - `"template_editor_session"`

  - `template: str`

    ID of the underlying template that this edits.

  - `url: str`

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

  - `back_url: Optional[str]`

    The URL supplied when this editor session was created.

  - `styles: Optional[Styles]`

    Style overrides for the template editor session.

    - `canvas: Optional[StylesCanvas]`

      Style overrides for the template editor canvas.

      - `background_color: Optional[str]`

        The canvas background color.

    - `panel_text: Optional[StylesPanelText]`

      Style overrides for template editor panel text.

      - `color: Optional[str]`

        The panel text color.

    - `save_button: Optional[StylesSaveButton]`

      Style overrides for the template editor save button.

      - `background_color: Optional[str]`

        The save button background color.

      - `text_color: Optional[str]`

        The save button text color.

  - `title: Optional[str]`

    The title supplied when this editor session was created.

  - `trackers: Optional[Union[Literal["all", "none"], List[str], null]]`

    Controls which Trackers are displayed in the template editor session.

    - `Literal["all", "none"]`

      - `"all"`

      - `"none"`

    - `List[str]`

### Template Editor Session Delete Response

- `class TemplateEditorSessionDeleteResponse: …`

  - `id: str`

    A unique ID prefixed with `template_editor_session_`.

  - `deleted: Literal[true]`

    - `true`

  - `object: Literal["template_editor_session"]`

    Always `template_editor_session`.

    - `"template_editor_session"`
