# Bulk Asset Operations POST https://api.trebellar.app/api/v2/assets/bulk Content-Type: application/json Execute multiple asset operations in a single atomic batch request. Supports add, update, delete, move, and get operations within one transaction. All operations succeed or fail together, ensuring data consistency. Ideal for large-scale imports, reorganizations, or synchronized updates across the asset hierarchy. Reference: https://docs.trebellar.app/api-reference/api-resources/assets/bulk-operations ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Bulk Asset Operations version: endpoint_assets.bulkOperations paths: /api/v2/assets/bulk: post: operationId: bulk-operations summary: Bulk Asset Operations description: >- Execute multiple asset operations in a single atomic batch request. Supports add, update, delete, move, and get operations within one transaction. All operations succeed or fail together, ensuring data consistency. Ideal for large-scale imports, reorganizations, or synchronized updates across the asset hierarchy. tags: - - subpackage_assets parameters: - name: X-Trebellar-Api-Key in: header required: true schema: type: string responses: '200': description: All batch operations completed successfully as an atomic transaction content: application/json: schema: $ref: '#/components/schemas/assets_bulkOperations_Response_200' '400': description: >- Invalid operations array, conflicting operations, or business logic violations content: {} '500': description: Server error during batch processing - all operations rolled back content: {} requestBody: content: application/json: schema: type: object properties: operations: type: array items: $ref: '#/components/schemas/AssetOperations' required: - operations components: schemas: AssetId: type: string AssetLabel: type: string PolygonLocationSchemaType: type: string enum: - value: Point - value: Line - value: Polygon Point: type: array items: type: number format: double Line: type: array items: $ref: '#/components/schemas/Point' Polygon: type: array items: $ref: '#/components/schemas/Point' PolygonLocationSchemaCoordinates2: type: array items: $ref: '#/components/schemas/Polygon' PolygonLocationSchemaCoordinates: oneOf: - $ref: '#/components/schemas/Point' - $ref: '#/components/schemas/Line' - $ref: '#/components/schemas/PolygonLocationSchemaCoordinates2' PolygonLocationSchema: type: object properties: type: $ref: '#/components/schemas/PolygonLocationSchemaType' description: Type of geographic location coordinates: $ref: '#/components/schemas/PolygonLocationSchemaCoordinates' required: - type - coordinates Coordinates: type: object properties: lat: type: number format: double lon: type: number format: double required: - lat - lon AssetURLResourceSchema: type: object properties: name: type: string url: type: string dataUri: type: string StructureAssetStatus: type: string enum: - value: active - value: mothball - value: reserve - value: pending_exit - value: pending_new - value: new - value: closed StructureStaticProperties: type: object properties: externalId: type: string seats: type: number format: double capacity: type: number format: double headcount: type: number format: double address: type: string coordinates: $ref: '#/components/schemas/Coordinates' holidays: type: array items: type: string rentableSqft: type: number format: double businessHoursStart: type: string businessHoursEnd: type: string businessDays: type: array items: type: string locationGroup: type: string photos: type: array items: $ref: '#/components/schemas/AssetURLResourceSchema' status: $ref: '#/components/schemas/StructureAssetStatus' timezone: type: string required: - timezone StructureInput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: STRUCTURE staticProperties: $ref: '#/components/schemas/StructureStaticProperties' children: type: array items: $ref: '#/components/schemas/AssetInput' required: - label - type - staticProperties FloorStaticProperties: type: object properties: externalId: type: string seats: type: number format: double capacity: type: number format: double headcount: type: number format: double image: type: object additionalProperties: description: Any type description: Floor image data scale: type: object additionalProperties: description: Any type description: Floor scale data FloorInput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: FLOOR staticProperties: $ref: '#/components/schemas/FloorStaticProperties' children: type: array items: $ref: '#/components/schemas/AssetInput' required: - label - type - staticProperties SpaceInputStaticPropertiesBookable: oneOf: - type: boolean - type: string SpaceInputStaticProperties: type: object properties: externalId: type: string seats: type: number format: double capacity: type: number format: double headcount: type: number format: double spaceType: type: string bookable: $ref: '#/components/schemas/SpaceInputStaticPropertiesBookable' photos: type: array items: $ref: '#/components/schemas/AssetURLResourceSchema' description: type: string SpaceInput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: SPACE staticProperties: $ref: '#/components/schemas/SpaceInputStaticProperties' description: Properties for space assets children: type: array items: $ref: '#/components/schemas/AssetInput' required: - label - type - staticProperties DeskInputStaticPropertiesBookable: oneOf: - type: boolean - type: string DeskInputStaticProperties: type: object properties: externalId: type: string seats: type: number format: double capacity: type: number format: double headcount: type: number format: double bookable: $ref: '#/components/schemas/DeskInputStaticPropertiesBookable' DeskInput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: DESK staticProperties: $ref: '#/components/schemas/DeskInputStaticProperties' description: Properties for desk assets children: type: array items: $ref: '#/components/schemas/AssetInput' required: - label - type - staticProperties SensorGroupInput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: SENSOR_GROUP staticProperties: type: object additionalProperties: description: Any type children: type: array items: $ref: '#/components/schemas/AssetInput' required: - label - type - staticProperties SensorInputSensorProperties: type: object properties: sensorId: type: string name: type: string required: - sensorId SensorInput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: SENSOR staticProperties: type: object additionalProperties: description: Any type sensorProperties: $ref: '#/components/schemas/SensorInputSensorProperties' description: Sensor-specific properties children: type: array items: $ref: '#/components/schemas/AssetInput' required: - label - type - staticProperties - sensorProperties AssetInput: oneOf: - $ref: '#/components/schemas/StructureInput' - $ref: '#/components/schemas/FloorInput' - $ref: '#/components/schemas/SpaceInput' - $ref: '#/components/schemas/DeskInput' - $ref: '#/components/schemas/SensorGroupInput' - $ref: '#/components/schemas/SensorInput' AssetOperations0: type: object properties: type: type: string enum: - type: stringLiteral value: add asset: $ref: '#/components/schemas/AssetInput' timestampMs: type: number format: double timestampMsDelete: type: number format: double required: - type - asset AssetOperations1: type: object properties: type: type: string enum: - type: stringLiteral value: update asset: $ref: '#/components/schemas/AssetInput' timestampMs: type: number format: double required: - type - asset AssetOperations2: type: object properties: type: type: string enum: - type: stringLiteral value: move id: $ref: '#/components/schemas/AssetId' newParentId: $ref: '#/components/schemas/AssetId' required: - type - id - newParentId AssetOperations3: type: object properties: type: type: string enum: - type: stringLiteral value: delete id: $ref: '#/components/schemas/AssetId' required: - type - id AssetOperations4: type: object properties: type: type: string enum: - type: stringLiteral value: get id: $ref: '#/components/schemas/AssetId' embedChildren: type: boolean required: - type - id AssetOperations: oneOf: - $ref: '#/components/schemas/AssetOperations0' - $ref: '#/components/schemas/AssetOperations1' - $ref: '#/components/schemas/AssetOperations2' - $ref: '#/components/schemas/AssetOperations3' - $ref: '#/components/schemas/AssetOperations4' StructureInputOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: STRUCTURE staticProperties: $ref: '#/components/schemas/StructureStaticProperties' children: type: array items: $ref: '#/components/schemas/AssetInputOutput' required: - label - type - staticProperties FloorInputOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: FLOOR staticProperties: $ref: '#/components/schemas/FloorStaticProperties' children: type: array items: $ref: '#/components/schemas/AssetInputOutput' required: - label - type - staticProperties SpaceInputOutputStaticPropertiesBookable: oneOf: - type: boolean - type: string SpaceInputOutputStaticProperties: type: object properties: externalId: type: string seats: type: number format: double capacity: type: number format: double headcount: type: number format: double spaceType: type: string bookable: $ref: '#/components/schemas/SpaceInputOutputStaticPropertiesBookable' photos: type: array items: $ref: '#/components/schemas/AssetURLResourceSchema' description: type: string SpaceInputOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: SPACE staticProperties: $ref: '#/components/schemas/SpaceInputOutputStaticProperties' description: Properties for space assets children: type: array items: $ref: '#/components/schemas/AssetInputOutput' required: - label - type - staticProperties DeskInputOutputStaticPropertiesBookable: oneOf: - type: boolean - type: string DeskInputOutputStaticProperties: type: object properties: externalId: type: string seats: type: number format: double capacity: type: number format: double headcount: type: number format: double bookable: $ref: '#/components/schemas/DeskInputOutputStaticPropertiesBookable' DeskInputOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: DESK staticProperties: $ref: '#/components/schemas/DeskInputOutputStaticProperties' description: Properties for desk assets children: type: array items: $ref: '#/components/schemas/AssetInputOutput' required: - label - type - staticProperties SensorGroupInputOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: SENSOR_GROUP staticProperties: type: object additionalProperties: description: Any type children: type: array items: $ref: '#/components/schemas/AssetInputOutput' required: - label - type - staticProperties SensorInputOutputSensorProperties: type: object properties: sensorId: type: string name: type: string required: - sensorId SensorInputOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID location: $ref: '#/components/schemas/PolygonLocationSchema' dynamicProperties: type: object additionalProperties: description: Any type description: Dynamic properties as JSON type: type: string enum: - type: stringLiteral value: SENSOR staticProperties: type: object additionalProperties: description: Any type sensorProperties: $ref: '#/components/schemas/SensorInputOutputSensorProperties' description: Sensor-specific properties children: type: array items: $ref: '#/components/schemas/AssetInputOutput' required: - label - type - staticProperties - sensorProperties AssetInputOutput: oneOf: - $ref: '#/components/schemas/StructureInputOutput' - $ref: '#/components/schemas/FloorInputOutput' - $ref: '#/components/schemas/SpaceInputOutput' - $ref: '#/components/schemas/DeskInputOutput' - $ref: '#/components/schemas/SensorGroupInputOutput' - $ref: '#/components/schemas/SensorInputOutput' AssetOperationsOutput0: type: object properties: type: type: string enum: - type: stringLiteral value: add asset: $ref: '#/components/schemas/AssetInputOutput' timestampMs: type: number format: double timestampMsDelete: type: number format: double required: - type - asset AssetOperationsOutput1: type: object properties: type: type: string enum: - type: stringLiteral value: update asset: $ref: '#/components/schemas/AssetInputOutput' timestampMs: type: number format: double required: - type - asset AssetOperationsOutput2: type: object properties: type: type: string enum: - type: stringLiteral value: move id: $ref: '#/components/schemas/AssetId' newParentId: $ref: '#/components/schemas/AssetId' required: - type - id - newParentId AssetOperationsOutput3: type: object properties: type: type: string enum: - type: stringLiteral value: delete id: $ref: '#/components/schemas/AssetId' required: - type - id AssetOperationsOutput4: type: object properties: type: type: string enum: - type: stringLiteral value: get id: $ref: '#/components/schemas/AssetId' embedChildren: type: boolean required: - type - id AssetOperationsOutput: oneOf: - $ref: '#/components/schemas/AssetOperationsOutput0' - $ref: '#/components/schemas/AssetOperationsOutput1' - $ref: '#/components/schemas/AssetOperationsOutput2' - $ref: '#/components/schemas/AssetOperationsOutput3' - $ref: '#/components/schemas/AssetOperationsOutput4' assets_bulkOperations_Response_200: type: object properties: success: type: boolean operations: type: array items: $ref: '#/components/schemas/AssetOperationsOutput' required: - success - operations ``` ## SDK Code Examples ```typescript import { TrebellarApiClient } from "@trebellar/api-sdk"; async function main() { const client = new TrebellarApiClient({ environment: "https://api.trebellar.app", }); await client.assets.bulkOperations({ operations: [], }); } main(); ``` ```python from trebellar import TrebellarApi client = TrebellarApi( base_url="https://api.trebellar.app", api_key= ) client.assets.bulk_operations( operations=[] ) ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.trebellar.app/api/v2/assets/bulk" payload := strings.NewReader("{\n \"operations\": [\n {\n \"type\": \"string\",\n \"asset\": {\n \"label\": \"San Francisco Tower - Floor 42\",\n \"type\": \"string\",\n \"staticProperties\": {\n \"address\": \"123 Main St, San Francisco, CA 94105\",\n \"coordinates\": {\n \"lat\": 37.7749,\n \"lon\": -122.4194\n },\n \"rentableSqft\": 50000,\n \"businessHoursStart\": \"08:00\",\n \"businessHoursEnd\": \"18:00\",\n \"businessDays\": [\n \"monday\",\n \"tuesday\",\n \"wednesday\",\n \"thursday\",\n \"friday\"\n ],\n \"status\": \"active\",\n \"timezone\": \"America/Los_Angeles\"\n }\n }\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Trebellar-Api-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.trebellar.app/api/v2/assets/bulk") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-Trebellar-Api-Key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"operations\": [\n {\n \"type\": \"string\",\n \"asset\": {\n \"label\": \"San Francisco Tower - Floor 42\",\n \"type\": \"string\",\n \"staticProperties\": {\n \"address\": \"123 Main St, San Francisco, CA 94105\",\n \"coordinates\": {\n \"lat\": 37.7749,\n \"lon\": -122.4194\n },\n \"rentableSqft\": 50000,\n \"businessHoursStart\": \"08:00\",\n \"businessHoursEnd\": \"18:00\",\n \"businessDays\": [\n \"monday\",\n \"tuesday\",\n \"wednesday\",\n \"thursday\",\n \"friday\"\n ],\n \"status\": \"active\",\n \"timezone\": \"America/Los_Angeles\"\n }\n }\n }\n ]\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.trebellar.app/api/v2/assets/bulk") .header("X-Trebellar-Api-Key", "") .header("Content-Type", "application/json") .body("{\n \"operations\": [\n {\n \"type\": \"string\",\n \"asset\": {\n \"label\": \"San Francisco Tower - Floor 42\",\n \"type\": \"string\",\n \"staticProperties\": {\n \"address\": \"123 Main St, San Francisco, CA 94105\",\n \"coordinates\": {\n \"lat\": 37.7749,\n \"lon\": -122.4194\n },\n \"rentableSqft\": 50000,\n \"businessHoursStart\": \"08:00\",\n \"businessHoursEnd\": \"18:00\",\n \"businessDays\": [\n \"monday\",\n \"tuesday\",\n \"wednesday\",\n \"thursday\",\n \"friday\"\n ],\n \"status\": \"active\",\n \"timezone\": \"America/Los_Angeles\"\n }\n }\n }\n ]\n}") .asString(); ``` ```php request('POST', 'https://api.trebellar.app/api/v2/assets/bulk', [ 'body' => '{ "operations": [ { "type": "string", "asset": { "label": "San Francisco Tower - Floor 42", "type": "string", "staticProperties": { "address": "123 Main St, San Francisco, CA 94105", "coordinates": { "lat": 37.7749, "lon": -122.4194 }, "rentableSqft": 50000, "businessHoursStart": "08:00", "businessHoursEnd": "18:00", "businessDays": [ "monday", "tuesday", "wednesday", "thursday", "friday" ], "status": "active", "timezone": "America/Los_Angeles" } } } ] }', 'headers' => [ 'Content-Type' => 'application/json', 'X-Trebellar-Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.trebellar.app/api/v2/assets/bulk"); var request = new RestRequest(Method.POST); request.AddHeader("X-Trebellar-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"operations\": [\n {\n \"type\": \"string\",\n \"asset\": {\n \"label\": \"San Francisco Tower - Floor 42\",\n \"type\": \"string\",\n \"staticProperties\": {\n \"address\": \"123 Main St, San Francisco, CA 94105\",\n \"coordinates\": {\n \"lat\": 37.7749,\n \"lon\": -122.4194\n },\n \"rentableSqft\": 50000,\n \"businessHoursStart\": \"08:00\",\n \"businessHoursEnd\": \"18:00\",\n \"businessDays\": [\n \"monday\",\n \"tuesday\",\n \"wednesday\",\n \"thursday\",\n \"friday\"\n ],\n \"status\": \"active\",\n \"timezone\": \"America/Los_Angeles\"\n }\n }\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-Trebellar-Api-Key": "", "Content-Type": "application/json" ] let parameters = ["operations": [ [ "type": "string", "asset": [ "label": "San Francisco Tower - Floor 42", "type": "string", "staticProperties": [ "address": "123 Main St, San Francisco, CA 94105", "coordinates": [ "lat": 37.7749, "lon": -122.4194 ], "rentableSqft": 50000, "businessHoursStart": "08:00", "businessHoursEnd": "18:00", "businessDays": ["monday", "tuesday", "wednesday", "thursday", "friday"], "status": "active", "timezone": "America/Los_Angeles" ] ] ] ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.trebellar.app/api/v2/assets/bulk")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```