Overview
The Locations API enables management of hierarchical location structures within containers. Locations can be nested to create organizational hierarchies, allowing for precise tracking of where inventory items are stored.Endpoints
Get Locations
Retrieves all locations associated with a specific container.Path Parameters
The ID of the container whose locations to retrieve
Response
Array of location objects
Example Request
Example Response
Error Responses
Unauthorized - Authentication required or token invalid
Container not found
Create Location
Creates a new location within a container.Request Body
ID of the container to create the location in
Name of the location
Optional description of the location
ID of the parent location (omit for root-level location)
Response
The newly created location object
Example Request
Example Response
Error Responses
Location created successfully
Unauthorized - Invalid or missing authentication token
Bad request - Invalid parent_id or missing required fields
Update Location
Updates an existing location’s details.Path Parameters
The ID of the location to update
Request Body
Updated name of the location
Updated description
Updated parent location ID (use null to make it a root location)
Response
The updated location object
Example Request
Example Response
Error Responses
Location updated successfully
Unauthorized - Authentication required
Location not found
Bad request - Invalid parent_id (would create circular hierarchy)
Delete Location
Deletes a location from the system.Path Parameters
The ID of the location to delete
Response
Returns status code 204 (No Content) or 200 (OK) on successful deletion.Example Request
Error Responses
Location deleted successfully (no content returned)
Location deleted successfully
Unauthorized - Authentication required
Location not found
Conflict - Cannot delete location with child locations or assigned items
Business Logic Notes
Hierarchical Structure
- Locations support unlimited nesting depth through the
parent_idfield - The
childrenarray is populated recursively when retrieving locations - Root-level locations have
parent_idset tonull
Deletion Rules
- Locations with child locations must have children removed first
- Locations with assigned inventory items cannot be deleted until items are reassigned
- Consider implementing soft deletes for audit trail purposes
Performance Considerations
- The
childrenarray is not included intoJson()to prevent circular serialization issues - For deep hierarchies, consider implementing pagination or lazy loading of child locations
- The
getLocationsCount()method fetches all locations and returns the count - consider server-side counting for large datasets
Access Control
- All location operations require valid JWT authentication
- Users can only access locations within containers they have permission to view
- Container ownership determines location management permissions
