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

Adding a Deployment Key (Deprecated)

Function

Add a deployment key.

This API has been discarded. Use the API described in Adding a Deployment Key.

URI

POST /v1/repositories/{repository_id}/deploy_keys

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Repository short ID

Request Parameters

Table 2 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

The user token can be obtained by calling the corresponding IAM API. 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

Deployment key source

can_push

Yes

Boolean

Whether the deployment key can be used to push code

key

Yes

String

Deployment key

key_title

Yes

String

Deployment key name

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

Explanation:

Response status

Range:

  • success: The API call is successful.
  • failed: The API call failed.
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

Creating time of the deployment key

key

String

Deploy key

key_id

String

Deployment key ID

Minimum length: 1

Maximum length: 40

key_title

String

Deployment key name

Request Example

POST https://{endpoint}/v1/repositories/{repository_id}/deploy_keys

{
  "key_title" : "z00464114@SZXG4Z004641141",
  "key" : "ssh-rsa AAAAB3NzaC1yXXXXXXXX",
  "can_push" : true,
  "application" : ""
}

Response Example

Status code: 200

OK

{
  "result" : {
    "key_id" : "1034546",
    "key_title" : "z00464114@SZXG4Z004641141",
    "key" : "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAxxxxxxxxxxxxx"
  },
  "status" : "success"
}

Status Codes

Status Codes

Description

200

OK

Error Codes

See error codes.