API Reference - Service Areas
Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108068
← Back to API Reference | Getting Started
Service Areas
Service Areas defines geographic regions where a member provides services. Each record stores a location with precise coordinates and bounding box data, enabling radius-based search and geographic filtering on the directory.
Model name in URL:
service_areas — DB table: service_areasThe Service Areas Object
| Field | Type | Description |
|---|---|---|
area_id | integer | Unique service area record ID (primary key, read-only) |
user_id | integer | ID of the member this service area belongs to (foreign key to users) |
address | string | Human-readable address string for this service area (EG Pasadena, CA, USA) |
country_sn | string | Two-letter country code (EG US) |
state_sn | string | State or province abbreviation (EG CA) |
city | string | City name for this service area location |
zip_code | string | Zip or postal code for this service area location |
county_sn | string | County name for this service area location |
lat | number | Latitude coordinate of this service area (double precision) |
lon | number | Longitude coordinate of this service area (double precision) |
location_type | string | Type of location (EG City, State, County, Zip) |
place_id | string | Google Places API place ID for this location |
nelat | number | Northeast latitude of the bounding box for this area (default 0) |
nelng | number | Northeast longitude of the bounding box for this area (default 0) |
swlat | number | Southwest latitude of the bounding box for this area (default 0) |
swlng | number | Southwest longitude of the bounding box for this area (default 0) |
List Service Area Records
GET /api/v2/service_areas/get
Returns a paginated list of service area records.
Example Request
Copy
curl -X GET "https://www.yourdomain.com/api/v2/service_areas/get?limit=25" \ -H "X-Api-Key: your-api-key-here"
Example Response
Copy
{
"status": "success",
"message": [
{
"tablesExists": true,
"area_id": "1",
"user_id": "1",
"address": "Pasadena, CA, USA",
"country_sn": "US",
"state_sn": "CA",
"city": "Pasadena",
"zip_code": "",
"county_sn": "Los Angeles County",
"lat": "34.1477849",
"lon": "-118.1445155",
"location_type": "City",
"place_id": "ChIJUQszONzCwoARSo_RGhZBKwU",
"nelat": "34.251905",
"nelng": "-118.0654789",
"swlat": "34.1170368",
"swlng": "-118.1981391"
},
{
"tablesExists": true,
"area_id": "2",
"user_id": "44",
"address": "California, USA",
"country_sn": "US",
"state_sn": "CA",
"city": "",
"zip_code": "",
"county_sn": "",
"lat": "36.778261",
"lon": "-119.4179324",
"location_type": "State",
"place_id": "ChIJPV4oX_65j4ARVW8IJ6IJUYs",
"nelat": "42.009503",
"nelng": "-114.131211",
"swlat": "32.528832",
"swlng": "-124.482003"
}
],
"total": "10",
"current_page": 1,
"total_pages": 5,
"next_page": "MipfKjI="
}Retrieve a Service Area Record
GET /api/v2/service_areas/get/{area_id}
Example Request
Copy
curl -X GET "https://www.yourdomain.com/api/v2/service_areas/get/1" \ -H "X-Api-Key: your-api-key-here"
Example Response
Copy
{
"status": "success",
"message": [
{
"tablesExists": true,
"area_id": "1",
"user_id": "1",
"address": "Pasadena, CA, USA",
"country_sn": "US",
"state_sn": "CA",
"city": "Pasadena",
"zip_code": "",
"county_sn": "Los Angeles County",
"lat": "34.1477849",
"lon": "-118.1445155",
"location_type": "City",
"place_id": "ChIJUQszONzCwoARSo_RGhZBKwU",
"nelat": "34.251905",
"nelng": "-118.0654789",
"swlat": "34.1170368",
"swlng": "-118.1981391"
}
],
"total": "10",
"current_page": 1,
"total_pages": 1
}Create a Service Area Record
POST /api/v2/service_areas/create
Adds a new service area location for a member.
Example Request
Copy
curl -X POST "https://www.yourdomain.com/api/v2/service_areas/create" \ -H "X-Api-Key: your-api-key-here" \ -d "user_id=1" \ -d "address=Los Angeles, CA, USA" \ -d "country_sn=US" \ -d "state_sn=CA" \ -d "city=Los Angeles" \ -d "county_sn=Los Angeles County" \ -d "lat=34.0522342" \ -d "lon=-118.2436849" \ -d "location_type=City"
Example Response
Copy
{
"status": "success",
"message": {
"area_id": "910023",
"user_id": "1",
"address": "Los Angeles, CA, USA",
"country_sn": "US",
"state_sn": "CA",
"city": "Los Angeles",
"zip_code": null,
"county_sn": "Los Angeles County",
"lat": "34.0522342",
"lon": "-118.2436849",
"location_type": "City",
"place_id": null,
"nelat": null,
"nelng": null,
"swlat": null,
"swlng": null
}
}Update a Service Area Record
PUT /api/v2/service_areas/update
Example Request
Copy
curl -X PUT "https://www.yourdomain.com/api/v2/service_areas/update" \ -H "X-Api-Key: your-api-key-here" \ -d "area_id=910023" \ -d "city=Santa Monica"
Example Response
Copy
{
"status": "success",
"message": {
"area_id": "910023",
"user_id": "1",
"address": "Los Angeles, CA, USA",
"country_sn": "US",
"state_sn": "CA",
"city": "Santa Monica",
"zip_code": "",
"county_sn": "Los Angeles County",
"lat": "34.0522342",
"lon": "-118.2436849",
"location_type": "City",
"place_id": "",
"nelat": "0",
"nelng": "0",
"swlat": "0",
"swlng": "0"
}
}Delete a Service Area Record
DELETE /api/v2/service_areas/delete
Example Request
Copy
curl -X DELETE "https://www.yourdomain.com/api/v2/service_areas/delete" \ -H "X-Api-Key: your-api-key-here" \ -d "area_id=910023"
Example Response
Copy
{
"status": "success",
"message": "service_areas record was deleted"
}