# Create New Asset POST https://api.trebellar.app/api/v2/assets Content-Type: application/json Create a single new asset within the hierarchical structure. The asset will be automatically assigned a unique ID and can include children assets for bulk creation. When creating hierarchical assets, ensure parent assets exist or are created first. Supports all asset types: structures, floors, spaces, desks, and sensors. Reference: https://docs.trebellar.app/api-reference/api-resources/assets/add-single ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create New Asset version: endpoint_assets.addSingle paths: /api/v2/assets: post: operationId: add-single summary: Create New Asset description: >- Create a single new asset within the hierarchical structure. The asset will be automatically assigned a unique ID and can include children assets for bulk creation. When creating hierarchical assets, ensure parent assets exist or are created first. Supports all asset types: structures, floors, spaces, desks, and sensors. tags: - - subpackage_assets parameters: - name: X-Trebellar-Api-Key in: header required: true schema: type: string responses: '200': description: Asset and any child assets created successfully with assigned IDs content: application/json: schema: $ref: '#/components/schemas/assets_addSingle_Response_200' '400': description: >- Invalid asset data, missing required fields, or invalid parent relationship content: {} '500': description: >- Server error during asset creation, possibly due to database constraints content: {} requestBody: content: application/json: schema: type: object properties: asset: $ref: '#/components/schemas/AssetInput' required: - asset 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' StructureOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID parentIdPath: type: array items: type: string 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/AssetOutput' required: - id - label - type - staticProperties FloorOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID parentIdPath: type: array items: type: string 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/AssetOutput' required: - id - label - type - staticProperties SpaceOutputStaticPropertiesBookable: oneOf: - type: boolean - type: string SpaceOutputStaticProperties: 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/SpaceOutputStaticPropertiesBookable' photos: type: array items: $ref: '#/components/schemas/AssetURLResourceSchema' description: type: string SpaceOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID parentIdPath: type: array items: type: string 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/SpaceOutputStaticProperties' description: Properties for space assets children: type: array items: $ref: '#/components/schemas/AssetOutput' required: - id - label - type - staticProperties DeskOutputStaticPropertiesBookable: oneOf: - type: boolean - type: string DeskOutputStaticProperties: 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/DeskOutputStaticPropertiesBookable' DeskOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID parentIdPath: type: array items: type: string 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/DeskOutputStaticProperties' description: Properties for desk assets children: type: array items: $ref: '#/components/schemas/AssetOutput' required: - id - label - type - staticProperties SensorGroupOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID parentIdPath: type: array items: type: string 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/AssetOutput' required: - id - label - type - staticProperties SensorOutputSensorProperties: type: object properties: sensorId: type: string name: type: string required: - sensorId SensorOutput: type: object properties: id: $ref: '#/components/schemas/AssetId' label: $ref: '#/components/schemas/AssetLabel' parentId: type: string description: Parent asset ID parentIdPath: type: array items: type: string 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/SensorOutputSensorProperties' description: Sensor-specific properties children: type: array items: $ref: '#/components/schemas/AssetOutput' required: - id - label - type - staticProperties - sensorProperties AssetOutput: oneOf: - $ref: '#/components/schemas/StructureOutput' - $ref: '#/components/schemas/FloorOutput' - $ref: '#/components/schemas/SpaceOutput' - $ref: '#/components/schemas/DeskOutput' - $ref: '#/components/schemas/SensorGroupOutput' - $ref: '#/components/schemas/SensorOutput' assets_addSingle_Response_200: type: object properties: success: type: boolean asset: $ref: '#/components/schemas/AssetOutput' required: - success - asset ``` ## 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.addSingle({}); } main(); ``` ```python from trebellar import TrebellarApi client = TrebellarApi( base_url="https://api.trebellar.app", api_key= ) client.assets.add_single( asset= ) ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.trebellar.app/api/v2/assets" payload := strings.NewReader("{\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}") 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") 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 \"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}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.trebellar.app/api/v2/assets") .header("X-Trebellar-Api-Key", "") .header("Content-Type", "application/json") .body("{\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}") .asString(); ``` ```php request('POST', 'https://api.trebellar.app/api/v2/assets', [ 'body' => '{ "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"); var request = new RestRequest(Method.POST); request.AddHeader("X-Trebellar-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\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}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-Trebellar-Api-Key": "", "Content-Type": "application/json" ] let parameters = ["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")! 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() ```