curl --request POST \
--url https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert \
--header 'Content-Type: application/json' \
--header 'x-client-key: <api-key>' \
--header 'x-client-secret: <api-key>' \
--data '
{
"locations": [
{
"externalId": "DISTRICT-SW-3",
"name": "Southwest District 3",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d"
},
{
"externalId": "STORE-1042",
"name": "Store 1042 - Rosedale",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e",
"parentExternalId": "DISTRICT-SW-3"
}
]
}
'import requests
url = "https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert"
payload = { "locations": [
{
"externalId": "DISTRICT-SW-3",
"name": "Southwest District 3",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d"
},
{
"externalId": "STORE-1042",
"name": "Store 1042 - Rosedale",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e",
"parentExternalId": "DISTRICT-SW-3"
}
] }
headers = {
"x-client-key": "<api-key>",
"x-client-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-key': '<api-key>',
'x-client-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
locations: [
{
externalId: 'DISTRICT-SW-3',
name: 'Southwest District 3',
hierarchyId: '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
levelId: '5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d'
},
{
externalId: 'STORE-1042',
name: 'Store 1042 - Rosedale',
hierarchyId: '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
levelId: '6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e',
parentExternalId: 'DISTRICT-SW-3'
}
]
})
};
fetch('https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'locations' => [
[
'externalId' => 'DISTRICT-SW-3',
'name' => 'Southwest District 3',
'hierarchyId' => '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
'levelId' => '5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d'
],
[
'externalId' => 'STORE-1042',
'name' => 'Store 1042 - Rosedale',
'hierarchyId' => '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
'levelId' => '6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e',
'parentExternalId' => 'DISTRICT-SW-3'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-client-key: <api-key>",
"x-client-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert"
payload := strings.NewReader("{\n \"locations\": [\n {\n \"externalId\": \"DISTRICT-SW-3\",\n \"name\": \"Southwest District 3\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d\"\n },\n {\n \"externalId\": \"STORE-1042\",\n \"name\": \"Store 1042 - Rosedale\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e\",\n \"parentExternalId\": \"DISTRICT-SW-3\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-key", "<api-key>")
req.Header.Add("x-client-secret", "<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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert")
.header("x-client-key", "<api-key>")
.header("x-client-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"locations\": [\n {\n \"externalId\": \"DISTRICT-SW-3\",\n \"name\": \"Southwest District 3\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d\"\n },\n {\n \"externalId\": \"STORE-1042\",\n \"name\": \"Store 1042 - Rosedale\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e\",\n \"parentExternalId\": \"DISTRICT-SW-3\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-client-key"] = '<api-key>'
request["x-client-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"locations\": [\n {\n \"externalId\": \"DISTRICT-SW-3\",\n \"name\": \"Southwest District 3\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d\"\n },\n {\n \"externalId\": \"STORE-1042\",\n \"name\": \"Store 1042 - Rosedale\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e\",\n \"parentExternalId\": \"DISTRICT-SW-3\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"externalId": "DISTRICT-SW-3",
"id": "2f169333-21f1-4197-8cac-cd0860a83515",
"name": "Southwest District 3",
"created": true
},
{
"externalId": "STORE-1042",
"id": "8099a742-c9bb-40a7-976e-1963a07e77b6",
"name": "Store 1042 - Rosedale",
"created": true
}
],
"extra_meta": {
"message": "Locations upserted"
}
}Bulk Upsert Locations
Creates or renames up to 2,000 locations per call.
Identity resolution: externalId (recorded on first create, so re-runs resolve to the same location) → id. At least one is required. Unmatched rows create a new location.
Placement on create is optional: hierarchyId, levelId, and a parent given as either parentExternalId or parentId (not both). New locations inherit the workspace timezone and get the next location number.
Placement on an existing location is rejected. Supplying a hierarchyId, levelId, or parent that differs from the location’s current placement returns 400 — “Location ”…” cannot be moved or re-parented via the enterprise API (V1 supports create + rename only)”. Omit the placement fields to rename in place. Moving a location between parents (for example a store from one district to another) is planned for a later version; until then, do it in the Xenia UI, or model the changing dimension as a location attribute and update it through Bulk Upsert Attribute Values.
The whole batch runs in one transaction: if any row fails, no locations from that call are created.
Requires the Public API and Location Attributes workspace features plus CAN_MANAGE_LOCATIONS.
curl --request POST \
--url https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert \
--header 'Content-Type: application/json' \
--header 'x-client-key: <api-key>' \
--header 'x-client-secret: <api-key>' \
--data '
{
"locations": [
{
"externalId": "DISTRICT-SW-3",
"name": "Southwest District 3",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d"
},
{
"externalId": "STORE-1042",
"name": "Store 1042 - Rosedale",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e",
"parentExternalId": "DISTRICT-SW-3"
}
]
}
'import requests
url = "https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert"
payload = { "locations": [
{
"externalId": "DISTRICT-SW-3",
"name": "Southwest District 3",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d"
},
{
"externalId": "STORE-1042",
"name": "Store 1042 - Rosedale",
"hierarchyId": "9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34",
"levelId": "6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e",
"parentExternalId": "DISTRICT-SW-3"
}
] }
headers = {
"x-client-key": "<api-key>",
"x-client-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-key': '<api-key>',
'x-client-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
locations: [
{
externalId: 'DISTRICT-SW-3',
name: 'Southwest District 3',
hierarchyId: '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
levelId: '5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d'
},
{
externalId: 'STORE-1042',
name: 'Store 1042 - Rosedale',
hierarchyId: '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
levelId: '6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e',
parentExternalId: 'DISTRICT-SW-3'
}
]
})
};
fetch('https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'locations' => [
[
'externalId' => 'DISTRICT-SW-3',
'name' => 'Southwest District 3',
'hierarchyId' => '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
'levelId' => '5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d'
],
[
'externalId' => 'STORE-1042',
'name' => 'Store 1042 - Rosedale',
'hierarchyId' => '9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34',
'levelId' => '6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e',
'parentExternalId' => 'DISTRICT-SW-3'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-client-key: <api-key>",
"x-client-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert"
payload := strings.NewReader("{\n \"locations\": [\n {\n \"externalId\": \"DISTRICT-SW-3\",\n \"name\": \"Southwest District 3\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d\"\n },\n {\n \"externalId\": \"STORE-1042\",\n \"name\": \"Store 1042 - Rosedale\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e\",\n \"parentExternalId\": \"DISTRICT-SW-3\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-key", "<api-key>")
req.Header.Add("x-client-secret", "<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(string(body))
}HttpResponse<String> response = Unirest.post("https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert")
.header("x-client-key", "<api-key>")
.header("x-client-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"locations\": [\n {\n \"externalId\": \"DISTRICT-SW-3\",\n \"name\": \"Southwest District 3\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d\"\n },\n {\n \"externalId\": \"STORE-1042\",\n \"name\": \"Store 1042 - Rosedale\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e\",\n \"parentExternalId\": \"DISTRICT-SW-3\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xenia.team/api/v1/mgt/enterprise/workspaces/{workspaceId}/locations/bulk-upsert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-client-key"] = '<api-key>'
request["x-client-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"locations\": [\n {\n \"externalId\": \"DISTRICT-SW-3\",\n \"name\": \"Southwest District 3\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"5b6c7d8e-9f01-4a2b-8c3d-4e5f6a7b8c9d\"\n },\n {\n \"externalId\": \"STORE-1042\",\n \"name\": \"Store 1042 - Rosedale\",\n \"hierarchyId\": \"9c2a1b7e-4d3f-4a11-9c88-2f0e5a6b1c34\",\n \"levelId\": \"6c7d8e9f-0a12-4b3c-8d4e-5f6a7b8c9d0e\",\n \"parentExternalId\": \"DISTRICT-SW-3\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"externalId": "DISTRICT-SW-3",
"id": "2f169333-21f1-4197-8cac-cd0860a83515",
"name": "Southwest District 3",
"created": true
},
{
"externalId": "STORE-1042",
"id": "8099a742-c9bb-40a7-976e-1963a07e77b6",
"name": "Store 1042 - Rosedale",
"created": true
}
],
"extra_meta": {
"message": "Locations upserted"
}
}Path Parameters
UUID of the workspace. Must be the workspace your API key is bound to.
Body
1 - 2000 elementsShow child attributes
Show child attributes
Response
One row per input row, with the resolved Xenia id and whether it was newly created.