Use the following API methods to request details about labels.
get_label
Returns an existing label.
GET index.php?/api/v2/get_label/{label_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| label_id | integer | true | The ID of the label. |
Response content
Example response:
{
"id": 1,
"name": "Release 2.0",
"created_by":"user_id",
"created_on": unique timestamp,
}
Response codes
| Status Code | Description |
|---|---|
| 200 | Success (the label is returned as part of the response) |
| 400 | Invalid label |
| 403 | No access to the project |
| 429 | TestRail Cloud only—Too many requests (see API rate limit) |
get_labels
Returns a list of existing labels.
GET index.php?/api/v2/get_labels/{project_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
|
project_id |
integer | true | The ID of the project. |
|
offset |
integer | false | Where to start counting the test cases from the offset. |
|
limit |
integer | false | The number of labels the response should return. |
Response content
Example response:
{
"offset": 0,
"limit": 250,
"size": 250,
"_links": {
"next": "/api/v2/get_labels/1&limit=250&offset=250",
"prev": null
},
"labels": [
{
"id": 1,
"title": "label1",
"created_by":"2",
"created_on": "timestamp",
},
{
"id": 2,
"title": "label2",
"created_by":"2",
"created_on": "timestamp",
}
]
}
Response codes
| Status Code | Description |
|---|---|
| 200 | Success (the labels are returned as part of the response) |
| 400 | Invalid label |
| 403 | No access to the project |
| 429 | TestRail Cloud only—Too many requests (see API rate limit) |
update_label
Updates an existing label.
POST index.php?/api/v2/update_label/{label_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| project_id | integer | true | The ID of the project where the label is to be updated. |
| title | string | true | The title of the label. Maximum 20 characters allowed. |
Response content
Example response:
{
"id": 1,
"title": "Release 2.0",
}
Response codes
| Status Code | Description |
|---|---|
| 200 | Success (the label is returned as part of the response) |
| 400 | Invalid or unknown test case |
| 403 | No access to the project |
| 429 | TestRail Cloud only—Too many requests (see API rate limit) |