Skip to main content

Overview

The Sectores (Sectors) endpoint allows you to create and manage geographic sectors for advertising campaigns. Each sector defines a virtual geofence with coordinate boundaries and is associated with a specific company and campaign. The geographic data is stored in JSON format for flexibility.

Base URL

/api/sectores/

Endpoints

List All Sectors

Retrieve a list of all geographic sectors. Response
id_sector
integer
Unique identifier for the sector (auto-generated)
id_empresa
integer
Foreign key to the company (Empresa) that owns this sector
id_campana
integer
Foreign key to the advertising campaign (CampanaPublicitaria) this sector belongs to
nombre
string
Name of the sector (max 100 characters)
fecha_creacion
date
Date when the sector was created (format: YYYY-MM-DD)
cerco_virtual
json
JSON field containing the virtual geofence coordinates. Typically an array of coordinate objects defining the polygon boundary.
centro
json
JSON field containing the center coordinates of the sector. Typically includes latitude and longitude (default: empty object)
zoom
integer
Map zoom level for displaying the sector
id_ciudad
integer
Foreign key to the city where the sector is located
id_pais
integer
Foreign key to the country where the sector is located
fecha_modificacion
date
Date when the sector was last modified (format: YYYY-MM-DD)
estado
integer
Sector status (0: inactive, 1: active)

Create a Sector

Create a new geographic sector with virtual boundaries. Request Body
id_empresa
integer
required
ID of the company owning this sector
id_campana
integer
required
ID of the campaign this sector belongs to
nombre
string
required
Name of the sector (max 100 characters)
fecha_creacion
date
required
Creation date (YYYY-MM-DD)
cerco_virtual
json
required
Virtual geofence coordinates defining the sector boundary. Should be a JSON array of coordinate objects.Example structure:
[
  {"lat": -0.1234, "lng": -78.5678},
  {"lat": -0.1235, "lng": -78.5679},
  {"lat": -0.1236, "lng": -78.5680}
]
centro
json
Center coordinates of the sector (default: )Example structure:
{"lat": -0.1235, "lng": -78.5679}
zoom
integer
required
Map zoom level (typically between 1-20)
id_ciudad
integer
required
ID of the city for this sector
id_pais
integer
required
ID of the country for this sector
fecha_modificacion
date
required
Modification date (YYYY-MM-DD)
estado
integer
required
Sector status (0: inactive, 1: active)

Retrieve a Sector

Retrieve details of a specific sector by ID.

Update a Sector

Update all fields of a specific sector. Partially update specific fields of a sector.

Delete a Sector

Delete a specific sector by ID.

Special Endpoints

Get Sectors by User

Retrieve sectors filtered by user role and permissions. Behavior by Role:
  • Administrator (role 1): Returns all sectors
  • Publicista (role 2): Returns sectors for companies associated with the publicist
  • Empresa (role 3): Returns sectors for the specific company
Response Returns an array of sector objects following the same structure as the list endpoint.

Example Usage

Creating a Sector with Geographic Boundaries

{
  "id_empresa": 1,
  "id_campana": 5,
  "nombre": "Downtown Business District",
  "fecha_creacion": "2024-05-01",
  "cerco_virtual": [
    {"lat": -0.1807, "lng": -78.4678},
    {"lat": -0.1825, "lng": -78.4650},
    {"lat": -0.1843, "lng": -78.4670},
    {"lat": -0.1830, "lng": -78.4698},
    {"lat": -0.1807, "lng": -78.4678}
  ],
  "centro": {
    "lat": -0.1825,
    "lng": -78.4674
  },
  "zoom": 15,
  "id_ciudad": 1,
  "id_pais": 1,
  "fecha_modificacion": "2024-05-01",
  "estado": 1
}

Notes

  • The cerco_virtual field must contain valid JSON with coordinate data
  • The centro field is typically used for map centering and can be calculated as the centroid of the polygon
  • Coordinates should follow standard latitude/longitude format
  • The zoom level should be appropriate for the size of the sector area

Build docs developers (and LLMs) love