Code Examples
Quick-reference snippets for the most common operations. For full API details, refer to the topic-specific docs linked below.
Account Balance
Check your token balance and reserved tokens.
curl -s -H "Authorization: Bearer lb_live_xxxx" \
https://api.zplflow/v1/account/balance | jq
import requests
resp = requests.get(
"https://api.zplflow/v1/account/balance",
headers={"Authorization": "Bearer lb_live_xxxx"}
)
data = resp.json()
print(f"Balance: {data['balance']}, Reserved: {data['reserved']}")
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.zplflow/v1/account/balance", nil)
req.Header.Set("Authorization", "Bearer lb_live_xxxx")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var data struct {
Balance int `json:"balance"`
Reserved int `json:"reserved"`
}
json.NewDecoder(resp.Body).Decode(&data)
fmt.Printf("Balance: %d, Reserved: %d\n", data.Balance, data.Reserved)
}
<?php
$ch = curl_init("https://api.zplflow/v1/account/balance");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer lb_live_xxxx"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
echo "Balance: {$data['balance']}, Reserved: {$data['reserved']}\n";
AS400 / SQL Native (IBM i)
SELECT SYSTOOLS.HTTPGETCLOB(
'https://api.zplflow/v1/account/balance',
NULL,
'{"Authorization":"Bearer lb_live_xxxx"}'
) AS response
FROM SYSIBM.SYSDUMMY1;
AS400 / HTTPAPI (RPG)
dcl-s response varchar(32000);
dcl-s rc int(10);
rc = http_req('GET'
: 'https://api.zplflow/v1/account/balance'
: *null
: %trim(response)
: 'Authorization: Bearer lb_live_xxxx'
: *null
: *null
: 30000
: *null);
Sync PDF to ZPL
curl -X POST "https://api.zplflow/v1/convert/pdf-to-zpl?dpi=203&max_kb=64" \
-H "Authorization: Bearer lb_live_xxxx" \
-H "Content-Type: application/pdf" \
-H "Idempotency-Key: $(uuidgen)" \
--data-binary @label.pdf | jq '.pages[].zpl_base64'
AS400 / SQL Native (IBM i)
SELECT SYSTOOLS.HTTPPOSTCLOB(
'https://api.zplflow/v1/convert/pdf-to-zpl?dpi=203&max_kb=64',
SYSTOOLS.IFS_READ('/tmp/label.pdf'),
'{"Authorization":"Bearer lb_live_xxxx","Content-Type":"application/pdf","Idempotency-Key":"mypdf123"}'
) AS response
FROM SYSIBM.SYSDUMMY1;
AS400 / HTTPAPI (RPG)
dcl-s idempotencyKey varchar(80);
dcl-s response varchar(65000);
dcl-s rc int(10);
idempotencyKey = 'pdf_' + %char(%timestamp());
rc = http_put_raw(
'https://api.zplflow/v1/convert/pdf-to-zpl?dpi=203&max_kb=64'
: '/path/to/label.pdf'
: 'application/pdf'
: %trim(response)
: 'Authorization: Bearer lb_live_xxxx'
: 'Idempotency-Key: ' + %trim(idempotencyKey)
: 30000);
Full parameter reference and multi-language examples: Conversions
Sync ZPL to PDF
curl -X POST "https://api.zplflow/v1/convert/zpl-to-pdf?dpmm=8dpmm" \
-H "Authorization: Bearer lb_live_xxxx" \
-H "Content-Type: text/plain" \
-H "Idempotency-Key: $(uuidgen)" \
--data-binary '^XA^FO50,50^A0N,30,30^FDHello World^FS^XZ' \
| jq -r '.pages[0].pdf_base64' | base64 -d > output.pdf
<?php
$zpl = '^XA^FO50,50^A0N,30,30^FDHello World^FS^XZ';
$ch = curl_init("https://api.zplflow/v1/convert/zpl-to-pdf");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $zpl);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer lb_live_xxxx",
"Content-Type: text/plain",
"Idempotency-Key: " . uniqid("zpl_", true)
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$resp = curl_exec($ch);
curl_close($ch);
$data = json_decode($resp, true);
$pdf = base64_decode($data['pages'][0]['pdf_base64']);
file_put_contents('output.pdf', $pdf);
Full parameter reference and multi-language examples: Conversions
Estimate Cost
Pre-calculate token cost without executing the operation.
curl -X POST https://api.zplflow/v1/estimate \
-H "Authorization: Bearer lb_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"operation": "pdf_to_zpl",
"params": {"dpi": 203, "max_kb": 64},
"document_count": 3
}'
import requests
resp = requests.post(
"https://api.zplflow/v1/estimate",
headers={"Authorization": "Bearer lb_live_xxxx"},
json={
"operation": "pdf_to_zpl",
"params": {"dpi": 203, "max_kb": 64},
"document_count": 3
}
)
print(resp.json())
Apply Pipeline
ZPL_BASE64=$(echo -n '^XA^FO50,50^FDTest^FS^XZ' | base64)
curl -X POST https://api.zplflow/v1/pipelines/YOUR_PIPELINE_ID/apply \
-H "Authorization: Bearer lb_live_xxxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d "{\"documents\":[{\"zpl_base64\":\"$ZPL_BASE64\",\"variables\":{\"sku\":\"ABC-001\"}}]}"
Step reference and CRUD operations: Pipelines
Preview Pipeline (Free)
Test pipeline steps without spending tokens.
curl -X POST https://api.zplflow/v1/pipelines/preview \
-H "Authorization: Bearer lb_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"zpl": "^XA^FO50,50^FDHello^FS^XZ",
"steps": [{"type": "replace_text", "search": "Hello", "replace": "World"}],
"page": 0
}'
See Also
- Conversions — Full sync API reference with all parameters
- Jobs API — Complete async workflow documentation
- Pipelines — Pipeline step reference and CRUD operations
- Best Practices — Idempotency, error codes, rate limits