Skip to main content
POST
/
api
/
ext-v1
/
deviceAssignment
/
assignDevicesToOwner
curl -X POST https://admin.telemetron.ai/api/ext-v1/deviceAssignment/assignDevicesToOwner \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "john.doe@example.com",
    "deviceIdentifiers": ["SN-001", "SN-002", "SN-003"]
  }'
{
  "success": true,
  "message": "Successfully assigned 2 device(s) to customer",
  "customerId": "cust_abc123",
  "customerWasCreated": false,
  "assignedDevices": [
    { "identifier": "SN-001", "deviceId": "dev_x1y2z3", "wasCreated": false }
  ],
  "alreadyAssigned": [
    { "identifier": "SN-002", "deviceId": "dev_a4b5c6", "wasCreated": false }
  ],
  "skipped": ["SN-003"]
}

Overview

Assigns multiple devices to a single customer in one request. This is the bulk variant for assigning devices — use this when provisioning several devices for the same customer. Features:
  • Assign multiple devices to one customer in a single call
  • Auto-creates the customer if they don’t exist
  • Optional auto-create for devices (requires deviceType)
  • Reports which devices were newly assigned, already assigned, or skipped

Authentication

x-api-key
string
required
Your organization’s API key

Request Body

customerEmail
string
required
The email address of the customer to assign devices to. Must be a valid email format.
deviceIdentifiers
array
required
Array of device identifiers (e.g., serial numbers, MAC addresses) to assign. Must be a non-empty array.
autoCreateDevices
boolean
default:false
If true, creates devices automatically if they don’t exist in the system. Defaults to false.
deviceType
string
Required when autoCreateDevices is true. Specifies the device type (e.g., “sensor”, “Thermostat”, “Gateway”).

Response

success
boolean
Indicates if the operation was successful
message
string
Description of the operation result
customerId
string
The unique identifier of the customer in Telemetron
customerWasCreated
boolean
Indicates whether the customer was created during this operation
assignedDevices
array
Array of devices that were newly assigned in this request
alreadyAssigned
array
Array of devices that were already assigned to this customer (no-op)
skipped
array
Array of device identifier strings that were not found in the system (when autoCreateDevices is false)

Examples

Basic Bulk Assignment

curl -X POST https://admin.telemetron.ai/api/ext-v1/deviceAssignment/assignDevicesToOwner \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "john.doe@example.com",
    "deviceIdentifiers": ["SN-001", "SN-002", "SN-003"]
  }'

With Auto-Create Devices

curl -X POST https://admin.telemetron.ai/api/ext-v1/deviceAssignment/assignDevicesToOwner \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "john.doe@example.com",
    "deviceIdentifiers": ["SN-001", "SN-002"],
    "autoCreateDevices": true,
    "deviceType": "sensor"
  }'

Response

{
  "success": true,
  "message": "Successfully assigned 2 device(s) to customer",
  "customerId": "cust_abc123",
  "customerWasCreated": false,
  "assignedDevices": [
    { "identifier": "SN-001", "deviceId": "dev_x1y2z3", "wasCreated": false }
  ],
  "alreadyAssigned": [
    { "identifier": "SN-002", "deviceId": "dev_a4b5c6", "wasCreated": false }
  ],
  "skipped": ["SN-003"]
}
curl -X POST https://admin.telemetron.ai/api/ext-v1/deviceAssignment/assignDevicesToOwner \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "john.doe@example.com",
    "deviceIdentifiers": ["SN-001", "SN-002", "SN-003"]
  }'
{
  "success": true,
  "message": "Successfully assigned 2 device(s) to customer",
  "customerId": "cust_abc123",
  "customerWasCreated": false,
  "assignedDevices": [
    { "identifier": "SN-001", "deviceId": "dev_x1y2z3", "wasCreated": false }
  ],
  "alreadyAssigned": [
    { "identifier": "SN-002", "deviceId": "dev_a4b5c6", "wasCreated": false }
  ],
  "skipped": ["SN-003"]
}

Status Codes

CodeDescription
200Devices successfully assigned to customer
400Invalid request (missing required fields, empty array, or no valid devices)
401Invalid or missing API key
500Internal server error

Implementation Notes

  • Idempotent: Devices already assigned to the customer are reported in alreadyAssigned — no duplicates are created
  • Auto-create customer: The customer is automatically created if they don’t exist
  • Partial success: The response details which devices were assigned, already assigned, or skipped, allowing you to handle each case
  • Skipped devices: When autoCreateDevices is false, unknown device identifiers are returned in the skipped array
Required: When autoCreateDevices is true, you must provide deviceType or the request will fail with a 400 error.