Skip to content

Create a deploy key

POST
/api/v4/deploy_keys

Creates a deploy key for the GitLab instance. Requires administrator access.

Media type application/json
object
key
required

New deploy key

string
nullable
title
required

New deploy key’s title

string
nullable
expires_at

The expiration date of the SSH key in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ)

string format: date-time
nullable
Example generated
{
"key": "example",
"title": "example",
"expires_at": "2026-04-15T12:00:00Z"
}

Created

Media type application/json
object
id
integer format: int64
title
string
created_at
string format: date-time
expires_at
string format: date-time
last_used_at
string format: date-time
key
string
usage_type
string
fingerprint
string
fingerprint_sha256
string
projects_with_write_access
object
id
integer format: int64
description
string
name
string
name_with_namespace
string
path
string
path_with_namespace
string
created_at
string format: date-time
projects_with_readonly_access
object
id
integer format: int64
description
string
name
string
name_with_namespace
string
path
string
path_with_namespace
string
created_at
string format: date-time
Example
{
"id": 1,
"title": "Sample key 25",
"created_at": "2015-09-03T07:24:44.627Z",
"expires_at": "2020-09-03T07:24:44.627Z",
"last_used_at": "2020-09-03T07:24:44.627Z",
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNJAkI3Wdf0r13c8a5pEExB2YowPWCSVzfZV22pNBc1CuEbyYLHpUyaD0GwpGvFdx2aP7lMEk35k6Rz3ccBF6jRaVJyhsn5VNnW92PMpBJ/P1UebhXwsFHdQf5rTt082cSxWuk61kGWRQtk4ozt/J2DF/dIUVaLvc+z4HomT41fQ==",
"usage_type": "auth",
"fingerprint": "4a:9d:64:15:ed:3a:e6:07:6e:89:36:b3:3b:03:05:d9",
"fingerprint_sha256": "SHA256:Jrs3LD1Ji30xNLtTVf9NDCj7kkBgPBb2pjvTZ3HfIgU",
"projects_with_write_access": {
"id": 1,
"description": "desc",
"name": "project1",
"name_with_namespace": "John Doe / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
},
"projects_with_readonly_access": {
"id": 1,
"description": "desc",
"name": "project1",
"name_with_namespace": "John Doe / project1",
"path": "project1",
"path_with_namespace": "namespace1/project1",
"created_at": "2020-05-07T04:27:17.016Z"
}
}

Bad request

Unauthorized

Forbidden