> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/en/build/knowledge-base/tags-and-metadata.md).

# Document Management: Tags and Metadata

Knowledge base document management: classify documents and FAQs with tags, control retrieval scope and reference access with metadata, and understand their relationship to tag filtering and query meta

MaiAgent provides tag and metadata management to help you classify and organize the many documents and FAQs in your knowledge base.

## Tag Management <a href="#tag-management" id="tag-management"></a>

When your knowledge base contains large amounts of data, tags help you quickly organize document and FAQ attributes or control access to reference materials. For example:

```
Product information knowledge base (classified by product information)
|-- #Tents 
|-- #4-person-tents 
|-- #3-season-tents 
|-- #SnowPeak
```

```
Educational content knowledge base (classified by access level)
|-- #Non-members
|-- #Regular-members 
|-- #VIP
```

### Add a Tag <a href="#add-tag" id="add-tag"></a>

1. Click the Add button

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-00bd98ff99408eec10691f1f015409e8061114e5%2Fimage%20(185).png?alt=media" alt=""><figcaption></figcaption></figure>

2. Enter a tag name

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-0f4c9e1e2f4a092afaa565bb828a35b4e59f4c24%2Fimage%20(186).png?alt=media" alt=""><figcaption></figcaption></figure>

3. After you click Add, the tag you entered appears as shown below, including its ID, name, and other details

{% hint style="info" %}
You can use the ID to grant access to documents. For details, see the [Technical Manual—Query Metadata Controls](https://docs.maiagent.ai/tech/identity-and-access/zhi-shi-guan-li-quan-xian-query-metadata-cha-xun-yuan-zi-liao-zong-lan/json-interfaces#querymetadata-kong-zhi-xiang-mu-shuo-ming)
{% endhint %}

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-d5efb971745b4bd5297e31119ee1e45093192cb2%2Fimage%20(189).png?alt=media" alt=""><figcaption></figcaption></figure>

### Add Tags to a Document <a href="#tag-document" id="tag-document"></a>

After creating tags, go to the documents page

1. Click Edit File Information

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-9d52c164994d7a2c4b96f3782fdba3a5357ac0d9%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-18%20174411.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Select tags

Add the appropriate tags for each document (you can select multiple tags)

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-c1f4229d90f6e5b2796e969d31ac433b7bd2ff9b%2Fimage%20(193).png?alt=media" alt=""><figcaption></figcaption></figure>

The tags you added then appear after the corresponding document:

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-12fa488c87c8faad401ab5aa06df2f0ab7c7d431%2Fimage%20(194)%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

### Add Tags to an FAQ <a href="#tag-faq" id="tag-faq"></a>

To add hierarchical categories or manage tags for FAQs:

1. Open FAQ management in the knowledge base, select the FAQ to edit, and click the Edit button

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-ff5846eadc0e05b5d0e23d4cf87eab8877ba7ad7%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-19%20171433%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

2. Select the tags to add, then click “<mark style="color:blue;">Confirm</mark>”

<div><figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-e3a464d671878da74fc3b45506c5c4d0e6c29e38%2Fimage%20(174).png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-a2a9363722f24ac61d91273c32c9e1a09f98ec01%2Fimage%20(175).png?alt=media" alt=""><figcaption></figcaption></figure></div>

The added tags appear in the FAQ field

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-f74621f006e8057ab5b6f11f544dda782203da6a%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-19%20172123.png?alt=media" alt=""><figcaption></figcaption></figure>

***

### Tag-Based Access Control <a href="#tag-access-control" id="tag-access-control"></a>

You can use tags to control which content different users see. For example, VIP customers can see more advanced product tutorials, while non-members can only see general tutorials.

{% hint style="info" %}
Filters can apply to both FAQs and documents
{% endhint %}

{% hint style="success" %}
To make an Agent reference only files with specific tags by default across all conversation platforms, without passing parameters on each call, configure this on the Agent settings page. See [Knowledge Base Tag Filtering](/maiagent-user-guide/en/build/agent/label-filter.md).
{% endhint %}

Tag filtering has two levels: conditions within a group and conditions between groups. The interface uses plain language: choose “Include all tags (AND)” or “Include any tag (OR)” within a group, and “Match every group (AND)” or “Match any group (OR)” between groups. The older interface displays AND/OR buttons with the same meaning. The following two examples illustrate this.

#### Include All Tags (AND) <a href="#and-filter" id="and-filter"></a>

“Include all tags (AND)” allows only content that matches every tag in the group.

For example, in a conversation about tutorials for non-members, use tag filtering to let the Agent access only documents that match both the “<mark style="color:blue;">Non-member</mark>” and “<mark style="color:blue;">Tutorial</mark>” tags.

As shown below, after filtering, the Agent can use only the beginner camping document, preventing unrelated information from being disclosed in conversations with non-members.

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-ac0761fb82bb4bcd9a1564cdf5eb190398e39695%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-28%20124301.png?alt=media" alt=""><figcaption></figcaption></figure>

#### Include Any Tag (OR) <a href="#or-filter" id="or-filter"></a>

For conversations with members, switch to “Include any tag (OR)” so the Agent can reference documents tagged for either regular members or non-members:

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-b41ff641039d59dcbe21a70ef0dd6c014528c812%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-28%20124405.png?alt=media" alt=""><figcaption></figcaption></figure>

Members can then see more document content than non-members, providing tiered access.

{% hint style="info" %}
In tag filtering, click “<mark style="color:blue;">Include all tags (AND)</mark>” or “<mark style="color:blue;">Include any tag (OR)</mark>” to switch how this group is evaluated (the image below shows the older AND/OR buttons in the same location). A sentence at the bottom of the builder describes the current conditions so you can verify your settings.
{% endhint %}

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-0fe58d851aefc0a1256a26a0f265ba5a9ba1f9bc%2Fimage%20(156).png?alt=media" alt=""><figcaption></figcaption></figure>

> For filtering results, see: [Chat with an Agent (Agent Marketplace)](/maiagent-user-guide/en/work/explain.md)

## Document Metadata Management <a href="#document-metadata-management" id="document-metadata-management"></a>

### **What Is Metadata?** <a href="#what-is-metadata" id="what-is-metadata"></a>

Metadata is like an “identity card” for a document. It records detailed information to help the system manage and use documents more effectively.

**Example: 初級露營.pdf**

```
Metadata settings:
├── Document version: v2.1
├── Created on: 2024-03-15
├── Last updated: 2024-11-20
├── Next review: 2025-05-20
├── Updating department: Marketing
└── Version status: Reviewed and approved for access
```

### Why Use Metadata? <a href="#why-use-metadata" id="why-use-metadata"></a>

When managing complex datasets, metadata makes maintaining data quality easier and faster. It helps you:

**Improve Management Efficiency**

* Quickly identify document status and version information
* Organize bulk management of large numbers of documents
* Reduce time spent manually searching and checking

**Ensure Content Quality**

* Use the latest document version
* Track document update history and version status
* Ensure the Agent uses the latest reviewed content
* Record the next review date and regularly filter for documents due for review

### Documents Have No Expiration Date, and Metadata Does Not Trigger Automatic Reminders <a href="#no-expiration-or-reminder" id="no-expiration-or-reminder"></a>

Knowledge base documents have no “expiration date” field: uploaded documents remain available for retrieval until you delete or update them. Metadata such as “Next review” is simply a value you record. The platform **does not** use it to send reminders, notify administrators, add tags automatically, or stop retrieving a document when that date arrives. Schedule periodic reviews yourself:

1. Create a date field such as `next_review` in <mark style="color:blue;">Metadata Management</mark> and enter values for documents (default values can be applied automatically to newly uploaded documents).
2. When reviewing, use [Bulk Metadata Management](/maiagent-user-guide/en/build/knowledge-base/km.md#batch-manage-labels-metadata) to download an Excel file containing metadata for the entire knowledge base. Sort or filter by this field to find documents overdue for review.
3. Update or delete the overdue documents, then enter new review dates and upload the metadata again.

Another approach is to represent “Version status” with tags (such as `Reviewed` and `Pending review`) and use [Knowledge Base Tag Filtering](/maiagent-user-guide/en/build/agent/label-filter.md) to let the Agent reference only reviewed documents. Change documents under review to the `Pending review` tag to exclude them from retrieval.

### Metadata Management Page: Fields, Defaults, and Use During Retrieval <a href="#metadata-management-page" id="metadata-management-page"></a>

First define metadata fields under “<mark style="color:blue;">Metadata Management</mark>” on the left of the knowledge base settings page. You can then enter values for individual documents and FAQs. The description at the top explains: “Metadata fields provide additional structured information for documents to help organize and retrieve content. After you set global defaults, newly uploaded documents will automatically use them.” The list contains these columns:

| Field                                               | Description                                                                                                                                                                              |
| --------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <mark style="color:blue;">Field Name</mark>         | The metadata key, such as `url` or `version`                                                                                                                                             |
| <mark style="color:blue;">Type</mark>               | <mark style="color:blue;">Default</mark> = built-in system field; <mark style="color:blue;">Custom</mark> = a field you created with “<mark style="color:blue;">Add Custom Field</mark>” |
| <mark style="color:blue;">Field Description</mark>  | A description of its purpose for administrators                                                                                                                                          |
| <mark style="color:blue;">Default Value</mark>      | Applied automatically to newly uploaded documents; displays “(None)” when unset                                                                                                          |
| <mark style="color:blue;">Retrieval Settings</mark> | A check mark indicates that “<mark style="color:blue;">Use During Retrieval</mark>” is enabled                                                                                           |
| <mark style="color:blue;">Actions</mark>            | <mark style="color:blue;">Edit</mark>, <mark style="color:blue;">Delete</mark> (requires knowledge base edit/delete permissions)                                                         |

When you click “<mark style="color:blue;">Add Custom Field</mark>” or “<mark style="color:blue;">Edit</mark>”, fill in:

* **Field Name**: Must start with a letter, contain only letters, numbers, and underscores, and be no longer than 50 characters.
* **Field Description**: Optional, up to 200 characters, such as “Link to the cited document”.
* **Default Value**: Optional. The interface explains: “Set a global default value; newly uploaded documents will automatically use it.” Existing documents are not backfilled. Use [Bulk Metadata Management](/maiagent-user-guide/en/build/knowledge-base/km.md#batch-manage-labels-metadata) to populate their values.
* **Use During Retrieval**: When enabled, the interface explains: “Send this information to the LLM during retrieval to support answer evaluation and reference.” When a fragment is retrieved, this metadata value for the document is also passed to the Agent. This suits information that affects answers, such as “Document version”, “Applicable region”, and “Effective date”. Fields such as `url` used only for [Custom URL Mapping](#custom-url-mapping) do not need this enabled, saving tokens.

{% hint style="warning" %}
Editing a field affects all documents using it. Deleting a field removes its data from all documents and cannot be undone.
{% endhint %}

### Add Metadata to a Document <a href="#add-metadata-to-document" id="add-metadata-to-document"></a>

1. Go to the documents page and click Edit Document Information:

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-9d52c164994d7a2c4b96f3782fdba3a5357ac0d9%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-18%20174411.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Switch to the metadata tab and enter metadata mappings

> MaiAgent uses key-value mappings to access metadata

<div><figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-d214e20dbb079f0c87ec8d22719fc03d5c79c196%2Fimage%20(142).png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-9cce0ff156c9b371e02ec40a8276f12a958c3ccb%2Fimage%20(143).png?alt=media" alt=""><figcaption></figcaption></figure></div>

After entering values, click “<mark style="color:blue;">Add Metadata</mark>” to add the key-value mappings you entered (you can add multiple metadata entries at once).

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-011bf009a0b4bd5dabe3ef5a6bc76f00fbd3360c%2Fimage%20(202).png?alt=media" alt=""><figcaption></figcaption></figure>

The new metadata then appears in the fields.

### Add Metadata to an FAQ <a href="#add-metadata-to-faq" id="add-metadata-to-faq"></a>

1. Open FAQ management in the knowledge base, select the FAQ to edit, and click the Edit button

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-ff5846eadc0e05b5d0e23d4cf87eab8877ba7ad7%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-19%20171433%20(1).png?alt=media" alt=""><figcaption></figcaption></figure>

2. Switch to the metadata page, enter values, and click Add Metadata

After entering all values, click “Confirm”

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-08208baf117c66b801d1ef1a61b5c9f0a685aaff%2Fimage%20(176).png?alt=media" alt=""><figcaption></figcaption></figure>

The added metadata appears in the FAQ list

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-cbc2c61f59c8b5f38fcbd561916ff731eadc4687%2Fimage%20(177).png?alt=media" alt=""><figcaption></figcaption></figure>

### Custom URL Mapping <a href="#custom-url-mapping" id="custom-url-mapping"></a>

url is a reserved word in the metadata system. If you set `url: https://...your-specified-url`, this URL replaces the original file location when users view cited fragments in a conversation, opening the URL you specified instead.

**Example Scenario: A Brand’s Spring Sale**

**Original Settings:**

```yaml
title: "2025 Spring Sale Details"
content: "This promotion includes 20% off storewide, gifts with qualifying purchases, and other offers..."
url: https://www.yourstore.com/spring-sale-2025
```

**Result:** When a user asks “What offers are available in the spring sale?” in a conversation:

* AI references this knowledge fragment to answer the question
* Clicking the cited source does not open the internal file location
* Instead, the user goes directly to the official promotion page at `https://www.yourstore.com/spring-sale-2025`
* The user can immediately see the latest promotion details, purchase buttons, countdown timers, and other dynamic content

**Practical Uses:**

* **Website announcements**: `url: https://www.company.com/announcements/system-maintenance`
* **Product specifications**: `url: https://www.product.com/specs/model-x1`
* **Customer support policies**: `url: https://support.company.com/return-policy`
* **Event registration**: `url: https://events.company.com/register/webinar-2025`

This makes AI answers more useful: they provide information and guide users directly to relevant pages to take action, improving the user experience and conversion rate.

***

#### Before Setting url <a href="#before-url-setting" id="before-url-setting"></a>

As shown below, before you set a url value, clicking any citation node (such as 初級露營.pdf) lets you view the original document (you can configure whether users may download original files on the conversation platform):

{% hint style="info" %}
[Conversation Platform - Allow Downloads of Cited Documents](/maiagent-user-guide/en/build/conversation-settings/platform-settings/function-settings.md#ai-interaction)
{% endhint %}

<div><figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-8344183badd7e8fdd95aa5f1e778701af26bcc7e%2Fimage%20(167).png?alt=media" alt=""><figcaption><p>View citation nodes</p></figcaption></figure> <figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-156940c18e495edd0ec2d91f8d188c777605d01f%2Fimage%20(168).png?alt=media" alt=""><figcaption><p>View the original file location</p></figcaption></figure></div>

#### After Setting url (Using Google as an Example) <a href="#after-url-setting" id="after-url-setting"></a>

<figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-5ffe6b54062d9c5cceaccffb6b189011dbc19e98%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-19%20145947.png?alt=media" alt=""><figcaption></figcaption></figure>

Clicking the cited file node (露營注意事項.txt) again opens the Google homepage instead of displaying a document preview:

<div><figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-1610be021a9a165d138832964ce0e9e9b88482e5%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-19%20145734.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://1360999650-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6v6TNkkOQVfRYfcNirHL%2Fuploads%2Fgit-blob-5dd779938cea62c819f6df072ec2cfdb7c1dcb5a%2F%E8%9E%A2%E5%B9%95%E6%93%B7%E5%8F%96%E7%95%AB%E9%9D%A2%202025-08-19%20150246.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Once you set the `url` metadata field, users who see the Agent cite that document in a conversation can click it to open your specified link and obtain more complete information


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/maiagent-user-guide/en/build/knowledge-base/tags-and-metadata.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
