Accept a label request of Grocy's label printer webhook
const url = 'https://example.com/api/v1/webhook/grocy/label';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"battery":"example","chore":"example","due_date":"example","grocycode":"example","product":"example","recipe":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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).
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”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
Header Parameters
Section titled “Header Parameters”The same key as a header, for callers that can send headers
Request Bodyrequired
Section titled “Request Bodyrequired”The JSON object Grocy sends with LABEL_PRINTER_HOOK_JSON=true, at most 1 MiB. Fields not listed are ignored
What the hub reads from one label request of Grocy.
object
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
Example generated
{ "battery": "example", "chore": "example", "due_date": "example", "grocycode": "example", "product": "example", "recipe": "example"}Responses
Section titled “Responses”Successful Response
202 Accepted response body for both webhook endpoints.
object
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}
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.