Devices - Create

Create or update a device
Create a new device.

PUT https://{subdomain}.{baseDomain}/api/devices/{deviceId}?api-version=2022-07-31

URI Parameters

Name In Required Type Description
baseDomain
path True

string

The base domain for all Azure IoT Central service requests.

deviceId
path True

string

Unique ID of the device.

subdomain
path True

string

The application subdomain.

api-version
query True

string

The version of the API being called.

Request Body

Name Type Description
displayName

string

Display name of the device.

enabled

boolean

Whether the device connection to IoT Central has been enabled.

etag

string

ETag used to prevent conflict in device updates.

organizations

string[]

List of organization IDs that the device is a part of, only one organization is supported today, multiple organizations will be supported soon.

simulated

boolean

Whether the device is simulated.

template

string

The device template definition for the device.

Responses

Name Type Description
200 OK

Device

Success

Other Status Codes

Error

An error response received from the IoT Central Service.

Headers

x-ms-error-code: string

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Create device

Sample Request

PUT https://appsubdomain.azureiotcentral.com/api/devices/ccc?api-version=2022-07-31

{
  "displayName": "CheckoutThermostatccc",
  "template": "dtmi:contoso:testDeviceTemplate;1",
  "simulated": true,
  "enabled": true,
  "organizations": [
    "seattle"
  ]
}

Sample Response

{
  "id": "ccc",
  "etag": "eyJoZWFkZXIiOiJcIjE1MDE2ZDFiLTAwMDAtMGQwMC0wMDAwLTVkYWNkNDIxMDAwMFwiIiwiZGF0YSI6IlwiMTUwMTZhMWItMDAwMC0wZDAwLTAwMDAtNWRhY2Q0MjEwMDAwXCIifQ",
  "displayName": "CheckoutThermostatccc",
  "template": "dtmi:contoso:testDeviceTemplate;1",
  "simulated": true,
  "provisioned": false,
  "enabled": true,
  "organizations": [
    "seattle"
  ]
}

Definitions

Name Description
Device

The device definition.

Error

The response error definition.

ErrorDetails

The detail information of the error.

Device

The device definition.

Name Type Description
displayName

string

Display name of the device.

enabled

boolean

Whether the device connection to IoT Central has been enabled.

etag

string

ETag used to prevent conflict in device updates.

id

string

Unique ID of the device.

organizations

string[]

List of organization IDs that the device is a part of, only one organization is supported today, multiple organizations will be supported soon.

provisioned

boolean

Whether resources have been allocated for the device.

simulated

boolean

Whether the device is simulated.

template

string

The device template definition for the device.

Error

The response error definition.

Name Type Description
error

ErrorDetails

Error details for current request.

ErrorDetails

The detail information of the error.

Name Type Description
code

string

Error code.

message

string

Error message details.

requestId

string

Correlation Id for current request.

time

string

The time that error request failed.