# Insertar PENDIENTE

Para insertar una Orden de Trabajo en estado PENDIENTE, hay que obviar los campos siguientes en "assignation\_info"

* assignation\_info.date
* assignation\_info.starts\_min
* assignation\_info.responsibles

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

#### 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                                                                                                                                                                |
| -------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| uid\_client<mark style="color:red;">\*</mark>                              | String      | El número/identificador de cliente (es un valor alfanumérico). Es el cliente en el que queremos realizar el trabajo.                                                       |
| wo\_data.schema\_id<mark style="color:red;">\*</mark>                      | Number      | Identificador de la plantilla/esquema de la OT que estamos insertando.                                                                                                     |
| wo\_data.service\_time<mark style="color:red;">\*</mark>                   | Number      | Numero representando los minutos de duración estimado del trabajo                                                                                                          |
| labels\_ids                                                                | Number\[]   | Array de numeros. Cada item representa una etiqueta que deberia estar creada en el sistema. De todas maneras, si no existe la etiqueta la consulta continua sin problemas. |
| assignation\_info.responsibles\_required<mark style="color:red;">\*</mark> | Number      | Cantidad de tecnicos que requiere el trabajo. Min: 1                                                                                                                       |
| wo\_data.instructions.formvalues                                           | JSON Object | Valores de cada uno de los widgets del formulario de instrucciones                                                                                                         |

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

```javascript
{
    "success": true,
    "data": {
        "_id": "144",
        "note_id": 615,
        "state": "PENDIENTE",
        "created": "2022-05-20T18:02:09.000Z",
        "created_by_user_name": "Creado por Api",
        "created_by_user_id": -1,
        "labels_ids": [
            1,
            6
        ],
        "client": {
            "id": 10216,
            "name": "Fabrica de Motores",
            "uid_client": "CL3213L"
        },
        "wo_data": {
            "schema_id": 452,
            "wo_instance": null,
            "wo_rule_id": null,
            "service_time": 45,
            "instructions": {       
                "formvalues": {
                    "FWMnigD1k": "Valor por default",
                    "FWlDmoApZ": "valor por default"
                }
            }            
        }
    }
}
```

{% endtab %}

{% 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": "'uid_client' es obligatorio y debe ser un string identificando al cliente"
    }
}
```

{% endtab %}

{% tab title="404: Not Found El cliente o el schema\_id no existen" %}

```javascript
{
    "success": false,
    "error": {
        "status": 404,
        "type": "NOT_FOUND",
        "userMessage": "No hay un cliente con este nro."
    }
}
```

{% endtab %}
{% endtabs %}

### Ejemplo de request

#### body

```json
{
    "uid_client": "AABC9098",
    "labels_ids": [1,6],    /* Opcional */
    "wo_data": {
        "schema_id": 452,
        "service_time": 45,
        "instructions": {        /* Opcional */
            "formvalues": {
                "FWMnigD1k": "Revisar la caldera",
                "FWlDmoApZ": 250.23
            }
        }
    },
    "assignation_info": {
        "responsibles_required": 1
    }
}
```

Los campos se describen en [Obtener OT](/modulos/ordenes-de-trabajo/obtener-ot.md)

Algunas consideraciones durante la inserción:

**labels\_ids:** Es opcional. En caso de no enviarse, la OT será cargada con las etiquetas por defecto definidas en el schema\_id. Ahora si lo que quiero es que quede con ninguna etiqueta, entonces hay que enviar un array vacio.

```
"labels_ids": [],
```

**wo\_data.instructions:** Instrucciones que le llegan al tecnico. Podemos no enviar estos datos si es que no los tenemos, ya que la OT no va a quedar asignada si no en estado PENDIENTE. Luego cuando el coordinador la quiera asignar, entonces deberá completar el formulario de instrucciones.

**assignation\_info.responsibles\_required:** Numero indicando la cantidad de personal requerido para realizar ael trabajo

### Análisis de la respuesta

```json
{
    "success": true,
    "data": {
        "_id": "144",
        "note_id": 615,
        "state": "PENDIENTE",
        "created": "2022-05-20T18:02:09.000Z",
        "created_by_user_name": "Creado por Api",
        "created_by_user_id": -1,
        "labels_ids": [
            1,
            6
        ],
        "client": {
            "id": 10216,
            "name": "Fabrica de Motores",
            "uid_client": "CL3213L"
        },
        "wo_data": {
            "schema_id": 452,
            "wo_instance": null,
            "wo_rule_id": null,
            "service_time": 45,
            "instructions": {       
                "formvalues": {
                    "FWMnigD1k": "Revisar la caldera",
                    "FWlDmoApZ": 250.23
                }
            }            
        }
    }
}
```

La respuesta se puede analizar siguiento la seccion [Pendiente con Instrucciones](/modulos/ordenes-de-trabajo/obtener-ot/pendiente-con-instrucciones.md)


---

# 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/ordenes-de-trabajo/insertar-ot/insertar-pendiente.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.
