# Geocercas

Métodos relacionados con las geocercas.

# Lista de geocercas - getGeofences

##### <span class="api-method" data-method="POST">POST</span> https://api.service24gps.com/api/v1/getGeofences

Obtiene el listado de geocercas de tipo poligonal (dibujo), lineal (ruta) o circular.

<details class="mb-m" id="bkmrk-body-parametersparam"><summary class="text-muted">Ver parámetros de solicitud:</summary>

<div><table class="table" style="height: 139px; width: 809px;"><tbody><tr style="height: 41px;"><th style="width: 106px; height: 41px;">Parámetros</th><th style="width: 329px; height: 41px;">Descripción</th><th style="width: 97px;">Longitud</th><th style="width: 277px; height: 41px;">Ejemplo</th></tr><tr style="height: 57px;"><td style="width: 106px; height: 57px;">apikey</td><td style="width: 329px; height: 57px;">Llave de autorización para uso de los Servicios Web.</td><td style="width: 97px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">50</span></td><td style="width: 277px; height: 57px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">25sdsd234234aa93sdsdsd37c70118e72</span></td></tr><tr style="height: 41px;"><td style="width: 106px; height: 41px;">token</td><td style="width: 329px; height: 41px;">Token devuelto por el método getToken.</td><td style="width: 97px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">500</span></td><td style="width: 277px; height: 41px;"><span style="color: #3366ff;">wfszR/oPIQKjt5HT5NgjDnZ2SAZQ==</span></td></tr></tbody></table>

</div></details>##### Solicitud de ejemplo:

```shell
curl --location --request POST 'https://api.service24gps.com/api/v1/getGeofences' \
--form 'apikey="25sdsd234234aa93sdsdsd37c70118e72"' \
--form 'token="wfszR/oPIQKjt5HT5NgjDnZ2SAZQ=="'
```

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": [
 		{
            "idCerca": 987984,
            "idtipo_cerca": 2,
            "tipo_cerca": "Circulo",
            "nombre": "Geocerca 2",
            "color": "#024769",
            "puntos": [
                {
                    "lat": 19.12084,
                    "lng": -98.24436
                }
            ],
            "radio": 160,
            "limite_velocidad": 10,
            "solo_mi_usuario": 0,
            "visible": 0,
            "umbral": {
                "puntos_poligono": [],
                "tolerancia": 0
            },
            "grupo": "Sin Asignar",
            "compartida": 1
        },
        {
            "idCerca": 46468,
            "idtipo_cerca": 3,
            "tipo_cerca": "Ruta",
            "nombre": "Geocerca 3",
            "color": "#FF0000",
            "puntos": [
                {
                    "lat": -15.350319,
                    "lng": -75.145134
                },
                {
                    "lat": -15.350459,
                    "lng": -75.145083
                },
                {
                    "lat": -15.35056,
                    "lng": -75.145035
                },
                {
                    "lat": -15.350728,
                    "lng": -75.144909
                }
            ],
            "radio": 0,
            "limite_velocidad": 50,
            "solo_mi_usuario": 0,
            "visible": 0,
            "umbral": {
                "puntos_poligono": [
                    {
                        "lat": -15.350557,
                        "lng": -75.145837
                    },
                    {
                        "lat": -15.350758,
                        "lng": -75.14576
                    },
                    {
                        "lat": -15.35022,
                        "lng": -75.144379
                    },
                    {
                        "lat": -15.35008,
                        "lng": -75.14443
                    }
                ],
                "tolerancia": 40
            },
            "grupo": "GRUPO TEST",
            "compartida": 0
        }
    ]
}
```

<details class="mb-m" id="bkmrk-ver-par%C3%A1metros%3A-par%C3%A1" open="open"><summary class="text-muted">Ver campos de respuesta:</summary>

<div><table class="table" id="bkmrk-campo-descripci%C3%B3n-fo" style="width: 809px; height: 659px;"><tbody><tr style="height: 47px;"><th style="width: 174px; height: 47px;">Campo</th><th style="width: 392px; height: 47px;">Descripción

</th><th style="width: 243px; height: 47px;">Formato</th></tr><tr style="height: 41px;"><td style="width: 174px; height: 41px;">idCerca</td><td style="width: 392px; height: 41px;">Identificador único de la geocerca en el sistema.

</td><td style="width: 243px; height: 41px;">Entero</td></tr><tr style="height: 114px;"><td style="width: 174px; height: 114px;">idtipo\_cerca</td><td style="width: 392px; height: 114px;">Indica el tipo de geocerca.

1 = Poligonal o dibujo

2 = Circular

3 = Lineal o ruta

</td><td style="width: 243px; height: 114px;">Entero</td></tr><tr style="height: 47px;"><td style="width: 174px; height: 47px;">tipo\_cerca</td><td style="width: 392px; height: 47px;"> Nombre del tipo de geocerca.

</td><td style="width: 243px; height: 47px;">Cadena de Texto</td></tr><tr style="height: 47px;"><td style="width: 174px; height: 47px;">nombre</td><td style="width: 392px; height: 47px;">Nombre con el que se identifica la geocerca dentro de la plataforma.

</td><td style="width: 243px; height: 47px;">Cadena de Texto</td></tr><tr style="height: 47px;"><td style="width: 174px; height: 47px;">color

</td><td style="width: 392px; height: 47px;">Color con el que se muestra e identifica la geocerca en la plataforma.

</td><td style="width: 243px; height: 47px;">Cadena de Texto **(RGB hexadecimal)**</td></tr><tr style="height: 35px;"><td style="height: 35px; width: 174px;">puntos

</td><td style="width: 392px; height: 35px;">Punto o puntos que conforman la geocerca.

</td><td style="height: 35px; width: 243px;">JSON

</td></tr><tr style="height: 35px;"><td style="height: 35px; width: 174px;">radio

</td><td style="width: 392px; height: 35px;">Radio en metros que abarca la **geocerca circular**.

</td><td style="height: 35px; width: 243px;">Entero

</td></tr><tr style="height: 35px;"><td style="height: 35px; width: 174px;">limite\_velocidad

</td><td style="width: 392px; height: 35px;">Velocidad máxima (Km/h) permitida en la geocerca.

</td><td style="height: 35px; width: 243px;">Entero

</td></tr><tr style="height: 35px;"><td style="height: 35px; width: 174px;">solo\_mi\_usuario

</td><td style="width: 392px; height: 35px;">Indica si la geocerca solo es visible para el usuario que la generó.

1 = Mi usuario

0 = Todos los usuarios

</td><td style="height: 35px; width: 243px;">Entero</td></tr><tr style="height: 35px;"><td style="height: 35px; width: 174px;">visible

</td><td style="width: 392px; height: 35px;">Indica si la geocerca se debe o no mostrar.

1 = Mostrar

0 = Ocultar

</td><td style="height: 35px; width: 243px;">Entero

</td></tr><tr style="height: 47px;"><td style="width: 174px; height: 47px;">umbral

</td><td style="width: 392px; height: 47px;">Datos de la **geocerca lineal o ruta**, el cual contiene los puntos del polígono y la tolerancia.

</td><td style="width: 243px; height: 47px;">JSON

</td></tr><tr style="height: 47px;"><td style="width: 174px; height: 47px;">grupo

</td><td style="width: 392px; height: 47px;">Nombre del grupo que pertenece la geocerca.

</td><td style="width: 243px; height: 47px;">Cadena de Texto

</td></tr><tr style="height: 47px;"><td style="width: 174px; height: 47px;">compartida

</td><td style="width: 392px; height: 47px;">Indica si la geocerca es compartida.

1 = Compartida

0 = No compartida

</td><td style="width: 243px; height: 47px;">Entero

</td></tr></tbody></table>

</div></details>

# Crear geocerca - createGeofence

##### <span class="api-method" data-method="POST">POST</span> https://api.service24gps.com/api/v1/createGeofence

Este método permite crear una geocerca de tipo: circular, poligonal o lineal.

<details class="mb-m" id="bkmrk-body-parametersparam"><summary class="text-muted">Ver parámetros de solicitud:</summary>

<div><table class="table" style="width: 809px;"><tbody><tr><th style="width: 146px;">Parámetros</th><th style="width: 370px;">Descripción</th><th style="width: 293px;">Ejemplo</th></tr><tr><td style="width: 146px;">apikey</td><td style="width: 370px;">**(Requerido)** Llave de autorización para uso de los Servicios Web.</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">25sdsd234234aa93sdsdsd37c70118e72</span></td></tr><tr><td style="width: 146px;">token</td><td style="width: 370px;">**(Requerido)** Token devuelto por el método [**getToken**](https://docs.redgps.com/books/webservice/page/metodo-de-autenticacion-gettoken-7ef).</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">wfszR/oPIQKjt5HT5NgjDnZ2SAZQ==</span></td></tr><tr><td style="width: 146px;">nombre</td><td style="width: 370px;">**(Requerido)** Nombre con el que se identificará la geocerca dentro de la plataforma.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">GeoHome</span></span></td></tr><tr><td style="width: 146px;">puntos

</td><td style="width: 370px;" width="351">**(Requerido)** Punto o puntos que conformarán la geocerca.

</td><td style="width: 293px;"><span style="color: #3366ff;">\[{"lat":-12.087574155453476,"lng":-77.08396062254906},{"lat":-12.087672508218587,"lng":-77.08401560783386},{"lat":-12.087707915205174,"lng":-77.08394654095173},{"lat":-12.087658083148632,"lng":-77.08388954401016},{"lat":-12.087618086359699,"lng":-77.08389893174171},{"lat":-12.08758989189834,"lng":-77.08392508327961},{"lat":-12.08757546682392,"lng":-77.08395726978779}\]</span>

</td></tr><tr><td style="width: 146px;">tipo\_cerca

</td><td style="width: 370px;">**(Requerido)** Indica el tipo de geocerca a crear.

1 = Poligonal o dibujo

2 = Circular

3 = Lineal o ruta.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">1</span></span></td></tr><tr><td style="width: 146px;">color

</td><td style="width: 370px;">**(Opcional)** Color con el que se mostrará e identificará la geocerca en la plataforma, en formato RGB hexadecimal.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">\#223344</span></span></td></tr><tr><td style="width: 146px;">radio

</td><td style="width: 370px;" width="351">**(Opcional)** Radio en metros que abarcará la geocerca circular.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">0 </span></span></td></tr><tr><td style="width: 146px;">limite\_velocidad

</td><td style="width: 370px;" width="351">**(Opcional)** Velocidad máxima (Km/h) permitida en la geocerca.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;"> 50</span></span></td></tr><tr><td style="width: 146px;">solo\_mi\_usuario

</td><td style="width: 370px;" width="351">**(Opcional)** Indica si la geocerca solo es visible para el usuario que la generó.

1 = Mi usuario

0 = Todos los usuarios

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">1 </span></span></td></tr></tbody></table>

</div></details>##### Solicitud de ejemplo:

```shell
curl --location --request POST 'https://api.service24gps.com/api/v1/createGeofence' \
--form 'apikey="25sdsd234234aa93sdsdsd37c70118e72"' \
--form 'token="wfszR/oPIQKjt5HT5NgjDnZ2SAZQ=="' \
--form 'nombre="GeoHome"' \
--form 'puntos="[{\"lat\":-12.087574155453476,\"lng\":-77.08396062254906},{\"lat\":-12.087672508218587,\"lng\":-77.08401560783386},{\"lat\":-12.087707915205174,\"lng\":-77.08394654095173},{\"lat\":-12.087658083148632,\"lng\":-77.08388954401016},{\"lat\":-12.087618086359699,\"lng\":-77.08389893174171},{\"lat\":-12.08758989189834,\"lng\":-77.08392508327961},{\"lat\":-12.08757546682392,\"lng\":-77.08395726978779}]"' \
--form 'tipo_cerca="1"' \
--form 'color="#223344"' \
--form 'radio="0"' \
--form 'limite_velocidad="50"' \
--form 'solo_mi_usuario="1"'
```

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": ""
}
```

# Actualizar geocerca - updateGeofence

##### <span class="api-method" data-method="POST">POST</span> https://api.service24gps.com/api/v1/updateGeofence

Este método permite actualizar cualquier valor de una geocerca.

<details class="mb-m" id="bkmrk-body-parametersparam"><summary class="text-muted">Ver parámetros de solicitud:</summary>

<div><table class="table" style="width: 809px;"><tbody><tr><th style="width: 146px;">Parámetros</th><th style="width: 370px;">Descripción</th><th style="width: 293px;">Ejemplo</th></tr><tr><td style="width: 146px;">apikey</td><td style="width: 370px;">**(Requerido)** Llave de autorización para uso de los Servicios Web.</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">25sdsd234234aa93sdsdsd37c70118e72</span></td></tr><tr><td style="width: 146px;">token</td><td style="width: 370px;">**(Requerido)** Token devuelto por el método getToken.</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">wfszR/oPIQKjt5HT5NgjDnZ2SAZQ==</span></td></tr><tr><td style="width: 146px;">idCerca</td><td style="width: 370px;" width="351">**(Requerido)** Identificador único de la geocerca en el sistema.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;"> 138225</span></span></td></tr><tr><td style="width: 146px;">nombre</td><td style="width: 370px;">Nombre con el que se identificará la geocerca dentro de la plataforma.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">GeoHome</span></span></td></tr><tr><td style="width: 146px;">puntos

</td><td style="width: 370px;" width="351">Punto o puntos que conformarán la geocerca.

</td><td style="width: 293px;"><span style="color: #3366ff;">\[{"lat":-12.087574155453476,"lng":-77.08396062254906},{"lat":-12.087672508218587,"lng":-77.08401560783386},{"lat":-12.087707915205174,"lng":-77.08394654095173},{"lat":-12.087658083148632,"lng":-77.08388954401016},{"lat":-12.087618086359699,"lng":-77.08389893174171},{"lat":-12.08758989189834,"lng":-77.08392508327961},{"lat":-12.08757546682392,"lng":-77.08395726978779}\]</span>

</td></tr><tr><td style="width: 146px;">color

</td><td style="width: 370px;">Color con el que se mostrará e identificará la geocerca en la plataforma, en formato RGB hexadecimal.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">\#223344</span></span></td></tr><tr><td style="width: 146px;">radio

</td><td style="width: 370px;" width="351">Radio en metros que abarcará la geocerca circular.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">0 </span></span></td></tr><tr><td style="width: 146px;">limite\_velocidad

</td><td style="width: 370px;" width="351">Velocidad máxima (Km/h) permitida en la geocerca.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;"> 50</span></span></td></tr><tr><td style="width: 146px;">solo\_mi\_usuario

</td><td style="width: 370px;" width="351">Indica si la geocerca solo es visible para el usuario que la generó.

1 = Mi usuario

0 = Todos los usuarios

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">0</span></span></td></tr><tr><td style="width: 146px;">visible

</td><td style="width: 370px;">Indica si la geocerca se debe o no mostrar.

1 = Mostrar

0 = Ocultar

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;">1</span></span></td></tr></tbody></table>

</div></details>##### Solicitud de ejemplo:

```shell
curl --location --request POST 'https://api.service24gps.com/api/v1/createGeofence' \
--form 'apikey="25sdsd234234aa93sdsdsd37c70118e72"' \
--form 'token="wfszR/oPIQKjt5HT5NgjDnZ2SAZQ=="' \
--form 'idCerca="138225"' \
--form 'nombre="GeoHome"' \
--form 'puntos="[{\"lat\":-12.087574155453476,\"lng\":-77.08396062254906},{\"lat\":-12.087672508218587,\"lng\":-77.08401560783386},{\"lat\":-12.087707915205174,\"lng\":-77.08394654095173},{\"lat\":-12.087658083148632,\"lng\":-77.08388954401016},{\"lat\":-12.087618086359699,\"lng\":-77.08389893174171},{\"lat\":-12.08758989189834,\"lng\":-77.08392508327961},{\"lat\":-12.08757546682392,\"lng\":-77.08395726978779}]"' \
--form 'color="#223344"' \
--form 'radio="0"' \
--form 'limite_velocidad="50"' \
--form 'solo_mi_usuario="0"' \
--form 'visible="1"'
```

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": ""
}
```

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": ""
}
```

<p class="callout danger"><span style="color: #800000;">**Nota:** Si la geocerca es de **tipo compartida**, no permitirá actualizar y mostrará un mensaje de error .</span></p>

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": {
        "status": 30300,
        "msg": "La geocerca es compartida, no se puede actualizar"
    }
}
```

# Eliminar geocerca - deleteGeofence

##### <span class="api-method" data-method="POST">POST</span> https://api.service24gps.com/api/v1/deleteGeofence

Este método permite eliminar una geocerca especifica.

<details class="mb-m" id="bkmrk-body-parametersparam"><summary class="text-muted">Ver parámetros de solicitud:</summary>

<div><table class="table" style="width: 809px;"><tbody><tr><th style="width: 146px;">Parámetros</th><th style="width: 370px;">Descripción</th><th style="width: 293px;">Ejemplo</th></tr><tr><td style="width: 146px;">apikey</td><td style="width: 370px;">**(Requerido)** Llave de autorización para uso de los Servicios Web.</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">25sdsd234234aa93sdsdsd37c70118e72</span></td></tr><tr><td style="width: 146px;">token</td><td style="width: 370px;">**(Requerido)** Token devuelto por el método getToken.</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">wfszR/oPIQKjt5HT5NgjDnZ2SAZQ==</span></td></tr><tr><td style="width: 146px;">idCerca</td><td style="width: 370px;" width="351">**(Requerido)** Identificador único de la geocerca en el sistema.

</td><td style="width: 293px;"><span role="presentation" style="padding-right: 0.1px;"><span style="color: #3366ff;"> 138225</span></span></td></tr></tbody></table>

</div></details>##### Solicitud de ejemplo:

```shell
curl --location --request POST 'https://api.service24gps.com/api/v1/deleteGeofence' \
--form 'apikey="25sdsd234234aa93sdsdsd37c70118e72"' \
--form 'token="wfszR/oPIQKjt5HT5NgjDnZ2SAZQ=="' \
--form 'idCerca="138225"'
```

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": ""
}
```

<p class="callout danger"><span style="color: #800000;">**Nota:** Si la geocerca es de **tipo compartida**, no permitirá eliminar y mostrará un mensaje de error .</span></p>

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": {
        "status": 30300,
        "msg": "La geocerca es compartida, no se puede eliminar"
    }
}
```