# Crear Entrega Simple

<mark style="color:green;">`POST`</mark> `https://api.persat.com.ar/v1/deliveries`

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer API\_KEY  |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json |

#### Request Body

| Name                                                                          | Type              | Description                                                                                                                                                                          |
| ----------------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| \_id<mark style="color:red;">\*</mark>                                        | String            | Identificador de la entrega. Debe ser único.                                                                                                                                         |
| labels\_ids                                                                   | Array of Numbers  | Array de numeros con el id de las etiquetas                                                                                                                                          |
| delivery\_data.schema\_id<mark style="color:red;">\*</mark>                   | Number            | Identificador de la plantilla/esquema de la entrega                                                                                                                                  |
| delivery\_data.service\_time                                                  | Number            | Duración en minutos estimada de la entrega                                                                                                                                           |
| delivery\_data.wt                                                             | \[number, number] | Ventana horaria de visita. Array de 2 posiciones indicando inicio y fin de la visita en minutos. Por ej: Si hay que visitar entre las 08:00 y las 15:00, se debe recibir \[840, 900] |
| delivery\_data.capacity                                                       | Number            | Dimension x. Puede ser Peso, volumen, cantidad.                                                                                                                                      |
| delivery\_data.contact<mark style="color:red;">\*</mark>                      | JSON Object       |                                                                                                                                                                                      |
| delivery\_data.contact.name<mark style="color:red;">\*</mark>                 | String            | Nombre del contacto que va a recibir la entrega.                                                                                                                                     |
| delivery\_data.contact.phone                                                  | String            | Telefono del contacto                                                                                                                                                                |
| delivery\_data.contact.email                                                  | String            | Email del contacto                                                                                                                                                                   |
| delivery\_data.position<mark style="color:red;">\*</mark>                     | JSON Object       |                                                                                                                                                                                      |
| delivery\_data.position.address<mark style="color:red;">\*</mark>             | JSON Object       |                                                                                                                                                                                      |
| delivery\_data.position.address.clean<mark style="color:red;">\*</mark>       | String            | Direccion "limpia". Nombrede la calle + altura. Ej: Rivadavia 1200, Caba                                                                                                             |
| delivery\_data.position.address.extra\_info<mark style="color:red;">\*</mark> | String            | Datos extra de la direccion. Ej: Piso, Color de la puerta, etc                                                                                                                       |
| delivery\_data.position.location                                              | Array Numbers     | \[longitud, latitud] Indicando donde se va a realiar la entrega                                                                                                                      |
| delivery\_data.instructions<mark style="color:red;">\*</mark>                 | JSON Object       |                                                                                                                                                                                      |

{% tabs %}
{% tab title="400: Bad Request Error en alguno de los campos enviados. userMessage contiene informacipon adicional." %}

```javascript
{
    "success": false,
    "error": {
        "status": 400,
        "type": "BAD_REQUEST",
        "userMessage": "\"_id\" es obligatorio. Debe ser un string identificando la entrega. Max: 50 caracteres"
    }
}
```

{% endtab %}

{% tab title="200: OK La consulta se ejecutó con éxito" %}

```javascript
{
    "success": true,
    "data": {
        "_id": "ASDKSAL23",
        "state": "FINISHED",
        "created": "2022-05-12T13:26:19.292Z",
        "source_tag":"Jose 19/07/2021 17:19:24",
        "labels_ids": [
            133
        ],
        "due_date": "2022-05-14T00:00:00.000Z",
        "client": {
            "id": 12816,
            "name": "Zapatería Don José",
            "uid_client": "CL565LK"
        },
        "delivery_data": {
            "schema_id": 5,
            "service_time": 150,
            "wt": [480, 1080],
            "capacity": 278,
            "contact": {
                "name": "Jose Perez",
                "phone": "5555-5555",
                "email": "jose@empresa.com.ar"
            },
            "position": {
                "address": {
                    "clean": "Av. Independencia 1987",
                    "extra_info": "Piso 1A"
                },
                "location": [
                    -58.49390429,
                    -34.677806633
                ]
            },
            "instructions": {
                "FWtQn2m9v": "Entregar zapatos color Rojo",
                "FWJt5MLSn": 5687.00,
                "FWBsxBUIQ": "Cobrar"
            },
            "results": {
                "formvalues": {
                    "FW40IlFW1": "El cliente quedo conforme",
                    "FWy1RBJ2j": "Cobrado",
                    "FWGa6f4zq": 5687.00,
                    "FW_FINAL_STATE": "DELIVERED"
                },
                "log": [
                    {
                        "user_name": "pedro@empresa.com.ar",
                        "user_real_name": "Pedro Lopez",
                        "user_id": 37,
                        "date": "2022-05-12T14:10:24.000Z"
                    },
                    {
                        "user_name": "pedro@empresa.com.ar",
                        "user_real_name": "Pedro Lopez",
                        "user_id": 37,
                        "date": "2022-05-13T14:43:37.867Z"
                    }
                ]
            },
            "rework": {
                "retry": 1,
                "prev": "ASDKSAL22",
                "next": "ASDKSAL22-R3"
            }
        },
        "assignation_info": {
            "date": "2022-05-12T00:00:00.000Z",
            "device_id": 18,
            "device_name": "Vechiculo AB 123 LK",
            "route_id": 1652362114021
        }
    }
}
```

{% endtab %}

{% tab title="409: Conflict Conflicto. El identificador de entrega ya existe dentro de Persat" %}

```javascript
{
    "success": false,
    "error": {
        "status": 409,
        "type": "CONFLICT",
        "userMessage": "El nro. de entrega ya existe"
    }
}
```

{% endtab %}
{% endtabs %}

### Ejemplo de request

#### body

```json
{
    "_id": "ASDKSAL23",
    "labels_ids": [133],
    "delivery_data": {
        "schema_id": 5,    
    	"service_time": 150,
    	"capacity": 278,
        "wt": [480, 1080],
        "contact": {
            "name": "Jose Perez",
            "phone": "5555-5555",
            "email": "jose@empresa.com.ar"
        },        
        "instructions": {
            "FWtQn2m9v": "Entregar zapatos color Rojo",
            "FWJt5MLSn": 5687.00,
            "FWBsxBUIQ": "Cobrar"
        },            
        "position": {
            "address": {
                "clean": "Av. Independencia 1987",
                "extra_info": "Piso 1A"
            },
            "location": [
                -58.49390429,
                -34.677806633
            ]
        }
    }
}
```

Los campos se explican en [Obtener Entrega](/modulos/gestion-de-entregas/obtener-entrega.md), pero durante la inserción hay muchos campos que son opcionales.&#x20;

**labels\_ids:** En caso de no enviarlo en la consulta, labels\_ids tomará el valor definido por defecto en la plantilla/esquema para esta entrega (schema\_id)

**delivery\_data.service\_time:** En caso de no enviarlo en la consulta, service\_time tomará el valor definido por defecto en la plantilla/esquema para esta entrega (schema\_id)

**delivery\_data.wt:** En caso de no enviarlo en la consulta, su valor será null y por lo tanto indicará que la entrega no tiene restricción de horario alguna. Es decir que puede ser realizada a cualquier hora del dia.

**delivery\_data.capacity:** En caso de no enviarlo en la consulta, capacity tomará el valor 0

**delivery\_data.contact.phone:** En caso de no enviarlo en la consulta, phone tomará el valor ""

**delivery\_data.contact.email:** En caso de no enviarlo en la consulta, phone tomará el valor ""

**delivery\_data.position.location:** En caso de no enviarlo en la consulta, la entrega se creará correctamente, pero no se podrá mmodificar su estado hasta que un usuario corrija el valor de posición.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.persat.com.ar/modulos/gestion-de-entregas/crear-entrega/crear-entrega-simple.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
