How to onboard a Tier-2 device
Take a Tier-2 device from registration to publishing telemetry over mTLS.
Part A is executed by a platform operator against the management API. Part B is executed by the device firmware. Placeholders are listed under Placeholders.
Prerequisites
- Management API access with a bearer token. Management calls go through the API gateway at
https://api.example.com/api. - An enrollment group with attestation type
secretand operational credentialcertificate. - For Part B: the device flashed with its device id, its enrollment secret from step A2, the
device-facing host
https://devices.example.com, and the Beacon Tower Onboarding CA certificate. The Onboarding CA is the only CA the device needs flashed: it verifies the device-facing host. The broker is verified with the tenant's Device CA, which the device fetches in step B2.
The device-facing host is not the management API host.
Part A — Operator
A1. Check the group's workflow set
GET https://api.example.com/api/enrollment-groups/ENROLLMENT_GROUP_ID/workflows
Authorization: Bearer MANAGEMENT_JWT
If the set is not ["basic-device-activation"], replace it:
PATCH https://api.example.com/api/enrollment-groups/ENROLLMENT_GROUP_ID
Content-Type: application/merge-patch+json
Authorization: Bearer MANAGEMENT_JWT
{
"workflows": ["basic-device-activation"]
}
This is a JSON Merge Patch: omitted fields are unchanged, and workflows is replaced as a whole.
A2. Register the device
POST https://api.example.com/api/devices/register
Content-Type: application/json
Authorization: Bearer MANAGEMENT_JWT
{
"deviceId": "DEVICE_ID",
"attestationType": "secret",
"enrollmentGroupId": "ENROLLMENT_GROUP_ID"
}
Capture secret from the 201 response. It is returned only here and cannot be retrieved
afterward — store it and provision it to the device immediately. If it is lost, re-register the
device to mint a new one.
For many devices use POST /api/devices/register/bulk with application/x-ndjson, one
registration object per line. See How to register devices.
A3. Run the activation workflow
POST https://api.example.com/api/enrollment-groups/ENROLLMENT_GROUP_ID/workflows/basic-device-activation/run
Content-Type: application/json
Authorization: Bearer MANAGEMENT_JWT
{
"params": {
"device.id": "DEVICE_ID"
}
}
Supply only device.id — the group supplies the rest. Useful optional inputs:
| Input | Effect |
|---|---|
asset.id | Asset identity; defaults to the device id |
asset.display_name | Human-readable asset name; defaults to the asset id |
asset.tag.KEY | Adds tag KEY:value to the asset; any number of these |
client.display_name | Provider client name |
client.id | Provider client identity |
Confirm the exact split for your group before running:
GET https://api.example.com/api/enrollment-groups/ENROLLMENT_GROUP_ID/workflows/basic-device-activation
Authorization: Bearer MANAGEMENT_JWT
The response carries callerRequiredInputs, callerOptionalInputs, and groupSuppliedInputs.
That is authoritative; this page is not.
A4. Verify
201 means the device was newly provisioned — provider client, asset, and binding created.
Other outcomes are listed under If it doesn't work.
Part B — Firmware
B1. Fetch connection settings
GET https://devices.example.com/get_settings
Authorization: Basic DEVICE_ID:ENROLLMENT_SECRET
The body is rendered from the enrollment group's response template. Four keys are the device-facing contract and must appear flat at the top level, in snake_case:
{
"broker_url": "BROKER_HOST",
"broker_port": 8884,
"est_enrollment_url": "https://devices.example.com",
"est_renewal_url": "https://devices.example.com",
"topics": {
"telemetry": "device/DEVICE_ID/telemetry",
"twin_desired": "device/DEVICE_ID/twin/desired",
"twin_reported": "device/DEVICE_ID/twin/reported",
"command_invoke": "device/DEVICE_ID/command/+/invoke",
"command_response": "device/DEVICE_ID/command/{name}/response/{correlationId}"
}
}
| Key | Meaning |
|---|---|
broker_url | MQTT broker hostname |
broker_port | MQTT broker port — the mTLS listener |
est_enrollment_url | Base URL for first enrollment and cacerts |
est_renewal_url | Base URL for mTLS certificate renewal |
topics | Additive topic map — see below |
broker_url, broker_port, est_enrollment_url, and est_renewal_url must be top-level scalars.
Grouping them into nested broker or est objects is a template authoring error: the response
still renders, but device tooling that reads the contract will not find them.
The EST URLs are base URLs — append the paths from B2 and B3.
topics is an additive object beyond the four contract keys. command_invoke is a subscription
filter; publish results to command_response, substituting the invoked command name and the
correlationId from the invoke payload.
The enrollment secret is not consumed by this call. Keep it: the device needs it again after firmware updates and to re-enroll once its certificate expires.
B2. Fetch and pin the CA chain
GET https://devices.example.com/.well-known/est/cacerts
Anonymous. Add ?device_id=DEVICE_ID to scope the chain to the device's routing target.
This is the tenant's Device CA. Pin it — it validates the MQTT broker's server certificate in B5.
Use the canonical RFC 7030 /.well-known/est/... paths. EST client libraries derive them from a
bare hostname automatically, and they work in every environment. Tenant deployments also accept the
short /est/... form — see Path aliases.
B3. Enroll
POST https://devices.example.com/.well-known/est/serverkeygen
Authorization: Basic DEVICE_ID:ENROLLMENT_SECRET
No request body. 200 returns the certificate and private key in the group's configured format:
| Format | Response |
|---|---|
pkcs7 (default) | multipart/mixed — base64 PKCS#7 certs-only part, plus a base64 PKCS#8 private-key part |
pem | application/x-pem-file — certificate PEM followed by a PKCS#8 PRIVATE KEY PEM |
The issued certificate is an ECDSA P-256 leaf signed ecdsa-with-SHA384, subject CN=DEVICE_ID,
extended key usage clientAuth, valid 90 days.
The call is idempotent. An already-enrolled device may call it again with its secret to obtain a fresh certificate.
B4. Store the credentials
- Put the private key and the enrollment secret in the secure element or secure storage. The key never leaves the device; on renewal, overwrite it with the newly issued key.
- Keep the enrollment secret for the life of the device. Transmit it only as Basic auth to
get_settingsandserverkeygen. - There is no recovery if the secret is lost — the device must be re-registered, which mints a new one.
- Retry every onboarding step with exponential backoff. All of them are safe to retry.
B5. Connect over mTLS
Read the broker URL and port from the B1 response. Do not hardcode them — they follow the device's routing target.
| Parameter | Value |
|---|---|
| Broker | From get_settings |
| Port | From get_settings — the mTLS listener |
| TLS | Mutual. The device presents its EST-issued certificate; validate the server against the chain pinned in B2 |
| Username | Taken from the client certificate. The broker uses the certificate CN, which is the device id — send no password |
| Client id | The device id |
B6. Publish telemetry
Use the topics from the B1 response. Treat that topics object as the complete topic map rather
than composing topics in firmware.
Payload field names must match the device's model definition.
B7. Renew before expiry
Renew with the current operational certificate over mTLS — same endpoint, no Basic credentials, no body:
POST /.well-known/est/serverkeygenover mTLS.200returns a new certificate and new private key, in the same formats as B3.- Store both; discard the old ones.
- Reconnect to the broker with the new certificate.
Renewal needs no enrollment secret and does not change device state.
Try mTLS, fall back to Basic
mTLS renewal requires onboarding 2.19.1 or newer and ingress certificate forwarding configured for the deployment. The version alone is not sufficient, and there is no endpoint that reports whether a given tenant has both.
Firmware should therefore attempt the mTLS call and fall back on failure, rather than trying to detect support up front:
POST /.well-known/est/serverkeygenover mTLS with the current certificate.- On
200, store the new certificate and key. Done. - On
401— the response carrieswww-authenticate: Bearerand an empty body — retry the same endpoint with BasicDEVICE_ID:ENROLLMENT_SECRET.
The fallback always works, because the enrollment secret is permanent. It is also the recovery path
for a certificate that has already expired, where mTLS is rejected at the TLS layer before the
request is even seen. Basic-auth renewal is permitted when the group's renewal policy is Allow.
Build the fallback in from the start. A device that only speaks mTLS renewal is unrecoverable on a tenant that lacks forwarding, and unrecoverable once its certificate lapses.
If you renew with simplereenroll instead
serverkeygen over mTLS is the simpler firmware path — no body, and the server returns both the
certificate and the key. If you use simplereenroll and submit your own CSR, two extra rules apply:
| Rule | Failure |
|---|---|
| The CSR must use a freshly generated key, not the current one | 400 csr_public_key_reuses_current_key |
The CSR must carry the same SAN as the current certificate — URI urn:beacontower:device:DEVICE_ID | 400 san_mismatch |
A CSR subject that does not match the current certificate is rejected with 400 subject_mismatch.
Device lifecycle
Placeholders
| Placeholder | Meaning |
|---|---|
ENROLLMENT_GROUP_ID | The enrollment group's id — attestation secret, operational credential certificate |
DEVICE_ID | The device's identity: certificate CN, MQTT username and client id, topic segment |
ENROLLMENT_SECRET | The device's enrollment secret, minted at registration in A2 |
MANAGEMENT_JWT | The operator's bearer token |
BROKER_HOST | MQTT broker endpoint — always read from get_settings |
If it doesn't work
| Symptom | Action |
|---|---|
405 on the enrollment-group update | Use PATCH, not PUT |
400 validation_failed on the enrollment-group PATCH, naming a member | The key is misspelled or wrongly cased — it is workflows |
409 on the enrollment-group PATCH | Concurrent modification — retry |
400 workflow_input_missing on the run | Add the keys named in missingFields and re-run |
409 device_already_provisioned on the run | The device is already active — tear it down first to re-provision |
409 otherwise on the run | The device's state blocks the run — check the device record |
503 on the run | Safe to retry; the engine resumes uncompleted steps |
401 from get_settings or serverkeygen with Basic | Check the device id and secret. If the secret is lost, re-register the device (A2) |
400 from EST | Malformed device id — correct and retry |
429 from EST | Rate limited — back off and retry |
202 from serverkeygen with Basic | Back off per the Retry-After header and retry |
401 from serverkeygen over mTLS, www-authenticate: Bearer and empty body | mTLS renewal is unavailable on this deployment — fall back to Basic (B7) |
404 from serverkeygen over mTLS | Device or group not found, or the group is disabled — escalate to the platform operator |
403 from serverkeygen over mTLS | Device not eligible — escalate to the platform operator |
400 csr_public_key_reuses_current_key from simplereenroll | Generate a fresh keypair for the CSR |
400 san_mismatch from simplereenroll | The CSR SAN must match the current certificate: URI urn:beacontower:device:DEVICE_ID |
400 subject_mismatch from simplereenroll | The CSR subject must match the current certificate |
503 or unreachable from get_settings | Retry with exponential backoff |
See also
- Registered workflows — inputs and steps for
basic-device-activation - Workflow error codes
- Onboarding flows — the tier model and EST
- MQTT Protocol Reference — topic tree and payloads