Skip to content

Update property by key

PUT/devices/{id}/properties/{propertyKey}

Mobile API · Devices

Update a device property by key.

Parameters

Name In Type Required Description
id path string (uuid) Yes Unique object identifier.
propertyKey path string Yes Device property key.
Must be at most 100 characters long.
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

valuestringrequired
Value of the device property.
Must be at most 4096 characters long.

Request samples

curl -X PUT "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties/<propertyKey>" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
  \"value\": \"changedValue\"
}"

import requests

response = requests.put(
    "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties/<propertyKey>",
    headers={
        "Authorization": "Bearer <access-token>",
        "X-Tenant-ID": "<tenant-id>",
        "Content-Type": "application/json",
    },
    json={'value': 'changedValue'},
)
print(response.json())

$headers = @{
    "Authorization" = "Bearer <access-token>"
    "X-Tenant-ID" = "<tenant-id>"
    "Content-Type" = "application/json"
}
$body = '{
  "value": "changedValue"
}'
Invoke-RestMethod -Method PUT -Uri "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties/<propertyKey>" -Headers $headers -Body $body -ContentType "application/json"

package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    req, err := http.NewRequest("PUT", "https://api-<data-region>.central.sophos.com/mobile/v1/devices/<id>/properties/<propertyKey>", strings.NewReader(`{
  "value": "changedValue"
}`))
    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/<propertyKey>", {
  method: "PUT",
  headers: {
    "Authorization": "Bearer <access-token>",
    "X-Tenant-ID": "<tenant-id>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
  "value": "changedValue"
}),
});
const data = await response.json();
console.log(data);

Responses

200 — A device property.

Response fields

keystring
Key of the device property.
valuestring
Value of the device property.
typestring (enum)
The type of a device property.
Must be one of: system, custom.
createdAtstring (date-time)
Time when the object was created.
updatedAtstring (date-time)
Time when the object was updated.
createdByobject
Principal reference.
Show child attributesHide child attributes
idstring (uuid)
Principal ID.
typestring (enum)required
Principal type.
Must be one of: user, service, system.
accountIdstring (uuid)
Account ID.
accountTypestring (enum)
Account type.
Must be one of: partner, tenant, organization.
namestring
Principal name or email.
updatedByobject
Principal reference.
Show child attributesHide child attributes
idstring (uuid)
Principal ID.
typestring (enum)required
Principal type.
Must be one of: user, service, system.
accountIdstring (uuid)
Account ID.
accountTypestring (enum)
Account type.
Must be one of: partner, tenant, organization.
namestring
Principal name or email.

Errors

Status Meaning
400 Invalid request.
401 Unauthorized.
403 Forbidden.
409 Conflicting modification.
429 Too many requests. See Retry-After header.
500 Internal server error.

All error responses share the same shape — see the error response object.

Response examples

200

{
  "key": "custom.someProperty",
  "value": "someValue",
  "type": "custom"
}

See the guide for a narrative walkthrough of this API.