2020-06-16 23:08:38 -04:00
---
stage: Verify
group: Runner
2020-11-26 01:09:20 -05:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-06-16 23:08:38 -04:00
---
2021-09-07 17:10:59 -04:00
# Runners API **(FREE)**
2016-02-01 08:31:49 -05:00
2020-08-21 20:10:21 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/2640) in GitLab 8.5.
2016-02-22 07:30:22 -05:00
2019-04-05 00:52:00 -04:00
## Registration and authentication tokens
2020-08-21 20:10:21 -04:00
There are two tokens to take into account when connecting a runner with GitLab.
2019-04-05 00:52:00 -04:00
| Token | Description |
| ----- | ----------- |
2021-06-28 08:38:12 -04:00
| Registration token | Token used to [register the runner ](https://docs.gitlab.com/runner/register/ ). It can be [obtained through GitLab ](../ci/runners/index.md ). |
2021-09-21 08:11:06 -04:00
| Authentication token | Token used to authenticate the runner with the GitLab instance. It is obtained automatically when you [register a runner ](https://docs.gitlab.com/runner/register/ ) or by the Runner API when you manually [register a runner ](#register-a-new-runner ) or [reset the authentication token ](#reset-runners-authentication-token ). |
2019-04-05 00:52:00 -04:00
2020-08-21 20:10:21 -04:00
Here's an example of how the two tokens are used in runner registration:
2019-04-05 00:52:00 -04:00
2020-08-21 20:10:21 -04:00
1. You register the runner via the GitLab API using a registration token, and an
2019-04-05 00:52:00 -04:00
authentication token is returned.
1. You use that authentication token and add it to the
2020-08-21 20:10:21 -04:00
[runner's configuration file ](https://docs.gitlab.com/runner/commands/#configuration-file ):
2019-04-05 00:52:00 -04:00
2019-07-09 03:16:17 -04:00
```toml
[[runners]]
token = "< authentication_token > "
```
2019-04-05 00:52:00 -04:00
2020-08-21 20:10:21 -04:00
GitLab and the runner are then connected.
2019-04-05 00:52:00 -04:00
2016-02-02 09:52:02 -05:00
## List owned runners
2016-02-01 08:31:49 -05:00
2016-02-05 06:25:16 -05:00
Get a list of specific runners available to the user.
2016-02-01 08:31:49 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2016-02-01 08:31:49 -05:00
GET /runners
2016-02-03 08:39:55 -05:00
GET /runners?scope=active
2018-06-11 07:37:47 -04:00
GET /runners?type=project_type
2018-06-11 09:17:46 -04:00
GET /runners?status=active
2018-06-11 12:04:46 -04:00
GET /runners?tag_list=tag1,tag2
2016-02-01 08:31:49 -05:00
```
2018-06-11 12:04:46 -04:00
| Attribute | Type | Required | Description |
|-------------|----------------|----------|---------------------|
| `scope` | string | no | Deprecated: Use `type` or `status` instead. The scope of specific runners to show, one of: `active` , `paused` , `online` , `offline` ; showing all runners if none provided |
| `type` | string | no | The type of runners to show, one of: `instance_type` , `group_type` , `project_type` |
| `status` | string | no | The status of runners to show, one of: `active` , `paused` , `online` , `offline` |
2020-04-08 02:09:54 -04:00
| `tag_list` | string array | no | List of the runner's tags |
2016-02-01 08:31:49 -05:00
2020-02-27 22:09:04 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/runners"
2016-02-01 08:31:49 -05:00
```
2016-02-02 07:22:51 -05:00
Example response:
2016-02-01 08:31:49 -05:00
```json
[
{
"active": true,
"description": "test-1-20150125",
"id": 6,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2021-06-07 11:09:56 -04:00
"is_shared": false,
"runner_type": "project_type",
2017-05-27 09:23:27 -04:00
"name": null,
2017-06-13 16:03:34 -04:00
"online": true,
"status": "online"
2016-02-01 08:31:49 -05:00
},
{
"active": true,
"description": "test-2-20150125",
"id": 8,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-01 08:31:49 -05:00
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "group_type",
2017-05-27 09:23:27 -04:00
"name": null,
2017-06-13 16:03:34 -04:00
"online": false,
"status": "offline"
2016-02-01 08:31:49 -05:00
}
]
```
2021-09-07 17:10:59 -04:00
## List all runners **(FREE SELF)**
2016-02-02 09:52:02 -05:00
2016-02-03 08:39:55 -05:00
Get a list of all runners in the GitLab instance (specific and shared). Access
2021-09-23 02:12:14 -04:00
is restricted to users with the administrator role.
2016-02-02 09:52:02 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2016-02-02 09:52:02 -05:00
GET /runners/all
2016-02-05 06:25:16 -05:00
GET /runners/all?scope=online
2018-06-11 07:37:47 -04:00
GET /runners/all?type=project_type
2018-06-11 09:17:46 -04:00
GET /runners/all?status=active
2018-06-11 12:04:46 -04:00
GET /runners/all?tag_list=tag1,tag2
2016-02-02 09:52:02 -05:00
```
2018-06-11 12:04:46 -04:00
| Attribute | Type | Required | Description |
|-------------|----------------|----------|---------------------|
| `scope` | string | no | Deprecated: Use `type` or `status` instead. The scope of runners to show, one of: `specific` , `shared` , `active` , `paused` , `online` , `offline` ; showing all runners if none provided |
| `type` | string | no | The type of runners to show, one of: `instance_type` , `group_type` , `project_type` |
| `status` | string | no | The status of runners to show, one of: `active` , `paused` , `online` , `offline` |
2020-04-08 02:09:54 -04:00
| `tag_list` | string array | no | List of the runner's tags |
2016-02-02 09:52:02 -05:00
2020-02-27 22:09:04 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/runners/all"
2016-02-02 09:52:02 -05:00
```
Example response:
```json
[
{
"active": true,
"description": "shared-runner-1",
"id": 1,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-02 09:52:02 -05:00
"is_shared": true,
2021-06-07 11:09:56 -04:00
"runner_type": "instance_type",
2017-05-27 09:23:27 -04:00
"name": null,
2017-06-13 16:03:34 -04:00
"online": true,
"status": "online"
2016-02-02 09:52:02 -05:00
},
{
"active": true,
"description": "shared-runner-2",
"id": 3,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-02 09:52:02 -05:00
"is_shared": true,
2021-06-07 11:09:56 -04:00
"runner_type": "instance_type",
2017-05-27 09:23:27 -04:00
"name": null,
2021-04-29 08:09:58 -04:00
"online": false,
2017-06-13 16:03:34 -04:00
"status": "offline"
2016-02-02 09:52:02 -05:00
},
{
"active": true,
"description": "test-1-20150125",
"id": 6,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-02 09:52:02 -05:00
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "project_type",
2017-05-27 09:23:27 -04:00
"name": null,
2021-04-29 08:09:58 -04:00
"online": true,
2017-06-13 16:03:34 -04:00
"status": "paused"
2016-02-02 09:52:02 -05:00
},
{
"active": true,
"description": "test-2-20150125",
"id": 8,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-02 09:52:02 -05:00
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "group_type",
2017-05-27 09:23:27 -04:00
"name": null,
2017-06-13 16:03:34 -04:00
"online": false,
"status": "offline"
2016-02-02 09:52:02 -05:00
}
]
```
2021-09-14 11:12:05 -04:00
To view more than the first 20 runners, use [pagination ](index.md#pagination ).
2016-02-01 08:31:49 -05:00
## Get runner's details
Get details of a runner.
2021-07-10 17:08:26 -04:00
At least the [Maintainer role ](../user/permissions.md ) is required to get runner details at the
2021-05-31 14:09:56 -04:00
project and group level.
2021-04-08 23:09:05 -04:00
Instance-level runner details via this endpoint are available to all signed in users.
2020-02-27 22:09:04 -05:00
```plaintext
2016-02-01 08:31:49 -05:00
GET /runners/:id
```
2016-02-02 07:22:51 -05:00
| Attribute | Type | Required | Description |
2016-02-01 08:31:49 -05:00
|-----------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a runner |
2020-02-27 22:09:04 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/runners/6"
2016-02-01 08:31:49 -05:00
```
2020-12-04 16:09:29 -05:00
NOTE:
2020-05-13 08:07:54 -04:00
The `token` attribute in the response was deprecated [in GitLab 12.10 ](https://gitlab.com/gitlab-org/gitlab/-/issues/214320 ).
and removed in [GitLab 13.0 ](https://gitlab.com/gitlab-org/gitlab/-/issues/214322 ).
2020-04-15 08:09:18 -04:00
2016-02-02 07:22:51 -05:00
Example response:
2016-02-01 08:31:49 -05:00
```json
{
"active": true,
"architecture": null,
"description": "test-1-20150125",
"id": 6,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-01 08:31:49 -05:00
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "project_type",
2016-02-17 15:23:14 -05:00
"contacted_at": "2016-01-25T16:39:48.066Z",
2016-02-01 08:31:49 -05:00
"name": null,
2017-05-27 09:23:27 -04:00
"online": true,
2017-06-13 16:03:34 -04:00
"status": "online",
2016-02-01 08:31:49 -05:00
"platform": null,
2016-02-02 12:47:02 -05:00
"projects": [
{
"id": 1,
2016-02-17 15:06:21 -05:00
"name": "GitLab Community Edition",
2016-02-16 06:45:43 -05:00
"name_with_namespace": "GitLab.org / GitLab Community Edition",
2019-09-18 14:06:14 -04:00
"path": "gitlab-foss",
"path_with_namespace": "gitlab-org/gitlab-foss"
2016-02-02 12:47:02 -05:00
}
],
2016-02-01 08:31:49 -05:00
"revision": null,
"tag_list": [
"ruby",
"mysql"
],
2017-08-23 12:28:57 -04:00
"version": null,
2018-02-19 11:21:00 -05:00
"access_level": "ref_protected",
2018-03-06 10:14:23 -05:00
"maximum_timeout": 3600
2016-02-01 08:31:49 -05:00
}
```
## Update runner's details
Update details of a runner.
2020-02-27 22:09:04 -05:00
```plaintext
2016-02-01 08:31:49 -05:00
PUT /runners/:id
```
2016-02-02 07:22:51 -05:00
| Attribute | Type | Required | Description |
2016-02-01 08:31:49 -05:00
|---------------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a runner |
| `description` | string | no | The description of a runner |
| `active` | boolean | no | The state of a runner; can be set to `true` or `false` |
| `tag_list` | array | no | The list of tags for a runner; put array of tags, that should be finally assigned to a runner |
2019-07-04 18:46:12 -04:00
| `run_untagged` | boolean | no | Flag indicating the runner can execute untagged jobs |
| `locked` | boolean | no | Flag indicating the runner is locked |
| `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` |
2020-11-24 13:09:14 -05:00
| `maximum_timeout` | integer | no | Maximum timeout set when this runner handles the job |
2016-02-01 08:31:49 -05:00
2020-02-27 22:09:04 -05:00
```shell
2021-06-02 11:09:59 -04:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/runners/6" \
--form "description=test-1-20150125-test" --form "tag_list=ruby,mysql,tag1,tag2"
2016-02-01 08:31:49 -05:00
```
2020-12-04 16:09:29 -05:00
NOTE:
2021-09-07 17:10:59 -04:00
The `token` attribute in the response was [deprecated ](https://gitlab.com/gitlab-org/gitlab/-/issues/214320 ) in GitLab 12.10.
and [removed ](https://gitlab.com/gitlab-org/gitlab/-/issues/214322 ) in GitLab 13.0.
2020-04-15 08:09:18 -04:00
2016-02-02 07:22:51 -05:00
Example response:
2016-02-01 08:31:49 -05:00
```json
{
"active": true,
"architecture": null,
"description": "test-1-20150125-test",
"id": 6,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-01 08:31:49 -05:00
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "group_type",
2016-02-17 15:23:14 -05:00
"contacted_at": "2016-01-25T16:39:48.066Z",
2016-02-01 08:31:49 -05:00
"name": null,
2017-05-27 09:23:27 -04:00
"online": true,
2017-06-13 16:03:34 -04:00
"status": "online",
2016-02-01 08:31:49 -05:00
"platform": null,
2016-02-10 08:20:51 -05:00
"projects": [
{
"id": 1,
2016-02-17 15:06:21 -05:00
"name": "GitLab Community Edition",
2016-02-16 06:45:43 -05:00
"name_with_namespace": "GitLab.org / GitLab Community Edition",
2019-09-18 14:06:14 -04:00
"path": "gitlab-foss",
"path_with_namespace": "gitlab-org/gitlab-foss"
2016-02-10 08:20:51 -05:00
}
],
2016-02-01 08:31:49 -05:00
"revision": null,
"tag_list": [
"ruby",
"mysql",
"tag1",
"tag2"
],
2017-08-23 12:28:57 -04:00
"version": null,
2018-02-19 11:21:00 -05:00
"access_level": "ref_protected",
2018-03-06 10:14:23 -05:00
"maximum_timeout": null
2016-02-01 08:31:49 -05:00
}
```
2020-10-07 14:08:34 -04:00
### Pause a runner
Pause a specific runner.
```plaintext
PUT --form "active=false" /runners/:runner_id
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|---------------------|
| `runner_id` | integer | yes | The ID of a runner |
```shell
2021-06-02 11:09:59 -04:00
curl --request PUT --header "PRIVATE-TOKEN: < your_access_token > " \
--form "active=false" "https://gitlab.example.com/api/v4/runners/6"
2020-10-07 14:08:34 -04:00
```
2017-11-21 14:16:14 -05:00
## List runner's jobs
2017-11-16 11:12:33 -05:00
2020-02-06 10:09:11 -05:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/15432) in GitLab 10.3.
2019-04-01 03:53:18 -04:00
2020-08-21 20:10:21 -04:00
List jobs that are being processed or were processed by specified runner.
2017-11-16 11:12:33 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2017-11-16 11:12:33 -05:00
GET /runners/:id/jobs
```
| Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a runner |
2017-11-21 14:16:14 -05:00
| `status` | string | no | Status of the job; one of: `running` , `success` , `failed` , `canceled` |
2019-06-12 16:03:21 -04:00
| `order_by` | string | no | Order jobs by `id` . |
2019-06-12 16:03:21 -04:00
| `sort` | string | no | Sort jobs in `asc` or `desc` order (default: `desc` ) |
2017-11-16 11:12:33 -05:00
2020-02-27 22:09:04 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/runners/1/jobs?status=running"
2017-11-16 11:12:33 -05:00
```
Example response:
```json
[
{
"id": 2,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2017-11-16 11:12:33 -05:00
"status": "running",
"stage": "test",
"name": "test",
"ref": "master",
"tag": false,
"coverage": null,
"created_at": "2017-11-16T08:50:29.000Z",
"started_at": "2017-11-16T08:51:29.000Z",
"finished_at": "2017-11-16T08:53:29.000Z",
"duration": 120,
2017-11-21 14:16:14 -05:00
"user": {
2017-11-16 11:12:33 -05:00
"id": 1,
2017-11-21 14:16:14 -05:00
"name": "John Doe2",
"username": "user2",
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80& d=identicon",
"web_url": "http://localhost/user2",
"created_at": "2017-11-16T18:38:46.000Z",
"bio": null,
"location": null,
2018-09-25 12:40:24 -04:00
"public_email": "",
2017-11-21 14:16:14 -05:00
"skype": "",
"linkedin": "",
"twitter": "",
"website_url": "",
"organization": null
},
"commit": {
"id": "97de212e80737a608d939f648d959671fb0a0142",
"short_id": "97de212e",
"title": "Update configuration\r",
"created_at": "2017-11-16T08:50:28.000Z",
"parent_ids": [
"1b12f15a11fc6e62177bef08f47bc7b5ce50b141",
"498214de67004b1da3d820901307bed2a68a8ef6"
],
"message": "See merge request !123",
"author_name": "John Doe2",
"author_email": "user2@example.org",
"authored_date": "2017-11-16T08:50:27.000Z",
"committer_name": "John Doe2",
"committer_email": "user2@example.org",
"committed_date": "2017-11-16T08:50:27.000Z"
2017-11-16 11:12:33 -05:00
},
"pipeline": {
"id": 2,
"sha": "97de212e80737a608d939f648d959671fb0a0142",
"ref": "master",
2017-11-21 14:16:14 -05:00
"status": "running"
2017-11-16 13:44:14 -05:00
},
"project": {
"id": 1,
"description": null,
"name": "project1",
"name_with_namespace": "John Doe2 / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2017-11-16T18:38:46.620Z"
2017-11-16 11:12:33 -05:00
}
}
]
```
2016-02-01 08:31:49 -05:00
## List project's runners
2016-02-03 08:39:55 -05:00
List all runners (specific and shared) available in the project. Shared runners
2018-10-19 06:09:08 -04:00
are listed if at least one shared runner is defined.
2016-02-01 08:31:49 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2016-02-01 08:31:49 -05:00
GET /projects/:id/runners
2018-06-11 09:25:00 -04:00
GET /projects/:id/runners?scope=active
GET /projects/:id/runners?type=project_type
GET /projects/:id/runners?status=active
2018-06-11 12:04:46 -04:00
GET /projects/:id/runners?tag_list=tag1,tag2
2016-02-01 08:31:49 -05:00
```
2018-06-11 12:04:46 -04:00
| Attribute | Type | Required | Description |
|------------|----------------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2018-06-11 12:04:46 -04:00
| `scope` | string | no | Deprecated: Use `type` or `status` instead. The scope of specific runners to show, one of: `active` , `paused` , `online` , `offline` ; showing all runners if none provided |
| `type` | string | no | The type of runners to show, one of: `instance_type` , `group_type` , `project_type` |
| `status` | string | no | The status of runners to show, one of: `active` , `paused` , `online` , `offline` |
2020-04-08 02:09:54 -04:00
| `tag_list` | string array | no | List of the runner's tags |
2016-02-01 08:31:49 -05:00
2020-02-27 22:09:04 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/9/runners"
2016-02-01 08:31:49 -05:00
```
2016-02-02 07:22:51 -05:00
Example response:
2016-02-01 08:31:49 -05:00
```json
[
{
"active": true,
"description": "test-2-20150125",
"id": 8,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-01 08:31:49 -05:00
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "project_type",
2017-05-27 09:23:27 -04:00
"name": null,
2017-06-13 16:03:34 -04:00
"online": false,
"status": "offline"
2016-02-01 08:31:49 -05:00
},
{
"active": true,
"description": "development_runner",
"id": 5,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-01 08:31:49 -05:00
"is_shared": true,
2021-06-07 11:09:56 -04:00
"runner_type": "instance_type",
2017-05-27 09:23:27 -04:00
"name": null,
2021-04-29 08:09:58 -04:00
"online": true,
2017-06-13 16:03:34 -04:00
"status": "paused"
2016-02-01 08:31:49 -05:00
}
]
```
## Enable a runner in project
2016-02-03 08:39:55 -05:00
Enable an available specific runner in the project.
2016-02-01 08:31:49 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2016-02-16 06:43:43 -05:00
POST /projects/:id/runners
2016-02-01 08:31:49 -05:00
```
2016-02-02 07:22:51 -05:00
| Attribute | Type | Required | Description |
2016-02-01 08:31:49 -05:00
|-------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-02-01 08:31:49 -05:00
| `runner_id` | integer | yes | The ID of a runner |
2020-02-27 22:09:04 -05:00
```shell
2021-06-02 11:09:59 -04:00
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/9/runners" \
--form "runner_id=9"
2016-02-01 08:31:49 -05:00
```
2016-02-02 07:22:51 -05:00
Example response:
2016-02-01 08:31:49 -05:00
```json
{
"active": true,
"description": "test-2016-02-01",
"id": 9,
2018-06-22 05:50:32 -04:00
"ip_address": "127.0.0.1",
2016-02-01 08:31:49 -05:00
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "project_type",
2017-05-27 09:23:27 -04:00
"name": null,
2017-06-13 16:03:34 -04:00
"online": true,
"status": "online"
2016-02-01 08:31:49 -05:00
}
```
## Disable a runner from project
2016-02-03 08:39:55 -05:00
Disable a specific runner from the project. It works only if the project isn't
the only project associated with the specified runner. If so, an error is
2020-09-24 17:09:38 -04:00
returned. Use the call to [delete a runner ](#delete-a-runner ) instead.
2016-02-01 08:31:49 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2016-02-02 08:52:33 -05:00
DELETE /projects/:id/runners/:runner_id
2016-02-01 08:31:49 -05:00
```
2016-02-02 07:22:51 -05:00
| Attribute | Type | Required | Description |
2016-02-01 08:31:49 -05:00
|-------------|---------|----------|---------------------|
2021-06-28 11:08:03 -04:00
| `id` | integer/string | yes | The ID or [URL-encoded path of the project ](index.md#namespaced-path-encoding ) owned by the authenticated user |
2016-02-01 08:31:49 -05:00
| `runner_id` | integer | yes | The ID of a runner |
2020-02-27 22:09:04 -05:00
```shell
2018-12-27 04:03:08 -05:00
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/projects/9/runners/9"
2016-02-01 08:31:49 -05:00
```
2018-01-16 03:29:48 -05:00
2020-03-30 14:08:07 -04:00
## List group's runners
List all runners (specific and shared) available in the group as well it's ancestor groups.
Shared runners are listed if at least one shared runner is defined.
```plaintext
GET /groups/:id/runners
GET /groups/:id/runners?type=group_type
GET /groups/:id/runners?status=active
GET /groups/:id/runners?tag_list=tag1,tag2
```
| Attribute | Type | Required | Description |
|------------|----------------|----------|---------------------|
| `id` | integer | yes | The ID of the group owned by the authenticated user |
| `type` | string | no | The type of runners to show, one of: `instance_type` , `group_type` , `project_type` |
| `status` | string | no | The status of runners to show, one of: `active` , `paused` , `online` , `offline` |
2020-04-08 02:09:54 -04:00
| `tag_list` | string array | no | List of the runner's tags |
2020-03-30 14:08:07 -04:00
```shell
curl --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/groups/9/runners"
```
Example response:
```json
[
{
"id": 3,
"description": "Shared",
"ip_address": "127.0.0.1",
"active": true,
"is_shared": true,
2021-06-07 11:09:56 -04:00
"runner_type": "instance_type",
2020-03-30 14:08:07 -04:00
"name": "gitlab-runner",
"online": null,
"status": "not_connected"
},
{
"id": 6,
"description": "Test",
"ip_address": "127.0.0.1",
"active": true,
"is_shared": true,
2021-06-07 11:09:56 -04:00
"runner_type": "instance_type",
2020-03-30 14:08:07 -04:00
"name": "gitlab-runner",
"online": false,
"status": "offline"
},
{
"id": 8,
"description": "Test 2",
"ip_address": "127.0.0.1",
"active": true,
"is_shared": false,
2021-06-07 11:09:56 -04:00
"runner_type": "group_type",
2020-03-30 14:08:07 -04:00
"name": "gitlab-runner",
"online": null,
"status": "not_connected"
}
]
```
2020-08-21 20:10:21 -04:00
## Register a new runner
2018-01-16 03:29:48 -05:00
2020-08-21 20:10:21 -04:00
Register a new runner for the instance.
2018-01-16 03:29:48 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2018-01-16 03:29:48 -05:00
POST /runners
```
2019-07-04 18:46:12 -04:00
| Attribute | Type | Required | Description |
|--------------|---------|----------|---------------------|
| `token` | string | yes | [Registration token ](#registration-and-authentication-tokens ). |
| `description` | string | no | Runner's description|
2020-10-16 17:09:08 -04:00
| `info` | hash | no | Runner's metadata. You can include `name` , `version` , `revision` , `platform` , and `architecture` , but only `version` is displayed in the Admin area of the UI. |
2020-08-21 20:10:21 -04:00
| `active` | boolean | no | Whether the runner is active |
| `locked` | boolean | no | Whether the runner should be locked for current project |
| `run_untagged` | boolean | no | Whether the runner should handle untagged jobs |
| `tag_list` | string array | no | List of runner's tags |
2019-07-04 18:46:12 -04:00
| `access_level` | string | no | The access_level of the runner; `not_protected` or `ref_protected` |
2020-11-24 13:09:14 -05:00
| `maximum_timeout` | integer | no | Maximum timeout set when this runner handles the job |
2018-01-16 03:29:48 -05:00
2020-02-27 22:09:04 -05:00
```shell
2021-06-02 11:09:59 -04:00
curl --request POST "https://gitlab.example.com/api/v4/runners" \
--form "token=< registration_token > " --form "description=test-1-20150125-test" \
--form "tag_list=ruby,mysql,tag1,tag2"
2018-01-16 03:29:48 -05:00
```
Response:
| Status | Description |
|-----------|---------------------------------|
| 201 | Runner was created |
Example response:
```json
{
2021-01-21 13:09:11 -05:00
"id": 12345,
2018-01-16 03:29:48 -05:00
"token": "6337ff461c94fd3fa32ba3b1ff4125"
}
```
2020-09-24 17:09:38 -04:00
## Delete a runner
There are two ways to delete a runner:
- By specifying the runner ID.
- By specifying the runner's authentication token.
2018-01-16 03:29:48 -05:00
2020-09-24 17:09:38 -04:00
### Delete a runner by ID
To delete the runner by ID, use your access token with the runner's ID:
```plaintext
DELETE /runners/:id
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a runner. The ID is visible in the UI under **Settings > CI/CD** . Expand **Runners** , and below the **Remove Runner** button is an ID preceded by the pound sign, for example, `#6` . |
```shell
curl --request DELETE --header "PRIVATE-TOKEN: < your_access_token > " "https://gitlab.example.com/api/v4/runners/6"
```
### Delete a runner by authentication token
To delete the runner by using its authentication token:
2018-01-16 03:29:48 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2018-01-16 03:29:48 -05:00
DELETE /runners
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|---------------------|
2020-09-24 17:09:38 -04:00
| `token` | string | yes | The runner's [authentication token ](#registration-and-authentication-tokens ). |
2018-01-16 03:29:48 -05:00
2020-02-27 22:09:04 -05:00
```shell
2021-06-02 11:09:59 -04:00
curl --request DELETE "https://gitlab.example.com/api/v4/runners" \
--form "token=< authentication_token > "
2018-01-16 03:29:48 -05:00
```
Response:
| Status | Description |
|-----------|---------------------------------|
| 204 | Runner was deleted |
2020-08-21 20:10:21 -04:00
## Verify authentication for a registered runner
2018-01-16 03:29:48 -05:00
2020-08-21 20:10:21 -04:00
Validates authentication credentials for a registered runner.
2018-01-16 03:29:48 -05:00
2020-02-27 22:09:04 -05:00
```plaintext
2018-01-16 03:29:48 -05:00
POST /runners/verify
```
| Attribute | Type | Required | Description |
|-------------|---------|----------|---------------------|
2019-04-05 00:52:00 -04:00
| `token` | string | yes | Runner's [authentication token ](#registration-and-authentication-tokens ). |
2018-01-16 03:29:48 -05:00
2020-02-27 22:09:04 -05:00
```shell
2021-06-02 11:09:59 -04:00
curl --request POST "https://gitlab.example.com/api/v4/runners/verify" \
--form "token=< authentication_token > "
2018-01-16 03:29:48 -05:00
```
Response:
| Status | Description |
|-----------|---------------------------------|
| 200 | Credentials are valid |
| 403 | Credentials are invalid |
2021-08-31 23:11:03 -04:00
## Reset instance's runner registration token
2021-09-16 23:11:13 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/30942) in GitLab 14.3.
2021-08-31 23:11:03 -04:00
Resets the runner registration token for the GitLab instance.
```plaintext
POST /runners/reset_registration_token
```
```shell
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
"https://gitlab.example.com/api/v4/runners/reset_registration_token"
```
## Reset project's runner registration token
2021-09-16 23:11:13 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/30942) in GitLab 14.3.
2021-08-31 23:11:03 -04:00
Resets the runner registration token for a project.
```plaintext
POST /projects/:id/runners/reset_registration_token
```
```shell
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
"https://gitlab.example.com/api/v4/projects/9/runners/reset_registration_token"
```
## Reset group's runner registration token
2021-09-16 23:11:13 -04:00
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/30942) in GitLab 14.3.
2021-08-31 23:11:03 -04:00
Resets the runner registration token for a group.
```plaintext
POST /groups/:id/runners/reset_registration_token
```
```shell
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
"https://gitlab.example.com/api/v4/groups/9/runners/reset_registration_token"
```
2021-09-21 08:11:06 -04:00
## Reset runner's authentication token
Resets the runner's authentication token.
```plaintext
POST /runners/:id/reset_authentication_token
```
| Attribute | Type | Required | Description |
|-----------|---------|----------|---------------------|
| `id` | integer | yes | The ID of a runner |
```shell
curl --request POST --header "PRIVATE-TOKEN: < your_access_token > " \
"https://gitlab.example.com/api/v4/runners/1/reset_authentication_token"
```
Example response:
```json
{
"token": "6337ff461c94fd3fa32ba3b1ff4125"
}
```