Provider SDK Public Surface
The Provider SDK exposes its public contract across three transports: an HTTP REST API, a NATS bus API, and a CloudEvents-based event bus. This page is the canonical map of that surface — what you can call, what you can subscribe to, and the conventions that hold across all three.
For the .NET library that implements this surface, see the Provider SDK section. For step-by-step device wiring, see the Device Connectivity guide.
Release notes — 1.38.x (canonical wire + templateId passthrough)
Released: mqttprovider v1.38.x, paired with onboarding v1.41.x.
The provider control-plane RPC (provision / unprovision / get-credential / device-exists / set-state / revoke-certificate / get-device-data / set-desired / invoke-method / get-desired / get-reported) moves from HTTP+OAuth2 to the canonical BeaconTower wire:
- Transport: NATS, via a keyed
INatsConnection("btbus") registered byBeaconTower.BusApi. - Serialization: MessagePack (
[MessagePackObject]records). - Contracts:
BeaconTower.Bus.Contracts ≥ 1.1.0(Provider/*,Coremgmt/*,Common/*). - Subjects: built from
BeaconTower.Bus.Contracts.Common.BusApiSubjects. - Reply envelope:
BusApiResult<TResponse>discriminates success vs. structuredErrorResponse.
templateId passthrough is the second half of the migration: onboarding
sends only an opaque TemplateId on the provision request; the SDK's
ITemplateClient resolves it against core-management on demand
(bt.coremgmt.providerTemplates.get), with a 60 s positive + negative cache
and a 5 s call budget.
Breaking changes
- HTTP+OAuth2
provider-apipath is removed. Pre-1.38 mqttprovider builds talking to pre-1.41 onboarding over HTTP no longer interop with current builds. There is no soft-deprecation window — both sides must roll forward together. Initial*template fields are removed from the provision contract. Onboarding sendsTemplateIdonly; templates are resolved at the provider edge.
Migration call-outs
If you operate a provider that fronts onboarding's NATS RPC (for example, an
in-house bridge to a cloud IoT hub), update against
BeaconTower.Bus.Contracts ≥ 1.1.0:
- Add NuGet references —
BeaconTower.Bus.ContractsandBeaconTower.BusApi(see your service'snuget.configfor the source mapping). - Wire
AddBeaconTowerBusApibeforeAddBeaconTowerProvider— the SDK resolves the keyed"btbus"connection as a dependency. See Configuration › Bus API. - Subscribe on canonical subjects built from
BusApiSubjects(seebt.provider.*subject map). - Reply with
BusApiResult<TResponse>— never raw response records. InspectIsSuccessbefore readingResponse. - Stop sending template payloads — onboarding now sends
TemplateIdonly; if you proxy the provision request, forward the ID unchanged.
Reference material
- Provider SDK overview › Canonical wire and
templateIdpassthrough - Template Resolution — wire shape, cache, transport-fault map
- Reference › Canonical-wire reply envelope
- Reference ›
ITemplateClient
Transport overview
┌─────────────────────┐ ┌─────────────────────┐
│ Onboarding service │◀──────│ Operator / Admin │ HTTP (JWT Bearer)
│ Provider service │ └─────────────────────┘
└──────────┬──────────┘
│ NATS request-reply (bus API)
│ NATS JetStream (events)
▼
┌─────────────────────────────────────────────────┐
│ Other Beacon Tower services (asset, flow, ...) │
└─────────────────────────────────────────────────┘
| Transport | Audience | Auth | Pattern |
|---|---|---|---|
HTTP REST (/api/...) | Operators, automation | JWT Bearer | Synchronous, idempotent |
HTTP REST (/devices/...) | Service-to-service | X-Api-Key header | Synchronous, idempotent |
| HTTP REST (device-facing) | Devices on first boot | HTTP Basic (deviceId:bootstrapKey) | Synchronous |
| NATS request-reply | Internal services | NATS auth (mTLS) | Synchronous, 5 s timeout |
| NATS JetStream | Internal subscribers | NATS auth (mTLS) | Asynchronous, durable |
Provider HTTP API
Every protocol provider (MQTT, AMQP, HTTP polling, …) implements the same three endpoints. Onboarding and operator tools call these endpoints over service-to-service auth.
POST /devices/{deviceId}/provision
Idempotent device registration. The first call creates the device and returns freshly generated credentials. Subsequent calls return the same credentials (or new ones, depending on the regenerate flag).
Auth: X-Api-Key header.
Response 200 OK
Content-Type: application/json
{
"device_id": "pump-042",
"created": true,
"primary_key": "base64...",
"secondary_key": "base64..."
}
created: true indicates the first call; created: false means the device already existed.
GET /devices/{deviceId}
Existence probe. Returns 200 with { exists: true, device_id, status } if the device is registered, 404 otherwise. Onboarding uses 404 as the canonical "not provisioned" signal.
GET /devices/{deviceId}/credentials
Returns the device's decrypted primary and secondary keys. Used internally during the bootstrap flow to render device connection settings.
Response 200 OK
{
"device_id": "pump-042",
"primary_key": "base64...",
"secondary_key": "base64..."
}
Onboarding HTTP API (device-facing)
These endpoints are called by the device itself during its first boot. They are exposed by the onboarding service, not by the provider.
GET /get_settings
Auth: HTTP Basic (deviceId:bootstrapKey).
Returns a JSON document containing the device's MQTT (or other transport) connection settings. The exact shape is defined per enrollment group via a response template, but the canonical Tier 1 shape is:
Response 200 OK
{
"url": "mqtts://mqtt.example.com:8883",
"client_id": "pump-042",
"username": "pump-042",
"password": "<primary_key>"
}
The device must connect to the host in url by name — never by IP — and send it as the TLS SNI;
see TLS, Hostname, and SNI.
| Status | Meaning |
|---|---|
| 200 | Settings rendered successfully |
| 401 | invalid_shared_key — collapses every pre-condition failure so the endpoint cannot be used to probe enrollment state |
| 403 | device_not_provisioned — the device is registered but was never activated |
| 503 | Provider unavailable (NATS request-reply timeout) |
See the Onboarding Device API for the generated contract.
Activation
Admin-side provisioning is no longer a single endpoint. A device is registered with
POST /api/devices/register, then activated by running its enrollment group's activation
workflow:
POST /api/enrollment-groups/{groupId}/workflows/device-activation/run
A fresh activation returns 201. Running it again against an already-active device is rejected
with 409 device_already_provisioned; 200 is returned only when a failed run is resumed through
the retry route. See
How to run a workflow and the
Onboarding Management API.
The provider's own device surface is separate and lives under /api/devices on the provider host —
including POST /api/devices/{deviceId}/provision, which onboarding calls on your behalf.
Bus API (NATS request-reply)
The bus API uses NATS subjects for synchronous request-reply between services. A provider answers on provider.{providerId}.client.*, where {providerId} is the SDK's ProviderId. The provider's type (mqtt, iothub, http) is not part of any subject. The subject for each operation comes from the SubjectFor(providerId) method of its request type in BeaconTower.Bus.Contracts.
| Subject | Purpose | Request type |
|---|---|---|
provider.mqtt.client.provision | Onboarding provisions a device on the provider | ProvisionRequest |
provider.mqtt.client.credential.get | Onboarding fetches a device's MQTT credentials | GetCredentialRequest |
provider.mqtt.client.command.invoke | Core management invokes a command on a device | InvokeCommandRequest |
Default reply timeout: 5 seconds. Callers must handle timeouts as transient failures and retry.
For the full subject layout used by your provider, list NATS streams or read the provider's bus-api consumer registration.
Events catalog (NATS JetStream)
The provider publishes events to NATS JetStream under the beacontower.> namespace. All events use the CloudEvents 1.0 envelope. The type attribute follows the convention:
cloud.beacontower.{service}.{action}
The full schema set is in the BeaconTower.Events.Contracts package, which the SDK pulls in and btk3s provider fetch places in your project's packages/.
schemaVersion convention
Beacon Tower uses type-name versioning rather than an explicit schemaVersion field. The CloudEvent type attribute carries the version implicitly:
- Compatible additions (new optional fields) keep the same
type. - Breaking changes mint a new event type with a version suffix, e.g.
cloud.beacontower.{service}.{action}.v2.
Consumers MUST filter by type exactly and MUST NOT assume forward compatibility across major versions.
Authentication
The platform uses three distinct auth schemes — choose by audience:
JWT Bearer (operator API)
Endpoints under /api/... require a JWT Bearer token. The validator checks:
issagainst the configured authorityaudagainst the service's audienceroleclaim against the policy (e.g.,DeviceAdmin)
Token issuance is out of scope for the SDK — providers consume tokens only.
X-Api-Key (service-to-service)
Endpoints under /devices/... are not intended for end users. They authenticate via a static API key in the X-Api-Key header. Onboarding holds this key in its config; rotate via the provider's secret store.
HTTP Basic (device bootstrap)
The device-facing /get_settings endpoint uses HTTP Basic Auth with the device ID as the username and the bootstrap key as the password. This is the only entry point that accepts bootstrap keys.
Error contract
All HTTP error responses use a uniform JSON shape (NOT RFC 7807 application/problem+json):
{
"error": "enrollment_group_not_found",
"message": "Enrollment group 'tier1-pumps' does not exist"
}
| Field | Required | Description |
|---|---|---|
error | yes | Machine-readable error code, snake_case |
message | no | Human-readable description, may be localised |
Common error codes:
| Code | HTTP status | Meaning |
|---|---|---|
device_not_found | 404 | The device ID is not registered |
enrollment_group_not_found | 404 | The enrollment group is unknown |
bootstrap_key_invalid | 401 | The supplied bootstrap key is wrong or revoked |
provider_unavailable | 503 | Bus-API request to the provider timed out |
device_already_exists | 409 | Concurrent provisioning lost a race |
Reserved namespaces
The platform reserves the following identifier namespaces. Providers and integrators MUST NOT publish or register under them.
| Namespace | Used for |
|---|---|
beacontower.* (NATS subjects) | All platform-published JetStream events |
bt.provider.* (NATS subjects) | Provider bus-API request-reply queries |
cloud.beacontower.* (CloudEvent types) | All platform CloudEvent type names |
device/{deviceId}/# (MQTT topics) | Device-scoped telemetry, twin, and methods |
Custom integrations should pick a distinct namespace prefix (for example, your organisation's reverse-DNS) for any subjects, types, or topics they introduce.
Related references
- Provider SDK overview — the .NET library surface
- MQTT Provider concepts — broker integration internals
- Onboarding concepts — the flow that drives
/devices/* - Device Connectivity guide — concrete device wiring