# Etichette

> Crea e gestisci etichette per organizzare le attività

- Pagina: https://tbit.app/it/docs/api/tags
- URL base: `https://rest-api.tbit.app/v1`
- Autenticazione: header `X-API-Key` con la tua chiave in ogni richiesta (gli esempi la leggono dalla variabile d'ambiente `TBIT_API_KEY`)

## Panoramica

Le etichette servono a classificare e organizzare le attività. Ogni etichetta ha un nome, un colore facoltativo e una descrizione facoltativa. Le etichette sono associate al tuo agente.

## Endpoint

| Metodo | Percorso | Descrizione |
| --- | --- | --- |
| `GET` | `/v1/tags` | Elenca tutte le etichette |
| `POST` | `/v1/tags` | Crea una nuova etichetta |
| `PATCH` | `/v1/tags/:id` | Aggiorna un'etichetta |
| `DELETE` | `/v1/tags/:id` | Elimina un'etichetta |

## Elencare le etichette

`GET /v1/tags`

```bash
curl "https://rest-api.tbit.app/v1/tags" \
  -H "X-API-Key: $TBIT_API_KEY"
```

## Creare un'etichetta

`POST /v1/tags`

```bash
curl -X POST "https://rest-api.tbit.app/v1/tags" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "VIP",
    "color": "#ef4444",
    "description": "High-priority customers"
  }'
```

## Aggiornare un'etichetta

`PATCH /v1/tags/tag_id_1`

```bash
curl -X PATCH "https://rest-api.tbit.app/v1/tags/tag_id_1" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Premium",
    "color": "#8b5cf6"
  }'
```

## Rimuovere un'etichetta

`DELETE /v1/tags/tag_id_1`

```bash
curl -X DELETE "https://rest-api.tbit.app/v1/tags/tag_id_1" \
  -H "X-API-Key: $TBIT_API_KEY"
```

## Formato della risposta

Un oggetto etichetta:

```json
{
  "data": [
    {
      "id": "tag_id_1",
      "name": "VIP",
      "color": "#ef4444",
      "description": "High-priority customers",
      "created_at": "2024-09-01T12:00:00Z",
      "updated_at": "2024-09-01T12:00:00Z"
    },
    {
      "id": "tag_id_2",
      "name": "New Lead",
      "color": "#3b82f6",
      "description": null,
      "created_at": "2024-09-02T08:00:00Z",
      "updated_at": "2024-09-02T08:00:00Z"
    }
  ]
}
```
