`lumail@2.1.0` · [`lumail.tags`](/docs/sdk/v2/tags)

```typescript
tags.create({ name: string }): Promise<LumailResult<CreateTagResponse>>
```

Create a tag.

## Body Parameters

| Name | Type | Description |
| ------ | ------ | ----------------------- |
| `name` | string | **Required.** Tag name. |

## Response Fields

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

`data` is `{ id, name }`. Failures return `{ data: null, error: { name, message, statusCode } }`.


## API Reference
**Method:** POST
**Endpoint:** /api/v2/tags

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

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

### cURL
```bash
curl -X POST https://lumail.io/api/v2/tags \
  -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", {
  method: "POST",
  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": "validation_error",
  "message": "name is required",
  "statusCode": 422
}
```
