Bulk create or update assets
const url = 'https://safe-api.safetyradar.com/v2/assets/bulk';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"assets":[{"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"]}]}'};
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/bulk \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "assets": [ { "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" ] } ] }'Create or update multiple assets in a single request. Assets are upserted based on externalId. Maximum 1000 assets per request. Equipment assets require equipmentTypeId. externalParentId may name an existing asset OR another asset in the same request, in any order: parents are written before their children, so a new parent and all its children (for example a re-org) need only one request. A row that cannot be placed fails alone and the rest of the batch is written: its result has success: false and an error when its parent is in neither the database nor the request, when it is its own parent, when it is part of a parent cycle, when the move would put it under one of its own descendants, when an earlier row has the same externalId, or when its parent row failed (the error names the parent). Results are in request order. tags (tag names) and tagIds follow the same rules as the single upsert: omitted = tags unchanged, [] = clear, a list = replace; an unknown tag name fails that row; a row with both tags and tagIds rejects the request with 400.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
object
Asset type. If omitted on update, preserves existing type.
External identifier (required for bulk upsert)
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); parentId: null does NOT, it leaves the parent unchanged. A parentId must be an asset of your organization.
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 fails that row. Send tags or tagIds, not both.
Example
[ "Region North"]Responses
Section titled “Responses”Bulk operation completed
object
object
object
object
Examplegenerated
{ "data": { "results": [ { "externalId": "example", "success": true, "created": true, "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "error": "example" } ], "summary": { "total": 1, "created": 1, "updated": 1, "failed": 1 } }}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"}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"}
