Create a server

Create a server, a virtual machine in this zone.

POST https://{availability_zone}.betterstackcloud.com/v1/servers
Authorization string required

Bearer $TOKEN

Content-Type string

application/json

team_id string required

The ID of the team that owns the server. Get the team ID via List teams.

name string required

The server's name. Must be unique among your organization's servers that aren't destroyed or terminated.

server_type string required

The name of the server type, such as AM4. Get the types via List server types.

image string required

The slug of an available image, such as ubuntu-26-04. Get the images via List images. Can't be changed after the server is created.

network_ids array of strings

The IDs of private networks to attach. Each network must belong to the server's team. To change them later, use Attach a network or Detach a network.

firewall_ids array of strings

The firewall to attach, as a list with at most one ID. The firewall must belong to the server's team. To change it later, use Attach a firewall or Detach a firewall.

placement_group_id string or null

The ID of a placement group to add the server to. The placement group must belong to the server's team. Can't be changed after the server is created.

ssh_keys array of strings

The slug of each SSH key to add. Get the keys via List SSH keys, or add one via Create an SSH key. Each key must belong to the server's team. Send at least one key, unless root_password is true.

metadata object

Your own tags, as string keys and values. At most 10. Accepts any keys.

ddos_protection boolean default: false

Whether to turn on DDoS protection. Can't be changed after the server is created.

ai_engineer_access boolean default: true

Whether the Better Stack AI Engineer can sign in to the server over SSH. Can't be changed after the server is created.

vulnerability_monitoring boolean default: false

Whether to scan the server daily for open ports and vulnerable software versions.

observability boolean default: false

Whether to install the Better Stack collector. Can't be changed after the server is created.

reserved_ip_ids array of strings

The IDs of reserved IPs the server boots with, instead of new addresses. Each one must belong to the server's team and not be assigned to a server.

public_ipv4 boolean default: true

Whether to give the server a new public IPv4 address. A reserved IPv4 address in reserved_ip_ids replaces it. Send false for a server with only IPv6. A server with only IPv6 can't boot with a reserved IPv4 address and can't have cloudflare_records.

cloudflare_records array of objects

Cloudflare DNS records to point to the new server. Each entry adds an A and an AAAA record.

cloudflare_records[].cloudflare_account_id string required

The ID of the Cloudflare account that holds the zone. Connect the account to your team first, under Integrations → Cloudflare in the web app.

cloudflare_records[].cloudflare_domain string required

The Cloudflare zone to add the records to, such as example.com.

cloudflare_records[].cloudflare_a_record string required

The name of the A and AAAA records, such as www.

cloudflare_records[].cloudflare_proxied boolean default: false

Whether Cloudflare proxies traffic to the server.

cloudflare_records[].cloudflare_a_record_ttl integer

The records' TTL in seconds, from 60 to 86400, or 1 for automatic. A proxied record must use 1. Defaults to 1.

root_password boolean default: false

Whether to return a one-time root password. The password is returned only in this response, and we don't store it.

subdomain boolean default: true

Whether to give the server a free subdomain, <server-name>.onbetterstack.com.

user_data string

A cloud-init document or a script that runs once, at the first boot, at most 32 KiB of UTF-8. A cloud-init document starts with #cloud-config. A script starts with #! and runs as root. No response returns it, but root can read it on the server, so don't put a long-lived credential in it.

term string default: monthly

The billing term. Defaults to monthly.
Valid values:
monthly: Billed each month.
annual: Paid for a year at a time.

202

Returns the newly created server.

202 Accepted
{
  "root_password": "example"
}
400

The body isn't valid JSON.

400 Bad Request
{
  "error": {
    "message": "Malformed JSON body.",
    "code": "bad_request"
  }
}
401

The API token is missing or invalid.

401 Unauthorized
{
  "error": {
    "message": "Missing or invalid token.",
    "code": "unauthorized"
  }
}
402

Your organization hasn't made its first payment yet, with the code payment_required. The error can also have first_purchase, with the url of a page where you make the payment. Paying creates the server. The page works until expires_at, 24 hours after the response.

403

Your organization has reached one of its limits, such as its number of servers, with the code quota_exceeded. Or the organization is restricted because of fraud, with the code organization_restricted. Or the request sets a parameter the token can't set, with the code forbidden.

404

We couldn't find the team, server type, image, SSH key, network, firewall, placement group or one of the reserved_ip_ids in the request. Or the Cloudflare account in a cloudflare_account_id isn't connected to your team.

409

The zone has no capacity, with the code no_capacity.

422

A value is missing or invalid, such as a user_data that breaks a rule or a term other than monthly or annual, with the code validation_failed. The error's details names each field. A Cloudflare account that you must connect again returns validation_failed. A cloudflare_domain that isn't a zone of the account in cloudflare_account_id returns validation_failed too. A deprecated server_type returns the code type_deprecated, and details.replacement names the type to send instead.

423

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.

429

Too many requests, with the code rate_limited. We limit requests per client IP and per organization, and some costly endpoints have a stricter limit. Wait as long as the Retry-After header says.

500

An unexpected, temporary error on our side, with the code internal_error. Try again.

500 Internal Server Error
{
  "error": {
    "message": "The request could not be completed right now. Please try again in a few moments.",
    "code": "internal_error"
  }
}
503

We couldn't set up the server, with the code orchestration_failed. Or the organization is creating too many servers at the same time, with the code concurrent_create_limit. Try again shortly.

root_password string

The one-time root password, returned only when you send root_password as true.