PDF4.dev
Templates
PUT
/api/v1/templates/{id}

Authorization

AuthorizationRequiredBearer <token>

API key from Settings page. Keys start with p4_live_ prefix.

In: header

Request Body

application/jsonRequired
namestring
htmlstring
plain_textstring
pdf_formatobject

Page format configuration. If omitted, defaults to A4 portrait with 20mm top/bottom and 15mm left/right margins.

sample_dataobject
header_component_idstring

Header component ID or null to remove

footer_component_idstring

Footer component ID or null to remove

Path Parameters

idRequiredstring

Template ID (tmpl_xxx) or slug (e.g. monthly-invoice)

curl -X PUT "https://docs.pdf4.dev/api/proxy/api/v1/templates/<string>" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Updated Invoice #{{number}}</h1>",
    "sample_data": {
      "number": "INV-002"
    }
  }'

Template updated

{
  "id": "tmpl_a1b2c3d4e5f6",
  "name": "Invoice",
  "slug": "invoice",
  "html": "string",
  "plain_text": "string",
  "pdf_format": {
    "preset": "a4",
    "width": "210mm",
    "height": "297mm",
    "margins": {
      "top": "20mm",
      "bottom": "20mm",
      "left": "15mm",
      "right": "15mm"
    },
    "background_color": "#ffffff",
    "font_family": "Inter, sans-serif",
    "font_size": "14px",
    "text_align": "left",
    "horizontal_align": "left",
    "vertical_align": "top",
    "google_fonts_url": "https://fonts.googleapis.com/css2?family=Roboto&display=swap",
    "color": "#333333",
    "line_height": "1.5",
    "component_gap": "5mm",
    "footer_position": "after-content"
  },
  "sample_data": {},
  "header_component_id": "string",
  "footer_component_id": "string",
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z"
}