Renames an audience tag. `:tag` is an id or current name. Permission: `audience`.

## Path Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `tag` | string | **Required.** Tag id or current name. |

## Body Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| `name` | string | **Required.** New tag name. Min 1, max 100. |

## Response Fields

| Field | Type | Description |
| ----- | ---- | ----------- |
| `id` | string | Tag id. |
| `name` | string | New name. |

## Errors

| Status | `name` | When |
| ------ | ------ | ---- |
| 401 | `missing_api_key` | Missing or invalid bearer token |
| 403 | `missing_permission` | Token lacks the `audience` permission |
| 404 | `not_found` | Unknown id or name |
| 422 | `validation_error` | Empty or missing `name` |

## Related

- [Get Tag](/docs/api-reference/v2/tags-get)
- [SDK: lumail.tags.update](/docs/sdk/v2/tags-update)


## API Reference
**Method:** PATCH
**Endpoint:** /api/v2/tags/:tag

### SDK
```ts
import { Lumail } from "lumail";

const lumail = new Lumail({ apiKey: process.env.LUMAIL_API_KEY });
const { data, error } = await lumail.tags.update("customer", {
  name: "vip",
});
if (error) {
  throw error;
}
console.log(data.name);
```

### cURL
```bash
curl -X PATCH https://lumail.io/api/v2/tags/customer \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"vip"}'
```

### JavaScript
```javascript
const response = await fetch("https://lumail.io/api/v2/tags/customer", {
  method: "PATCH",
  headers: {
    Authorization: "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "vip" }),
});
const data = await response.json();
```

### Success Response
```json
{
  "id": "tag_abc123",
  "name": "vip"
}
```

### Error Response
```json
{
  "name": "not_found",
  "message": "Tag not found",
  "statusCode": 404
}
```
