Use this API to retrieve information about SSH keys, manage a user’s SSH and GPG keys, and manage SSH certificates for top-level groups.

Queries about deploy key fingerprints also retrieve information about the projects using that key. If you use a SHA256 fingerprint in an API call, URL-encode the fingerprint.

Managing group SSH certificates requires the Owner role for a top-level group.

Retrieve user by SSH key fingerprint

GET /api/v4/keys

Retrieves user by SSH key fingerprint. Administrators only.

Parameters

NameTypeDescription
fingerprint
Query, required
StringThe fingerprint of an SSH key
Example: ba:81:59:68:d7:6c:cd:02:02:bf:6a:9b:55:4e:af:d1

Responses

CodeDescriptionSchema
200OKAPIEntitiesUserWithAdmin
400Bad Request—

Retrieve user by SSH key ID

GET /api/v4/keys/{id}

Retrieves user by SSH key ID. Administrators only.

Parameters

NameTypeDescription
id
Path, required
String or integerThe ID of an SSH key
Example: 2

Responses

CodeDescriptionSchema
200OKAPIEntitiesSSHKeyWithUser
400Bad Request—
404Not Found—

List all GPG keys

GET /api/v4/user/gpg_keys

Lists all GPG keys for the currently authenticated user.

Parameters

NameTypeDescription
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesGpgKey
400Bad Request—

Add a GPG key

POST /api/v4/user/gpg_keys

Adds a GPG key for the currently authenticated user.

Request body (application/json)

PropertyTypeDescription
key
Required
StringThe new GPG key

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesGpgKey
400Bad Request—

Retrieve a GPG key

GET /api/v4/user/gpg_keys/{key_id}

Retrieves a GPG key for the currently authenticated user.

Parameters

NameTypeDescription
key_id
Path, required
IntegerThe ID of the GPG key

Responses

CodeDescriptionSchema
200OKAPIEntitiesGpgKey
400Bad Request—
404Not Found—

Delete a GPG key

DELETE /api/v4/user/gpg_keys/{key_id}

Deletes a GPG key from your user account.

Parameters

NameTypeDescription
key_id
Path, required
IntegerThe ID of the SSH key

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
404Not Found—

List all SSH keys

GET /api/v4/user/keys

Lists all SSH keys for the currently authenticated user.

Parameters

NameTypeDescription
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesSSHKey
400Bad Request—

Add an SSH key

POST /api/v4/user/keys

Adds an SSH key for the currently authenticated user.

Request body (application/json)

PropertyTypeDescription
expires_atString (date-time)The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
key
Required
StringThe new SSH key
title
Required
StringThe title of the new SSH key
usage_typeStringScope of usage for the SSH key
Allowed values: auth_and_signing, auth, signing
Default: auth_and_signing

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesSSHKey
400Bad Request—

Retrieve an SSH key

GET /api/v4/user/keys/{key_id}

Retrieves a specified SSH key for the currently authenticated user.

Parameters

NameTypeDescription
key_id
Path, required
IntegerThe ID of the SSH key

Responses

CodeDescriptionSchema
200OKAPIEntitiesSSHKey
400Bad Request—
404Not Found—

Delete an SSH key

DELETE /api/v4/user/keys/{key_id}

Deletes a specified SSH key from the currently authenticated user.

Parameters

NameTypeDescription
key_id
Path, required
IntegerThe ID of the SSH key

Responses

CodeDescriptionSchema
200OKAPIEntitiesSSHKey
400Bad Request—
404Not Found—

List all GPG keys for a user

GET /api/v4/users/{id}/gpg_keys

Lists all GPG keys for a specified user account. This endpoint does not require authentication.

Parameters

NameTypeDescription
id
Path, required
IntegerThe ID of the user
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesGpgKey
400Bad Request—
404Not Found—

Retrieve a GPG key for a user

GET /api/v4/users/{id}/gpg_keys/{key_id}

Retrieves a GPG key for a specified user account. This endpoint does not require authentication.

Parameters

NameTypeDescription
id
Path, required
IntegerThe ID of the user
key_id
Path, required
IntegerThe ID of the GPG key

Responses

CodeDescriptionSchema
200OKAPIEntitiesGpgKey
400Bad Request—
404Not Found—

Delete a GPG key for a user

DELETE /api/v4/users/{id}/gpg_keys/{key_id}

Deletes a GPG key from a specified user account. Administrators only.

Parameters

NameTypeDescription
id
Path, required
IntegerThe ID of the user
key_id
Path, required
IntegerThe ID of the GPG key

Responses

CodeDescriptionSchema
204No Content—
400Bad Request—
404Not Found—

Retrieve an SSH key for a user

GET /api/v4/users/{id}/keys/{key_id}

Retrieves an SSH key for a specified user account. This endpoint does not require authentication.

Parameters

NameTypeDescription
id
Path, required
IntegerThe ID of the user
key_id
Path, required
IntegerThe ID of the SSH key

Responses

CodeDescriptionSchema
200OKAPIEntitiesSSHKey
400Bad Request—
404Not Found—

Delete an SSH key for a user

DELETE /api/v4/users/{id}/keys/{key_id}

Deletes an SSH key from a specified user account. Administrators only.

Parameters

NameTypeDescription
id
Path, required
IntegerThe ID of the user
key_id
Path, required
IntegerThe ID of the SSH key

Responses

CodeDescriptionSchema
200OKAPIEntitiesSSHKey
400Bad Request—
404Not Found—

List all SSH keys for a user

GET /api/v4/users/{user_id}/keys

Lists all SSH keys for a specified user account.

Parameters

NameTypeDescription
user_id
Path, required
StringThe ID or username of the user
page
Query
IntegerCurrent page number
Default: 1
Example: 1
per_page
Query
IntegerNumber of items per page
Default: 20
Example: 20

Responses

CodeDescriptionSchema
200OKAPIEntitiesSSHKey
400Bad Request—
404Not Found—

Add an SSH key for a user

POST /api/v4/users/{user_id}/keys

Adds an SSH key for a specified user account. Administrators only.

Parameters

NameTypeDescription
user_id
Path, required
IntegerThe ID of the user

Request body (application/json)

PropertyTypeDescription
expires_atString (date-time)The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)
key
Required
StringThe new SSH key
title
Required
StringThe title of the new SSH key
usage_typeStringScope of usage for the SSH key
Allowed values: auth_and_signing, auth, signing
Default: auth_and_signing

Responses

CodeDescriptionSchema
201CreatedAPIEntitiesSSHKey
400Bad Request—
404Not Found—

Schemas

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

APIEntitiesCustomAttribute

PropertyTypeDescription
keyStringExample: foo
valueStringExample: bar

APIEntitiesGpgKey

PropertyTypeDescription
created_atString (date-time)Example: 2017-09-05T09:17:46.264Z
idInteger (int64)Example: 1
keyStringExample: -----BEGIN PGP PUBLIC KEY BLOCK-----

APIEntitiesIdentity

PropertyTypeDescription
extern_uidString—
providerString—

APIEntitiesSSHKey

PropertyTypeDescription
created_atString (date-time)Example: 2015-09-03T07:24:44.627Z
expires_atString (date-time)Example: 2020-09-03T07:24:44.627Z
idInteger (int64)Example: 1
keyStringExample: ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt1256k6Yjz\ GGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCdd\ NaP0L+hM7zhFNzjFvpaMgJw0=
last_used_atString (date-time)Example: 2020-09-03T07:24:44.627Z
titleStringExample: Sample key 25
usage_typeStringExample: auth

APIEntitiesSSHKeyWithUser

PropertyTypeDescription
created_atString (date-time)Example: 2015-09-03T07:24:44.627Z
expires_atString (date-time)Example: 2020-09-03T07:24:44.627Z
idInteger (int64)Example: 1
keyStringExample: ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt1256k6Yjz\ GGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCdd\ NaP0L+hM7zhFNzjFvpaMgJw0=
last_used_atString (date-time)Example: 2020-09-03T07:24:44.627Z
titleStringExample: Sample key 25
usage_typeStringExample: auth
userAPIEntitiesUserPublic—

APIEntitiesUserBasic

PropertyTypeDescription
avatar_pathStringExample: /user/avatar/28/The-Big-Lebowski-400-400.png
avatar_urlStringExample: https://gravatar.com/avatar/1
custom_attributesArray of APIEntitiesCustomAttribute—
idInteger (int64)Example: 1
lockedBoolean—
nameStringExample: Administrator
public_emailStringExample: john@example.com
stateStringExample: active
usernameStringExample: admin
web_urlStringExample: https://gitlab.example.com/root

APIEntitiesUserPublic

PropertyTypeDescription
avatar_pathStringExample: /user/avatar/28/The-Big-Lebowski-400-400.png
avatar_urlStringExample: https://gravatar.com/avatar/1
bioString—
botBoolean—
can_create_groupBooleanExample: true
can_create_projectBooleanExample: true
color_scheme_idIntegerExample: 1
commit_emailString—
confirmed_atString (date-time)Example: 2015-09-03T07:24:01.670Z
created_atString—
current_sign_in_atString (date-time)Example: 2015-09-03T07:24:01.670Z
custom_attributesArray of APIEntitiesCustomAttribute—
discordString—
emailStringExample: john@example.com
externalBoolean—
followersString—
followingString—
githubString—
idInteger (int64)Example: 1
identitiesAPIEntitiesIdentity—
is_followedString—
job_titleString—
last_activity_onString (date-time)Example: 2015-09-03T07:24:01.670Z
last_sign_in_atString (date-time)Example: 2015-09-03T07:24:01.670Z
linkedinString—
local_timeString—
locationString—
lockedBoolean—
nameStringExample: Administrator
organizationString—
preferred_languageStringExample: en
private_profileBooleanExample: false
projects_limitIntegerExample: 10
pronounsString—
public_emailStringExample: john@example.com
stateStringExample: active
theme_idIntegerExample: 2
twitterString—
two_factor_enabledBooleanExample: true
usernameStringExample: admin
web_urlStringExample: https://gitlab.example.com/root
website_urlString—
work_informationString—

APIEntitiesUserWithAdmin

PropertyTypeDescription
avatar_pathStringExample: /user/avatar/28/The-Big-Lebowski-400-400.png
avatar_urlStringExample: https://gravatar.com/avatar/1
bioString—
botBoolean—
can_create_groupBooleanExample: true
can_create_projectBooleanExample: true
color_scheme_idIntegerExample: 1
commit_emailString—
confirmed_atString (date-time)Example: 2015-09-03T07:24:01.670Z
created_atString—
created_byAPIEntitiesUserBasic—
current_sign_in_atString (date-time)Example: 2015-09-03T07:24:01.670Z
custom_attributesArray of APIEntitiesCustomAttribute—
discordString—
emailStringExample: john@example.com
externalBoolean—
followersString—
followingString—
githubString—
idInteger (int64)Example: 1
identitiesAPIEntitiesIdentity—
is_adminString—
is_followedString—
job_titleString—
last_activity_onString (date-time)Example: 2015-09-03T07:24:01.670Z
last_sign_in_atString (date-time)Example: 2015-09-03T07:24:01.670Z
linkedinString—
local_timeString—
locationString—
lockedBoolean—
nameStringExample: Administrator
namespace_idString—
noteString—
organizationString—
preferred_languageStringExample: en
private_profileBooleanExample: false
projects_limitIntegerExample: 10
pronounsString—
provisioned_by_project_idString—
public_emailStringExample: john@example.com
stateStringExample: active
theme_idIntegerExample: 2
twitterString—
two_factor_enabledBooleanExample: true
usernameStringExample: admin
web_urlStringExample: https://gitlab.example.com/root
website_urlString—
work_informationString—