Skip to main content

How to run a workflow

Activate a device, tear one down, or run any other registered workflow through an enrollment group.

Running through a group is the normal path: the group supplies its own routing, organization, and provider values, so you send only what is genuinely per-device.

Prerequisites​

  • A registered device — see How to register devices
  • An enrollment group whose workflows set includes the workflow you want
  • A JWT access token with onboarding management permissions
export API="https://api.example.com/api"
export TOKEN="YOUR_ACCESS_TOKEN"
export GROUP_ID="YOUR_ENROLLMENT_GROUP_ID"

Steps​

1. See what the group can run​

curl -s "$API/enrollment-groups/$GROUP_ID/workflows" \
-H "Authorization: Bearer $TOKEN" | jq -r '.[] | "\(.name) \(.kind)"'
device-activation      activation
device-deactivation deactivation

Only workflows in the group's set appear here. Anything else returns 404 workflow_not_found on this route.

2. Ask what you must supply​

curl -s "$API/enrollment-groups/$GROUP_ID/workflows/device-activation" \
-H "Authorization: Bearer $TOKEN" \
| jq '{callerRequiredInputs, callerOptionalInputs, groupSuppliedInputs}'
{
"callerRequiredInputs": ["device.id", "customer.id", "meter.id", "meter.address"],
"callerOptionalInputs": [
{ "key": "auth.method", "default": "symmetricKey" },
{ "key": "client.display_name", "default": null }
],
"groupSuppliedInputs": ["organization.id", "model.id", "provider_template.id", "provider.id"]
}

Build params from callerRequiredInputs. Do not hard-code this list — it differs per group, and it shrinks as a group is configured with more workflowInputs.

3. Run it​

curl -X POST "$API/enrollment-groups/$GROUP_ID/workflows/device-activation/run" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"params": {
"device.id": "temp-sensor-001",
"customer.id": "customer-ext-42",
"meter.id": "meter-9001",
"meter.address": "1 Example Street"
}
}'

Input keys keep their dotted and underscored form. They are dictionary keys, not DTO properties, so they are not camelCased.

Verify it worked​

A fresh activation returns 201:

{ "deviceId": "temp-sensor-001", "created": true }

Provider credentials are never in this response. The device fetches its own connection settings from the device-facing GET /get_settings.

Confirm from the run history:

curl -s "$API/workflow-runs?subjectId=temp-sensor-001&limit=1" \
-H "Authorization: Bearer $TOKEN" | jq '.items[0] | {outcome, workflowId, finishedAt}'

Variations​

Deactivate. Same route, device-deactivation, with only device.id in params. Returns 200 and the device derives back to registered.

Run by id instead of slug. The scoped route accepts either. The generic route POST /api/workflows/{workflowId}/run accepts a UUID only.

Run without a group. POST /api/workflows/{workflowId}/run takes every input from the caller, including provider.id and organization.id. There is no group to fill gaps and no opt-in check — treat it as an administrative surface.

Override a group-supplied value. Send the key in params. Caller values win over group values.

If it doesn't work​

400 workflow_input_missing — the response names the offending keys in missingFields. Nothing ran and no run record was written. Re-read step 2; blank strings count as missing.

404 workflow_not_found — the workflow is not in this group's workflows set, or the id is wrong on the generic route.

409 device_already_provisioned — the device is not in a state this workflow admits. Activation admits registered and provider_client_only. If the device is already active there is nothing to do; tear it down first if you intend to re-provision.

409 routing_target_corrupted — the group's own configuration is unresolvable, not your request. Check the routing target and its provider credential.

503 — either a transient step failure or a run already in progress for this device. Both are safe to retry after a pause.

Anything with a failedStep — the run got partway. Read Workflow Error Codes, then retry the run rather than re-issuing this request.

See also​