Skip to content

Preview a sheet print

POST
/api/v1/print/{printer_key}/sheet/preview
curl --request POST \
--url https://example.com/api/v1/print/example/sheet/preview \
--header 'Content-Type: application/json' \
--header 'X-Label-Hub-Key: <X-Label-Hub-Key>' \
--data '{ "expected_cells": [ { "cells": [ 1 ], "id_cell": 1, "sheet": "example" } ], "items": [ { "content_type": "qr_only", "data": { "items": [], "primary_id": "example", "qr_payload": "example", "secondary": [], "title": "example" }, "lookup": { "app": "example", "identifier": "example" }, "purpose": "example", "ref": "example", "source": "example" } ], "placements": [ { "cells": "first_free", "count": 1, "new_sheet": { "id_placement": "cell", "type": "example", "version": 1 }, "sheet": "example", "skip": [ 1 ] } ], "tray": "example" }'

Plans where the items would go and draws them, without reserving or printing anything. Per page: every cell with its state, a 150 dpi PNG of the new content only, whether the sheet ID and the feed-direction mark are printed, and where. Also the cells left free, the plan to send back as expected_cells, and where lookup items were printed before. The picture is never calibrated. Only page (IPP) printers print sheets. A run plans one sheet: a second placement is refused (preview_too_large), and the items the sheet does not take are left out (placed, remaining).

printer_key
required
Printer Key

Printer slug or UUID.

string
<= 100 characters

Printer slug or UUID.

Media typeapplication/json
SheetPrintRequest
object
expected_cells
Expected Cells
Any of:
Array<object>
<= 50 items
ExpectedPageModel

What a preview promised for one page; the print refuses a different plan.

object
cells
required
Cells
Array<integer>
<= 400 items
id_cell
Id Cell
Any of:
integer
>= 1 <= 400
sheet
required
Sheet

Sheet code, or new.

string
<= 24 characters
items
required
Items
Array<object>
>= 1 items <= 500 items
SheetItem

One label to print: a content type plus raw data or an integration lookup.

purpose is what the cell is recorded as (default: the label’s title, else its primary id). source names the origin of raw data (default api); a lookup is recorded under the integration’s name and its identifier as ref.

object
content_type
required
ContentType

Tape-independent semantic content types for label rendering.

string
Allowed values: qr_only qr_one_line qr_two_lines qr_three_lines text_one_line text_two_lines qr_with_listing
data
Any of:
SheetRawLabelData

Raw label data of a sheet item: the same fields, every free text bounded.

A page job stores its labels in the job row, and a preview renders them, so the sizes are capped at the request: qr_payload at 512 characters, every other text at 512, at most 10 secondary lines and 100 items (listing rows). A cell shows far less than that; the renderer shortens what does not fit. Since #258 the tape RawLabelData carries the same caps, so this class adds nothing but its name.

object
items
Items
Array<object>
default: <= 100 items
RawListingItem

One listing row of raw label data, with bounded text.

object
item
required
Item
string
<= 512 characters
qr_payload
Qr Payload
Any of:
string
<= 512 characters
primary_id
Primary Id
Any of:
string
<= 512 characters
qr_payload
Qr Payload
Any of:
string
<= 512 characters
secondary
Secondary
Array<string>
default: <= 10 items
title
Title
Any of:
string
<= 512 characters
lookup
Any of:
PrintLookupRequest

Resolve label data via an integration plugin.

object
app
required
App
string
identifier
required
Identifier
string
purpose
Purpose
Any of:
string
<= 120 characters
ref
Ref
Any of:
string
<= 120 characters
source
Source
Any of:
string
/^[a-z][a-z0-9_-]{0,31}$/
placements
required
Placements
Array<object>
>= 1 items <= 50 items
PlacementInModel

Either an existing sheet (sheet) or a new one (new_sheet), never both.

Items fill the placements in order; the last placement may leave count out and takes the rest. cells and skip belong to an existing sheet only.

object
cells
Cells

first_free, or the cell numbers, in the order the items fill them.

Any of:
string
Allowed value: first_free
count
Count
Any of:
integer
>= 1 <= 500
new_sheet
Any of:
NewSheetModel
object
id_placement
Id Placement

Where the sheet ID is printed; margin if left out.

string
default: margin
Allowed values: cell margin manual
type
required
Type

Sheet type key.

string
<= 64 characters /^[a-z0-9][a-z0-9-]{1,62}[a-z0-9]$/
version
Version

Defaults to the current version.

Any of:
integer
>= 1 <= 1000000
sheet
Sheet

Sheet code.

Any of:
string
<= 24 characters
skip
Skip

Cells first_free leaves out for this request (never stored).

Array<integer>
<= 400 items
tray
Tray
Any of:
string
>= 1 characters <= 100 characters

Successful Response

Media typeapplication/json
SheetPreview
object
expected_cells
required
Expected Cells

Send this back as expected_cells when printing.

Array<object>
ExpectedPageModel

What a preview promised for one page; the print refuses a different plan.

object
cells
required
Cells
Array<integer>
<= 400 items
id_cell
Id Cell
Any of:
integer
>= 1 <= 400
sheet
required
Sheet

Sheet code, or new.

string
<= 24 characters
free_after
required
Free After

Free cells left on each page’s sheet afterwards.

Array<integer>
pages
required
Pages
Array<object>
PreviewPage
object
cells
required
Cells
Array<object>
PreviewCell
object
cell
required
Cell
integer
hw_margin
required
Hw Margin

New cells only: may be cut off by this printer’s hardware margins.

boolean
is_id
required
Is Id

The sheet ID label of a cell sheet.

boolean
item_index
required
Item Index

Index into the request’s items; new cells only.

Any of:
integer
mapped
required
Mapped

Drawn as text because the sheet type has no QR (spec 12.5).

boolean
purpose
required
Purpose
Any of:
string
state
required
State
string
Allowed values: used reserved unconfirmed new free
truncated
required
Truncated

Text had to be shortened to fit.

boolean
feed_mark
required
Feed Mark

The feed-direction mark is printed on this page.

boolean
geometry
required
GeometryMm
object
cols
required
Cols
integer
>= 1 <= 400
corner_radius
Corner Radius
Any of:
number
<= 1000
label_h
required
Label H
number
<= 1000
label_w
required
Label W
number
<= 1000
margin_left
required
Margin Left
number
<= 1000
margin_top
required
Margin Top
number
<= 1000
page_h
Page H
Any of:
number
<= 1000
page_size
required
Page Size
string
Allowed values: A4 Letter
page_w
Page W
Any of:
number
<= 1000
pitch_x
required
Pitch X
number
<= 1000
pitch_y
required
Pitch Y
number
<= 1000
rows
required
Rows
integer
>= 1 <= 400
shape
required
Shape
string
Allowed values: rectangle round
id_not_printed
required
Id Not Printed

No margin band is deep enough: no ID on this page.

boolean
load_hint
required
Load Hint

How to load the tray, if the printer has a hint.

Any of:
string
margin_band
required
Margin Band
Any of:
string
Allowed values: top bottom right left
margin_id
required
Margin Id

The sheet ID is printed in a margin band on this page.

boolean
new_code_hint
required
New Code Hint

The probable code of a new sheet.

Any of:
string
png_base64
required
Png Base64

1-bit PNG, 150 dpi, page size: only the new content.

string
sheet_code
required
Sheet Code

Null for a sheet this request creates.

Any of:
string
type_key
required
Type Key
string
version
required
Version
integer
placed
required
Placed

Items this run places: the first ones of items, as many as the sheet takes.

integer
remaining
required
Remaining

Items left out because one run prints one sheet; print them in another run.

integer
reprint_hints
required
Reprint Hints

Where lookup items were printed before: the newest ones per item, on the first copy of the item. reprint_totals has the full count.

Array<object>
ReprintHint

One earlier print of a lookup item: a used cell it was printed into.

object
cell
required
Cell

The cell of the earlier print.

integer
item_index
required
Item Index

Index of the item in items. Only on the first copy of an item (the first item with this source and ref): its other copies, and later cart lines of the same item, carry no hints.

integer
printed_at
required
Printed At

When the cell was printed (UTC).

string
sheet_code
required
Sheet Code

The sheet the earlier print is on.

string
reprint_totals
required
Reprint Totals

One entry per item that has reprint_hints: the count of all its earlier prints.

Array<object>
ReprintTotal

How often an item was printed before: all earlier prints, not only the listed ones.

object
item_index
required
Item Index

The item the hints are on (see ReprintHint.item_index).

integer
sheets
required
Sheets

Earlier prints of the item per sheet code.

object
key
additional properties
integer
total
required
Total

Earlier prints of the item; reprint_hints lists the newest ones only.

integer

Example

{
"pages": [
{
"cells": [
{
"state": "used"
}
],
"geometry": {
"page_size": "A4",
"shape": "rectangle"
},
"margin_band": "top"
}
]
}

These credentials may not use this printer (printer_not_allowed).

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}

Unknown printer (printer_not_found), sheet (sheet_not_found), sheet type, or an item the integration does not have (app-lookup-not-found).

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}

Not a page printer (media_kind_mismatch), the printer is disabled (printer_disabled), the sheet is discarded or archived, or the cells do not fit (insufficient_cells, cells_taken).

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}

Invalid request (invalid_request, field paths only), an unknown or disabled tray (tray_unknown), an item the cell cannot show (content_type_data_mismatch), a plan of more than one sheet (preview_too_large), or an unknown integration (integration_unknown_app). Item errors carry item_index.

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}

The key has a preview in progress already, or a render of the key is stuck past the time limit (too-many-previews): one per key at a time. The body has the rate limit’s shape (retry_after_seconds).

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}

An integration lookup failed (integration_lookup_failed).

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}

An integration is not configured (integration_not_configured), or no render slot became free in time (render-unavailable): every slot is held by a stuck render, the callers without a key have a stuck render, or the wait for the caller’s turn (one slot per key, one for all callers without a key) reached LABELYARD_RENDER_TIMEOUT_S.

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}

A page took longer than LABELYARD_RENDER_TIMEOUT_S to draw (render-timeout). The drawing goes on: the key’s next preview answers 429 too-many-previews until it has ended.

Media typeapplication/json
object
detail
required
object
error_code
required
string
error_detail
Any of:
object
key
additional properties
any
error_message
required
string

Example generated

{
"detail": {
"error_code": "example",
"error_detail": {},
"error_message": "example"
}
}