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

```typescript
subscribers.addTags(idOrEmail: string, tags: string[]): Promise<LumailResult<AddTagsResponse>>
```

Attach tags without replacing the rest.

## Path Parameters

| Name | Type | Description |
| ----------- | ------ | ------------------------------------- |
| `idOrEmail` | string | **Required.** Subscriber id or email. |

## Body Parameters

| Name | Type | Description |
| ------ | -------- | ----------------------------------------------------------------------- |
| `tags` | string[] | **Required.** Second argument. Tag names to attach. Sent as `{ tags }`. |

## Response Fields

| Field | Type | Description |
| ------- | ---------------- | ------------------------ |
| `added` | number | Count of tags attached. |
| `tags` | `{ id, name }[]` | Resulting or added tags. |

`data` is `{ added?, tags? }`. Failures return `{ data: null, error: { name, message, statusCode } }`.


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

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

const lumail = new Lumail({ apiKey: process.env.LUMAIL_API_KEY });
const { data, error } = await lumail.subscribers.addTags(
  "user@example.com",
  ["vip"],
);
if (error) {
  throw error;
}
console.log(data.added ?? data.tags);
```

### cURL
```bash
curl -X POST https://lumail.io/api/v2/subscribers/user@example.com/tags \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tags":["vip"]}'
```

### JavaScript
```javascript
const response = await fetch("https://lumail.io/api/v2/subscribers/user@example.com/tags", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ tags: ["vip"] }),
});
const data = await response.json();
```

### Success Response
```json
{
  "added": 1,
  "tags": [{ "id": "tag_abc", "name": "vip" }]
}
```

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