Custom Attributes
Attributes can be added to Users, Devices and Services. Attributes can have overrides defined by context. This is used for your own custom metadata.

Add/Update Attribute

Parameter
Data Type
Description
name
String
required
Name of attribute
value
String
required
Value of attribute null to remove
serviceId
String
required
The userId, deviceId or serviceId the attribute is assigned to
context
String
defined context of the attribute. Allows for override of attribute value for the same name
1
mutation {
2
setAttribute(
3
name: "CustomAttribute",
4
value: "ValueOfAttribute",
5
serviceId: "80:00:00:00:12:34:56:78",
6
context: "CustomContext"
7
)
8
}
Copied!
Query Response
1
{
2
"data": {
3
"setAttribute": "ValueOfAttribute"
4
}
5
}
Copied!

Category and Status Fields

We have reserved names of remote.it Device attributes which will be displayed on the Web Portal and Desktop UIs. These attributes are for Category and Status fields. The UI currently can display Category A-E and Status A-E. These must be set against the Device ID (also known as the Bulk Service's "Service ID" of the remote.it Device). The convention for the name is $remoteit.categoryA for category attributes and $remoteit.statusA for status attributes. The convention is the same for removing and retrieving these attributes.
Example Category Mutation
1
mutation {
2
setAttribute(
3
name: "$remoteit.categoryA",
4
value: "my category A value",
5
serviceId: "80:00:00:00:12:34:56:78",
6
)
7
}
Copied!

Remove Attribute

1
mutation {
2
setAttribute(
3
name: "CustomAttribute",
4
value: null,
5
serviceId: "80:00:00:00:12:34:56:78",
6
)
7
}
Copied!

Set Multiple Attributes

This method shows how to update multiple attributes on a single device by passing in a JSON formatted variables.
1
#Query
2
mutation UpdateMultipleAttributes($attributes: Object!, $serviceId: String!) {
3
setAttributes(attributes: $attributes, serviceId: $serviceId)
4
}
5
6
#Variables
7
{
8
"attributes": {
9
"$remoteit": {
10
"categoryA": "Uptime: 1h, 06m",
11
"categoryB": "Version: 1.0",
12
"categoryC": "Serial Number: x292jsu2",
13
"categoryD": "MAC: AUWS83729A"
14
},
15
"MoreJsonAttributes": {
16
"version": "1.0"
17
},
18
"StringAttribute": "newvalue"
19
},
20
"serviceId": "80:00:00:00:01:12:12:12"
21
}
Copied!

Retrieve Attributes

1
{
2
login {
3
attributes #User Attributes
4
devices{
5
items{
6
attributes #Device Attributes
7
services{
8
attributes(context: "customContext") #Service Attributes
9
}
10
}
11
}
12
}
13
}
Copied!
Query Response
1
{
2
"data": {
3
"login": {
4
"attributes": { #User Attributes
5
"newAttribute": "CustomAttributeValue",
6
},
7
"devices": {
8
"items": [
9
{
10
"attributes": { #Device Attributes
11
"newAttribute": "CustomAttributeValue"
12
},
13
"services": [
14
{
15
"attributes": { #Service Attributes
16
"newAttribute": "ContextAttributeValue"
17
}
18
},...]
19
}
20
]
21
}
22
}
23
}
24
}
Copied!