Skip to main content

Devices

Manage AsaHome OS devices in your account.

Endpoints Overview

MethodEndpointDescriptionAuth
POST/devices/registerRegister a new deviceYes
GET/devicesList user's devicesYes
GET/devices/:idGet device detailsYes
PUT/devices/:idUpdate deviceYes
POST/devices/:id/linkLink device to userYes
POST/devices/auth/:uuidGet device auth tokenYes
POST/devices/heartbeat/:uuidDevice heartbeatYes

Base URL: https://cloud.asahome.io/api/v1


POST Register Device

Register a new AsaHome OS device with the cloud service.

Request

POST /api/v1/devices/register

Headers

HeaderRequiredDescription
AuthorizationYesBearer <accessToken>

Request Body

FieldTypeRequiredDescription
uuidstringYesDevice UUID (from AsaHome OS)
deviceIdstringYesHuman-readable device ID
namestringYesDisplay name for the device
ipAddressstringNoLocal IP address
portstringNoDevice API port (default: 8123)
metadataobjectNoAdditional device information

Example

curl -X POST "https://cloud.asahome.io/api/v1/devices/register" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"deviceId": "asahome-home-001",
"name": "Home Hub",
"ipAddress": "192.168.1.100",
"port": "8123",
"metadata": {
"version": "2024.1.0",
"location": "Living Room"
}
}'

Response

{
"id": "device-internal-uuid",
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"deviceId": "asahome-home-001",
"name": "Home Hub",
"ipAddress": "192.168.1.100",
"port": "8123",
"isOnline": false,
"metadata": {
"version": "2024.1.0",
"location": "Living Room"
},
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}

The registering user automatically becomes the device owner.


GET List Devices

Retrieve all devices the authenticated user has access to.

Request

GET /api/v1/devices

Headers

HeaderRequiredDescription
AuthorizationYesBearer <accessToken>

Query Parameters

ParameterTypeDefaultDescription
pagenumber1Page number
limitnumber20Items per page
onlineboolean-Filter by online status

Example

curl -X GET "https://cloud.asahome.io/api/v1/devices?online=true" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response

{
"data": [
{
"id": "device-uuid-1",
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"deviceId": "asahome-home-001",
"name": "Home Hub",
"isOnline": true,
"lastSeenAt": "2024-01-15T10:30:00.000Z",
"role": "owner"
},
{
"id": "device-uuid-2",
"uuid": "550e8400-e29b-41d4-a716-446655440001",
"deviceId": "asahome-office-001",
"name": "Office Hub",
"isOnline": false,
"lastSeenAt": "2024-01-14T15:00:00.000Z",
"role": "editor"
}
],
"meta": {
"total": 2,
"page": 1,
"limit": 20,
"totalPages": 1
}
}

GET Get Device

Retrieve details of a specific device.

Request

GET /api/v1/devices/:id

Path Parameters

ParameterTypeDescription
idstringDevice ID (UUID)

Headers

HeaderRequiredDescription
AuthorizationYesBearer <accessToken>

Example

curl -X GET "https://cloud.asahome.io/api/v1/devices/device-uuid-1" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response

{
"id": "device-uuid-1",
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"deviceId": "asahome-home-001",
"name": "Home Hub",
"ipAddress": "192.168.1.100",
"port": "8123",
"isOnline": true,
"lastSeenAt": "2024-01-15T10:30:00.000Z",
"metadata": {
"version": "2024.1.0",
"location": "Living Room"
},
"role": "owner",
"users": [
{
"id": "user-uuid-1",
"email": "owner@example.com",
"role": "owner"
},
{
"id": "user-uuid-2",
"email": "family@example.com",
"role": "editor"
}
],
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:30:00.000Z"
}

PUT Update Device

Update device details. Only the device owner can update.

Request

PUT /api/v1/devices/:id

Path Parameters

ParameterTypeDescription
idstringDevice ID (UUID)

Headers

HeaderRequiredDescription
AuthorizationYesBearer <accessToken>

Request Body

FieldTypeRequiredDescription
namestringNoDisplay name
ipAddressstringNoLocal IP address
portstringNoDevice API port
metadataobjectNoAdditional info

Example

curl -X PUT "https://cloud.asahome.io/api/v1/devices/device-uuid-1" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Main Home Hub",
"metadata": {
"version": "2024.2.0",
"location": "Living Room"
}
}'

Response

{
"id": "device-uuid-1",
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"deviceId": "asahome-home-001",
"name": "Main Home Hub",
"ipAddress": "192.168.1.100",
"port": "8123",
"isOnline": true,
"metadata": {
"version": "2024.2.0",
"location": "Living Room"
},
"updatedAt": "2024-01-15T11:00:00.000Z"
}

Error Responses

Forbidden (403)

{
"statusCode": 403,
"message": "Only the device owner can update device settings",
"error": "Forbidden"
}

Link an existing device to a user with a specific role.

Request

POST /api/v1/devices/:id/link

Path Parameters

ParameterTypeDescription
idstringDevice ID (UUID)

Headers

HeaderRequiredDescription
AuthorizationYesBearer <accessToken>

Request Body

FieldTypeRequiredDescription
emailstringYesUser email to link
rolestringYesRole: owner, editor, or viewer

Example

curl -X POST "https://cloud.asahome.io/api/v1/devices/device-uuid-1/link" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "family@example.com",
"role": "editor"
}'

Response

{
"success": true,
"deviceUser": {
"id": "device-user-uuid",
"userId": "user-uuid-2",
"deviceId": "device-uuid-1",
"role": "editor",
"isActive": true,
"createdAt": "2024-01-15T11:00:00.000Z"
}
}

Role Permissions

RoleViewControlSettingsDeleteShare
ownerYesYesYesYesYes
editorYesYesNoNoNo
viewerYesNoNoNoNo

POST Get Device Auth Token

Generate an authentication token for the device to connect to the WebSocket tunnel.

Request

POST /api/v1/devices/auth/:uuid

Path Parameters

ParameterTypeDescription
uuidstringDevice UUID

Headers

HeaderRequiredDescription
AuthorizationYesBearer <accessToken>

Example

curl -X POST "https://cloud.asahome.io/api/v1/devices/auth/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Response

{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiresIn": 86400
}

The device uses this token to authenticate with the WebSocket tunnel.


POST Device Heartbeat

Update device online status and metadata. Called periodically by the AsaHome OS device.

Request

POST /api/v1/devices/heartbeat/:uuid

Path Parameters

ParameterTypeDescription
uuidstringDevice UUID

Headers

HeaderRequiredDescription
AuthorizationYesBearer <deviceToken>

Request Body

FieldTypeRequiredDescription
ipAddressstringNoCurrent local IP
metadataobjectNoUpdated metadata

Example

curl -X POST "https://cloud.asahome.io/api/v1/devices/heartbeat/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer DEVICE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"ipAddress": "192.168.1.100",
"metadata": {
"uptime": 86400,
"entities": 150
}
}'

Response

{
"success": true,
"device": {
"id": "device-uuid-1",
"isOnline": true,
"lastSeenAt": "2024-01-15T11:00:00.000Z"
}
}
Heartbeat Interval

Devices should send a heartbeat every 30-60 seconds. If no heartbeat is received for 5 minutes, the device is marked offline.


Device Object

Full Device Object

FieldTypeDescription
idstringInternal device ID
uuidstringDevice UUID (from AsaHome OS)
deviceIdstringHuman-readable device ID
namestringDisplay name
ipAddressstringLast known local IP
portstringDevice API port
isOnlinebooleanCurrent online status
lastSeenAtstringLast heartbeat timestamp
metadataobjectAdditional device info
createdAtstringRegistration timestamp
updatedAtstringLast update timestamp

Device User Relationship

FieldTypeDescription
idstringRelationship ID
userIdstringUser ID
deviceIdstringDevice ID
rolestringowner, editor, or viewer
isActivebooleanLink active status