# Update a label

`PATCH https://api.coach-platform.com/api/public/labels/{labelId}`

Rename a label or change its color.

- Resource: Labels
- Authentication: API key in the `Authorization: Bearer cp_live_...` header
- HTML version: https://www.coach-platform.com/docs/api/reference/patch-labels-label-id
- OpenAPI spec: https://www.coach-platform.com/openapi.json

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `labelId` | string | Yes |   |

## Header parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Idempotency-Key` | string | No | Optional. Send a unique key (e.g. a UUID) to make this POST safe to retry. The same key within 24h returns the original result instead of creating a duplicate. |

## Request body

Content type: `application/json`. Required.

| Field | Type | Required | Description |
|---|---|---|---|
| `text` | string | No |   |
| `color` | string | No | Tailwind color key, e.g. "green-500" |

## Responses

| Status | Description |
|---|---|
| `200` OK | Successful response |
| `400` Bad Request |  |
| `401` Unauthorized |  |
| `403` Forbidden |  |
| `404` Not Found |  |
| `409` Conflict |  |
| `429` Too Many Requests |  |
| `500` Internal Server Error |  |

### 200 OK

Content type: `application/json`

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string |   |
| `data.text` | string |   |
| `data.color` | string |   |
| `data.coachId` | string |   |

Example:

```json
{
  "data": {
    "id": "<string>",
    "text": "<string>",
    "color": "<string>",
    "coachId": "<string>"
  }
}
```

### Error responses 400, 401, 403, 404, 409, 429, 500

Content type: `application/json`

| Field | Type | Description |
|---|---|---|
| `error` | object |   |
| `error.code` | string |   |
| `error.message` | string |   |
| `error.fix` | string \| null |   |
| `error.details` | object \| null |   |
| `error.retryAfterMs` | number \| null |   |

Example:

```json
{
  "error": {
    "code": "<string>",
    "message": "<string>",
    "fix": "<string>",
    "details": {},
    "retryAfterMs": 123
  }
}
```

## Examples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.coach-platform.com/api/public/labels/<labelId>' \
  --header 'Authorization: Bearer cp_live_...' \
  --header 'Content-Type: application/json' \
  --data '{
  "text": "<string>"
}'
```

### JavaScript (fetch)

```js
const response = await fetch('https://api.coach-platform.com/api/public/labels/<labelId>', {
  method: 'PATCH',
  headers: {
    Authorization: 'Bearer cp_live_...',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "text": "<string>"
  }),
});

const data = await response.json();
```

## Related endpoints

- [List labels](https://www.coach-platform.com/docs/api/reference/get-labels/index.md): `GET /api/public/labels`. List all trainee labels (tags) defined by the coach.
- [Add labels to a trainee](https://www.coach-platform.com/docs/api/reference/post-trainees-trainee-id-labels/index.md): `POST /api/public/trainees/{traineeId}/labels`. Add labels to a trainee.
- [Remove a label from a trainee](https://www.coach-platform.com/docs/api/reference/delete-trainees-trainee-id-labels-label-id/index.md): `DELETE /api/public/trainees/{traineeId}/labels/{labelId}`. Detach a single label from one trainee.
- [Delete a label](https://www.coach-platform.com/docs/api/reference/delete-labels-label-id/index.md): `DELETE /api/public/labels/{labelId}`. Delete a label.
- Previous: [Remove a label from a trainee](https://www.coach-platform.com/docs/api/reference/delete-trainees-trainee-id-labels-label-id/index.md): `DELETE /api/public/trainees/{traineeId}/labels/{labelId}`. Detach a single label from one trainee.
- Next: [Delete a label](https://www.coach-platform.com/docs/api/reference/delete-labels-label-id/index.md): `DELETE /api/public/labels/{labelId}`. Delete a label.
