# Modificar etiquetas

Las etiquetas en el módulo de Órdenes de Trabajo, son utilizadas generalmente para la creación de filtros, o para la obtención de reportes particulares.

{% hint style="info" %}
Las etiquetas son una "referencia débil", es decir que una OT puede indicar que tiene las etiquetas con ids 3 y 4, siendo que la etiqueta con id 4 fue eliminada del sistema.
{% endhint %}

Para modificar las etiquetas de una OT, se debe utilizar el siguiente endpoint.

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

#### Path Parameters

| Name                                     | Type   | Description            |
| ---------------------------------------- | ------ | ---------------------- |
| wo\_id<mark style="color:red;">\*</mark> | String | Identificador de la OT |

#### 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                                                                                                                                                                                                      |
| --------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| labels\_ids<mark style="color:red;">\*</mark> | 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. Debido a que es una referencia débil. |

{% 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": "'labels_ids' es debe ser un array de enteros representando las etiqueta"
    }
}
```

{% 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 una ot con este numero de wo_id: xxxx"
    }
}
```

{% endtab %}

{% tab title="200: OK La consulta se ejecutó con éxito. Luego se recibe la OT completa" %}

```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 %}
{% endtabs %}

### Ejemplo de request

#### body

```json
{
    "labels_ids": [1,6,7,22],
}
```

{% hint style="danger" %}
Recuerde que el valor de labels\_ids termina pisando el valor original de la OT. Con lo cual si quisieramos <mark style="color:purple;">**agregar**</mark> una etiqueta, deberíamos primero [Obtener OT](/modulos/ordenes-de-trabajo/obtener-ot.md), para luego agregar al array de labels\_ids la nueva etiqueta y asi poder finalmente ejecutar este endpoint.
{% endhint %}

### Análisis de la respuesta

Se recibe la OT completa

{% code fullWidth="false" %}

```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,
            7,
            22
        ],
        "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
                }
            }            
        }
    }
}
```

{% endcode %}

Los campos mostrados se explican en detalle en [Obtener OT](/modulos/ordenes-de-trabajo/obtener-ot.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/modificar-ot/modificar-etiquetas.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.
