Zum Inhalt springen

Accept a label request of Grocy's label printer webhook

POST
/api/v1/webhook/grocy/label
curl --request POST \
--url https://example.com/api/v1/webhook/grocy/label \
--header 'Content-Type: application/json' \
--data '{ "battery": "example", "chore": "example", "due_date": "example", "grocycode": "example", "product": "example", "recipe": "example" }'

Grocy’s label printer webhook (LABEL_PRINTER_WEBHOOK) for products, stock entries, chores, batteries and recipes. Authentication: an API key with the print scope as the token query parameter (Grocy sends no headers) or the X-Label-Hub-Key header; a read key answers 403 insufficient_scope, an admin key 403 token_scope_too_wide, every other failure of the token 401 invalid_token. The key’s printer restriction and rate limit apply. The webhook is off until integrations.grocy.label.enabled is set. The label type comes from the Grocycode; content type and printer come from the mapping of that type in Settings > Integrations > Grocy (a type without a printer uses the default target, and without one the first enabled tape printer). A page printer prints the label onto one cell of its sheet type: the lowest free cell of the started sheet with the fewest free cells, else a new sheet with its ID in the margin. The route answers 202 within 1.5 s with the job’s UUID: printing runs afterwards, and a printer failure (offline, no tape) sets the job failed with the code POST /api/v1/print would answer; on a page printer a sheet failure sets the code of the sheet print (for example content_type_data_mismatch). A label that cannot be built (unreadable body, invalid Grocycode, name field of another type) also answers 202, with a failed job (grocy_label_invalid, grocy_label_mismatch).

token
string
<= 128 characters

A Labelyard API key with the print scope (D24, ADR 0027). Read from a literal ‘token=’ parameter only; the X-Label-Hub-Key header wins when both are sent. The hub hides the value in its own logs

X-Label-Hub-Key
string
<= 128 characters

The same key as a header, for callers that can send headers

The JSON object Grocy sends with LABEL_PRINTER_HOOK_JSON=true, at most 1 MiB. Fields not listed are ignored

Media typeapplication/json
GrocyLabelPayload

What the hub reads from one label request of Grocy.

object
battery
Battery

The battery name, for a battery label

Any of:
string
<= 512 characters
chore
Chore

The chore name, for a chore label

Any of:
string
<= 512 characters
due_date
Due Date

Grocy’s localised due date line of a stock entry, for example ‘DD: 2026-12-01’. Printed as the third line of a stock entry label

Any of:
string
<= 64 characters
grocycode
required
Grocycode

The Grocycode of the object, for example ‘grcy:p:12’ (product), ‘grcy:p:12:63a1b2c3d4e5f’ (stock entry), ‘grcy:c:3’ (chore), ‘grcy:b:4’ (battery) or ‘grcy:r:5’ (recipe). It decides the label type and is the QR code

string
/^grcy:(p|b|c|r):[0-9]{1,10}(:[^:\s]{1,64}){0,3}$/
product
Product

The product name, for a product or stock entry label

Any of:
string
<= 512 characters
recipe
Recipe

The recipe name, for a recipe label

Any of:
string
<= 512 characters

Example generated

{
"battery": "example",
"chore": "example",
"due_date": "example",
"grocycode": "example",
"product": "example",
"recipe": "example"
}

Successful Response

Media typeapplication/json
WebhookAcceptedResponse

202 Accepted response body for both webhook endpoints.

object
job_id
required
Job Id

UUID of the new print job. Webhook jobs have no owner: an admin or SSO caller can follow it under GET /api/v1/jobs/{job_id}

string format: uuid

Example generated

{
"job_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
}

invalid_token: the token is missing, unknown, disabled or expired.

insufficient_scope (a read key), token_scope_too_wide (an admin key) or printer_not_allowed (the key may not use the label’s printer; the message does not name it).

body_too_large: the body is larger than 1 MiB.

json_required: set LABEL_PRINTER_HOOK_JSON=true in Grocy.

rate_limit_exceeded: the key’s per-minute limit, with Retry-After.

grocy_label_disabled (the webhook is switched off), grocy_label_printer_unavailable (the mapped printer is unknown or disabled), grocy_label_sheet_type_unavailable (a page printer whose sheet type is not set, unknown or archived) or no enabled tape printer.