# Batch Assign People to Assets PATCH https://api.trebellar.app/api/v2/people/batch/assets/upsert Content-Type: application/json Create or update assignments between employees and workspace assets (desks, spaces, etc.). This is typically used for desk assignments, office allocations, or space reservations. Each person can be assigned to multiple assets, and assets can have multiple people assigned (depending on capacity). Reference: https://docs.trebellar.app/api-reference/api-resources/people/upsert-people-asset-batch ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Batch Assign People to Assets version: endpoint_people.upsertPeopleAssetBatch paths: /api/v2/people/batch/assets/upsert: patch: operationId: upsert-people-asset-batch summary: Batch Assign People to Assets description: >- Create or update assignments between employees and workspace assets (desks, spaces, etc.). This is typically used for desk assignments, office allocations, or space reservations. Each person can be assigned to multiple assets, and assets can have multiple people assigned (depending on capacity). tags: - - subpackage_people parameters: - name: X-Trebellar-Api-Key in: header required: true schema: type: string responses: '200': description: All people successfully assigned to the specified assets content: application/json: schema: $ref: '#/components/schemas/UpsertPeopleAssetBatchResponse' '400': description: Bad Request Error content: {} '500': description: Internal Server Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/UpsertPeopleAssetBatchRequest' components: schemas: AssetId: type: string UpsertPeopleAssetBatchRequest: type: object properties: peopleIds: type: array items: type: string assetIds: type: array items: $ref: '#/components/schemas/AssetId' required: - peopleIds - assetIds UpsertPeopleAssetBatchResponseData: type: object properties: {} UpsertPeopleAssetBatchResponse: type: object properties: data: $ref: '#/components/schemas/UpsertPeopleAssetBatchResponseData' required: - data ``` ## SDK Code Examples ```typescript import { TrebellarApiClient } from "@trebellar/api-sdk"; async function main() { const client = new TrebellarApiClient({ environment: "https://api.trebellar.app", }); await client.people.upsertPeopleAssetBatch({ peopleIds: [ "string", ], assetIds: [ "st_sf_tower_01", ], }); } main(); ``` ```python from trebellar import TrebellarApi client = TrebellarApi( base_url="https://api.trebellar.app", api_key= ) client.people.upsert_people_asset_batch( people_ids=[ "string" ], asset_ids=[ "st_sf_tower_01" ] ) ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.trebellar.app/api/v2/people/batch/assets/upsert" payload := strings.NewReader("{\n \"peopleIds\": [\n \"string\"\n ],\n \"assetIds\": [\n \"st_sf_tower_01\"\n ]\n}") req, _ := http.NewRequest("PATCH", 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/people/batch/assets/upsert") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["X-Trebellar-Api-Key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"peopleIds\": [\n \"string\"\n ],\n \"assetIds\": [\n \"st_sf_tower_01\"\n ]\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.patch("https://api.trebellar.app/api/v2/people/batch/assets/upsert") .header("X-Trebellar-Api-Key", "") .header("Content-Type", "application/json") .body("{\n \"peopleIds\": [\n \"string\"\n ],\n \"assetIds\": [\n \"st_sf_tower_01\"\n ]\n}") .asString(); ``` ```php request('PATCH', 'https://api.trebellar.app/api/v2/people/batch/assets/upsert', [ 'body' => '{ "peopleIds": [ "string" ], "assetIds": [ "st_sf_tower_01" ] }', 'headers' => [ 'Content-Type' => 'application/json', 'X-Trebellar-Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.trebellar.app/api/v2/people/batch/assets/upsert"); var request = new RestRequest(Method.PATCH); request.AddHeader("X-Trebellar-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"peopleIds\": [\n \"string\"\n ],\n \"assetIds\": [\n \"st_sf_tower_01\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-Trebellar-Api-Key": "", "Content-Type": "application/json" ] let parameters = [ "peopleIds": ["string"], "assetIds": ["st_sf_tower_01"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.trebellar.app/api/v2/people/batch/assets/upsert")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" 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() ```