Overview
The Zones & Cities API provides endpoints for managing geographic boundaries, zones, and cities used in trip planning and routing. Zones represent larger geographic areas (like provinces or regions), while cities are specific locations within zones.Authentication
Most endpoints require authentication. Admin endpoints require admin role. Include the JWT token in the Authorization header:Zones
Get All Zones
Retrieve all zones with pagination, search, and filtering options.Query Parameters
Page number for pagination
Number of items per page (max 100)
Search zones by name
Filter by active status
Sort field:
name, created, or activeSort order:
asc or descResponse
List of zones
Total number of zones
Current page number
Items per page
Total number of pages
Example Request
Example Response
Get Zone by ID
Retrieve detailed information about a specific zone.Path Parameters
Zone unique identifier
Response
Returns a single zone object with the same structure as in the zones list.Example Request
Create Zone
Create a new zone. Admin only.Request Body
Zone name (2-100 characters)
Whether trips within the zone are allowed
ISO country code (2 characters, e.g., “SA”, “AE”)
Response
Created zone ID
Zone name
Intra-zone transport setting
Country code
Success message
Example Request
Example Response
Update Zone
Update zone information. Admin only.Path Parameters
Zone unique identifier
Request Body
Updated zone name
Updated intra-zone transport setting
Updated country code
Updated active status
Example Request
Delete Zone
Soft delete a zone. Admin only.Path Parameters
Zone unique identifier
Response
Success message
Example Request
Validate Travel Between Zones
Validate if travel is allowed between two locations (origin and destination zones).Request Body
Origin zone ID
Destination zone ID
Response
Whether travel is allowed between zones
Explanation message
Example Request
Cities
Get All Cities
Retrieve all cities with pagination, search, and filtering. Public endpoint.Query Parameters
Page number
Items per page (max 100)
Search cities by name
Filter by active status
Filter by zone ID
Sort field:
name, created, or activeSort order:
asc or descResponse
List of cities
Total number of cities
Current page
Items per page
Total pages
Example Request
Example Response
Get City by ID
Retrieve detailed information about a specific city.Path Parameters
City unique identifier
Example Request
Create City
Create a new city. Admin only.Request Body
City name (2-100 characters)
City latitude (-90 to 90)
City longitude (-180 to 180)
Associated zone ID
Geographic bounding box [minLat, minLon, maxLat, maxLon]
GeoJSON string representing city boundaries
City importance (0.0 to 1.0)
Response
Created city ID
City name
Success message
Example Request
Update City
Update city information. Admin only.Path Parameters
City unique identifier
Request Body
Same parameters as Create City, all optional.Set city active status
Example Request
Delete City
Soft delete a city. Admin only.Path Parameters
City unique identifier
Example Request
Get Cities for Map
Get cities optimized for map display with minimal data.Response
Returns a simplified list of cities with only essential fields: ID, Name, Latitude, Longitude, IsActive.Example Request
Get Available Destinations
Get available destination cities from a specific origin city.Query Parameters
Origin city ID
Response
List of reachable destination cities
Example Request
Error Responses
All endpoints may return the following error responses:Error message in Arabic or English
Detailed validation errors
Common Error Codes
400 Bad Request- Invalid request parameters or validation errors401 Unauthorized- Missing or invalid authentication token403 Forbidden- Insufficient permissions (admin role required)404 Not Found- Zone or city not found409 Conflict- Duplicate zone/city name500 Internal Server Error- Server error
Example Error Response
Notes
Zone Validation
- Zones control inter-city travel permissions
AllowIntraZoneTransportdetermines if trips within the same zone are allowed- Cross-zone travel is validated using the
/zones/validate-travelendpoint
City Boundaries
- Cities can have both simple coordinates (Latitude/Longitude) and complex boundaries (GeoJSON)
BoundingBoxprovides a simple rectangular boundary for quick filteringGeoJsonprovides precise polygon boundaries for accurate location checkingImportancehelps prioritize cities in autocomplete and search results
Best Practices
- Always validate travel between cities before creating trips
- Use bounding boxes for initial filtering, then GeoJSON for precise validation
- Cache city and zone data in client applications to reduce API calls
- Sort by importance when displaying city search results to users