`https://lumail.io/api/v1/tags`

Creates a new tag in your organization to help organize subscribers and create targeted segments for your email campaigns.

## Response

- **Success (200 OK)** - Returns the created tag object.
- **Error (400 Bad Request)** - Returned if the tag name is invalid or missing.

## Response Fields

| Field      | Type    | Description                               |
| ---------- | ------- | ----------------------------------------- |
| `success`  | boolean | Indicates if the operation was successful |
| `tag`      | object  | The created tag object                    |
| `tag.id`   | string  | Unique identifier for the tag             |
| `tag.name` | string  | Name of the tag                           |

## Request Schema

```json
{
  "name": "string" // Required: Name of the tag
}
```

## Usage Example

Use this API endpoint to create new tags for your organization, which can help you:

- Categorize subscribers based on interests, behavior, or demographics
- Set up tags for segmentation and targeting in email campaigns
- Organize subscribers for automation workflows
- Create logical groupings for reporting and analytics
- Implement tag-based features in your application


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

### SDK
```ts
import { Lumail } from "lumail";
const lumail = new Lumail({ apiKey: "YOUR_API_TOKEN" });

const { tag } = await lumail.tags.create({ name: "newsletter" });
console.log(tag);
```

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

### JavaScript
```javascript
const response = await fetch('https://lumail.io/api/v1/tags', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'newsletter',
  }),
});

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

### Python
```python
import requests

url = "https://lumail.io/api/v1/tags"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
payload = {
    "name": "newsletter"
}

response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data)
```

### Success Response
```json
{
  "success": true,
  "tag": {
    "id": "tag_xY3zAb7cDe",
    "name": "newsletter"
  }
}
```

### Error Response
```json
{
  "message": "Invalid API token"
}
```
