DEVELOPERS / WORKFLOWS / SDK 3.0
Keep the Printing Logic in a Workflow. Trigger It From Code.
Build the printing logic visually as a workflow, then start it from your code with one call: test it with sample data, mint a signed trigger, fire it with a record. Python, Node.js, .NET, Go.
result = client.workflows.test("wf_orders", row={"order_id": "ORD-9876", "sku": "A-1042"})
print(result["trace"])THE PROBLEM
Printing is rarely one call. Pick the right design for the product, look up the missing fields, print one label per line, mark the order as printed, email someone if it fails. Writing that in your application means every rule change is a code change.
In LabelInn you build that logic as a workflow, visually, and your code starts it with a record. From version 3.0 the SDKs cover the whole workflow API.
01 / WORKFLOWS
1. Test the workflow with a sample record
A test run walks the whole graph and returns the trace. Nothing prints.
result = client.workflows.test("wf_orders", row={"order_id": "ORD-9876", "sku": "A-1042"})
print(result["trace"])02 / WEBHOOKS
2. Mint a signed trigger, once
trigger = client.workflows.create_trigger("wf_orders", signed=True)
# Store trigger["token"] and trigger["secret"] now — the secret is shown once.03 / SDK
3. Fire it from your system
run = client.workflows.fire(
"wf_orders",
trigger["token"],
{"order_id": "ORD-9876", "sku": "A-1042"},
secret=trigger["secret"],
)
print(run["accepted"], run["printJobIds"])With a secret, the SDK signs the exact request bytes with HMAC-SHA256 and sends them as X-LabelInn-Signature. A forged or altered request is refused.
04 / AUTOMATION
The same in other languages
// Node.js
const trigger = await client.workflows.createTrigger('wf_orders', { signed: true });
const run = await client.workflows.fire('wf_orders', trigger.token,
{ order_id: 'ORD-9876', sku: 'A-1042' }, { secret: trigger.secret });// C#
var trigger = await client.Workflows.CreateTriggerAsync("wf_orders", signed: true);
var run = await client.Workflows.FireAsync("wf_orders", trigger.Token,
new { order_id = "ORD-9876", sku = "A-1042" }, trigger.Secret);// Go
trigger, _ := client.Workflows.CreateTrigger("wf_orders", "", true)
run, err := client.Workflows.Fire("wf_orders", trigger.Token,
map[string]string{"order_id": "ORD-9876", "sku": "A-1042"}, trigger.Secret)
if err != nil {
log.Fatal(err)
}
fmt.Println(run.Accepted, run.PrintJobIDs)05 / WORKFLOWS
No SDK? Any HTTP client works
The trigger URL accepts a JSON POST from anything: an ERP, a Make or Zapier scenario, a shell script. For a signed trigger, send X-LabelInn-Signature: sha256=<hex HMAC-SHA256 of the body>.
06 / WEBHOOKS
What the workflow can do with the record
- Pick the design by product, customer or country.
- Look up missing fields in a file or database.
- Print one label per line, numbered "3 / 12".
- Write back that it printed.
- Alert someone when the printer needs attention.
Requires SDK 3.0 or later: pip install -U labelinn, npm install labelinn@3, dotnet add package LabelInn --version 3.0.0, go get github.com/labelinn/labelinn-go/v3.
Printing through the API is part of the Pro plan, and the free trial includes it. Keys that start with sk_test_ run against a sandbox that never prints, so you can build and test before going live. See pricing.
QUESTIONS / FAQ
Frequently asked questions
How do I start a label printing workflow from my code?
Create a trigger for the workflow once, then call workflows.fire with the trigger token and a record. The SDK sends the record to the workflow's trigger URL and returns whether it was accepted and which print jobs it created.
Can I test a workflow without printing?
Yes. workflows.test runs the whole graph with a sample record and returns the trace without printing anything.
How are triggers secured?
Each trigger has its own unguessable token, and a signed trigger also requires an HMAC-SHA256 signature of the request body in the X-LabelInn-Signature header. The SDKs sign automatically when you pass the secret.
Which SDK version do I need?
Version 3.0 or later of the Python, Node.js, .NET or Go SDK.
KEEP GOING
Related
NEXT STEP / LABELINN
Rules in the workflow, one call in your code
Build the printing logic visually and start it from wherever your data lives. · Test runs with no printing · Signed triggers · Python, Node.js, .NET, Go