> For the complete documentation index, see [llms.txt](https://docs.datasaur.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datasaur.ai/api/labeling/get-list-of-label-sets-in-a-project.md).

# 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.

{% code overflow="wrap" %}

```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"
    }
  }'
```

{% endcode %}

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.

{% code overflow="wrap" %}

```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" }}'
```

{% endcode %}

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

{% code overflow="wrap" %}

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

{% endcode %}

* **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.

{% code overflow="wrap" %}

```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": {}
}
```

{% endcode %}
