# create\_label\_set

`imerit_ango.sdk.SDK.`

## create\_label\_set(project\_id, tools, classifications, relations, raw\_category\_schema)

Update the ontology of your project.

### Parameters

* **project\_id:** string
  * The unique identifier for the project. You can find the project ID in [the user interface](/sdk/sdk-documentation.md#project-ids) or retrieve it using the [`list_projects`](/sdk/sdk-documentation/project-level-sdk-functions/list_projects.md) function.
* **tools:** List\[ToolCategory], *optional*

  * List of tools that will be added to the label set.
  * Example:

  ```python
  [
      ToolCategory(
          Tool.Segmentation, 
          title="Segmentation Tool"
      )
  ]
  ```
* **classifications:** List\[ClassificationCategory], *optional, default None*

  * List of classifications that will be added to the label set.
  * Example: &#x20;

  ```python
  [
      ClassificationCategory(
          Classification.Single_dropdown,
          title = "Single Choice Question",
          options=[LabelOption("First Option"), LabelOption("Second Option")]
      )
  ]
  ```
* **relations:** List\[RelationCategory], *optional, default None*

  * List of relations that will be added to the label set.
  * Example:

  ```python
  [
      RelationCategory(
          Relation.Single, 
          title="Single Relation Tool"
      )
  ] 
  ```
* **raw\_category\_schema**: Dict, *optional, default None*
  * Instead of creating the label set (category schema) using the previous 'tools', 'classifications', and 'relations' parameters, you may pass here a dictionary representing the entire category schema.
  * See the section below for an example.

To get an example of what can be passed as the `raw_category_schema`, there are two ways:

* Using the SDK itself, get the category schema from another existing project. This will also allow you to programmatically copy the category schema between two projects, like so:

<details>

<summary>Example Code</summary>

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

# Extract category schema info from the existing project
existing_project = ango_sdk.get_project(project_id="<EXISTING_PROJECT_ID>")
cat_schema = existing_project.get("data").get("project").get("categorySchema")

# Create a new project and retrieve the ID of the newly created project
new_project = ango_sdk.create_project("New Project Title", "New Project Description")  
new_project_id = new_project.get("data").get("project").get("_id")

# Add new category schema to newly created project
ango_sdk.create_label_set(project_id=new_project_id, raw_category_schema=cat_schema)
```

</details>

* From the UI, navigate to an existing project, then from the *Settings* tab, navigate to the *Category Schema* section. From there, click on the <img src="/files/ZlRFCNQ4nMvyBv6Jmxt3" alt="" data-size="line">button on the right side to open the schema's JSON. Copy that JSON.

As an example, a `raw_category_schema` obtained from a project could be this:

<details>

<summary>Sample Category Schema</summary>

```json
{
  "tools": [
    {
      "title": "Vehicle",
      "tool": "bounding-box",
      "required": false,
      "schemaId": "c053da596995f93c2c71520",
      "ocrEnabled": false,
      "classifications": [],
      "multiple": false,
      "color": "#f44336",
      "shortcutKey": "1"
    }
  ],
  "classifications": [
    {
      "title": "Color",
      "tool": "radio",
      "required": false,
      "schemaId": "75c02176796c17e7c657955",
      "frameSpecific": false,
      "classifications": [],
      "multiple": false,
      "options": [
        {
          "value": "Red",
          "schemaId": "95df97dc43d2e1dcc77d536"
        },
        {
          "value": "Yellow",
          "schemaId": "f477d05947e30259cc53538"
        },
        {
          "value": "Blue",
          "schemaId": "18a8212c7c48c2ee3464602"
        }
      ],
      "shortcutKey": "2"
    }
  ],
  "relations": []
}
```

</details>

***

#### Label Set Classes

{% tabs %}
{% tab title="ToolCategory" %}
**ToolCategory**

```python
from imerit_ango.models.label_category import ToolCategory
```

Parameters:

* **tool:** Tool
  * The tool type.
  * Options:
    * <kbd>Tool.BoundingBox</kbd>
    * <kbd>Tool.Segmentation</kbd>
    * <kbd>Tool.Polyline</kbd>
    * <kbd>Tool.Polygon</kbd>
    * <kbd>Tool.RotatedBoundingBox</kbd>
    * <kbd>Tool.Ner</kbd>
    * <kbd>Tool.Point</kbd>
    * <kbd>Tool.Pdf</kbd>
    * <kbd>Tool.Brush</kbd>
    * <kbd>Tool.PCT</kbd>

```python
from imerit_ango.models.label_category import Tool
```

* **title:** string, *default ""*
  * The title of the tool.
* **required:** bool, *default None*
  * Whether annotators are required to draw at least one instance of this tool.
* **schemaId:** string, *default None*
  * Sets the tool's schemaId.
* **columnField:** bool, *default False*
  * Whether this tool should be a table column.
* **color:** string, *default ""*
  * The color assigned to this labeling tool, in the format "#FFFFFF"
* **shortcutKey:** string, *default ""*
  * The shortcut to quickly select this tool, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"
* **classifications:** List\[ClassificationCategory], *default \[]*
  * List of nested classifications, if any
* **options:** List\[LabelOption], *default \[]*
  * The tool's answers (options)
    {% endtab %}

{% tab title="ClassificationCategory" %}
**ClassificationCategory**

```python
from imerit_ango.models.label_category import ClassificationCategory
```

Parameters:

* **classification:** Classification
  * The classification type.
  * Options:
    * <kbd>Classification.Multi\_dropdown</kbd>&#x20;
    * <kbd>Classification.Single\_dropdown</kbd>
    * <kbd>Classification.Tree\_dropdown</kbd>
    * <kbd>Classification.Radio</kbd>
    * <kbd>Classification.Checkbox</kbd>
    * <kbd>Classification.Text</kbd>
    * <kbd>Classification.Instance</kbd>
    * <kbd>Classification.Boolean</kbd>

```python
from imerit_ango.models.label_category import Classification
```

* **title:** string, *default ""*
  * The title of the classification.
* **required:** bool, *default None*
  * Whether annotators have to answer this classification or not.
* **schemaId:** string, *default None*
  * Sets the classification's Schema ID.
* **columnField:** bool, *default False*
  * Whether this classification should be a table column.
* **color:** string, *default ""*
  * The color assigned to this labeling tool, in the format "#FFFFFF"
* **shortcutKey:** string, *default ""*
  * The shortcut to quickly select this tool, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"
* **classifications:** List, *default \[ClassificationCategory]*
  * List of nested classifications, if any
* **options:** List\[LabelOption], *default \[]*
  * The classification's answers (options.)
* **treeOptions:** List\[TreeOption], *default \[]*
  * For trees, the tree's leaves/branches.
* **parentOptionId:** string, *default ""*
  * The schema ID of the parent option. That is, the option that the labeler needs to select in order for this classification to appear. Enables conditional nesting.
* **richText**: *bool, default False*
  * Set to True to enable the Rich Text editor for the selected text classification tool.
    {% endtab %}

{% tab title="RelationCategory" %}
**RelationCategory**

```python
from imerit_ango.models.label_category import RelationCategory
```

Parameters:

* **relation:** Relation
  * The classification type.
    * Options:
      * <kbd>Relation.Single</kbd>
      * <kbd>Relation.Group</kbd>

```python
from imerit_ango.models.label_category import Relation
```

* **title:** string, *default ""*
  * The title of the relation.
* **required:** bool, *default None*
  * Whether annotators have to include at least one such relation in order to submit their annotation.
* **schemaId:** string, *default None*
  * Sets the schemaId of the relation.
* **columnField:** bool, *default False*
  * Whether this relation should be a table column.
* **color:** string, *default ""*
  * The color assigned to this relation, in the format "#FFFFFF"
* **shortcutKey:** string, *default ""*
  * The shortcut to quickly select this relation, "0"-"9", "ctrl+0"-"ctrl+9", "a"-"k"
* **classifications:** List\[ClassificationCategory], *default \[]*
  * List of nested classifications, if any
* **options:** List\[LabelOption], *default \[]*
  * The relation's answers (options.)
    {% endtab %}
    {% endtabs %}

*LabelOption* parameters:

* **value:** string
  * The text of the answer (option).
* **schemaId:** string, *default None*
  * The schema ID of the option. Necessary for conditional nesting.

```python
from imerit_ango.models.label_category import LabelOption
```

Returns:

* A dictionary containing the result of the operation.
* Including a `status` field indicating whether the request was successful and a `data` field containing the response payload with updated resources produced by the operation.

<details open>

<summary><strong>How to verify in Ango Hub?</strong></summary>

After successfully executing the `create_label_set` function, you can validate the changes directly in Ango Hub.

Navigate to: **Projects → \[Your Project] → Settings → Category Schema**

* Confirm that the category schema has been updated successfully.

{% hint style="info" %}
Changes made via the SDK are reflected in Ango Hub in near real-time. If updates are not immediately visible, please refresh the page.
{% endhint %}

</details>

### Examples

**Example-1:** Creating an ontology with:

* A [Single Dropdown](/labeling/labeling-tools/classification-tools/single-dropdown.md) classification, with two choices named "First" and "Second":

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import LabelOption, ClassificationCategory, Classification

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

category = ClassificationCategory(
    classification=Classification.Single_dropdown,
    title = "Choice",
    options = [LabelOption("First"), LabelOption("Second")]
)

label_set = [category]
response = ango_sdk.create_label_set(project_id=project_id, classifications=label_set)
```

{% endtab %}

{% tab title="curl" %}
{% code overflow="wrap" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "categorySchema": {
      "classifications": [
        {
          "classifications": [],
          "color": "#20549F",
          "columnField": false,
          "frameSpecific": false,
          "options": [
            {
              "schemaId": "793a5f9474b64bf5919d943b4cef9b65",
              "value": "First"
            },
            {
              "schemaId": "47e022c1cc9b41aa9a3d000c7bbc6524",
              "value": "Second"
            }
          ],
          "parentOptionId": null,
          "regex": null,
          "required": false,
          "richText": false,
          "schemaId": "e4dd1c6f65a04d51b3ea66d23c92a321",
          "shortcutKey": "",
          "showDropdown": false,
          "title": "Choice",
          "tool": "single-dropdown",
          "treeOptions": []
        }
      ],
      "relations": [],
      "tools": []
    }
  }'
```

{% endcode %}
{% endtab %}
{% endtabs %}

<details>

<summary>Resulting category schema</summary>

```json
{
  "tools": [],
  "classifications": [
    {
      "treeOptions": [],
      "tool": "single-dropdown",
      "title": "Choice",
      "required": false,
      "columnField": false,
      "color": "#20549F",
      "shortcutKey": "",
      "classifications": [],
      "options": [
        {
          "value": "First",
          "schemaId": "793a5f9474b64bf5919d943b4cef9b65"
        },
        {
          "value": "Second",
          "schemaId": "47e022c1cc9b41aa9a3d000c7bbc6524"
        }
      ],
      "schemaId": "e4dd1c6f65a04d51b3ea66d23c92a321",
      "regex": null,
      "parentOptionId": null,
      "frameSpecific": false,
      "showDropdown": false,
      "richText": false
    }
  ],
  "relations": []
}
```

</details>

**Example-2:** Creating an ontology with:

* A [Single Dropdown](/labeling/labeling-tools/classification-tools/single-dropdown.md) classification with the classifications "First" and "Second"
* A [Segmentation](/labeling/labeling-tools/tools/segmentation.md) tool called "SegmentationTool"
* A [Single Relation](/labeling/labeling-tools/relation/single-relation.md) called "SingleRelationTool"

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, Classification, LabelOption, Tool, ToolCategory, RelationCategory, Relation

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

dropdown = ClassificationCategory(
    classification=Classification.Single_dropdown,
    title = "SingleDropdown",
    options = [LabelOption('First'), LabelOption('Second')]
)
classifications = [dropdown]

segmentation = ToolCategory(
    tool=Tool.Segmentation, 
    title="SegmentationTool"
)
tools = [segmentation]

relation = RelationCategory(
    relation=Relation.Single, 
    title="SingleRelationTool"
)
relations = [relation]

ango_sdk.create_label_set(
    project_id=project_id,
    tools=tools,
    classifications=classifications,
    relations=relations
)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "categorySchema": {
      "classifications": [
        {
          "abbreviatedName": null,
          "attributeType": null,
          "classifications": [],
          "color": "#E4B398",
          "columnField": false,
          "defaultValue": null,
          "displayName": null,
          "exportName": null,
          "frameSpecific": false,
          "options": [
            {
              "schemaId": "8916867ab3fc43fc9e448a9dfaccece5",
              "value": "First"
            },
            {
              "schemaId": "6668b16981ff4eef8b5dc1c10f3151c6",
              "value": "Second"
            }
          ],
          "parentOptionId": null,
          "regex": null,
          "required": false,
          "richText": false,
          "schemaId": "3347652357c84d3ba303a5500882b09f",
          "shortcutKey": "",
          "showDropdown": false,
          "title": "SingleDropdown",
          "tool": "single-dropdown",
          "treeOptions": []
        }
      ],
      "relations": [
        {
          "classifications": [],
          "color": "#C2CEFD",
          "columnField": false,
          "options": [],
          "required": false,
          "schemaId": "804e2eee4522452abe3daf59aa94dae1",
          "shortcutKey": "",
          "title": "SingleRelationTool",
          "tool": "one-to-one"
        }
      ],
      "tools": [
        {
          "classifications": [],
          "color": "#28E93F",
          "columnField": false,
          "options": [],
          "required": false,
          "schemaId": "2f601f7756554d94b8a5bb50ee6536a1",
          "shortcutKey": "",
          "title": "SegmentationTool",
          "tool": "segmentation"
        }
      ]
    }
  }'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Resulting category schema</summary>

```json
{
  "tools": [
    {
      "tool": "segmentation",
      "title": "SegmentationTool",
      "required": false,
      "columnField": false,
      "color": "#8BE297",
      "shortcutKey": "",
      "classifications": [],
      "options": [],
      "schemaId": "c51c18700440443695cf1c8239c44360"
    }
  ],
  "classifications": [
    {
      "treeOptions": [],
      "tool": "single-dropdown",
      "title": "SingleDropdown",
      "required": false,
      "columnField": false,
      "color": "#C3C6FF",
      "shortcutKey": "",
      "classifications": [],
      "options": [
        {
          "value": "First",
          "schemaId": "0c26447159ce4e7790b47da8c4481681"
        },
        {
          "value": "Second",
          "schemaId": "e39099d2176a494da89833488cf1f88e"
        }
      ],
      "schemaId": "5375ac19fd264d6b9fe07060faaac0d6",
      "regex": null,
      "parentOptionId": null,
      "frameSpecific": false,
      "showDropdown": false,
      "richText": false
    }
  ],
  "relations": [
    {
      "tool": "one-to-one",
      "title": "SingleRelationTool",
      "required": false,
      "columnField": false,
      "color": "#2D0509",
      "shortcutKey": "",
      "classifications": [],
      "options": [],
      "schemaId": "412f56e2fce4479da05470317e2845c8"
    }
  ]
}
```

</details>

**Example-3:** Creating an ontology with:

* A Single Dropdown classification called "Entity Type" with the choices "Vehicle" and "Person"
* Another Single Dropdown classification nested inside the first unconditionally (that is, any choice in the first dropdown will open this second) named "Position" with the choices "On Road" and "Off Road".

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, LabelOption, Classification

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

nested_class_in_dropdown = ClassificationCategory(
    classification=Classification.Single_dropdown,
    title="Position",
    options=[LabelOption('On Road'), LabelOption('Off Road')]
)

dropdown = ClassificationCategory(
    classification=Classification.Single_dropdown,
    title="Entity Type",
    options=[LabelOption('Vehicle'), LabelOption('Person')],
    classifications=[nested_class_in_dropdown],
    required=True
)

classifications = [dropdown]

ango_sdk.create_label_set(project_id=project_id, classifications=classifications)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "categorySchema": {
      "tools": [],
      "classifications": [
        {
          "treeOptions": [],
          "tool": "single-dropdown",
          "title": "Entity Type",
          "required": true,
          "columnField": false,
          "color": "#C5B651",
          "shortcutKey": "",
          "classifications": [
            {
              "treeOptions": [],
              "tool": "single-dropdown",
              "title": "Position",
              "required": false,
              "columnField": false,
              "color": "#4D521D",
              "shortcutKey": "",
              "classifications": [],
              "options": [
                {
                  "value": "On Road",
                  "schemaId": "b65a5bf7a3a04b84bae18d868d2a9d05"
                },
                {
                  "value": "Off Road",
                  "schemaId": "1d5a213f81814191a46cc4d2a7910932"
                }
              ],
              "schemaId": "05ea6a512fc041f5803209e4e0ac5ae7",
              "regex": null,
              "parentOptionId": null,
              "frameSpecific": false,
              "showDropdown": false,
              "richText": false,
              "exportName": null,
              "displayName": null,
              "abbreviatedName": null,
              "attributeType": null,
              "defaultValue": null
            }
          ],
          "options": [
            {
              "value": "Vehicle",
              "schemaId": "820cf6ff47934f5c9a6358de269753c1"
            },
            {
              "value": "Person",
              "schemaId": "478cc12634624952a9316339454c0d21"
            }
          ],
          "schemaId": "1c07b66e47f945c29d8530db364c71fb",
          "regex": null,
          "parentOptionId": null,
          "frameSpecific": false,
          "showDropdown": false,
          "richText": false,
          "exportName": null,
          "displayName": null,
          "abbreviatedName": null,
          "attributeType": null,
          "defaultValue": null
        }
      ],
      "relations": []
    }
  }'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Resulting category schema</summary>

```json
{
  "tools": [],
  "classifications": [
    {
      "treeOptions": [],
      "tool": "single-dropdown",
      "title": "Entity Type",
      "required": true,
      "columnField": false,
      "color": "#96934B",
      "shortcutKey": "",
      "classifications": [
        {
          "treeOptions": [],
          "tool": "single-dropdown",
          "title": "Position",
          "required": false,
          "columnField": false,
          "color": "#978D5E",
          "shortcutKey": "",
          "classifications": [],
          "options": [
            {
              "value": "On Road",
              "schemaId": "8b9cad52f7b84905a697589f402e11e0"
            },
            {
              "value": "Off Road",
              "schemaId": "cbd698bc6805461c9ce2380bec54c429"
            }
          ],
          "schemaId": "ab3ed5e9422c453d93c2bb02d6461ca3",
          "regex": null,
          "parentOptionId": null,
          "frameSpecific": false,
          "showDropdown": false,
          "richText": false
        }
      ],
      "options": [
        {
          "value": "Vehicle",
          "schemaId": "a21ba3c88b8440738e7945e295ca7545"
        },
        {
          "value": "Person",
          "schemaId": "7c13355b336840f9a9eb10def5c04971"
        }
      ],
      "schemaId": "9b42eea24ffc405788a4fad64e21af54",
      "regex": null,
      "parentOptionId": null,
      "frameSpecific": false,
      "showDropdown": false,
      "richText": false
    }
  ],
  "relations": []
}
```

</details>

**Example-4:** Creating an ontology with:

* A [Tree Dropdown ](/labeling/labeling-tools/classification-tools/tree-dropdown.md)tool with:
  * A root
    * With a "tree0" branch
      * With a "subtree0" leaf
      * With a "subtree1" leaf
    * With a "tree1" leaf

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, Classification, TreeOption

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

subtree0 = TreeOption(title="subtree0")
subtree1 = TreeOption(title="subtree1")
tree0 = TreeOption(title="tree0", children=[subtree0, subtree1])
tree1 = TreeOption(title="tree1")

tree_tool = ClassificationCategory(
    classification=Classification.Tree_dropdown,
    title="Tree One",
    treeOptions=[tree0, tree1]
)

ango_sdk.create_label_set(project_id=project_id, classifications=[tree_tool])
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "categorySchema": {
      "tools": [],
      "classifications": [
        {
          "treeOptions": [
            {
              "title": "tree0",
              "children": [
                {
                  "title": "subtree0",
                  "children": [],
                  "key": "c12fb1fa9f6c4d7f93869d70bbb8532d",
                  "value": "c12fb1fa9f6c4d7f93869d70bbb8532d"
                },
                {
                  "title": "subtree1",
                  "children": [],
                  "key": "7813fd60bde344fe8d39c73fd4e1ed96",
                  "value": "7813fd60bde344fe8d39c73fd4e1ed96"
                }
              ],
              "key": "e9e9b3616e5e4f1682e0773a8bf87b1c",
              "value": "e9e9b3616e5e4f1682e0773a8bf87b1c"
            },
            {
              "title": "tree1",
              "children": [],
              "key": "681cfeefd69648c5a49d932e9e29fa04",
              "value": "681cfeefd69648c5a49d932e9e29fa04"
            }
          ],
          "tool": "tree-dropdown",
          "title": "Tree One",
          "required": false,
          "columnField": false,
          "color": "#2ED91A",
          "shortcutKey": "",
          "classifications": [],
          "options": [
            {
              "value": "tree0",
              "schemaId": "e9e9b3616e5e4f1682e0773a8bf87b1c"
            },
            {
              "value": "tree0 / subtree0",
              "schemaId": "c12fb1fa9f6c4d7f93869d70bbb8532d"
            },
            {
              "value": "tree0 / subtree1",
              "schemaId": "7813fd60bde344fe8d39c73fd4e1ed96"
            },
            {
              "value": "tree1",
              "schemaId": "681cfeefd69648c5a49d932e9e29fa04"
            }
          ],
          "schemaId": "d591e47c370141e7aee40ea8fb80c316",
          "regex": null,
          "parentOptionId": null,
          "frameSpecific": false,
          "showDropdown": false,
          "richText": false,
          "exportName": null,
          "displayName": null,
          "abbreviatedName": null,
          "attributeType": null,
          "defaultValue": null
        }
      ],
      "relations": []
    }
  }'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Resulting category schema</summary>

```json
{
  "tools": [],
  "classifications": [
    {
      "treeOptions": [
        {
          "title": "tree0",
          "children": [
            {
              "title": "subtree0",
              "children": [],
              "key": "b4188077d99e4f2cb81cb8089977ee02",
              "value": "b4188077d99e4f2cb81cb8089977ee02"
            },
            {
              "title": "subtree1",
              "children": [],
              "key": "1d313ed3c7e54082af5400f1f589fc4c",
              "value": "1d313ed3c7e54082af5400f1f589fc4c"
            }
          ],
          "key": "bcadecdb205d41e783289638a23ad959",
          "value": "bcadecdb205d41e783289638a23ad959"
        },
        {
          "title": "tree1",
          "children": [],
          "key": "96e3ae4f72c84539a0cfc91d7f48c54c",
          "value": "96e3ae4f72c84539a0cfc91d7f48c54c"
        }
      ],
      "tool": "tree-dropdown",
      "title": "Tree One",
      "required": false,
      "columnField": false,
      "color": "#9B0EE5",
      "shortcutKey": "",
      "classifications": [],
      "options": [
        {
          "value": "tree0",
          "schemaId": "bcadecdb205d41e783289638a23ad959"
        },
        {
          "value": "tree0 / subtree0",
          "schemaId": "b4188077d99e4f2cb81cb8089977ee02"
        },
        {
          "value": "tree0 / subtree1",
          "schemaId": "1d313ed3c7e54082af5400f1f589fc4c"
        },
        {
          "value": "tree1",
          "schemaId": "96e3ae4f72c84539a0cfc91d7f48c54c"
        }
      ],
      "schemaId": "70d5b1df35764048bfebdec5290d6294",
      "regex": null,
      "parentOptionId": null,
      "frameSpecific": false,
      "showDropdown": false,
      "richText": false
    }
  ],
  "relations": []
}
```

</details>

**Example-5:** Creating an ontology with:

* A [radio classification tool](/labeling/labeling-tools/classification-tools/radio.md) with two possible answers, "Radio Option 1" and "Radio Option 2"
* A conditionally nested [Text classification tool](/labeling/labeling-tools/classification-tools/text.md) using the rich text editor, which only appears if the labeler clicks on "Radio Option 1" (here, `parentOptionId` links the text tool to the option which reveals it)

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, LabelOption, Classification

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

radio1 = LabelOption(value="Radio Option 1", schemaId="schema_id_1")
radio2 = LabelOption(value="Radio Option 2")

conditional_text = ClassificationCategory(
    classification=Classification.Text,
    title="Text Tool",
    parentOptionId="schema_id_1",
    color="#333333",
    richText=True
)

radio = ClassificationCategory(
    classification=Classification.Radio,
    title="Radio Classification",
    options=[radio1, radio2],
    classifications=[conditional_text]
)

ango_sdk.create_label_set(project_id=project_id, classifications=[radio])
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "categorySchema": {
      "tools": [],
      "classifications": [
        {
          "treeOptions": [],
          "tool": "radio",
          "title": "Radio Classification",
          "required": false,
          "columnField": false,
          "color": "#715F3E",
          "shortcutKey": "",
          "classifications": [
            {
              "treeOptions": [],
              "tool": "text",
              "title": "Text Tool",
              "required": false,
              "columnField": false,
              "color": "#333333",
              "shortcutKey": "",
              "classifications": [],
              "options": [],
              "schemaId": "cd65a110c6e04ffab8cb642df37036c1",
              "regex": null,
              "parentOptionId": "schema_id_1",
              "frameSpecific": false,
              "showDropdown": false,
              "richText": true,
              "exportName": null,
              "displayName": null,
              "abbreviatedName": null,
              "attributeType": null,
              "defaultValue": null
            }
          ],
          "options": [
            {
              "value": "Radio Option 1",
              "schemaId": "schema_id_1"
            },
            {
              "value": "Radio Option 2",
              "schemaId": "2403ab5a2c8f4e448e636399e212d845"
            }
          ],
          "schemaId": "3d078f7a45914bd1a9832383f5f8b1f3",
          "regex": null,
          "parentOptionId": null,
          "frameSpecific": false,
          "showDropdown": false,
          "richText": false,
          "exportName": null,
          "displayName": null,
          "abbreviatedName": null,
          "attributeType": null,
          "defaultValue": null
        }
      ],
      "relations": []
    }
  }'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Resulting category schema</summary>

```json
{
  "tools": [],
  "classifications": [
    {
      "treeOptions": [],
      "tool": "radio",
      "title": "Radio Classification",
      "required": false,
      "columnField": false,
      "color": "#C9ABFF",
      "shortcutKey": "",
      "classifications": [
        {
          "treeOptions": [],
          "tool": "text",
          "title": "Text Tool",
          "required": false,
          "columnField": false,
          "color": "#333333",
          "shortcutKey": "",
          "classifications": [],
          "options": [],
          "schemaId": "62d8398f548b4fa4915e639cf4180fbc",
          "regex": null,
          "parentOptionId": "radioOption1SchemaId",
          "frameSpecific": false,
          "showDropdown": false,
          "richText": true
        }
      ],
      "options": [
        {
          "value": "Radio Option 1",
          "schemaId": "radioOption1SchemaId"
        },
        {
          "value": "Radio Option 2",
          "schemaId": "8daa04c07bd6462294a45870c9c4fa49"
        }
      ],
      "schemaId": "b79f2aeda12346eea6bf16ab5dc0c84f",
      "regex": null,
      "parentOptionId": null,
      "frameSpecific": false,
      "showDropdown": false,
      "richText": false
    }
  ],
  "relations": []
}
```

</details>

**Example-6:** Creating an ontology with:

* A [radio classification tool](/labeling/labeling-tools/classification-tools/radio.md) with the possible answers "Radio Answer 1" and "Radio Answer 2"
* A [Tree Dropdown classification tool](/labeling/labeling-tools/classification-tools/tree-dropdown.md) which only appears if the annotator clicks on "Radio Answer 1"
  * The Tree Dropdown has a main root
    * With a branch called "Branch 1"
      * With leaves called "Leaf 1" and "Leaf 2"
    * With a leaf called "Leaf 3"

{% tabs %}
{% tab title="python" %}

```python
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
from imerit_ango.models.label_category import ClassificationCategory, TreeOption, LabelOption, Classification

load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')

ango_sdk = SDK(api_key)

leaf1 = TreeOption(title="Leaf 1")
leaf2 = TreeOption(title="Leaf 2")
leaf3 = TreeOption(title="Leaf 3")

branch1 = TreeOption(title="Branch 1", children=[leaf1, leaf2])

tree_tool = ClassificationCategory(
    classification=Classification.Tree_dropdown,
    title='tree',
    treeOptions=[branch1, leaf3],
    parentOptionId="radioOptionSchemaId"
)

radio_1 = LabelOption(value="Radio Answer 1")
radio_2 = LabelOption(value="Radio Answer 2")

radio = ClassificationCategory(
    classification=Classification.Radio,
    title='radio',
    classifications=[tree_tool],
    options=[radio_1, radio_2]
)

ango_sdk.create_label_set(project_id=project_id, classifications=[radio])
```

{% endtab %}

{% tab title="curl" %}

```bash
curl -X POST "https://imeritapi.ango.ai/v2/project/$PROJECT_ID" \
  -H "Content-Type: application/json" \
  -H "apikey: $ANGO_API_KEY" \
  -d '{
    "categorySchema": {
      "tools": [],
      "classifications": [
        {
          "treeOptions": [],
          "tool": "radio",
          "title": "radio",
          "required": false,
          "columnField": false,
          "color": "#71F7DC",
          "shortcutKey": "",
          "classifications": [
            {
              "treeOptions": [
                {
                  "title": "Branch 1",
                  "children": [
                    {
                      "title": "Leaf 1",
                      "children": [],
                      "key": "52b1181d28c043949e06cf5bed3f5737",
                      "value": "52b1181d28c043949e06cf5bed3f5737"
                    },
                    {
                      "title": "Leaf 2",
                      "children": [],
                      "key": "76923960542945f88ea1de0f85bfad65",
                      "value": "76923960542945f88ea1de0f85bfad65"
                    }
                  ],
                  "key": "e4505ca8412d471c8c5dae4215e9609a",
                  "value": "e4505ca8412d471c8c5dae4215e9609a"
                },
                {
                  "title": "Leaf 3",
                  "children": [],
                  "key": "e836383ee08a47eea03008b128b6324f",
                  "value": "e836383ee08a47eea03008b128b6324f"
                }
              ],
              "tool": "tree-dropdown",
              "title": "tree",
              "required": false,
              "columnField": false,
              "color": "#9F9486",
              "shortcutKey": "",
              "classifications": [],
              "options": [
                {
                  "value": "Branch 1",
                  "schemaId": "e4505ca8412d471c8c5dae4215e9609a"
                },
                {
                  "value": "Branch 1 / Leaf 1",
                  "schemaId": "52b1181d28c043949e06cf5bed3f5737"
                },
                {
                  "value": "Branch 1 / Leaf 2",
                  "schemaId": "76923960542945f88ea1de0f85bfad65"
                },
                {
                  "value": "Leaf 3",
                  "schemaId": "e836383ee08a47eea03008b128b6324f"
                }
              ],
              "schemaId": "83affb25a25e4105991102dc18ef7335",
              "regex": null,
              "parentOptionId": "radioOptionSchemaId",
              "frameSpecific": false,
              "showDropdown": false,
              "richText": false,
              "exportName": null,
              "displayName": null,
              "abbreviatedName": null,
              "attributeType": null,
              "defaultValue": null
            }
          ],
          "options": [
            {
              "value": "Radio Answer 1",
              "schemaId": "44e03176a8d44f19b621db1acfbe25d3"
            },
            {
              "value": "Radio Answer 2",
              "schemaId": "d06a62bc40724d54b40f6d58b6293710"
            }
          ],
          "schemaId": "878c782e676a4e6885f28e2c8247c864",
          "regex": null,
          "parentOptionId": null,
          "frameSpecific": false,
          "showDropdown": false,
          "richText": false,
          "exportName": null,
          "displayName": null,
          "abbreviatedName": null,
          "attributeType": null,
          "defaultValue": null
        }
      ],
      "relations": []
    }
  }'
```

{% endtab %}
{% endtabs %}

<details>

<summary>Resulting category schema</summary>

```json
{
  "tools": [],
  "classifications": [
    {
      "treeOptions": [],
      "tool": "radio",
      "title": "radio",
      "required": false,
      "columnField": false,
      "color": "#C5FA61",
      "shortcutKey": "",
      "classifications": [
        {
          "treeOptions": [
            {
              "title": "Branch 1",
              "children": [
                {
                  "title": "Leaf 1",
                  "children": [],
                  "key": "a5932cf49f804e0fa5c6ae2066875242",
                  "value": "a5932cf49f804e0fa5c6ae2066875242"
                },
                {
                  "title": "Leaf 2",
                  "children": [],
                  "key": "bbb54a7814f84b96857b0b8acb96c0b0",
                  "value": "bbb54a7814f84b96857b0b8acb96c0b0"
                }
              ],
              "key": "ba8ce5a3b853420f9b2fb146db969d3f",
              "value": "ba8ce5a3b853420f9b2fb146db969d3f"
            },
            {
              "title": "Leaf 3",
              "children": [],
              "key": "25b78c7dceff4600ad4074ad316980e6",
              "value": "25b78c7dceff4600ad4074ad316980e6"
            }
          ],
          "tool": "tree-dropdown",
          "title": "tree",
          "required": false,
          "columnField": false,
          "color": "#F9F415",
          "shortcutKey": "",
          "classifications": [],
          "options": [
            {
              "value": "Branch 1",
              "schemaId": "ba8ce5a3b853420f9b2fb146db969d3f"
            },
            {
              "value": "Branch 1 / Leaf 1",
              "schemaId": "a5932cf49f804e0fa5c6ae2066875242"
            },
            {
              "value": "Branch 1 / Leaf 2",
              "schemaId": "bbb54a7814f84b96857b0b8acb96c0b0"
            },
            {
              "value": "Leaf 3",
              "schemaId": "25b78c7dceff4600ad4074ad316980e6"
            }
          ],
          "schemaId": "499e34ff61f4404eac8d7925f8a48119",
          "regex": null,
          "parentOptionId": "radioOptionSchemaId",
          "frameSpecific": false,
          "showDropdown": false,
          "richText": false
        }
      ],
      "options": [
        {
          "value": "Radio Answer 1",
          "schemaId": "0805c3451c6045e0b2bd5179f8c2f858"
        },
        {
          "value": "Radio Answer 2",
          "schemaId": "22f59c2ee19d4ca4856a0894388d9780"
        }
      ],
      "schemaId": "fbb179f75e334396b31774d4d83badf3",
      "regex": null,
      "parentOptionId": null,
      "frameSpecific": false,
      "showDropdown": false,
      "richText": false
    }
  ],
  "relations": []
}
```

</details>

{% hint style="info" %}
**See also**

[get\_project](/sdk/sdk-documentation/project-level-sdk-functions/get_project.md)
{% endhint %}


---

# Agent Instructions: 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://docs.imerit.net/sdk/sdk-documentation/project-level-sdk-functions/create_label_set.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.
