# Labels

> Maak en beheer labels om activiteiten te ordenen

- Pagina: https://tbit.app/nl/docs/api/tags
- Basis-URL: `https://rest-api.tbit.app/v1`
- Authenticatie: header `X-API-Key` met je sleutel bij elk verzoek (de voorbeelden lezen hem uit de omgevingsvariabele `TBIT_API_KEY`)

## Overzicht

Met labels deel je activiteiten in en houd je ze overzichtelijk. Elk label heeft een naam, een optionele kleur en een optionele beschrijving. Labels horen bij je agent.

## Endpoints

| Methode | Pad | Beschrijving |
| --- | --- | --- |
| `GET` | `/v1/tags` | Alle labels opvragen |
| `POST` | `/v1/tags` | Nieuw label maken |
| `PATCH` | `/v1/tags/:id` | Label bijwerken |
| `DELETE` | `/v1/tags/:id` | Label verwijderen |

## Labels opvragen

`GET /v1/tags`

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

## Label maken

`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"
  }'
```

## Label bijwerken

`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"
  }'
```

## Label verwijderen

`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"
```

## Responseformaat

Een labelobject:

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