Create an SSH key

Create an SSH key in this zone. We copy it to every other zone in the background, shortly after the response. With server_ids, we also add the key to those servers that are running, in every zone.

POST https://{availability_zone}.betterstackcloud.com/v1/ssh-keys
Authorization string required

Bearer $TOKEN

Content-Type string

application/json

slug string required

The key's name, unique in its team. The name is up to 255 characters long and starts and ends with a letter or digit. Dots, hyphens and underscores are allowed in between. A deleted key's slug stays taken until the key is removed from every zone.

public_key string required

Exactly one OpenSSH public key. Never send a private key. The CLI can read it from a file or from standard input, or import it from GitHub. The public key can't be changed after the key is created.

team_id string required

The ID of the team that owns the key. betterstack team list shows it.

server_ids array of strings

The IDs of the servers to add the new key to, at most 100, in any zone. Only running servers get the key, and the key is created even when a server can't get it. Order doesn't matter.

metadata object

Your tags, as an object of string keys and values, at most 10. An update replaces every tag, so an empty object removes all tags. Accepts any keys.

201 Created
{
  "servers": {
    "queued": [
      "example"
    ],
    "skipped": [
      {
        "server_id": "123456789",
        "reason": "kubernetes_managed"
      }
    ],
    "forwarded": [
      "example"
    ]
  }
}

Returns the newly created SSH key.

servers object

What we did with each server in server_ids, returned only when you sent it. Each server's events show whether adding the key worked.

servers.queued array of strings

The IDs of the servers of this zone we're adding the key to.

servers.skipped array of objects

The servers of this zone that can't get the key now, each with a reason.

servers.skipped[].server_id string

The ID of the skipped server.

servers.skipped[].reason string

Why we skipped the server.
Valid values:
kubernetes_managed: The server is a Kubernetes worker node.
locked: The server is locked.
server_not_running: The server isn't running.

servers.forwarded array of strings

The IDs of the servers in other zones. The key is added to each of them once it has been copied to the server's zone.