Use this API to interact with CI/CD job token scopes.

All requests to the CI/CD job token scope API endpoint must be authenticated. The authenticated user must have the Maintainer or Owner role for the project.

Retrieve the CI/CD job token access settings for a project

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

Retrieves the CI/CD job token access settings (job token scope) of a specified project.

Parameters

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

Responses

CodeDescriptionSchema
200OKAPIEntitiesProjectJobTokenScope
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Update the CI/CD job token access settings for a project

PATCH /api/v4/projects/{id}/job_token_scope

Updates the Authorized groups and projects setting (job token scope) of a specified project. If the Enforce job token allowlist instance setting is enabled, setting enabled to false returns 400 Bad Request with an error message.

Parameters

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

Request body (application/json)

PropertyTypeDescription
enabled
Required
BooleanIndicates CI/CD job tokens generated in other projects have restricted access to this project. Set to false to allow access from all projects. The Enforce job token allowlist instance setting can override this parameter

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

List all projects in a CI/CD job token allowlist

GET /api/v4/projects/{id}/job_token_scope/allowlist

Lists all projects in the CI/CD job token allowlist of a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerID or URL-encoded path of the project
page
Query
IntegerPage number of results to retrieve
Default: 1
Example: 1
per_page
Query
IntegerNumber of items to list per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKArray of APIEntitiesBasicProjectDetails
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Add a project to a CI/CD job token allowlist

POST /api/v4/projects/{id}/job_token_scope/allowlist

Adds a project to the CI/CD job token allowlist of a specified project.

Parameters

NameTypeDescription
id
Path, required
IntegerID of the project
Example: 1

Request body (application/json)

PropertyTypeDescription
target_project_id
Required
IntegerID of the project to add to the CI/CD job token inbound allowlist
Example: 2

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesProjectScopeLink
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
422Unprocessable entity—

Delete a project from a CI/CD job token allowlist

DELETE /api/v4/projects/{id}/job_token_scope/allowlist/{target_project_id}

Deletes a project from the CI/CD job token allowlist of a specified project.

Parameters

NameTypeDescription
id
Path, required
IntegerID of the project
Example: 1
target_project_id
Path, required
IntegerID of the project to remove from the CI/CD job token inbound allowlist
Example: 2

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

List all groups in a CI/CD job token allowlist

GET /api/v4/projects/{id}/job_token_scope/groups_allowlist

Lists all groups in the CI/CD job token allowlist of a specified project.

Parameters

NameTypeDescription
id
Path, required
String or integerID or URL-encoded path of the project
page
Query
IntegerPage number of results to retrieve
Default: 1
Example: 1
per_page
Query
IntegerNumber of items to list per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKArray of APIEntitiesBasicGroupDetails
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Add a group to a CI/CD job token allowlist

POST /api/v4/projects/{id}/job_token_scope/groups_allowlist

Adds a group to the CI/CD job token allowlist of a specified project.

Parameters

NameTypeDescription
id
Path, required
IntegerID of the project
Example: 1

Request body (application/json)

PropertyTypeDescription
target_group_id
Required
IntegerID of the group to add to the CI/CD job token groups allowlist
Example: 2

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesGroupScopeLink
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—
422Unprocessable entity—

Delete a group from a CI/CD job token allowlist

DELETE /api/v4/projects/{id}/job_token_scope/groups_allowlist/{target_group_id}

Deletes a group from the CI/CD job token allowlist of a specified project.

Parameters

NameTypeDescription
id
Path, required
IntegerID of the project
Example: 1
target_group_id
Path, required
IntegerID of the group to remove from the CI/CD job token groups allowlist
Example: 2

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
401Unauthorized—
403Forbidden—
404Not found—

Schemas

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

APIEntitiesBasicGroupDetails

PropertyTypeDescription
idInteger (int64)ID of the group
nameStringName of the group
Example: Diaspora
web_urlStringURL to access the group in a browser
Example: http://gitlab.example.com/groups/diaspora

APIEntitiesBasicProjectDetails

PropertyTypeDescription
avatar_urlStringExample: http://example.com/uploads/project/avatar/3/uploads/avatar.png
created_atString (date-time)Example: 2020-05-07T04:27:17.016Z
custom_attributesAPIEntitiesCustomAttribute—
default_branchStringExample: main
descriptionStringExample: desc
forks_countIntegerExample: 1
http_url_to_repoStringExample: https://gitlab.example.com/gitlab/gitlab.git
idInteger (int64)Example: 1
last_activity_atString (date-time)Example: 2013-09-30T13:46:02Z
licenseAPIEntitiesLicenseBasic—
license_urlStringExample: https://gitlab.example.com/gitlab/gitlab/blob/master/LICENCE
nameStringExample: project1
name_with_namespaceStringExample: John Doe / project1
namespaceAPIEntitiesNamespaceBasic—
pathStringExample: project1
path_with_namespaceStringExample: namespace1/project1
readme_urlStringExample: https://gitlab.example.com/gitlab/gitlab/blob/master/README.md
repository_storageStringExample: default
ssh_url_to_repoStringExample: git@gitlab.example.com:gitlab/gitlab.git
star_countIntegerExample: 1
tag_listArray of stringsExample: ["tag"]
topicsArray of stringsExample: ["topic"]
visibilityStringExample: public
web_urlStringExample: https://gitlab.example.com/gitlab/gitlab

APIEntitiesCustomAttribute

PropertyTypeDescription
keyStringExample: foo
valueStringExample: bar
PropertyTypeDescription
source_project_idInteger (int64)ID of the project whose CI/CD job token allowlist includes the group
target_group_idInteger (int64)ID of the group added to the allowlist

APIEntitiesLicenseBasic

PropertyTypeDescription
html_urlStringExample: http://choosealicense.com/licenses/gpl-3.0
keyStringExample: gpl-3.0
nameStringExample: GNU General Public License v3.0
nicknameStringExample: GNU GPLv3
source_urlString—

APIEntitiesNamespaceBasic

PropertyTypeDescription
avatar_urlStringURL of the namespace avatar. For a group, null if no avatar is set
Example: https://example.com/avatar/12345
full_pathStringFull path of the namespace, including the paths of its parent groups
Example: group/my_project
idInteger (int64)ID of the namespace
Example: 2
kindStringType of the namespace: user, group, or project
Example: project
nameStringName of the namespace
Example: project
parent_idInteger (int64)ID of the parent namespace. null for top-level namespaces
Example: 1
pathStringPath of the namespace
Example: my_project
web_urlStringWeb URL of the namespace. For a user namespace, the URL of the user profile
Example: https://example.com/group/my_project

APIEntitiesProjectJobTokenScope

PropertyTypeDescription
inbound_enabledBooleanIf true, only groups and projects in the job token allowlist can access this project. Also true when the instance enforces the job token allowlist. If false, all projects have access
outbound_enabledBooleanIf true, the CI/CD job token generated in this project can access only the projects in its outbound scope. Deprecated
PropertyTypeDescription
source_project_idInteger (int64)ID of the project whose job token inbound allowlist is updated
target_project_idInteger (int64)ID of the project added to the source project’s inbound allowlist