# Insertar datos de dispositivo - insertPositionData

##### <span class="api-method" data-method="POST">POST </span><span style="font-weight: 400;"> https://api.service24gps.com/api/v1/insertPositionData</span>

Basado en el documento de protocolo de comunicación service24gps. Para ingresar información en los reportes del equipo GPS y se muestre en la plataforma, tanto en el detalle nuevo del activo como en los eventos y/o alertas.

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

<div><table class="table" style="width: 801px; height: 566px;"><tbody><tr style="height: 41px;"><th style="width: 125.156px; height: 41px;">Parámetros</th><th style="width: 381.463px; height: 41px;">Descripción</th><th style="width: 293.381px; height: 41px;">Ejemplo</th></tr><tr style="height: 58px;"><td style="width: 125.156px; height: 58px;">apikey</td><td style="width: 381.463px; height: 58px;">**(Requerido)** Llave de autorización para uso de los Servicios Web.</td><td style="width: 293.381px; height: 58px;"><span role="presentation" style="padding-right: 0.1px; color: #3366ff;">25sdsd234234aa93sdsdsd37c70118e72</span></td></tr><tr style="height: 58px;"><td style="width: 125.156px; height: 58px;">token</td><td style="width: 381.463px; height: 58px;">**(Requerido)** Token devuelto por el método getToken.</td><td style="width: 293.381px; height: 58px;"><div><div><span style="color: #3366ff;">SJXC7PtRJwHcSY8O8DYjpH+c7mMBd0uXmRkw+8DE9TS09wi0Mzw==</span></div></div></td></tr><tr style="height: 69px;"><td style="width: 125.156px; height: 69px;">imei</td><td style="width: 381.463px; height: 69px;"><span style="font-weight: 400;">**(Requerido)** Identificador único / imei del dispositivo gps.</span>

</td><td style="width: 293.381px; height: 69px;"><span style="color: #3366ff;">6d7b91026765abcd</span></td></tr><tr style="height: 69px;"><td style="width: 125.156px; height: 69px;"><span style="font-weight: 400;">checksum</span></td><td style="width: 381.463px; height: 69px;"><span style="font-weight: 400;">**(Requerido)** Primeros 4 caracteres del md5 de reports.</span>

</td><td style="width: 293.381px; height: 69px;"><span style="color: #3366ff;">e71a</span></td></tr><tr style="height: 271px;"><td style="width: 125.156px; height: 271px;"><span style="font-weight: 400;">reports</span><span style="font-weight: 400;">  
</span></td><td style="width: 381.463px; height: 271px;"><span style="font-weight: 400; color: #333333;">**(Requerido)** String en formato json de ubicaciones </span>

<span style="font-weight: 400; color: #3366ff;"> </span>

</td><td style="width: 293.381px; height: 271px;"><span style="color: #3366ff;">\[</span>  
<span style="color: #3366ff;"> {</span>  
<span style="color: #3366ff;"> "stamp": "20220502184600",</span>  
<span style="color: #3366ff;"> "latlng": "4.6892583,-74.1159799",</span>  
<span style="color: #3366ff;"> "direction": 0,</span>  
<span style="color: #3366ff;"> "speed": 0,</span>

<span style="color: #3366ff;"> "sig": 10,</span>

<span style="color: #3366ff;"> "satellites": 15,</span>  
<span style="color: #3366ff;"> "event": 1,</span>  
<span style="color: #3366ff;"> "battery": 40,</span>

<span style="color: #3366ff;"> "bat": 100,</span>

<span style="color: #3366ff;"> "odm": 500,</span>

<span style="color: #3366ff;"> "bato": 50,</span>

<span style="color: #3366ff;"> "acc": 1,</span>

<span style="color: #3366ff;"> "alt": "10",</span>

<span style="color: #3366ff;"> }</span>  
<span style="color: #3366ff;">\]</span>

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

</div></details><p class="callout info"><span style="font-weight: 400;">Nota: **reports** es un array de objetos, así sea un solo reporte debe estar dentro de un array.</span></p>

<details class="mb-m" id="bkmrk-ver%C2%A0-tabla-de-par%C3%A1me"><summary class="text-muted">Ver tabla de parámetros reports:</summary>

<div><table class="table" style="width: 770px; height: 914px;"><tbody><tr style="height: 41px;"><th style="width: 110.122px; height: 41px;">Parámetros</th><th style="width: 347.396px; height: 41px;">Descripción</th><th style="width: 311.372px; height: 41px;">Ejemplo</th></tr><tr style="height: 41px;"><td style="width: 110.122px; height: 41px;">stamp</td><td style="width: 347.396px; height: 41px;"><span style="font-weight: 400; color: #333333;">**(Requerido)** </span>Fecha y hora en GMT 0.</td><td style="width: 311.372px; height: 41px;"><span style="color: #3366ff;">"stamp": "20230510235500"</span></td></tr><tr style="height: 41px;"><td style="width: 110.122px; height: 41px;">latlng</td><td style="width: 347.396px; height: 41px;"><span style="font-weight: 400; color: #333333;">**(Requerido)** </span>Latitud y longitud.</td><td style="width: 311.372px; height: 41px;"><span style="color: #3366ff;">"latlng": "4.6892583,-74.1159799"</span></td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;">direction</td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400; color: #333333;">**(Requerido)** </span>Dirección.

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;">"direction": 0</span></td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;"><span style="font-weight: 400;">speed</span></td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400;"><span style="font-weight: 400; color: #333333;">**(Requerido)** </span>Velocidad del dispositivo.</span>

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;"> "speed": 0</span></td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;"><span style="font-weight: 400;">sig</span></td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400;"><span style="font-weight: 400; color: #333333;">(Opcional) Señal GSM.   
Entre 0-10</span></span>

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;">"sig": 10</span></td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;">satellites</td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400; color: #333333;">**(Requerido)** </span>Satélite.</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;">"satellites": 15</span>

</td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;"><span style="font-weight: 400;">event</span></td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400; color: #333333;">**(Requerido)** Tipo de evento. </span>

<span style="font-weight: 400; color: #333333;">Ejemplo: </span>

<span style="font-weight: 400; color: #333333;">1: Ubicación</span>

<span style="font-weight: 400; color: #333333;">2: Botón SigMen  
Obtener listado de eventos en [**getEventTypes**](https://docs.redgps.com/books/webservice/page/lista-de-eventos-geteventtypes)</span>

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;"> "event": 1</span>

</td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;"><span style="font-weight: 400;">battery</span></td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400; color: #333333;">**(Requerido)** Batería del dispositivo.   
Entre 0 - 100 %</span>

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;"> "battery": 40</span>

</td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;"><span style="font-weight: 400;">bato</span></td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400; color: #333333;">(Opcional) Batería Vehículo.   
Entre 0 - 100 volts</span>

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;">"bato": 100</span>

</td></tr><tr><td style="width: 110.122px;"><span style="font-weight: 400;">acc</span></td><td style="width: 347.396px;"><span style="font-weight: 400; color: #333333;">(Opcional) Estado de ignición.  
Ejemplo:</span>

<span style="font-weight: 400; color: #333333;">1: Encendido</span>

<span style="font-weight: 400; color: #333333;">0: Apagado</span>

</td><td style="width: 311.372px;"><span style="color: #3366ff;">"acc": 1</span>

</td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;"><span style="font-weight: 400;">odm</span></td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400; color: #333333;">(Opcional) Odómetro.</span>

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;">"odm": 500</span>

</td></tr><tr style="height: 47px;"><td style="width: 110.122px; height: 47px;"><span style="font-weight: 400;">alt</span></td><td style="width: 347.396px; height: 47px;"><span style="font-weight: 400; color: #333333;">(Opcional) Altitud.</span>

</td><td style="width: 311.372px; height: 47px;"><span style="color: #3366ff;">"alt": "10"</span>

</td></tr><tr><td style="width: 110.122px;"><span style="font-weight: 400;">ad</span></td><td style="width: 347.396px;"><span style="font-weight: 400; color: #333333;">(Opcional) Información adicional para el envió de información de sensores en formato JSON.</span>

</td><td style="width: 311.372px;"><div data-block="true" data-editor="46is8" data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;">"ad": {</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "t1": 25.5,</span></div></div><div data-block="true" data-editor="46is8" data-offset-key="4fmoq-0-0"><div data-offset-key="4fmoq-0-0"><span data-offset-key="4fmoq-12-0" style="color: #3366ff;"> "h1": 10,</span></div></div><div data-block="true" data-editor="46is8" data-offset-key="dcb9b-0-0"><div data-offset-key="dcb9b-0-0"><span data-offset-key="dcb9b-12-0" style="color: #3366ff;"> "h2": 1</span></div><div data-offset-key="dcb9b-0-0"><span style="color: #3366ff;">}</span></div></div><span style="color: #3366ff;"> </span>

</td></tr><tr style="height: 108px;"><td style="width: 110.122px; height: 108px;"><span style="font-weight: 400;">infoextra</span></td><td style="width: 347.396px; height: 108px;"><span style="font-weight: 400; color: #333333;">(Opcional) Información extra para el dispositivo en formato JSON. </span>

</td><td style="width: 311.372px; height: 108px;"><div data-block="true" data-editor="46is8" data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;">"infoextra": {</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "qr\_buffer": "0",</span></div></div><div data-block="true" data-editor="46is8" data-offset-key="4fmoq-0-0"><div data-offset-key="4fmoq-0-0"><span data-offset-key="4fmoq-12-0" style="color: #3366ff;"> "qr\_idProceso": "2971599",</span></div></div><div data-block="true" data-editor="46is8" data-offset-key="dcb9b-0-0"><div data-offset-key="dcb9b-0-0"><span data-offset-key="dcb9b-12-0" style="color: #3366ff;"> "qr\_uid": "MiLugar1"</span></div><div data-offset-key="dcb9b-0-0"><span style="color: #3366ff;">}</span></div></div></td></tr></tbody></table>

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

```JSON
curl --location --request POST 'https://api.service24gps.com/api/v1/insertPositionData' \
--form 'apikey="25sdsd234234aa93sdsdsd37c70118e72"' \
--form 'token="SJXC7PtRJwHcSY8O8DYjpH+c7mMBd0uXmRkw+8DE9TS09wi0Mzw=="' \
--form 'imei="6d7b91026765abcd"' \
--form 'checksum="e71a"' \
--form 'reports="[
	{
      \"stamp\":\"20220119235500\",
      \"latlng\":\"4.6892583,-74.1159799\",
      \"direction\":0,
      \"speed\":0,
      \"sig\":10,
      \"satellites\":15,
      \"event\":501,
      \"battery\":40,
      \"bat\":100,
      \"odm\":500,
      \"bato\":50,
      \"acc\":1,
	  \"alt\":\"10\",
      \"ad\": {
          \"t1\":  25.5,
          \"h1\":  10,
          \"h2\":  1
       }
    }
]"'
```

##### Respuesta de ejemplo:

```JSON
{
    "status": 200,
    "data": {
        "checksum": "e71a",
        "match_checksum": 1,
        "received": 1,
        "processed": 1,
        "errors": []
    }
}

```

<p class="callout danger"><span style="font-weight: 400;">**Nota:** La key "**errors**" es un array con todos los errores encontrados al procesar las tramas. </span><span style="font-weight: 400;">En los errores se usa el mismo índice que en las tramas para relacionar en que reporte se originó.</span></p>

##### Respuesta de ejemplo s<span style="font-weight: 400;">i el checksum no coincide:</span>

```JSON
{
    "status": 200,
    "data": {
        "checksum": "3824",
        "match_checksum": 0
    }
}
```

##### Tipos de formato en infoextra

<details class="mb-m" id="bkmrk-ver-formatos%3A-format"><summary class="text-muted">Ver formatos:</summary>

<div><table class="table" style="width: 861px; height: 522px;"><tbody><tr style="height: 41px;"><th style="width: 98px;">Formato</th><th style="width: 229px;">Descripción </th><th style="width: 133px; height: 41px;">Nombre de la propiedad</th><th style="width: 113px; height: 41px;">Valor de la propiedad</th><th style="width: 288px; height: 41px;">Ejemplo</th></tr><tr style="height: 58px;"><td style="width: 98px;">**Tipo llave valor**</td><td style="width: 229px;">Este formato solo se completa el nombre y el valor a mostrar, es un modo simple de agregar información.

Tiene la limitante que no se puede dar formato o interacción a esta información dentro de la plataforma.

</td><td style="width: 133px; height: 58px;">"lampara 1"</td><td style="width: 113px; height: 58px;"> "encendido"</td><td style="width: 288px; height: 58px;"><div data-block="true" data-editor="46is8" data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;">"infoextra":{</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "lampara 1": "encendido",</span></div></div><div data-block="true" data-editor="46is8" data-offset-key="4fmoq-0-0"><div data-offset-key="4fmoq-0-0"><span data-offset-key="4fmoq-12-0" style="color: #3366ff;"> "lampara 2": "apagado",</span></div></div><div data-block="true" data-editor="46is8" data-offset-key="dcb9b-0-0"><div data-offset-key="dcb9b-0-0"><span data-offset-key="dcb9b-12-0" style="color: #3366ff;"> "lampara 3": "encendido"</span></div><div data-offset-key="dcb9b-0-0"><span style="color: #3366ff;">}</span></div></div></td></tr><tr style="height: 47px;"><td style="width: 98px;">**Tipo llave valor extendido** </td><td style="width: 229px;">Este formato tiene mas opciones, donde podremos definir las acciones sobre los elementos que vera el cliente dentro del detalle del activo.

**Llave:**

- **(Requerido)** label
- **(Requerido)** value
- (Opcional) unit
- (Opcional) color
- (Opcional) icon
- (Opcional) href
- (Opcional) onclick

</td><td style="width: 133px; height: 47px;">"label"</td><td style="width: 113px; height: 47px;">"Litros"

</td><td style="width: 288px; height: 47px;"><div data-block="true" data-editor="46is8" data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;">"infoextra":{</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "0":{</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "label": "Litros",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "value": "11.12",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "unit": "litros",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "icon": "i-lock-2",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "color": "#987456",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "href": "https://example.com",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "onclick": "function\_litro(\_litro\_)"</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> },</span></div><div data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "1":{</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "label": "Litros 2",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "value": "114.2",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "unit": "litros",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "icon": "i-lock-2",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "color": "#158456"</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> }</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;">}</span></div></div></div></td></tr><tr style="height: 271px;"><td style="width: 98px;">**Tipo llave texto** </td><td style="width: 229px;"><span style="font-weight: 400;">Este formato sirve para mostrar un mensaje de tipo texto dentro de la plataforma.</span>

**Llave:**

- **(Requerido)** text
- (Opcional) color
- (Opcional) bgcolor
- (Opcional) href
- (Opcional) onclick

</td><td style="width: 133px; height: 271px;"><span style="font-weight: 400;">"text"</span><span style="font-weight: 400;">  
</span></td><td style="width: 113px; height: 271px;"><span style="color: #333333;">"Mensaje de prueba"</span>

<span style="font-weight: 400; color: #3366ff;"> </span>

</td><td style="width: 288px; height: 271px;"><div data-block="true" data-editor="46is8" data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;">"infoextra":{</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "0":{</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "text": "Mensaje de prueba",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "color": "#987456",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "bcolor": "#284650",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "href": "https://example.com",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "onclick": "function\_msg(\_msg\_)"</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> },</span></div><div data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "1":{</span></div><div data-offset-key="es9i-0-0"><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "text": "Mensaje a plataforma",</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> "color": "#458756",</span></div></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;"> }</span></div><div data-offset-key="es9i-0-0"><span style="color: #3366ff;">}</span></div></div></div></td></tr></tbody></table>

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

```JSON
curl --location --request POST 'https://api.service24gps.com/api/v1/insertPositionData' \
--form 'apikey="25sdsd234234aa93sdsdsd37c70118e72"' \
--form 'token="SJXC7PtRJwHcSY8O8DYjpH+c7mMBd0uXmRkw+8DE9TS09wi0Mzw=="' \
--form 'imei="6d7b91026765abcd"' \
--form 'checksum="e71a"' \
--form 'reports="[
    {
        \"stamp\": \"20220502184600\",
        \"latlng\": \"4.6892583,-74.1159799\",
        \"direction\": 0,
        \"speed\": 0,
        \"satellites\": 15,
        \"event\": 501,
        \"battery\": 4.013,
        \"infoextra\":{
            \"lampara 1\": \"encendido\",
            \"lampara 2\": \"apagado\",
            \"lampara 3\": \"encendido\"
        },
    }
]"'
```