Help Center/ CodeArts Repo/ API Reference/ Historical APIs/ SSH Key/ Adding an SSH Key (Deprecated)
Updated on 2026-01-27 GMT+08:00

Adding an SSH Key (Deprecated)

Function

This API is used to configure an SSH key in CodeArts Repo to establish a secure connection between a local computer and a repository under your account.

This API has been discarded. Use the API described in Adding an SSH Public Key.

URI

POST /v1/users/sshkey

Request Parameters

Table 1 Request header parameter

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Explanation

User token. It can be obtained by calling the corresponding IAM API. The value of X-Subject-Token in the response header is the user token.

Constraints

Mandatory

Range

1–100,000 characters.

Default value

None.

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

key

Yes

String

Explanation

A locally generated SSH key.

Constraints

None.

Range

Max. 2,048 digits and letters.

Default value

None.

title

Yes

String

Explanation

A custom title set when the SSH key is added.

Range

Max. 255 characters.

Response Parameters

Table 3 Response body parameters

Parameter

Type

Description

error

Error object

Explanation

Response error.

Range

None.

result

PublicKey object

Explanation

Response result.

Range

None.

status

String

Explanation

Response status of the API.

Range

  • success: The API call is successful.
  • failed: The API call failed.
Table 4 Error

Parameter

Type

Description

code

String

Explanation

Error code returned when the API fails to be called.

Range

  • 40: Failed to add the key. Check whether the key is valid.
  • CH.080002: The key already exists. Generate a new one.

message

String

Explanation

Error message returned when the API fails to be called.

Range

  • Failed to add the key. Check whether the key is valid.
  • The key already exists. Generate a new one.
Table 5 PublicKey

Parameter

Type

Description

id

String

Explanation

Key ID.

Range

1–40 digits.

key

String

Explanation

Key, which is uploaded by a user.

Range

Max. 2,048 digits.

title

String

Explanation

A custom title set when the SSH key is added.

Range

Max. 255 characters.

Example Requests

POST https://{endpoint}/v1/users/sshkey

{
  "title" : "repo@xxx.com",
  "key" : "ssh-rsa AAAAB3NzaC1yc2EA*********************************************************U7xcma6HU8nj1E0i46VObWyOONl3gh142BV repo@xxx.com"
}

Example Responses

Status code: 200

OK

{
  "result" : {
    "id" : "1034531",
    "title" : "repo@xxx.com",
    "key" : "ssh-rsa AAAAB3NzaC1yc2EA*********************************************************U7xcma6HU8nj1E0i46VObWyOONl3gh142BV repo@xxx.com"
  },
  "status" : "success"
}

Status Code

Status Code

Description

200

OK

Error Codes

Table 6 Error codes

Status Code

Error Code

Error Message

Description

Measure

409

CH.080002

The key already exists. Generate a new one.

The key has been configured in CodeArts Repo. Generate a new one locally.

Re-generate a key locally and configure it in CodeArts Repo.

200

CH.010202

Failed to add the key. Check whether the key is valid.

The key cannot be added in CodeArts Repo. The key or title is invalid.

  • If the key is incomplete, copy it again.
  • If the title is invalid, enter a new one.

400

CH.080002

title cannot be left blank

Title is required.

Specify a title.

400

CH.080002

key is empty

SSH key is required.

Specify an SSH key.