Update token¶
PATCH/
Account Management API · Token Management
Update access token for a tenant.
Parameters¶
| Name | In | Type | Required | Description |
|---|---|---|---|---|
X-Tenant-ID | header | string (uuid) | Yes | Tenant ID. |
tokenId | path | string (uuid) | Yes | Token ID. |
Request body¶
Content type: application/json
Request body fields
labelstringToken label. Must be between 0 and 50 characters long and only contain alphanumeric characters, commas, hyphens and periods. Special characters are not allowed.
Must match the pattern
Must match the pattern
^[a-zA-Z\d,\s\-.]{0,50}$.expiresAtstring (datetime)Token expires on.
Request samples¶
curl -X PATCH "https://api.central.sophos.com/accounts/v1/access-tokens/<tokenId>" -H "Authorization: Bearer <access-token>" -H "X-Tenant-ID: <tenant-id>" -H "Content-Type: application/json" -d "{
\"label\": \"Test Token\",
\"expiresAt\": \"2021-04-29T15:32:28.482Z\"
}"
import requests
response = requests.patch(
"https://api.central.sophos.com/accounts/v1/access-tokens/<tokenId>",
headers={
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
json={'label': 'Test Token', 'expiresAt': '2021-04-29T15:32:28.482Z'},
)
print(response.json())
$headers = @{
"Authorization" = "Bearer <access-token>"
"X-Tenant-ID" = "<tenant-id>"
"Content-Type" = "application/json"
}
$body = '{
"label": "Test Token",
"expiresAt": "2021-04-29T15:32:28.482Z"
}'
Invoke-RestMethod -Method PATCH -Uri "https://api.central.sophos.com/accounts/v1/access-tokens/<tokenId>" -Headers $headers -Body $body -ContentType "application/json"
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
req, err := http.NewRequest("PATCH", "https://api.central.sophos.com/accounts/v1/access-tokens/<tokenId>", strings.NewReader(`{
"label": "Test Token",
"expiresAt": "2021-04-29T15:32:28.482Z"
}`))
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.central.sophos.com/accounts/v1/access-tokens/<tokenId>", {
method: "PATCH",
headers: {
"Authorization": "Bearer <access-token>",
"X-Tenant-ID": "<tenant-id>",
"Content-Type": "application/json",
},
body: JSON.stringify({
"label": "Test Token",
"expiresAt": "2021-04-29T15:32:28.482Z"
}),
});
const data = await response.json();
console.log(data);
Responses¶
200 — Access token.¶
Response fields
idstring (uuid)requiredUnique token ID.
tokenstringrequiredAccess token.
typestringrequiredToken type. * sophosLinuxSensor - Token that you can use to authenticate downloads of Sophos Linux Sensor.
Must be one of:
Must be one of:
sophosLinuxSensor.labelstringToken description.
createdAtstring (datetime)requiredToken created.
expiresAtstring (datetime)requiredToken expires on.
urlstringrequiredURL that the token gives access to.
createdByobjectrequiredShow child attributesHide child attributes
idstringrequiredPrincipal ID.
typestring (enum)requiredType of entity that made this change.
Must be one of:
Must be one of:
user, service.namestringPrincipal name.
accountTypestringAccount type for this principal.
Must be one of:
Must be one of:
partner, tenant, organization, distributor.accountIdstring (uuid)Account ID.
Errors¶
| Status | Meaning |
|---|---|
400 | Bad request. |
403 | Request is incompatible with tenant's current licenses. |
404 | Access token not found. |
500 | Unexpected error. |
All error responses share the same shape — see the error response object.
Response examples¶
200¶
{
"id": "00000000-0000-0000-0000-000000000000",
"token": "string",
"type": "sophosLinuxSensor",
"label": "string",
"createdAt": "string",
"expiresAt": "string",
"url": "string",
"createdBy": {
"id": "string",
"type": "user",
"name": "string",
"accountType": "partner",
"accountId": "00000000-0000-0000-0000-000000000000"
}
}
See the guide for a narrative walkthrough of this API.