文档

模板

获取模板

GET/templates/{id}

一个模板:其已保存版本的 Markdown,占位符为空处显示 {{标签}} 标记,以及用于构建表单或字段映射的占位符清单,每一项都带有要发送的键和要显示的标签。

参数

名称类型说明
id必填uuid模板的 ID。

请求

curl https://usepaperclerk.com/api/v1/templates/4d1f0c2e-7b3a-4c1e-9d2f-1a2b3c4d5e6f \
  -H "Authorization: Bearer pc_YOUR_TOKEN"

响应

JSON
{
  "id": "4d1f0c2e-7b3a-4c1e-9d2f-1a2b3c4d5e6f",
  "title": "Consulting invoice",
  "markdown": "# Consulting invoice\n\nInvoice {{Invoice number}} for {{Client name}} …",
  "html": "<div class=\"doc-page\" …>…</div>",
  "html_truncated": false,
  "placeholders": [
    {
      "label": "Client name",
      "key": "client_name",
      "count": 2,
      "value": "",
      "type": "text",
      "description": "The client's legal name, not the contact person."
    },
    {
      "label": "Payment terms",
      "key": "payment_terms",
      "count": 1,
      "value": "Net 30",
      "type": "select",
      "options": [
        "Net 15",
        "Net 30",
        "Due on receipt"
      ]
    },
    {
      "label": "Due date",
      "key": "due_date",
      "count": 1,
      "value": "",
      "type": "date",
      "format": "08/27/2026"
    },
    {
      "label": "Invoice number",
      "key": "invoice_number",
      "count": 1,
      "value": "",
      "type": "counter",
      "auto": true,
      "format": "INV-0001",
      "start": 1
    },
    {
      "label": "Issue date",
      "key": "issue_date",
      "count": 1,
      "value": "",
      "type": "today",
      "auto": true,
      "format": "August 27, 2026"
    }
  ],
  "groups": [
    {
      "label": "Line items",
      "key": "line_items",
      "fields": [
        {
          "label": "Item",
          "key": "item",
          "type": "text"
        },
        {
          "label": "Quantity",
          "key": "quantity",
          "type": "number",
          "format": "1,234"
        },
        {
          "label": "Amount",
          "key": "amount",
          "type": "number",
          "format": "1,234.56"
        }
      ]
    }
  ],
  "generation_count": 12,
  "updated_at": "2026-09-10T09:14:03.201Z"
}
  • markdown — 已保存的版本。空占位符显示为 {{标签}}。
  • html — 已保存版本的纸面级 HTML 预览;html_truncated 表示是否因大小被截断。
  • placeholders — 顶层占位符,每个占位符一项:key(values 所用的键)、label(可读名称)、count(填充的位置数)、value(默认值)、type(text、select、number、date、today 或 counter),以及在设置时的 options、format、description、auto 和 start。
  • groups — 重复组:key、label 和 fields,其中 fields 精确列出实例对象可携带的键,每个键的形状与占位符相同,并附带默认值。
  • generation_count — 从该模板生成的文档数量。