Rename a label key
const url = 'http://localhost:3000/api/v1/groups/labels/plant';const options = { method: 'PATCH', headers: {'X-API-Key': '<X-API-Key>', 'Content-Type': 'application/json'}, body: '{"newKey":"site"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url http://localhost:3000/api/v1/groups/labels/plant \ --header 'Content-Type: application/json' \ --header 'X-API-Key: <X-API-Key>' \ --data '{ "newKey": "site" }'Renames a label key on every device of the organization in one transaction. Deployment selectors and alert rules that reference the key are rewritten in the same transaction, so they keep targeting the same devices. Renaming onto a key that devices already carry, or that a selector or alert rule already references, fails with 409 and changes nothing.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Example
plantThe label key to rename
Header Parameters
Section titled “Header Parameters”UUID of the organization (tenant) the request acts in. It selects the tenant and grants nothing: the server checks membership or an open tenant switch. Not needed for global operations. A malformed value returns 400. API keys are fixed to their own organization; another organization returns 403. The x-organization-source header grants nothing.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The new label key. Must not already be carried by any device of the organization, nor referenced by any deployment selector or alert rule (409 otherwise).
Example
siteResponses
Section titled “Responses”Label key renamed
object
The label key that was renamed, or whose value was renamed
Key rename only: the new label key
Value rename only: the old value
Value rename only: the new value
Number of devices whose labels were rewritten
Deployments whose device selector referenced the renamed label and was rewritten to keep targeting the same devices
Alert rules whose label target referenced the renamed label and was rewritten to keep matching the same devices
Example
{ "newKey": "site", "value": "Plant-A", "newValue": "Plant-1", "affectedDevices": 42}Invalid key or new key
Unauthorized
Forbidden — caller lacks required permission
No device in the organization carries the key
The new key is already in use