ChartQuery

Label Compile

POST
/v1/label/compile

Compile a label to printer commands (tsc, zpl, epl, …). POST width, language, and elements. Text uses content and size (1-10), not text or fontSize. No barcode element. Example: {"width":40,"height":30,"unit":"mm","language":"zpl","elements":[{"type":"text","content":"ACME","x":10,"y":10,"size":2},{"type":"text","content":"SKU: BOX-12","x":10,"y":35,"size":2}]}

Credit cost: 3 credits per call

Query Parameters

fields?string

Comma-separated list of response fields to return, with dot notation for nested fields (e.g. name,location.city).

is_async?boolean

Run the request as a background job: the API answers 202 with a job_id to poll on GET /v1/jobs/{id}.

Defaultfalse
soft_fail?boolean

Return HTTP 200 even when the request fails; the error is in the error field of the body.

Defaultfalse

Request Body

application/json
  1. body
width*number

Label width. Required. Default unit is mm. Example: 40. Do not send query instead of width.

height?number

Label height in the same unit. Example: 30. Omit for receipt / continuous mode.

unit?string

Measurement unit for width and height. Default mm. Use mm unless you are working in printer dots.

Default"mm"
Value in"mm""inch""dot"
dpi?number

Printer DPI. Default 203.

gap?number

Gap between labels in mm. Ignored for receipts.

speed?number

Print speed, 1-18.

density?number

Print darkness, 0-15.

direction?number

Print direction. 0 = normal, 1 = reversed.

Default1
Value in01
copies?number

Number of copies. Minimum 1.

printer?string

Printer profile id (tsc-te210, zebra-zd420, …).

elements*array<>

Required array. Text items need type=text, content, and size (1-10 magnification). Do not use text, fontSize, or type=barcode. Positions x/y are in dots. Example item: {"type":"text","content":"Order: 1042","x":10,"y":10,"size":2}.

Items1 <= items
language*string

Required printer language. Example: zpl or tsc. Do not omit.

Default"tsc"
Value in"tsc""zpl""epl""cpcl""dpl""sbpl""escpos""starprnt""ipl"

Response Body

Successful response

response?stringapplication/json
Example Request
curl -X POST 'https://api.chartquery.com/v1/label/compile' \  -H 'Content-Type: application/json' \  -d '{  "width": 0,  "elements": [    {      "type": "text"    }  ],  "language": "tsc"}'
Example Response
"SIZE 40 mm, 30 mm\nGAP 3 mm, 0\nSPEED 4\nDENSITY 8\nDIRECTION 1\nCLS\nTEXT 10,10,\"2\",0,1,1,\"ACME Corp\"\nTEXT 10,35,\"1\",0,1,1,\"SKU: PRD-00123\"\nBAR 5,55,305,1\nBOX 5,5,315,235,2\nPRINT 1"