1. Locations
  2. Create & Update Locations

Locations

Create & Update Locations

The Location API enables you to create and manage physical locations in your organization. When you create a location, we automatically generate a location cache object to provide fast access to essential location data.

Create Location

POST
`/v1/locations`

You only need a name and address to create a location. To view all of the properties, check the Update Location section below.

Required Payload

  • name string
  • address string|object

Optional Payload

js
        {
  "code": string,
  "email": string,
  "address_line2": string,
  "easy_post_api_key": string,
  "activate_location": boolean,
  "provider_instructions": string,
  "service_levels": string[],
  "operating_hours": {
    "monday": {
      "active": boolean,
      "open": string,
      "close": string,
    },
    // ... same structure for all days of week
  },
  "settings": {
    "notifications": {
      "[notification_type]": {
        "enabled": boolean,
        "use_organization_rules": boolean,
        "limit_to_operating_hours": boolean,
        "batch_interval": string,
        "reminder": {
          "count": string,
          "interval": string,
        }
      }
    }
  },
  "metadata": object,
}

      

Default Values

When creating a new location:

  • Operating hours default to Monday-Friday, 9 AM - 5 PM
  • The location is assigned to both the creating user and all users with the owner role in the organization.
  • A default layout is created
  • Notification settings initialize with default configurations
  • Service levels include all available options by default

Plan Limitations

Location creation is subject to plan limits:

  • Free plan: Maximum of 2 locations
  • Professional plan: Maximum of 5 locations
  • Enterprise plan: Unlimited locations

Example Request

js
        const data = {
  name: "Company HQ",
  address: "500 7th Ave, Floor 10, New York, NY, 10018", //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)
}).then((res) => res.json());

const location = response.data;

      

Update Location

POST
`/v1/locations/:location`

Updates an existing location's attributes using the id of the location.

Path Parameters

  • location_id (required): The unique identifier of the location to update, prefixed with loc_
js
        const data = {
  name: "PackageX HQ",
  code: "PHQ",
  email: "abc.xyz@packagex.xyz",
  address: "500 7th Ave, Floor 10, New York, NY, 92110",
  operating_hours: {
    saturday: {
      active: true,
      open: "9:30",
      close: "15:45",
    },
    sunday: {
      active: false,
    },
  },
  provider_instructions: "Come in the blue door in the back",
  service_levels: ["in_person_pickup", "next_day_later"],
  metadata: {
    purpose: "testing"
  },
};

const response = await fetch(`https://api.packagex.io/v1/locations/${location_id}`, {
  method: "POST",
  headers: {
    "PX-API-KEY": process.env.PX_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(data),
}).then((res) => res.json());

const location = response.data;