Help Center> CodeArts Repo> API Reference> APIs> Repository> Adding a Deployment Key
Updated on 2023-09-12 GMT+08:00

Adding a Deployment Key

Function

Adding a Deployment Key

URI

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

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

repository_id

Yes

Integer

Warehouse Primary Key ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token.

It can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

application

Yes

String

Source of the SSH Key Used for Deployment

can_push

Yes

Boolean

Can the SSH Key Used for Deployment Push Code?

key

Yes

String

SSH key used for deployment

key_title

Yes

String

Name of the SSH key used for deployment

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error

Error object

Response error.

result

Key object

Result

status

String

Status code in a response

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

Deployment Key Creation Time

key

String

Deploy Keys

key_id

String

Deployment Key ID

Minimum: 1

Maximum: 40

key_title

String

Deployment Key Name

Example Requests

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

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

Example Responses

Status code: 200

OK

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

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.