Locations
Create & Update Locations
When you create or update your location, we'll automatically create the location cache object for you. The cache will let you access properties about all of your locations with much better latency to answer questions like, "Which location does this user have access to?"
Create LocationPOST `/v1/locations`
You only need a name
and address
to create a location. To view all of the properties, check the update locations section
js
const data = {
name: "PackageX HQ",
address: "500 7th Ave, Floor 10, New York, NY, 92110", //We'll parse the address
};
const response = await fetch(`https://api.packagex.io/v1/locations`, {
method: "POST",
headers: {
"PX-API-KEY": process.env.PX_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
const location = response.data;
Update LocationPOST `/v1/locations/:location`
js
const data = {
name: "PackageX HQ",
address: "500 7th Ave, Floor 10, New York, NY, 92110",
kiosk_message: "Please leave packages in the lobby",
pickup_types: ["in_person_pickup", "curbside_pickup"],
metadata: {}, //Whatever key value pairs you want to add
access: "Enter through the side door on 205 W 37th",
operating_hours: {
saturday: {
active: true,
open: "9:30",
close: "15:45",
},
sunday: {
active: false,
},
},
marketplace: {
active: false,
fees: {
local_amount: 500, //$5.00
tax_percent: 7.25,
toll_amount: 1550, //$15.50
},
capacity: 50,
},
};
const response = await fetch(`https://api.packagex.io/v1/locations/loc_8GiCVuqZqBJi43v2WebaME`, {
method: "POST",
headers: {
"PX-API-KEY": process.env.PX_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
const location = response.data;