Updated on 2026-01-08 GMT+08:00

Adding a Deploy Key

Description

This API is used to add a deploy key.

URI

POST /v2/repositories/{repository_id}/deploy-keys

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Repository primary key ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

application

Yes

String

Source of the SSH key for deployment

can_push

Yes

Boolean

Whether the SSH key for deployment can push code

key

Yes

String

SSH key for deployment

key_title

Yes

String

Name of the SSH key for deployment

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Response error

result

Key object

Response result

status

String

Response status

Table 5 Error

Parameter

Type

Description

code

String

Error codes

message

String

Error message

Table 6 Key

Parameter

Type

Description

can_push

Boolean

Whether to allow push

created_at

String

Creation time of the deploy key

key

String

Deploy key

key_id

String

Deployment key ID

Minimum length: 1

Maximum length: 40

key_title

String

Deploy key name

Request Examples

POST https://{endpoint}/v2/repositories/{repository_id}/deploy-keys

{
  "key_title" : "repo@test.com",
  "key" : "ssh-rsa AAAAB3NzaC1yc2EA*********************************************************U7xcma6HU8nj1E0i46VObWyOONl3gh142BV repo@test.com",
  "can_push" : true,
  "application" : ""
}

Response Examples

Status code: 200

Request succeeded

{
  "result" : {
    "key_id" : "1034546",
    "key_title" : "repo@test.com",
    "key" : "ssh-rsa AAAAB3NzaC1yc2EA*********************************************************U7xcma6HU8nj1E0i46VObWyOONl3gh142BV repo@test.com"
  },
  "status" : "success"
}

Status Codes

Status Codes

Description

200

Request succeeded

Error Codes

See Error Codes.