This commit is contained in:
seb
2026-09-28 06:50:00 +02:00
parent d2aa9ff8b1
commit e8e4265dc4
11 changed files with 747 additions and 116 deletions

View File

@@ -5,54 +5,26 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
Create label template
Creates a new ZPL label template for the selected company.
A 50×50 1-bit PNG thumbnail is automatically rendered from the content and stored with the template.
A 50×50 1-bit PNG thumbnail is automatically rendered from the content
and stored with the template.
## Body (JSON)
```json
{
"name": "…",
"width": 448,
"height": 200,
"dpi": 203,
"type": "zpl",
"content": {
"objects": []
}
}
{}
```
| Field | Required | Type | Description |
|-------|----------|------|-------------|
| `name` | yes | string | Template name |
| `width` | yes | integer | Canvas width in pixels |
| `height` | yes | integer | Canvas height in pixels |
| `dpi` | yes | integer | Printer DPI — `203` or `300` |
| `type` | yes | string | Template type — `"zpl"` |
| `content` | yes | object | Label editor JSON content |
## Response `201`
Created label template
```json
{
"labeltemplate": {
"id": 1,
"company_id": 1,
"name": "…",
"width": 448,
"height": 200,
"dpi": 203,
"type": "zpl",
"content": {},
"thumb": "…"
}
"labeltemplate": {}
}
```
`thumb` is a base64-encoded 50×50 1-bit PNG string, or `null` if rendering failed.
## Errors
| Status | Description |

View File

@@ -4,7 +4,7 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
Get label template by ID
Retrieves a single label template for the authenticated user's selected company. The `thumb` field is always included inline as a base64-encoded 50×50 1-bit PNG string (`null` if not yet rendered).
Retrieves a single label template for the authenticated user's selected company.
## Path parameters
@@ -18,17 +18,7 @@ Label template details
```json
{
"labeltemplate": {
"id": 1,
"company_id": 1,
"name": "…",
"width": 448,
"height": 200,
"dpi": 203,
"type": "zpl",
"content": {},
"thumb": "…"
}
"labeltemplate": {}
}
```

View File

@@ -4,7 +4,7 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
List label templates
Lists all ZPL label templates for the selected company. The `thumb` field is always included inline as a base64-encoded 50×50 1-bit PNG string (`null` if not yet rendered).
Lists all ZPL label templates for the selected company. The `thumb` field is returned as a base64-encoded PNG string when present. `content.objects` is omitted to reduce payload size.
## Response `200`
@@ -13,17 +13,7 @@ List of label templates
```json
{
"labeltemplates": [
{
"id": 1,
"company_id": 1,
"name": "…",
"width": 448,
"height": 200,
"dpi": 203,
"type": "zpl",
"content": {},
"thumb": "…"
}
{}
]
}
```

View File

@@ -1,13 +1,12 @@
# `PATCH /labeltemplate/{id}`
# `PUT /labeltemplate/{id}`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Update label template (partial)
Update label template
Updates specified fields of an existing label template for the selected company.
When `content`, `width`, or `height` is provided, the thumbnail is automatically re-rendered.
Replaces an existing label template.
When `content` (or `width`/`height`) is provided, the thumbnail is automatically re-rendered.
Also available as `PUT /labeltemplate/{id}`.
## Path parameters
@@ -17,47 +16,17 @@ Also available as `PUT /labeltemplate/{id}`.
## Body (JSON)
All fields are optional.
```json
{
"name": "…",
"width": 448,
"height": 200,
"dpi": 203,
"type": "zpl",
"content": {
"objects": []
}
}
{}
```
| Field | Type | Description |
|-------|------|-------------|
| `name` | string | Template name |
| `width` | integer | Canvas width in pixels |
| `height` | integer | Canvas height in pixels |
| `dpi` | integer | Printer DPI — `203` or `300` |
| `type` | string | Template type — `"zpl"` |
| `content` | object | Label editor JSON content |
## Response `200`
Updated label template
```json
{
"labeltemplate": {
"id": 1,
"company_id": 1,
"name": "…",
"width": 448,
"height": 200,
"dpi": 203,
"type": "zpl",
"content": {},
"thumb": "…"
}
"labeltemplate": {}
}
```