postsale templates
Manage label, packing-slip, invoice and email templates as records: list, copy, move and back them up; author them in the app with the Liquid guide.
Templates are the documents Postsale prints or sends for an order or a shipment: shipping labels, packing slips, invoices, and emails. Each one is a Liquid document, the same templating language the web app's editor uses, stored with its settings as a template record. The CLI manages those records: it lists, reads, creates, updates, moves, and deletes them, and it manages the folders they live in.
Authoring a template is still best done in the web app, where the visual editor previews the result against real orders. Use the CLI to back templates up, copy or rename them, move them between folders, and push a template you have already proven in the editor to another account or folder.
Note
Template commands need a login session. On an API key they answer api_key_unsupported (exit 100), whatever the key's permissions are.
Before you author a template
The help center already teaches how to build one. Read these first, in the web app's terms:
- Templates: Liquid Reference Guide: every variable and filter you can use in a template
- Advanced Editing of Templates: editing the Liquid source directly
- Personalize Your Templates
- The Default Postsale Templates: the built-in templates you can copy from
- Organize Your Templates: folders, which the CLI also manages
- Upload and Manage Template Images and Add or Replace Logos
Subcommands
| Command | Safety | Notes |
|---|---|---|
list / get <id> | read | get returns the full record, including the Liquid source in data |
create / update <id> | write | --input <file> or --json <body>; the body fields are below |
move <id> | write | --folder-id <folder_id> |
delete <id> | destructive | requires --yes; see Restore Templates for what can be recovered in the app |
folders list/create/update/delete | delete is destructive | folders group templates in the app's template list |
postsale templates list
postsale templates get <id>
postsale templates folders list
postsale templates move <id> --folder-id <folder_id>
postsale templates delete <id> --yesWhat a template body contains
create and update take the same JSON body the API does. These are the fields, from the CLI's schema (postsale schema templates.create); the three marked required must be present on create.
| Field | Required | Meaning |
|---|---|---|
name | yes | The name shown in the app |
description | yes | A short description shown with the name |
data | yes | The template itself: the Liquid document |
file_type | What the template renders to: html, pdf, csv, txt, or json | |
output_per | One document per order or per shipment | |
dimensions | Page size for printed documents | |
margin | Page margins for printed documents | |
folder | The folder the template lives in (move changes it too) | |
built_in_id | Which built-in template this one was copied from | |
sync_with_built_in | Keep following the built-in's updates instead of your own edits | |
disabled | Hide the template from use without deleting it |
The CLI sends the body as you give it. It does not check the Liquid, so a template that never rendered in the app's editor has never been proven; preview it there before you rely on it.
Copy a template with the CLI
Here's how to duplicate a template you have already tested, for example into another folder:
- Read the original and save it:
postsale templates get <id> > template.json-
Edit
template.json: changename, dropid,created_at, andupdated_at, and keepdataas it is. -
Create the copy:
postsale templates create --input template.jsonSuccess looks like a new template with its own id and the same data, visible in the app's template list.
Schema
templates.* and templates.folders.* (see schema slugs)
Agent tools
list_templates, get_template, update_template, delete_template
Additional Reading
- Templates: Printing and Saving
- Configuration: where templates sit among the other settings
- Sign In and Credentials: why templates need a login session
On this page
Related