Create or update asset
const url = 'https://safe-api.safetyradar.com/v2/assets';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","name":"example","description":"example","address1":"example","address2":"example","city":"example","state":"example","zip":"example","latitude":1,"longitude":1,"status":"active","type":"equipment","parentId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","externalId":"example","metadata":{"additionalProperty":"example"},"createdAt":"example","updatedAt":"example","deletedAt":"example","equipmentTypeId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","tagIds":["2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"],"externalParentId":"example","tags":["Region North"],"cascadeDeactivate":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://safe-api.safetyradar.com/v2/assets \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "name": "example", "description": "example", "address1": "example", "address2": "example", "city": "example", "state": "example", "zip": "example", "latitude": 1, "longitude": 1, "status": "active", "type": "equipment", "parentId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "externalId": "example", "metadata": { "additionalProperty": "example" }, "createdAt": "example", "updatedAt": "example", "deletedAt": "example", "equipmentTypeId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "tagIds": [ "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0" ], "externalParentId": "example", "tags": [ "Region North" ], "cascadeDeactivate": true }'Create a new asset or update an existing one if externalId matches (upsert behavior). Supports both location and equipment types. Equipment assets require equipmentTypeId. Changing an existing active asset to status: "inactive" returns 409 while it still has active child assets: deactivate or move the children first, or send cascadeDeactivate: true to deactivate the whole subtree. Tags: send tags with tag names (for example ["Region North"], matched case-insensitively) or tagIds, not both. Omitted = tags unchanged, [] = clear, a list = replace. An unknown tag returns 400; tags are not created by the API. Responses include tagNames (the asset’s tag names) next to tags ({ id, name } objects).
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
External identifier for upsert behavior
Resource tag ids, with the same semantics as tags. Send tags or tagIds, not both.
External ID of the parent asset. If provided, resolves to parentId. Takes precedence over parentId if both are specified. null moves the asset to the root (top level). On this single upsert, parentId: null also moves it to the root (bulk differs: there parentId: null leaves the parent unchanged). A parentId must be an asset of your organization, and the asset cannot move under itself or one of its descendants (400).
Resource tag NAMES, matched trimmed and case-insensitively against the organization’s tags (for example ["Region North"]). Omitted = the asset’s tags are not changed; [] = remove all tags; a list = replace the tags with exactly this set. Tags are not created by the API: an unknown name is an error. Send tags or tagIds, not both.
Example
[ "Region North"]With status: "inactive" on an existing asset, also deactivate every asset under it, in the same write. Without it, deactivating an active asset returns 409 while active child assets remain. Ignored when the asset is created.
Responses
Section titled “Responses”Asset updated (existing asset found by externalId)
object
object
External ID of the parent asset (computed from parentId lookup)
Names of the resource tags on the asset, sorted. Single-asset responses (GET by id, POST) also carry tags as { id, name } objects; tagNames is the same set as plain names.
Example
{ "data": { "status": "active", "type": "equipment", "tagNames": [ "Region North" ] }}Asset created
object
object
External ID of the parent asset (computed from parentId lookup)
Names of the resource tags on the asset, sorted. Single-asset responses (GET by id, POST) also carry tags as { id, name } objects; tagNames is the same set as plain names.
Example
{ "data": { "status": "active", "type": "equipment", "tagNames": [ "Region North" ] }}Bad request - equipment assets require equipmentTypeId, an unknown tag, or both tags and tagIds sent
object
Machine-readable error code
Human-readable error message
Additional error details. For validation_error: issues, a list of { location, path, message } (location is query, param, header or json).
object
Example
{ "code": "validation_error", "message": "Request validation failed"}Unauthorized
object
Machine-readable error code
Human-readable error message
Additional error details. For validation_error: issues, a list of { location, path, message } (location is query, param, header or json).
object
Example
{ "code": "validation_error", "message": "Request validation failed"}Conflict - the asset cannot be deactivated while it has active child assets (send cascadeDeactivate: true to deactivate them too)
object
Machine-readable error code
Human-readable error message
Additional error details. For validation_error: issues, a list of { location, path, message } (location is query, param, header or json).
object
Example
{ "code": "validation_error", "message": "Request validation failed"}Rate limit exceeded (rate_limit_exceeded)
object
Machine-readable error code
Human-readable error message
Additional error details. For validation_error: issues, a list of { location, path, message } (location is query, param, header or json).
object
Example
{ "code": "validation_error", "message": "Request validation failed"}Unexpected server error (internal_error)
object
Machine-readable error code
Human-readable error message
Additional error details. For validation_error: issues, a list of { location, path, message } (location is query, param, header or json).
object
Example
{ "code": "validation_error", "message": "Request validation failed"}
