Use this API to interact with the GitLab agent for Kubernetes.

List all agents

GET /api/v4/projects/{id}/cluster_agents

Lists all agents registered for the project. You must have the Developer, Maintainer, or Owner role to use this endpoint.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesClustersAgent
400Bad Request—
404Not Found—

Create an agent

POST /api/v4/projects/{id}/cluster_agents

Creates an agent for the project. You must have the Maintainer or Owner role to use this endpoint.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project

Request body (application/json)

PropertyTypeDescription
name
Required
StringThe name of the agent

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesClustersAgent
400Bad Request—
404Not Found—

Retrieve details on an agent

GET /api/v4/projects/{id}/cluster_agents/{agent_id}

Retrieves details on a specified agent. You must have the Developer, Maintainer, or Owner role to use this endpoint.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
agent_id
Path, required
IntegerThe ID of an agent

Responses

CodeDescriptionSchema
200OKAPIEntitiesClustersAgent
400Bad Request—
404Not Found—

Delete an agent

DELETE /api/v4/projects/{id}/cluster_agents/{agent_id}

Deletes an existing agent registration. You must have the Maintainer or Owner role to use this endpoint.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
agent_id
Path, required
IntegerThe ID of an agent

Responses

CodeDescriptionSchema
204Resource deleted—
400Bad Request—
404Not Found—

List all agent tokens

GET /api/v4/projects/{id}/cluster_agents/{agent_id}/tokens

Lists all active tokens for an agent. You must have the Developer, Maintainer, or Owner role to use this endpoint.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
agent_id
Path, required
IntegerThe ID of an agent
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesClustersAgentTokenBasic
400Bad Request—
404Not Found—

Create an agent token

POST /api/v4/projects/{id}/cluster_agents/{agent_id}/tokens

Creates a token for an agent. You must have the Maintainer or Owner role to use this endpoint. An agent can have only two active tokens at one time.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
agent_id
Path, required
IntegerThe ID of an agent

Request body (application/json)

PropertyTypeDescription
descriptionStringThe description for the token
name
Required
StringThe name for the token

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesClustersAgentTokenWithToken
400Bad Request—
404Not Found—

Retrieve an agent token

GET /api/v4/projects/{id}/cluster_agents/{agent_id}/tokens/{token_id}

Retrieves a specified agent token. You must have the Developer, Maintainer, or Owner role to use this endpoint. Returns a 404 if the agent token has been revoked.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
agent_id
Path, required
IntegerThe ID of an agent
token_id
Path, required
IntegerThe ID of the agent token

Responses

CodeDescriptionSchema
200OKAPIEntitiesClustersAgentToken
400Bad Request—
404Not Found—

Revoke an agent token

DELETE /api/v4/projects/{id}/cluster_agents/{agent_id}/tokens/{token_id}

Revokes an agent token. You must have the Maintainer or Owner role to use this endpoint.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID or URL-encoded path of the project
agent_id
Path, required
IntegerThe ID of an agent
token_id
Path, required
IntegerThe ID of the agent token

Responses

CodeDescriptionSchema
204Resource deleted—
400Bad Request—
404Not Found—

Schemas

Objects returned by the operations above and objects nested in their request bodies.

APIEntitiesClustersAgent

PropertyTypeDescription
config_projectAPIEntitiesProjectIdentity—
created_atString (date-time)—
created_by_user_idInteger (int64)Example: 1
idInteger (int64)Example: 1
nameString—

APIEntitiesClustersAgentToken

PropertyTypeDescription
agent_idInteger (int64)Example: 1
created_atString (date-time)—
created_by_user_idInteger (int64)Example: 1
descriptionString—
idInteger (int64)Example: 1
last_used_atString (date-time)—
nameString—
statusString—

APIEntitiesClustersAgentTokenBasic

PropertyTypeDescription
agent_idInteger (int64)Example: 1
created_atString (date-time)—
created_by_user_idInteger (int64)Example: 1
descriptionString—
idInteger (int64)Example: 1
nameString—
statusString—

APIEntitiesClustersAgentTokenWithToken

PropertyTypeDescription
agent_idInteger (int64)Example: 1
created_atString (date-time)—
created_by_user_idInteger (int64)Example: 1
descriptionString—
idInteger (int64)Example: 1
last_used_atString (date-time)—
nameString—
statusString—
tokenString—

APIEntitiesProjectIdentity

PropertyTypeDescription
created_atString (date-time)Example: 2020-05-07T04:27:17.016Z
descriptionStringExample: desc
idInteger (int64)Example: 1
nameStringExample: project1
name_with_namespaceStringExample: John Doe / project1
pathStringExample: project1
path_with_namespaceStringExample: namespace1/project1