CreateSSHKey - Create an SSH Key

Updated at:

Create an SSH key using OpenAPI.

Applicable editions

Central edition, Region edition

Endpoint and authorization information

  • Get the endpoint: Replace {domain} in the API request syntax.
  • Obtain a personal access token.
  • Obtain organizationId: Required only for the Central edition. Go to the Basic Information page in the Organization Management console to retrieve your organization ID.

Product

Resource

Required permission

Code Management

SSH keys

Read and write

Request syntax

Central edition

POST https://{domain}/oapi/v1/codeup/organizations/{organizationId}/keys

Region edition

POST https://{domain}/oapi/v1/codeup/keys

Request headers

Parameter

Type

Required

Description

Example value

x-yunxiao-token

string

Yes

Personal access token.

pt-0fh3****0fbG_35af****0484

Request parameters

Parameter

Type

Location

Required

Description

Example value

organizationId

string

path

  • Yes: Central edition

  • No: Region edition

Organization ID.

60d54f3daccf2bbd6659f3ad

-

object

body

No

expireTime

string

body

No

Time-to-live (TTL).

2024-10-05T15:30:45Z

key

string

body

Yes

SSH public key string.

xxx

keyScope

string

body

Yes

Access scope. ALL: full access including clone, pull, and push. READ: read-only access for clone and pull only.

ALL

title

string

body

Yes

SSH key title.

SSH Title

Request examples

Central edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/keys' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "expireTime": "2024-10-05T15:30:45Z",
        "key": "xxx",
        "keyScope": "ALL",
        "title": "SSH Title"
    }'

Region edition

curl -X 'POST' \
  'https://{domain}/oapi/v1/codeup/keys' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
  --data '
    {
        "expireTime": "2024-10-05T15:30:45Z",
        "key": "xxx",
        "keyScope": "ALL",
        "title": "SSH Title"
    }'

Response parameters

Parameter

Type

Description

Example value

-

object

createdAt

string

Creation time.

2024-10-05T15:30:45Z

expireTime

string

Time-to-live (TTL).

2024-10-05T15:30:45Z

fingerPrint

string

Device fingerprint.

xxx

id

integer

Primary key ID of the SSH key.

1

key

string

SSH public key string.

xxx

keyScope

string

Access scope. ALL: full access including clone, pull, and push. READ: read-only access for clone and pull only.

ALL

lastUsedTime

string

Last used time.

2024-10-05T15:30:45Z

title

string

SSH key title.

username@example

updatedAt

string

Update time.

2024-10-05T15:30:45Z

Response example

{
    "createdAt": "2024-10-05T15:30:45Z",
    "expireTime": "2024-10-05T15:30:45Z",
    "fingerPrint": "xxx",
    "id": 1,
    "key": "xxx",
    "keyScope": "ALL",
    "lastUsedTime": "2024-10-05T15:30:45Z",
    "title": "username@example",
    "updatedAt": "2024-10-05T15:30:45Z"
}

Error codes

For API error codes, see Error Code Center.