Skip to content

Key pair API reference

See https://docs.openstack.org/api-ref/compute/.

In these methods, {keypair_name} is a placeholder that should be replaced with the actual name of the key pair. The API allows you to list existing key pairs, show details of a specific key pair, create a new key pair or import an existing one, and delete a key pair. When creating a new key pair, the response includes the private key (which you should save securely). When importing a key pair, provide the public key in the request body.

List key pairs

Bash
GET /os-keypairs

Show key pair details

Bash
GET /os-keypairs/{keypair_name}

Create or import a key pair

Bash
POST /os-keypairs

Request body (for creating a new key pair)

JSON
{
    "keypair": {
      "name": "keypair_name"
    }
}

Request body (for importing an existing key pair)

JSON
{
    "keypair": {
      "name": "keypair_name",
        "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQ..."
    }
}

Delete a key pair

Bash
DELETE /os-keypairs/{keypair_name}