# Tags

> Create and manage tags for organizing activities

- Page: https://tbit.app/docs/api/tags
- Base URL: `https://rest-api.tbit.app/v1`
- Authentication: `X-API-Key` header with your key on every request (the examples read it from the `TBIT_API_KEY` environment variable)

## Overview

Tags allow you to categorize and organize activities. Each tag has a name, an optional color, and an optional description. Tags are scoped to your agent.

## Endpoints

| Method | Path | Description |
| --- | --- | --- |
| `GET` | `/v1/tags` | List all tags |
| `POST` | `/v1/tags` | Create a new tag |
| `PATCH` | `/v1/tags/:id` | Update a tag |
| `DELETE` | `/v1/tags/:id` | Delete a tag |

## List Tags

`GET /v1/tags`

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

## Create Tag

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

## Update Tag

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

## Delete Tag

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

## Response Format

A tag object:

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