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 and the instance.
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.
Managing instance SSH certificates requires administrator access.
Retrieve user by SSH key fingerprint
GET /api/v4/keys
Retrieves user by SSH key or deploy key fingerprint. For a deploy key, the response also includes the projects that use the key. Deploy keys are bound to the creating user. Administrators only.
Parameters
| Name | Type | Description |
|---|---|---|
fingerprintQuery, | String | Fingerprint of an SSH key or deploy key./ is %2 and : is %3Example: ba: |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
Retrieve user by SSH key ID
GET /api/v4/keys/{id}
Retrieves user by SSH key ID. Administrators only.
Parameters
| Name | Type | Description |
|---|---|---|
idPath, | String or integer | ID of the SSH key Example: 2 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
List all GPG keys
GET /api/v4/user/gpg_keys
Lists all GPG keys for the currently authenticated user.
Parameters
| Name | Type | Description |
|---|---|---|
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
per_Query | Integer | Number of items to list per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | Array of APIEntities |
400 | Bad Request | — |
Add a GPG key
POST /api/v4/user/gpg_keys
Adds a GPG key for the currently authenticated user.
Request body (application/json)
| Property | Type | Description |
|---|---|---|
keyRequired | String | Public key value of the GPG key |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Bad Request | — |
Retrieve a GPG key
GET /api/v4/user/gpg_keys/{key_id}
Retrieves a GPG key for the currently authenticated user.
Parameters
| Name | Type | Description |
|---|---|---|
key_Path, | Integer | ID of the GPG key |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Delete a GPG key
DELETE /api/v4/user/gpg_keys/{key_id}
Deletes a GPG key from your user account.
Parameters
| Name | Type | Description |
|---|---|---|
key_Path, | Integer | ID of the GPG key |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not Found | — |
List all SSH keys
GET /api/v4/user/keys
Lists all SSH keys for the currently authenticated user.
Parameters
| Name | Type | Description |
|---|---|---|
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
per_Query | Integer | Number of items to list per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | Array of APIEntities |
400 | Bad Request | — |
Add an SSH key
POST /api/v4/user/keys
Adds an SSH key for the currently authenticated user. If the key or its fingerprint is already in use, returns a validation error with the message has already been taken.
Request body (application/json)
| Property | Type | Description |
|---|---|---|
expires_ | String (date- | Date when the SSH key expires |
keyRequired | String | Public key value of the SSH key |
titleRequired | String | Title of the SSH key |
usage_ | String | Usage scope for the key Allowed values: auth_,auth,signingDefault: auth_ |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Bad Request | — |
Retrieve an SSH key
GET /api/v4/user/keys/{key_id}
Retrieves a specified SSH key for the currently authenticated user.
Parameters
| Name | Type | Description |
|---|---|---|
key_Path, | Integer | ID of the SSH key |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Delete an SSH key
DELETE /api/v4/user/keys/{key_id}
Deletes a specified SSH key from the currently authenticated user.
Parameters
| Name | Type | Description |
|---|---|---|
key_Path, | Integer | ID of the SSH key |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not 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
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the user |
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
per_Query | Integer | Number of items to list per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | Array of APIEntities |
400 | Bad Request | — |
404 | Not 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
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the user |
key_Path, | Integer | ID of the GPG key |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not 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
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the user |
key_Path, | Integer | ID of the GPG key |
Responses
| Code | Description | Schema |
|---|---|---|
204 | No Content | — |
400 | Bad Request | — |
404 | Not 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
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the user |
key_Path, | Integer | ID of the SSH key |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not 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
| Name | Type | Description |
|---|---|---|
idPath, | Integer | ID of the user |
key_Path, | Integer | ID of the SSH key |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
List all SSH keys for a user
GET /api/v4/users/{user_id}/keys
Lists all SSH keys for a specified user account. This endpoint does not require authentication.
Parameters
| Name | Type | Description |
|---|---|---|
user_Path, | String | ID or username of the user |
pageQuery | Integer | Page number of results to retrieve Default: 1Example: 1 |
per_Query | Integer | Number of items to list per page Default: 20Example: 20 |
Responses
| Code | Description | Schema |
|---|---|---|
200 | OK | Array of APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Add an SSH key for a user
POST /api/v4/users/{user_id}/keys
Adds an SSH key for a specified user account. This also adds an audit event. If the key or its fingerprint is already in use, returns a validation error with the message has already been taken. Administrators only.
Parameters
| Name | Type | Description |
|---|---|---|
user_Path, | Integer | ID of the user |
Request body (application/json)
| Property | Type | Description |
|---|---|---|
expires_ | String (date- | Date when the SSH key expires |
keyRequired | String | Public key value of the SSH key |
titleRequired | String | Title of the SSH key |
usage_ | String | Usage scope for the key Allowed values: auth_,auth,signingDefault: auth_ |
Responses
| Code | Description | Schema |
|---|---|---|
201 | Created | APIEntities |
400 | Bad Request | — |
404 | Not Found | — |
Schemas
Objects returned by the operations above and objects nested in their request bodies.
APIEntitiesCustomAttribute
| Property | Type | Description |
|---|---|---|
key | String | Example:foo |
value | String | Example:bar |
APIEntitiesGpgKey
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Example:2017- |
id | Integer (int64) | Example:1 |
key | String | Example:- |
APIEntitiesIdentity
| Property | Type | Description |
|---|---|---|
extern_ | String | ID of the user at the identity provider |
provider | String | Name of the identity provider,google_ or group_ |
APIEntitiesSSHKey
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Creation date and time of the key in ISO 8601 format Example: 2015- |
expires_ | String (date- | Expiration date and time of the key in ISO 8601 format Example: 2020- |
id | Integer (int64) | ID of the key Example: 1 |
key | String | Content of the key Example: ssh- |
last_ | String (date- | Last usage date and time of the key in ISO 8601 format Example: 2020- |
title | String | Title of the key Example: Sample key 25 |
usage_ | String | Usage type of the key:auth,signing,auth_.auth_Example: auth |
APIEntitiesSSHKeyWithUser
| Property | Type | Description |
|---|---|---|
created_ | String (date- | Creation date and time of the key in ISO 8601 format Example: 2015- |
expires_ | String (date- | Expiration date and time of the key in ISO 8601 format Example: 2020- |
id | Integer (int64) | ID of the key Example: 1 |
key | String | Content of the key Example: ssh- |
last_ | String (date- | Last usage date and time of the key in ISO 8601 format Example: 2020- |
title | String | Title of the key Example: Sample key 25 |
usage_ | String | Usage type of the key:auth,signing,auth_.auth_Example: auth |
user | APIEntities | User associated with the key |
APIEntitiesUserPublic
| Property | Type | Description |
|---|---|---|
avatar_ | String | Example:/ |
avatar_ | String | URL of the user’s avatar Example: https: |
bio | String | Biography of the user |
bot | Boolean | — |
can_ | Boolean | If true,Example: true |
can_ | Boolean | If true,Example: true |
color_ | Integer | Color scheme ID of the user Example: 1 |
commit_ | String | — |
confirmed_ | String (date- | Confirmation date and time of the user in ISO 8601 format Example: 2015- |
created_ | String (date- | Creation date and time of the user account in ISO 8601 format |
current_ | String (date- | Current sign- Example: 2015- |
custom_ | Array of APIEntities | — |
discord | String | Discord user ID of the user |
email | String | Email address of the user Example: john@example. |
external | Boolean | If true, |
followers | String | — |
following | String | — |
github | String | Git |
id | Integer (int64) | ID of the user Example: 1 |
identities | Array of APIEntities | Identities associated with the user.group_ provider also has saml_ |
is_ | String | — |
job_ | String | Job title of the user |
last_ | String (date- | Last activity date of the user Example: 2015- |
last_ | String (date- | Last sign- Example: 2015- |
linkedin | String | Linked |
local_ | String | — |
location | String | Location of the user |
locked | Boolean | If true, |
name | String | Name of the user.**** if the current user cannot read the bot’s project or groupExample: Administrator |
organization | String | Organization of the user |
preferred_ | String | Example:en |
private_ | Boolean | If true,Example: false |
projects_ | Integer | Project limit of the user Example: 10 |
pronouns | String | Pronouns of the user |
public_ | String | Public email address of the user Example: john@example. |
state | String | State of the user account.active,blocked,ldap_,blocked_,banned,deactivatedExample: active |
theme_ | Integer | Theme ID of the user Example: 2 |
twitter | String | Twitter username of the user |
two_ | Boolean | If true,Example: true |
username | String | Username of the user Example: admin |
web_ | String | URL of the user’s profile Example: https: |
website_ | String | Website of the user |
work_ | String | — |