Create device property¶
POST/
Mobile API · Devices
Create custom device property.
Parameters¶
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string (uuid) | Yes | Unique object identifier. |
X-Tenant-ID | header | string (uuid) | Yes | Tenant ID. |
fields | query | array of string | No | The fields to return in a partial response. |
view | query | string | No | Type of view to be returned in response. Must be one of: basic, summary, full. |
Request body¶
Content type: application/json
Request body fields
keystringrequiredKey of the device property.
Must match the pattern
Must match the pattern
^custom\.[a-zA-Z0-9.\-_]+$. Must be at most 100 characters long.valuestringrequiredValue of the device property.
Must be at most 4096 characters long.
Must be at most 4096 characters long.
Request samples¶
curl -X POST "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
\"key\": \"custom.someKey\",
\"value\": \"a test value\"
}"
import requests
response = requests.post(
"https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties",
headers={
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
json={'key': 'custom.someKey', 'value': 'a test value'},
)
print(response.json())
$headers = @{
"Authorization" = "Bearer <access-token>"
"X-Tenant-ID" = "<tenant-id>"
"Content-Type" = "application/json"
}
$body = '{
"key": "custom.someKey",
"value": "a test value"
}'
Invoke-RestMethod -Method POST -Uri "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties" -Headers $headers -Body $body -ContentType "application/json"
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, err := http.NewRequest("POST", "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties", strings.NewReader(`{
"key": "custom.someKey",
"value": "a test value"
}`))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer <access-token>")
req.Header.Set("X-Tenant-ID", "<tenant-id>")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
const response = await fetch("https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties", {
method: "POST",
headers: {
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"key": "custom.someKey",
"value": "a test value"
}),
});
const data = await response.json();
console.log(data);
Responses¶
201 — The new custom device property.¶
Response fields
keystringKey of the device property.
valuestringValue of the device property.
typestring (enum)The type of a device property.
Must be one of:
Must be one of:
system, custom.createdAtstring (date-time)Time when the object was created.
updatedAtstring (date-time)Time when the object was updated.
createdByobjectPrincipal reference.
Show child attributesHide child attributes
idstring (uuid)Principal ID.
typestring (enum)requiredPrincipal type.
Must be one of:
Must be one of:
user, service, system.accountIdstring (uuid)Account ID.
accountTypestring (enum)Account type.
Must be one of:
Must be one of:
partner, tenant, organization.namestringPrincipal name or email.
updatedByobjectPrincipal reference.
Show child attributesHide child attributes
idstring (uuid)Principal ID.
typestring (enum)requiredPrincipal type.
Must be one of:
Must be one of:
user, service, system.accountIdstring (uuid)Account ID.
accountTypestring (enum)Account type.
Must be one of:
Must be one of:
partner, tenant, organization.namestringPrincipal name or email.
Errors¶
| Status | Meaning |
|---|---|
400 | Invalid request. |
401 | Unauthorized. |
403 | Forbidden. |
409 | Conflicting modification. |
422 | Maximum number of custom device properties exceeded. |
429 | Too many requests. See Retry-After header. |
500 | Internal server error. |
All error responses share the same shape — see the error response object.
See the guide for a narrative walkthrough of this API.