> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trytalkvalue.com/llms.txt
> Use this file to discover all available pages before exploring further.

# talkvalue path tag attach

> Attach a tag to a channel or event by tag ID, or create a tag inline by name and attach it in one call.

Attach a tag to a Path source. A source is either a channel ID or an event ID. The same command handles both, because the underlying tag relationship is shared. Pass `--tag-id` to attach an existing tag, or pass `--name` to attach an existing tag by name (and create one with that name if none exists). At least one of the two flags is required. If you pass both `--tag-id` and `--name`, pass only the one you want; supplying both has no defined precedence.

## Synopsis

```bash theme={null}
talkvalue path tag attach <sourceId> --tag-id <id>
talkvalue path tag attach <sourceId> --name <name>
```

## Arguments

| Argument     | Type    | Description                                                                                                           |
| ------------ | ------- | --------------------------------------------------------------------------------------------------------------------- |
| `<sourceId>` | integer | Channel ID or event ID to attach the tag to. TalkValue detects whether the ID is a channel or an event automatically. |

## Options

| Flag            | Type    | Description                                                                                                                                                    |
| --------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--tag-id <id>` | integer | Attach an existing tag by ID. Find IDs with [`tag list`](/cli/commands/path/tag/index) or capture them when you [`tag create`](/cli/commands/path/tag/create). |
| `--name <name>` | string  | Attach by name. If no tag with that name exists, TalkValue creates one and attaches it in the same request.                                                    |

## Examples

### 1. Attach an existing tag by ID

```bash theme={null}
talkvalue path tag attach 7 --tag-id 42
```

Adds tag `42` to channel (or event) `7`. The response prints the tag as confirmation the write succeeded.

### 2. Create-or-attach by name

```bash theme={null}
talkvalue path tag attach 18 --name "Customer Day 2026"
```

Convenient when scripting against a list of source IDs and a small handful of tag names. You do not need to look up or create tags upfront.

### 3. Bulk-attach the same tag to many channels

```bash theme={null}
tag_id=42
for channel_id in 7 12 18 21; do
  talkvalue path tag attach "$channel_id" --tag-id "$tag_id"
done
```

Re-uses one ID across the loop. Attaching a tag is idempotent, so re-running the loop after a partial failure is safe.

## Response

```jsonc theme={null}
{
  "data": {
    "id": 42,
    "name": "LinkedIn"
  }
}
```

Returns the tag that was attached. The source's tag list (visible in `channel get` or `event get`) updates immediately and includes this tag on subsequent reads.

## See also

* [`tag create`](/cli/commands/path/tag/create). Create a tag first when you want a known ID before the attach.
* [Tags](/path/concepts/tags). How tags roll up to analytics and dashboard filters.
* [`path channel get`](/cli/commands/path/channel/get) and [`path event get`](/cli/commands/path/event/get). Re-read the source to confirm the tag landed.
