> For the complete documentation index, see [llms.txt](https://doc.telosys.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.telosys.org/models/tags.md).

# Tags

As Telosys aims to provide highly customizable models (and predefined annotations are usually not sufficient to handle all special cases) in version 3.3.0 "**tags**" have been added for attributes and since version 4.0.0 they can be used everywhere (entity, attribute and link).

Tags are a very simple way to easily customize your models by adding as much additional information as you want.

### Set tags in model

Each **entity**, **attribute** or **link** can have **0 to N tags**.&#x20;

Like annotations, tags provide additional information usable during the code generation. But, unlike annotations, **tags do not have predefined names**. The user can define as many tags as he wants.

A tag is **any name** starting with "**#**" and optionally having a value.\
If the tag has a **value** then the value is defined between "**(**" and "**)**".

Examples of tags :

```
MyEntity {
id  : int { @Id } ;

// tag "mytag" (without value) :
comment : string { #mytag } ;

// tag "OpenAPIFormat" with value :
val : long  { #OpenAPIFormat(int64) } ;

}
```

### Use tags in templates

In a template you can define conditions based on the presence (or absence) of a tag \
and you can retrieve the value of a tag (with default value if necessary).

To do this, use the following syntax:

* $x.**hasTag**("tagName")
* $x.**tagValue**("tagName")
* $x.**tagValue**("tagName", "defaultValue")
* $x.**tagValueAsBoolean**("tagName", true/false)
* $x.**tagValueAsInt**("tagName", 123)

Example : check tag presence and use its value if present

```
#if ( $attrib.hasTag("OpenAPIFormat") )  
$attrib.tagValue("OpenAPIFormat")
#end
```

See [Telosys objects](/bundles/telosys-objects.md) reference guide for detailed information \
(objects $entity, $attribute and $link).


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.telosys.org/models/tags.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
