Skip to main content

Your First Asset via API

A quickstart for creating your first asset programmatically using the Beacon Tower REST API. This guide covers the full workflow: authentication, model creation, asset creation, provider client provisioning, and binding.

Prerequisites​

Before you begin, ensure you have:

  • A Beacon Tower account with appropriate privileges (at minimum: asset_management and model_management)
  • Access to the API base URL for your Beacon Tower instance (e.g., https://api.beacontower.ai)
  • An HTTP client such as curl, Postman, or similar
  • A configured provider (e.g., an IoT Hub provider) — providers are typically set up by your platform operations team

Step 1: Authenticate​

Obtain a JWT access token using the Resource Owner Password Credentials (ROPC) flow:

curl -X POST https://api.beacontower.ai/auth/ropc \
-H "Content-Type: application/json" \
-d '{
"username": "user@example.com",
"password": "your-password"
}'

Response:

{
"accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Store the access token for convenience:

export TOKEN="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."

The token is valid for 60 minutes and the response carries no refresh token, so a longer session has to log in again.

Several later steps need an organization id. List yours:

curl -s https://api.beacontower.ai/organizations \
-H "Authorization: Bearer $TOKEN" | jq -r '.[] | "\(.id) \(.displayName)"'

export ORG_ID="<the id you want>"

For detailed information about authentication methods, see the Authentication guide.

Step 2: Create a Model​

Assets are instances of models defined using DTDL. Before creating an asset, you must create and publish a model.

Create a Model Draft​

The request body is a wrapper object. The DTDL interface goes inside modelData, which is an array.

export MODEL_ID="dtmi:mycompany_temperatureSensor;1.1"

curl -X POST https://api.beacontower.ai/models/drafts \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "'"$MODEL_ID"'",
"dtdlModelId": "'"$MODEL_ID"'",
"displayName": "Temperature Sensor",
"modelType": "asset",
"draft": true,
"modelData": [
{
"@id": "'"$MODEL_ID"'",
"@context": [
"dtmi:dtdl:context;3",
"dtmi:dtdl:extension:quantitativeTypes;1"
],
"@type": "Interface",
"displayName": "Temperature Sensor",
"contents": [
{
"@id": "dtmi:mycompany_temperatureSensor:_c:temperature;1.1",
"@type": ["Telemetry", "Temperature"],
"name": "temperature",
"displayName": "Temperature",
"schema": "double",
"unit": "degreeCelsius"
}
]
}
]
}'

201 Created, with an empty body. There is no separate draft id — the draft is addressed by the model id you chose, so $MODEL_ID is what the next call uses.

Two things about that id:

  • It needs a major and a minor version, and the minor may not be zero. ;1 is refused with "Major and minor versions are required on models", and ;1.0 with "Invalid model ID".
  • The Temperature semantic type and unit come from the quantitative types extension, so @context must include dtmi:dtdl:extension:quantitativeTypes;1. Without it the draft is accepted and promote later fails with 422.
Check the model before you send it

POST /models/dtdl/validate, with the same body, returns readable messages. POST /models/drafts answers 400 with an empty body, so it cannot tell you what is wrong.

Promote the Model​

Draft models are not usable until promoted. The call needs organizationId as a query parameter:

curl -X POST "https://api.beacontower.ai/models/drafts/$MODEL_ID/promote?organizationId=$ORG_ID" \
-H "Authorization: Bearer $TOKEN"

204 No Content. The model is now published and ready for use.

Step 3: Create the Asset​

With the model published, create an asset instance:

curl -X POST https://api.beacontower.ai/assets \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "temp-sensor-001",
"modelId": "dtmi:mycompany:TemperatureSensor;1",
"displayName": "Temperature Sensor 001",
"organizationId": "your-org-id"
}'

Note: organizationId is required. This determines which organization owns the asset and controls access permissions.

The asset exists but is not yet connected to any data source. To receive telemetry, you need to bind it — either to a provider client (for external devices) or to another asset (for asset-to-asset data routing).

Binding: Two Approaches​

Beacon Tower supports two binding approaches depending on where the data comes from:

ApproachWhen to UseKey Concept
Provider Client + AutobindConnecting to an external device (IoT Hub, MQTT, etc.)Create a provider client, provision it on the provider infrastructure, then autobind
Binding DescriptionRouting data from one asset to anotherUse a binding description to define how signals map between asset models

This quickstart covers the provider client approach since it's the most common for connecting physical devices. See Binding with Binding Descriptions at the end for the asset-to-asset flow.

Step 4: Create a Provider Client​

A provider client represents your device's identity on the provider infrastructure. You need the provider ID for your target provider (ask your administrator).

List the providers configured on your tenant:

curl -s https://api.beacontower.ai/providers \
-H "Authorization: Bearer $TOKEN" | jq -r '.[] | "\(.id) \(.type) \(.displayName)"'
export PROVIDER_ID="<the id from that list>"

curl -X POST https://api.beacontower.ai/providers/$PROVIDER_ID/clients \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"id": "device1",
"displayName": "Temperature Device 1",
"organizationId": "your-org-id",
"enabled": true
}'

The id must be unique within the provider. This becomes the device identity used for authentication and message routing.

Step 5: Provision the Provider Client​

Provisioning registers the provider client on the provider's infrastructure. For an IoT Hub provider it creates the device identity on the hub and generates its keys. The request body is the same for every provider built on the Provider SDK; only the options object depends on the provider type.

FieldRequiredMeaning
optionsYesProvider-specific settings. Use {} when the provider needs none.
templateIdNoA provider template that supplies default options and the parser for the device's telemetry.
authMethodNoSymmetricKey (default) or Certificate.
enabledNoWhether the device may connect. Defaults to true.
externalIdNoYour own identifier for the device, for example a serial number. It must be unique within the provider.

IoT Hub Device (minimal)​

curl -X POST https://api.beacontower.ai/providers/$PROVIDER_ID/clients/device1/provision \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"options": {}
}'

IoT Hub Device (with template, auth method, tags and desired properties)​

curl -X POST https://api.beacontower.ai/providers/$PROVIDER_ID/clients/device1/provision \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"templateId": "template-uuid",
"authMethod": "SymmetricKey",
"enabled": true,
"externalId": "SN-000123",
"options": {
"tags": {
"site": "plant-a"
},
"desiredProperties": {
"updateInterval": 10
}
}
}'

options.tags and options.desiredProperties are the two keys every SDK provider understands. They set the device twin's tags and desired properties at provisioning time. The hub is not part of the request. One IoT Hub provider is connected to one hub; the platform operations team configures it.

After provisioning, the provider client's providerData has what a device needs to connect:

KeyMeaning
hostNameThe hub's host name, for example my-hub.azure-devices.net
primaryKey, secondaryKeyThe device keys, in the form IoT Hub uses (standard base64)
primaryConnectionString, secondaryConnectionStringReady-to-use device connection strings
authenticationTypesas for symmetric keys, certificateAuthority for CA-signed certificates
curl -s "https://api.beacontower.ai/providers/$PROVIDER_ID/clients/device1" \
-H "Authorization: Bearer $TOKEN" | jq -r '.providerData.primaryConnectionString'

Step 6: Bind the Asset​

Now bind the asset to the provisioned provider client using autobind. The autobind function automatically creates content bindings that map the provider client's signals to the asset's telemetry definitions.

curl -X POST https://api.beacontower.ai/assets/temp-sensor-001/bind \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"autobindRemoteInstanceIds": [
"'$PROVIDER_ID'::device1"
]
}'

The autobindRemoteInstanceIds format is {providerId}::{clientId}. Autobind generates a default binding description if one doesn't exist, mapping signals from the provider client to matching telemetry definitions in the asset's model.

The asset is now fully connected. When the device sends telemetry through the provider, the data flows into the asset.

Connect a device​

Nothing has sent any data yet, so step 7 would return an empty result. Point a device at the broker first:

The device connects with its device id as the username and its primary key as the password. Provisioning in step 5 is what created that key; read it back from the provider client:

curl -s "https://api.beacontower.ai/providers/$PROVIDER_ID/clients/device1" \
-H "Authorization: Bearer $TOKEN" | jq -r '.providerData.primaryKey'

Then publish flat JSON, keyed by the telemetry names on your model, to device/device1/telemetry:

{"temperature": 22.5}

Step 7: Query Telemetry​

Once your device starts sending data, query it using the timeseries endpoints.

Get Latest Values​

curl -X POST https://api.beacontower.ai/timeseries/get/last \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"items": [
{
"assetId": "temp-sensor-001",
"componentId": null,
"timeseries": null
}
]
}'

Get Historical Data​

curl -X POST https://api.beacontower.ai/timeseries/get \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"assetId": "temp-sensor-001",
"timeseriesName": ["temperature"],
"searchSpanFrom": "2024-01-15T00:00:00Z",
"searchSpanTo": "2024-01-15T23:59:59Z",
"aggregationType": "avg",
"aggregationInterval": "PT5M"
}'

See Telemetry and Timeseries for details on aggregation types and intervals.

Expected status codes​

The calls above do not all answer the same way. What each returns on success:

CallSuccess
POST /auth/ropc200, with accessToken
POST /models/dtdl/validate200
POST /models/drafts201, empty body
POST /models/drafts/{id}/promote204
POST /assets201
POST /providers/{p}/clients200
POST /providers/{p}/clients/{c}/provision200
POST /assets/{id}/bind200
POST /timeseries/get/last200

Summary: Provider Client Flow​

The complete sequence for connecting an asset to an external device:

1. Create Model Draft    POST /models/drafts
2. Promote Model POST /models/drafts/{id}/promote
3. Create Asset POST /assets
4. Create Provider Client POST /providers/{providerId}/clients
5. Provision Client POST /providers/{providerId}/clients/{clientId}/provision
6. Bind Asset POST /assets/{assetId}/bind (autobindRemoteInstanceIds)

Binding with Binding Descriptions​

When routing data from one asset to another (instead of from a provider client), you use binding descriptions. A binding description defines how signals from a source asset model map to a target asset model.

When to Use​

  • Aggregating data from multiple assets into a summary asset
  • Routing processed data from one asset to another
  • Creating hierarchical data flows between asset models

Flow Overview​

1. Create both assets (source and target)
2. Get or generate a binding description for the target model
3. Bind the target asset using the binding description + source asset ID

Step 1: Get Binding Descriptions for a Model​

Check if a binding description already exists for your target model:

curl -X GET https://api.beacontower.ai/bindings/model/$TARGET_MODEL_ID \
-H "Authorization: Bearer $TOKEN"

This returns binding descriptions that define which source models are compatible (sources array) and how signals map between them.

Step 2: Generate a Binding Description (if needed)​

If no existing binding description fits, generate one:

curl -X POST https://api.beacontower.ai/bindings/generate/$TARGET_MODEL_ID/$SOURCE_MODEL_ID \
-H "Authorization: Bearer $TOKEN"

Then save the generated binding description:

curl -X POST https://api.beacontower.ai/bindings \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '<generated-binding-description>'

Step 3: Bind Using the Binding Description​

curl -X POST https://api.beacontower.ai/assets/$TARGET_ASSET_ID/bind \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"bindingDescriptions": [
{
"bindingDescriptionId": "btbi:dtmi:myModel;1:myBinding;1",
"instances": [
{
"instanceName": "Source Sensor",
"instanceId": "source-asset-id"
}
]
}
]
}'

The instances array maps source assets to the binding description's source slots. The system creates content bindings that route telemetry from the source asset into the target asset.


Next Steps​

For step-by-step guidance using the web interface, see Your First Asset via Web UI.