Skip to content

Label Templates

albert.resources.label_templates

LabelTemplateType

Bases: str, Enum

The type of a label template, describing what it renders.

Attributes:

Name Type Description
BATCH str

Product/Formula lot labels.

PROPERTY str

Property task labels.

INVENTORY str

Inventory lot labels.

BATCH_LABEL str

Batch task labels.

FORMULA_REPORT str

Product/Formula reports.

BATCH_TEMPLATE str

Batch task templates.

PROPERTY_TASK_REPORT str

Property task reports.

GENERAL_TASK_LABEL str

General task labels.

BATCH

BATCH = 'batch'

PROPERTY

PROPERTY = 'property'

INVENTORY

INVENTORY = 'inventory'

BATCH_LABEL

BATCH_LABEL = 'batchlabel'

FORMULA_REPORT

FORMULA_REPORT = 'formulareport'

BATCH_TEMPLATE

BATCH_TEMPLATE = 'batchtemplate'

PROPERTY_TASK_REPORT

PROPERTY_TASK_REPORT = 'propertytaskreport'

GENERAL_TASK_LABEL

GENERAL_TASK_LABEL = 'generaltasklabel'

LabelTemplate

Bases: BaseResource

A label template in the Albert platform.

A label template pairs a tenant-scoped HTML file with page rendering options. The HTML file is an ordinary HTML document containing Mustache placeholders (e.g. {{info.inventoryName}}) that are filled at render time from the print payload for the template's type: the payload's data["labels"] list holds one entry per printed entity, and each entry's fields are read under info. Templates drive the printable outputs in Albert, such as inventory lot barcode labels, batch task labels, and formula reports. Label Template IDs use the TMP prefix.

See LabelTemplateCollection for creating, retrieving, and rendering label templates.

Show JSON schema:
{
  "$defs": {
    "AuditFields": {
      "description": "The audit fields for a resource",
      "properties": {
        "by": {
          "default": null,
          "title": "By",
          "type": "string"
        },
        "byName": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Byname"
        },
        "at": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "At"
        }
      },
      "title": "AuditFields",
      "type": "object"
    },
    "LabelTemplateType": {
      "description": "The type of a label template, describing what it renders.\n\nAttributes\n----------\nBATCH : str\n    Product/Formula lot labels.\nPROPERTY : str\n    Property task labels.\nINVENTORY : str\n    Inventory lot labels.\nBATCH_LABEL : str\n    Batch task labels.\nFORMULA_REPORT : str\n    Product/Formula reports.\nBATCH_TEMPLATE : str\n    Batch task templates.\nPROPERTY_TASK_REPORT : str\n    Property task reports.\nGENERAL_TASK_LABEL : str\n    General task labels.",
      "enum": [
        "batch",
        "property",
        "inventory",
        "batchlabel",
        "formulareport",
        "batchtemplate",
        "propertytaskreport",
        "generaltasklabel"
      ],
      "title": "LabelTemplateType",
      "type": "string"
    },
    "Status": {
      "description": "The status of a resource.\n\nAttributes\n----------\nACTIVE : str\n    The resource is fully operational and visible in normal operations.\nINACTIVE : str\n    The resource is hidden from normal operations and disabled from use.",
      "enum": [
        "active",
        "inactive"
      ],
      "title": "Status",
      "type": "string"
    }
  },
  "description": "A label template in the Albert platform.\n\nA label template pairs a tenant-scoped HTML file with page rendering\noptions. The HTML file is an ordinary HTML document containing Mustache\nplaceholders (e.g. ``{{info.inventoryName}}``) that are filled at render\ntime from the print payload for the template's ``type``: the payload's\n``data[\"labels\"]`` list holds one entry per printed entity, and each\nentry's fields are read under ``info``. Templates drive the printable\noutputs in Albert, such as inventory lot barcode labels, batch task\nlabels, and formula reports. Label Template IDs use the ``TMP`` prefix.\n\nSee [`LabelTemplateCollection`][albert.collections.label_templates.LabelTemplateCollection]\nfor creating, retrieving, and rendering label templates.",
  "properties": {
    "status": {
      "anyOf": [
        {
          "$ref": "#/$defs/Status"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The status of the resource, optional."
    },
    "Created": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Audit fields for the creation of the resource, optional."
    },
    "Updated": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Audit fields for the update of the resource, optional."
    },
    "albertId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The Albert ID of the label template (format ``TMP...``).",
      "title": "Albertid"
    },
    "name": {
      "description": "The display name of the template. Unique per tenant.",
      "maxLength": 255,
      "minLength": 1,
      "title": "Name",
      "type": "string"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "A human-readable description of the template, optional.",
      "title": "Description"
    },
    "type": {
      "anyOf": [
        {
          "$ref": "#/$defs/LabelTemplateType"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The type of output the template renders (e.g. ``inventory`` for\ninventory lot labels)."
    },
    "templateFile": {
      "anyOf": [
        {
          "maxLength": 500,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The file name of the Mustache HTML template stored for the tenant\n(e.g. ``\"my-label.html\"``).",
      "title": "Templatefile"
    },
    "default": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "When True, this template is the tenant default for its type.",
      "title": "Default"
    },
    "customUiType": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "The display name of the template type shown in the UI. Read-only.",
      "title": "Customuitype"
    },
    "metadata": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Page rendering options and template settings, such as ``width``,\n``height``, ``margin``, and header/footer file names, optional.",
      "title": "Metadata"
    }
  },
  "required": [
    "name"
  ],
  "title": "LabelTemplate",
  "type": "object"
}

Fields:

id

id: str | None = None

The Albert ID of the label template (format TMP...).

name

name: str

The display name of the template. Unique per tenant.

description

description: str | None = None

A human-readable description of the template, optional.

type

type: LabelTemplateType | None = None

The type of output the template renders (e.g. inventory for inventory lot labels).

template_file

template_file: str | None = None

The file name of the Mustache HTML template stored for the tenant (e.g. "my-label.html").

default

default: bool | None = None

When True, this template is the tenant default for its type.

custom_ui_type

custom_ui_type: str | None = None

The display name of the template type shown in the UI. Read-only.

metadata

metadata: dict[str, Any] | None = None

Page rendering options and template settings, such as width, height, margin, and header/footer file names, optional.

LabelPrintPayload

Bases: BaseAlbertModel

The assembled render payload for printing a label.

Contains everything needed to generate the final PDF: the resolved template file URLs, the label data for each entity, page options, and the storage destination. Pass these fields to generate_pdf to render the PDF, or use generate_label_pdf to do both steps in one call.

Show JSON schema:
{
  "$defs": {
    "PDFS3Storage": {
      "description": "The storage destination for a generated PDF.",
      "properties": {
        "Bucket": {
          "description": "The S3 bucket the generated PDF is stored in.",
          "title": "Bucket",
          "type": "string"
        },
        "Key": {
          "description": "The S3 object key the generated PDF is stored under.",
          "title": "Key",
          "type": "string"
        },
        "ACL": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The S3 ACL applied to the generated PDF, optional.",
          "title": "Acl"
        },
        "forceOverwrite": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "When True, regenerate the PDF even if a cached copy already exists.",
          "title": "Forceoverwrite"
        }
      },
      "required": [
        "Bucket",
        "Key"
      ],
      "title": "PDFS3Storage",
      "type": "object"
    },
    "PDFTemplate": {
      "description": "The HTML template sources used to render a PDF.\n\nEach source is an HTML file with Mustache placeholders: ``{{field}}``\ninserts a value, ``{{#list}}...{{/list}}`` repeats a block per item, and\n``{{{field}}}`` inserts without HTML escaping (needed for image URLs).\nThe valid placeholder names are exactly the keys of the ``data`` object\nsupplied at render time, using dotted paths for nested values. Label\npayloads pass ``data={\"labels\": [...]}``, so those templates wrap their\nbody in ``{{#labels}}...{{/labels}}`` and read each entity's fields under\n``{{info.<field>}}``.\n\nWhen ``header`` or ``footer`` is set, the pages render with that header or\nfooter template. Header and footer templates can show page numbers and\ndocument metadata via elements with the classes ``pageNumber``,\n``totalPages``, ``date``, and ``title`` (e.g.\n``<span class=\"pageNumber\"></span>``).",
      "properties": {
        "body": {
          "description": "URL or S3 path of the Mustache HTML template for the document body.",
          "title": "Body",
          "type": "string"
        },
        "header": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "URL or S3 path of the Mustache HTML template for the page header, optional.",
          "title": "Header"
        },
        "footer": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "URL or S3 path of the Mustache HTML template for the page footer, optional.",
          "title": "Footer"
        }
      },
      "required": [
        "body"
      ],
      "title": "PDFTemplate",
      "type": "object"
    }
  },
  "description": "The assembled render payload for printing a label.\n\nContains everything needed to generate the final PDF: the resolved\ntemplate file URLs, the label data for each entity, page options, and the\nstorage destination. Pass these fields to\n[`generate_pdf`][albert.collections.pdf_generator.PDFGeneratorCollection.generate_pdf]\nto render the PDF, or use\n[`generate_label_pdf`][albert.collections.label_templates.LabelTemplateCollection.generate_label_pdf]\nto do both steps in one call.",
  "properties": {
    "template": {
      "$ref": "#/$defs/PDFTemplate",
      "description": "The resolved template file URLs. ``template.body`` is the URL of the\ntenant's Mustache HTML file."
    },
    "data": {
      "additionalProperties": true,
      "description": "The label data rendered into the template. For labels this contains a\n``labels`` list with one entry per printed entity, whose fields the\ntemplate reads under ``info`` (e.g. ``{{info.inventoryName}}``).",
      "title": "Data",
      "type": "object"
    },
    "s3Storage": {
      "$ref": "#/$defs/PDFS3Storage",
      "description": "The storage destination for the generated PDF."
    },
    "options": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Page rendering options such as ``width``, ``height``, and ``margin``,\noptional.",
      "title": "Options"
    },
    "metadata": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Template settings parsed from the template file's metadata block,\noptional.",
      "title": "Metadata"
    },
    "manualFields": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Fields the template expects the user to fill in manually, optional.",
      "title": "Manualfields"
    }
  },
  "required": [
    "template",
    "s3Storage"
  ],
  "title": "LabelPrintPayload",
  "type": "object"
}

Fields:

template

template: PDFTemplate

The resolved template file URLs. template.body is the URL of the tenant's Mustache HTML file.

data

data: dict[str, Any]

The label data rendered into the template. For labels this contains a labels list with one entry per printed entity, whose fields the template reads under info (e.g. {{info.inventoryName}}).

s3_storage

s3_storage: PDFS3Storage

The storage destination for the generated PDF.

options

options: dict[str, Any] | None = None

Page rendering options such as width, height, and margin, optional.

metadata

metadata: Any | None = None

Template settings parsed from the template file's metadata block, optional.

manual_fields

manual_fields: Any | None = None

Fields the template expects the user to fill in manually, optional.