# Get List of Label Sets in a Project

In addition to adding label sets to a project, you may also want to update them. To do this, you’ll first need to get the **label set ID** for the project.

Use the following GraphQL queries for this:

* [GetCabinetLabelSetsById](https://api-docs.datasaur.ai/#query-getCabinetLabelSetsById)
* [GetCabinet](https://api-docs.datasaur.ai/#query-getCabinet)

## cURL

Use the following cURL command to get the cabinet ID, which is required before you can fetch label sets. Copy and paste it, then replace the following:

* **`access_token`** with your own API access token.
* **`project-id`** with the ID of your project.
* **`role`** with the cabinet role you want to query.
  * Set to **REVIEWER** to check the reviewer cabinet.
  * Set to **LABELER** if you need the labeler cabinet.

```javascript
curl --location --request POST 'https://datasaur.ai/graphql' \
  --header 'Authorization: Bearer access_token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "query": "query GetCabinet($projectId: ID!, $role: Role!) { getCabinet(projectId: $projectId, role: $role) { id } }",
    "variables": {
      "projectId": "project-id",
      "role": "REVIEWER"
    }
  }'
```

Once you have the **cabinet ID**, use the command below to fetch all label sets added to that cabinet. Copy and paste it, then replace the following:

* **`access_token`** with your own API access token.
* The content of the label set items according to your needs.
* **`cabinet-id`** with the cabinet ID you previously retrieved.

```javascript
curl --location --request POST '<https://datasaur.ai/graphql>' \\
  --header 'Authorization: Bearer access_token' \\
  --header 'Content-Type: application/json' \\
  --data-raw '{ "operationName": "GetCabinetLabelSetsById", "query": "query getCabinetLabelSetsById($cabinetId: ID!) { getCabinetLabelSetsById(cabinetId: $cabinetId) { id name tagItems { id parentId tagName color } } }", "variables": { "cabinetId": "cabinet-id" }}'
```

For clarity, here’s a formatted version of the request body:

```javascript
{
    "operationName": "GetCabinetLabelSetsById",
    "query": "query getCabinetLabelSetsById($cabinetId: ID!) { getCabinetLabelSetsById(cabinetId: $cabinetId) { id name tagItems { id parentId tagName color } } }",
    "variables": {
        "cabinetId": "cabinet-id"
    }
}
```

* **operationName**: you can fill any alphanumeric string in as the operationName. Refer [this page](https://graphql.org/learn/queries/#operation-name) for best practices on choosing an `operationName` .
* **variables:**
  * **fileId:** string, the document ID for the project.
* **query**: Copy this from the example above.

{% hint style="info" %}
A **tag** has the same meaning as a **label**. In the near future, we will update the GraphQL Schema to refer to all instances as labels.
{% endhint %}

## Response

Here is the response you can expect after issuing the cURL command. Use the **id** to manage the project.

```javascript
{
    "data": {
        "document": {
            "id": "c541e403-776a-40b7-af4b-955c7be86c0d",
            "settings": {
                "labelSets": [
                    {
                        "id": "4585972",
                        "index": 0,
                        "name": "POS",
                        "tagItems": [
                            { "id": "PhvHFKDx0m1lA4bl46NhH", "color": null, "parentId": null, "tagName": "NOUN" },
                            { "id": "zlFF5EBksh8vvjm36Pb7-", "color": null, "parentId": null, "tagName": "VERB" }
                        ]
                    },
                    {
                        "id": "4586371",
                        "index": 1,
                        "name": "NER",
                        "signature": "67452b1cdb893096e521dbe9d1f9eeaea3a308bcaee2b9001f2c0b6d538172aa",
                        "tagItems": [
                            { "id": "qgvxaa-svCwj18KIcoCBu", "color": "red", "parentId": null, "tagName": "PER" },
                            { "id": "qgvxbb-svCwj18KIcoCBu", "color": "green", "parentId": null, "tagName": "GEO" },
                            { "id": "qgvxMd-svCwj18KIcoCBu", "color": null, "parentId": null, "tagName": "GPE" }
                        ]
                    }
                ]
            }
        }
    },
    "extensions": {}
}
```


---

# 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.datasaur.ai/api/labeling/get-list-of-label-sets-in-a-project.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.
