# Update Location Definitions PUT https://api.trebellar.app/api/v2/locations Content-Type: application/json Reference: https://docs.trebellar.app/api-reference/api-resources/assets/update-locations ## OpenAPI Specification ```yaml openapi: 3.1.0 info: title: API version: 1.0.0 paths: /api/v2/locations: put: operationId: update-locations summary: Update Location Definitions tags: - subpackage_assets parameters: - name: X-Trebellar-Api-Key in: header required: true schema: type: string responses: '200': description: Locations updated successfully content: application/json: schema: $ref: '#/components/schemas/UpdateLocationsResponse' '400': description: Bad Request — one or more location IDs not found content: application/json: schema: $ref: '#/components/schemas/ErrorSchema' '500': description: Internal Server Error content: application/json: schema: $ref: '#/components/schemas/ErrorSchema' requestBody: content: application/json: schema: $ref: '#/components/schemas/UpdateLocationsRequest' servers: - url: https://api.trebellar.app components: schemas: UpdateLocationsRequestLocationsItemsType: type: string enum: - region - sub-region - area - city - site - campus title: UpdateLocationsRequestLocationsItemsType UpdateLocationsRequestLocationsItemsStatus: type: string enum: - active - archived default: active title: UpdateLocationsRequestLocationsItemsStatus UpdateLocationsRequestLocationsItems: type: object properties: id: type: string name: type: string type: $ref: '#/components/schemas/UpdateLocationsRequestLocationsItemsType' parentId: type: string status: $ref: '#/components/schemas/UpdateLocationsRequestLocationsItemsStatus' required: - id - name - type title: UpdateLocationsRequestLocationsItems UpdateLocationsRequest: type: object properties: locations: type: array items: $ref: '#/components/schemas/UpdateLocationsRequestLocationsItems' required: - locations description: Request to update one or more existing location definitions title: UpdateLocationsRequest LocationDefinitionType: type: string enum: - region - sub-region - area - city - site - campus title: LocationDefinitionType LocationDefinitionStatus: type: string enum: - active - archived default: active title: LocationDefinitionStatus LocationDefinition: type: object properties: id: type: string name: type: string type: $ref: '#/components/schemas/LocationDefinitionType' parentId: type: string status: $ref: '#/components/schemas/LocationDefinitionStatus' required: - id - name - type description: A location definition within the organization hierarchy title: LocationDefinition UpdateLocationsResponse: type: object properties: data: type: array items: $ref: '#/components/schemas/LocationDefinition' required: - data description: Response after updating location definitions title: UpdateLocationsResponse ErrorSchema: type: object properties: code: type: number format: double message: type: string error: type: string details: type: object additionalProperties: description: Any type required: - code - message description: Common Error Schema title: ErrorSchema securitySchemes: apiKey: type: apiKey in: header name: X-Trebellar-Api-Key bearerAuth: type: http scheme: bearer ``` ## SDK Code Examples ```typescript import { TrebellarApiClient } from "@trebellar/api-sdk"; async function main() { const client = new TrebellarApiClient({ apiKey: "YOUR_API_KEY_HERE", }); await client.assets.updateLocations({ locations: [ { id: "string", name: "string", type: "region", }, ], }); } main(); ``` ```python from trebellar import TrebellarApi from trebellar.assets import UpdateLocationsRequestLocationsItem client = TrebellarApi( api_key="YOUR_API_KEY_HERE", ) client.assets.update_locations( locations=[ UpdateLocationsRequestLocationsItem( id="string", name="string", type="region", ) ], ) ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.trebellar.app/api/v2/locations" payload := strings.NewReader("{\n \"locations\": [\n {\n \"id\": \"string\",\n \"name\": \"string\",\n \"type\": \"region\"\n }\n ]\n}") req, _ := http.NewRequest("PUT", 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/locations") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["X-Trebellar-Api-Key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"locations\": [\n {\n \"id\": \"string\",\n \"name\": \"string\",\n \"type\": \"region\"\n }\n ]\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.trebellar.app/api/v2/locations") .header("X-Trebellar-Api-Key", "") .header("Content-Type", "application/json") .body("{\n \"locations\": [\n {\n \"id\": \"string\",\n \"name\": \"string\",\n \"type\": \"region\"\n }\n ]\n}") .asString(); ``` ```php request('PUT', 'https://api.trebellar.app/api/v2/locations', [ 'body' => '{ "locations": [ { "id": "string", "name": "string", "type": "region" } ] }', 'headers' => [ 'Content-Type' => 'application/json', 'X-Trebellar-Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.trebellar.app/api/v2/locations"); var request = new RestRequest(Method.PUT); request.AddHeader("X-Trebellar-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"locations\": [\n {\n \"id\": \"string\",\n \"name\": \"string\",\n \"type\": \"region\"\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 = ["locations": [ [ "id": "string", "name": "string", "type": "region" ] ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.trebellar.app/api/v2/locations")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" 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() ```