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.
Bearer $TOKEN
application/json
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.
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.
The ID of the team that owns the key. betterstack team list shows it.
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.
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.
{
"servers": {
"queued": [
"example"
],
"skipped": [
{
"server_id": "123456789",
"reason": "kubernetes_managed"
}
],
"forwarded": [
"example"
]
}
}
{
"error": {
"message": "Malformed JSON body.",
"code": "bad_request"
}
}
{
"error": {
"message": "Missing or invalid token.",
"code": "unauthorized"
}
}
{
"error": {
"message": "We require at least one successful credit card transaction before allowing billable actions via the API. This significantly helps us to prevent fraud. Once your first transaction is processed, you will be able to use the API unrestricted. Please add credit to your account at https://betterstack.com/settings/billing/card/new?credits=10&activate_api=true. Need help? We're here for you at hello@betterstack.com.",
"code": "payment_required"
}
}
{
"error": {
"message": "The request could not be completed right now. Please try again in a few moments.",
"code": "internal_error"
}
}
Returns the newly created SSH key.
The body isn't valid JSON.
The API token is missing or invalid.
The organization hasn't made its first payment yet, and the request creates a resource we charge for. The code is payment_required. A request that creates a server, load balancer, object cache, database, reserved IP or volume can also return first_purchase. The url in first_purchase opens a page where you make the payment. The resource is created after the payment. The page works until expires_at, 24 hours after the response.
The organization has as many SSH keys as its quota allows. The code is quota_exceeded.
The team in team_id doesn't exist, or your token can't access it. The code is not_found.
The resource's state doesn't allow the request, such as starting a running server or removing a placement group that still has servers.
The slug is taken in the team, public_key isn't a valid OpenSSH key, or server_ids isn't a list of at most 100 server IDs. The code is validation_failed.
We've locked the resource, with the code locked. Every change to a locked resource is refused, and so is a change that involves one.
A create with servers in server_ids counts toward the limit that attach and detach share, 30 requests per organization per minute. The code is rate_limited.
An unexpected, temporary error on our side, with the code internal_error. Try again.
The zone has no capacity, with the code no_capacity. Or we couldn't set up or change the resource, with the code orchestration_failed. Or the organization is creating too many resources at the same time, with the code concurrent_create_limit. Try again after a short wait.
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.
The IDs of the servers of this zone we're adding the key to.
The servers of this zone that can't get the key now, each with a reason.
The ID of the skipped server.
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.
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.