Skip to main content

How to create an enrollment group

Define a class of devices that share a routing target, an owning organization, and a set of runnable workflows.

Prerequisites​

  • A JWT access token with onboarding management permissions
  • A routing target id — create one with POST /api/routing-targets if you have none
  • The id of the organization that will own devices in this group
  • The slugs of the workflows this group should be able to run
export API="https://api.example.com/api"
export TOKEN="YOUR_ACCESS_TOKEN"
export ROUTING_TARGET_ID="YOUR_ROUTING_TARGET_ID"
export ORG_ID="YOUR_ORGANIZATION_ID"

Steps​

1. Choose the group's workflow set​

The workflows field is required and must be non-empty. It is the group's entire runnable set: exactly the workflows that may be listed, described, and run through it. Anything else returns 404 workflow_not_found on the scoped route.

List what is registered:

curl -s "$API/workflows" -H "Authorization: Bearer $TOKEN" \
| jq -r '.[] | "\(.id) \(.kind) \(.displayName)"'

For a group whose devices are activated and later torn down, ["device-activation", "device-deactivation"] is the usual pair.

2. Create the group​

curl -X POST "$API/enrollment-groups" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Temperature Sensors",
"routingTargetId": "'"$ROUTING_TARGET_ID"'",
"organizationId": "'"$ORG_ID"'",
"modelId": "YOUR_MODEL_ID",
"workflows": ["device-activation", "device-deactivation"],
"providerTemplateId": "YOUR_PROVIDER_TEMPLATE_ID",
"attestationType": "sharedKey",
"operationalCredential": "symmetricKey",
"responseTemplate": {
"mqtt_host": "{{brokerUrl}}",
"mqtt_port": "{{brokerPort}}",
"device_id": "{{deviceId}}",
"primary_key": "{{primaryKey}}",
"secondary_key": "{{secondaryKey}}"
}
}'

modelId is required only when a workflow in the set creates assets. A group running provider-client-only alone may omit it.

3. Supply group-level workflow inputs (optional)​

Values in workflowInputs are merged beneath the caller's params on every scoped run, so callers need not send them. Group values may reference other keys with {{other.key}}.

curl -X PATCH "$API/enrollment-groups/$GROUP_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/merge-patch+json" \
-d '{
"workflowInputs": {
"client.display_name": "Sensor {{meter.id}}"
}
}'

The update is an RFC 7396 JSON Merge Patch: fields you leave out are unchanged. workflowInputs is replaced as a whole, not merged key by key, so send every group-level input you want to keep. {} or null removes them all.

Verify it worked​

Ask the group what a caller must supply for one of its workflows:

curl -s "$API/enrollment-groups/$GROUP_ID/workflows/device-activation" \
-H "Authorization: Bearer $TOKEN" | jq '{callerRequiredInputs, groupSuppliedInputs}'

groupSuppliedInputs should list the keys the group resolves — typically provider.id, auth.method, organization.id, model.id, and provider_template.id. Whatever remains in callerRequiredInputs is what run requests must carry.

Variations​

Certificate-credential group. Set operationalCredential to certificate and optionally certificateTtlDays and certificateFormat. Devices then enroll over EST rather than fetching a shared key. See Onboarding flows.

Restricting re-enrollment. renewalPolicy accepts Allow (default), Deny, or Prompt. Prompt holds each re-enrollment for admin approval.

Changing the workflow set later. PATCH with a non-empty workflows array replaces the set wholesale. An empty array or null is rejected — the set cannot be cleared.

Changing other fields later. PATCH /api/enrollment-groups/{id} changes only the fields in the body. Field names are case-sensitive: a key the group does not have, or one with the wrong case (ModelId), is rejected with 400 validation_failed naming the key, and nothing is updated. An explicit null removes a field, and most fields reject that:

Fieldnull does
modelIdclears the asset model
certificateTtlDaysreverts to the default, 90
workflowInputsremoves all group-level inputs
status, renewalPolicy, organizationId, certificateFormat, responseTemplate, workflows400 — the stored value is unchanged

null is the only way to clear modelId; an empty string is rejected. responseTemplate, like workflowInputs, is replaced as a whole: to remove one key, send the template without it.

If it doesn't work​

400 on create — workflows was absent, empty, or contained a slug that resolves to no registered workflow. Compare against GET /api/workflows.

400 naming organizationId — the field is required and cannot be blank. On update, omit it to leave it unchanged; an empty string or null is rejected.

400 on update — the body was not a JSON object, a key was unknown or wrongly cased, a field had the wrong type, or a field that cannot be cleared was sent as null (see the table above). The message says which.

405 on update — the request used PUT. Updates are PATCH.

409 on update — the group was changed at the same moment, for example by a shared-key rotation, and the update could not be reconciled. Retry it.

Devices later fail activation with routing_target_corrupted — the group's routing target was deleted or its provider credential is unusable. Recreate the target and update the group.

See also​