Cloud.Server
A Better Stack Cloud server: a virtual machine running Ubuntu, with NVMe
storage, public IPv4 and IPv6, private networks and a firewall, billed
hourly up to a monthly cap. It is both a compute primitive and the host
Cloud.Service and Cloud.Website.* deploy code onto.
Sizes and images. serverType is a type name such as AM1 (the
smallest) or AM4; image is an image slug such as ubuntu-26-04. List
them with the Cloud lookups (listServerType / listImage in the SDK,
betterstack server-type list / betterstack image list in the CLI).
Billing. term defaults to monthly. annual commits you to a full
year of the server (about two months cheaper); leave it out unless you
mean that.
What replaces, what changes in place. image, userData,
bootstrap, publicIpv4, placementGroupId, ddosProtection,
observability, aiEngineerAccess, teamId and availabilityZone
replace the server (a new server is created, dependents move to it, the
old one is deleted; with an explicit name or shared reservedIpIds the
old one is deleted first). Everything else changes in place: name,
metadata, subdomain, term and vulnerabilityMonitoring through an
update; serverType through a rescale (the server reboots, and the deploy
waits until it runs again with the new type); networkIds,
firewallIds and sshKeys through attach/detach actions; reserved IPs
ADDED to reservedIpIds after the create through assign/unassign. The
reserved IPs a server is created with are its boot addresses: the API
won’t unassign them, so removing one replaces the server. A list prop left
out is not managed: only items it listed before are ever detached. A prop
that points at a resource created or replaced in the same deploy (a new
PlacementGroup’s id, say) is not known at plan time: when it is a
replacing prop, the plan replaces the server.
Networking. The attributes carry ipv4, ipv6, privateIps (one
address per attached network) and ipAddresses. Give a server a fixed
address in a network with Cloud.ServerPrivateIp, block storage with
Cloud.Volume, a stable public address with reservedIpIds.
The deploy key, and SSH. For every server it creates, Alchemy
generates an ed25519 key pair, registers the public half as a team SSH key
(slug <stack>-<id>-<stage>-…-deploy-<hex>, in deployKeySlug) installed on
the server at first boot, and keeps the private half Redacted in the
server’s state (privateKey). A deploy returns only once the server is
running and an SSH login as root with that key has succeeded, so
the next resource can SSH in at once. Open a session with Cloud.Ssh, or
by hand: ssh -i <privateKey file> root@<sshHost>. Deleting the server
detaches every key from it and then deletes the deploy key.
SSH host keys. Every connection checks the server’s host key — never
StrictHostKeyChecking=no. For a server it creates with its own bootstrap
(no userData), Alchemy generates the ed25519 host key pair locally and
the bootstrap installs it as /etc/ssh/ssh_host_ed25519_key before
anything else; hostPublicKey holds the public half (hostKeyTrust: "pinned"), so even the very first login (the deploy’s readiness check)
only succeeds against that key — until the bootstrap has swapped the
key, logins are refused and retried. The private half travels in the
server’s user_data only (never in state); anyone who can read the
server’s user data (root on it, Better Stack) could impersonate the host.
A server with your own userData can’t be given the key (the Cloud API
takes one first-boot document), nor can one Alchemy recovers or adopts:
those are trust-on-first-use — the key shown at the first login is
recorded (hostKeyTrust: "first-use") and required from then on. With
bootstrap: false (and for looked-up servers) no key is known: each
Cloud.Ssh session trusts the key it is shown and logs a warning. A
mismatch fails with SshError reason: "host-key-mismatch" and sends
nothing.
Waits are bounded: 15 minutes for a create, 30 for a rescale, 5 for an
attachment and for SSH, 10 for a delete; each fails with a typed
WaitTimeout (or WaitFailed when the server reaches stopped,
destroyed, terminating or terminated). A create whose server fails
deletes it again; one that times out leaves it, and the next deploy finds
it by name and carries on.
Ownership. Every object the stack creates carries an alchemy entry in its
metadata (<stack>/<stage>/<resource id>#<instance>), added on every write and left
out of the attributes and of diffs; your own keys are untouched (it takes one of the
10 slots). A deploy that lost track of an object it created (a create that failed
or timed out after the API accepted it) finds it by that marker and converges it
instead of creating another; list (and so alchemy nuke) returns only
Alchemy-created objects; an object with the same name but no marker of this
resource is taken over only with --adopt.
PaymentRequired on the first create. The first billable create of an
account can be refused with a typed PaymentRequired (HTTP 402
payment_required) whose message carries a payment link. Paying through
that link creates the object FROM THE REFUSED REQUEST, later and outside
the deploy (observed live 2026-12-01 for a server: our name, ownership
marker, type and ssh_keys). Deploy again after paying: the deploy finds
the object by its ownership marker and converges it instead of creating a
second one (proven offline; a recovered server’s host key is then
trust-on-first-use and its deploy key is replaced).
Verified live (one AM1 in us-west-2a, 2026-12-01): AM1 +
ubuntu-26-04 boot to running; deploy-key login as root; Node.js 26
from NodeSource through the bootstrap; rename and metadata in place (the
ownership marker survives); network attach/detach and firewall
detach/attach in place; a private IP configured on the interface; delete
removes the server and its deploy key. NOT live-verified: rescale,
replacement, reserved IPs, server pools, bootstrap: false, your own
userData, and the host-key pinning described above (added after that
run; proven offline and against a fake ssh only).
Creating a server
Section titled “Creating a server”The smallest server
const server = yield* BetterStack.Cloud.Server("web", { serverType: "AM1", image: "ubuntu-26-04",});Named, with your own key, tags and a monthly term
const key = yield* BetterStack.Cloud.SshKey("laptop", { publicKey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEF0uIiLF54lpavoiG7O95cChLJ80vbi0Nh08Kf3+G/a me@example.com",});const server = yield* BetterStack.Cloud.Server("api", { name: "api-1", serverType: "AM1", image: "ubuntu-26-04", term: "monthly", sshKeys: [key.slug], metadata: { role: "api" },});Networking
Section titled “Networking”A private network and a firewall
const network = yield* BetterStack.Cloud.Network("private", { ipPrefix: "10.0.0.0", ipPrefixLength: 24,});const firewall = yield* BetterStack.Cloud.Firewall("public", {});const server = yield* BetterStack.Cloud.Server("web", { serverType: "AM1", image: "ubuntu-26-04", networkIds: [network.id], firewallIds: [firewall.id],});First boot
Section titled “First boot”A cloud-config document
const server = yield* BetterStack.Cloud.Server("web", { serverType: "AM1", image: "ubuntu-26-04", userData: `#cloud-configpackages: - nginx`,});Run a command with the deploy key
const ssh = yield* BetterStack.Cloud.Ssh(server);const { stdout } = yield* ssh.exec("uname -a");Looking up an existing server
Section titled “Looking up an existing server”A looked-up server has no privateKey: Alchemy holds deploy keys only
for servers it created.
Reference a server by name
const existing = BetterStack.Cloud.Server.lookup({ name: "web-1" });image string required
The slug of the server's image, such as ubuntu-26-04, or null when the image was removed after the server was created. List the images with betterstack image list.
serverType string required
The name of the server type, such as AM4, which sets the server's size. List the types with betterstack server-type list.
aiEngineerAccess boolean
Whether the Better Stack AI Engineer can SSH into the server. Can't be changed after the server is created.
availabilityZone string
Availability zone the resource lives in, such as us-west-2a. Defaults to the credentials' zone (BETTERSTACK_AVAILABILITY_ZONE, or the profile's). Changing it replaces the resource. A child of a resource in another zone (a firewall rule, a node pool, a snapshot of an instance outside the credentials' zone) must repeat the parent's availabilityZone: it receives only the parent's id, so its zone cannot be derived.
bootstrap boolean
Whether Alchemy manages a deploy key for the server and proves it answers SSH before the deploy continues. false makes a plain server: no deploy key, no bootstrap script, no SSH check, and so no Cloud.Ssh / Cloud.Service without your own key. Changing it replaces the server. Default: true.
ddosProtection boolean
Whether DDoS protection is on. Can't be changed after the server is created.
firewallIds string[]
The ID of the firewall attached to the server, at most one. Must belong to the server's team.
metadata CreateServerRequestMetadataMap
Your own tags, as string keys and values, at most 10. An update replaces all tags, so an empty object removes every tag.
name string
The server's name, unique among the organization's servers that aren't destroyed or terminated. Defaults to a unique lowercase name generated from the stack, stage and logical id. Changes in place (a rename); a replacement that keeps an explicit name deletes the old server first.
networkIds string[]
The IDs of the private networks attached to the server.
observability boolean
Whether we installed the Better Stack collector when the server was created. Can't be changed after the server is created.
placementGroupId string
The ID of the placement group the server is in. Can't be changed after the server is created.
publicIpv4 boolean
Whether the server gets a public IPv4 address. A server without a public IPv4 address has only IPv6 and can't have a reserved IPv4 address. Can't be changed after the server is created.
reservedIpIds string[]
The IDs of the reserved IPs to attach at boot, instead of new addresses. Each reserved address must belong to the server's team and not be assigned. An address attached at boot stays until the server is destroyed. ip_addresses lists the addresses, not these IDs.
sshKeys string[]
Slugs of your own Cloud.SshKeys to authorize for root. Optional: the server always gets Alchemy's deploy key as well (unless bootstrap is false). Changes in place through attach/detach actions; only keys this prop listed before are detached, so keys attached elsewhere (an SshKey's serverIds) are left alone.
subdomain boolean
Whether the server has a generic subdomain, a free name in onbetterstack.com. The subdomain's records are in cloudflare_records. An update adds or removes the subdomain.
teamId string
Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.
term "monthly" | "annual"
The billing term: monthly (the default) or annual. annual commits you to paying for a whole year. The server's public IPs and add-ons are billed on the same term. Changes in place.
userData string | Redacted<string>
A cloud-init #cloud-config document or a script starting with #!, run on the first boot, at most 32 KiB. The API never returns it. Without it, Alchemy sends its own bootstrap script (it preinstalls Node.js for Cloud.Service); with it, your document is sent unchanged instead (the Cloud API takes one document, not a multipart one) and Cloud.Service installs Node.js over SSH when it is missing. Cloud-init runs once, so changing it replaces the server.
vulnerabilityMonitoring boolean
Whether we scan the server daily for open ports and vulnerable versions. Get the latest findings with betterstack server security-scan.
Attributes
Section titled “Attributes”availabilityZone string always set
Availability zone the resource lives in, such as us-west-2a.
firewallIds string[] always set
IDs of the firewalls attached to the server (at most one).
id string always set
The server's ID.
ipv4 string always set
The first public IPv4 address, or undefined for a server without one (publicIpv4: false).
ipv6 string always set
The first public IPv6 address, or undefined.
name string always set
The server's name.
networkIds string[] always set
IDs of the private networks the server is attached to.
serverId string always set
Same as id: lets props that take a serverId accept the server's attributes.
serverType string always set
The server type, such as AM1.
sshHost string always set
The address to SSH to: ipv4, else ipv6.
sshKeys string[] always set
Slugs of every SSH key on the server, the deploy key included.
sshUser string always set
The user to SSH as: always root on Better Stack Cloud.
status string always set
The server's power and lifecycle status; running after every successful deploy.
aiEngineerAccess boolean
Whether the Better Stack AI Engineer can SSH into the server. Can't be changed after the server is created.
bootReservedIpIds string[]
The reserved IPs the server was created with: its boot addresses. The API refuses to unassign them (IpIsPrimary), so removing one from reservedIpIds replaces the server.
claimedAt string | null
When a claim handed the server over from its pool, or null for a warm server that's still in its pool and for a server you created directly.
cloudflareRecords ServerCloudflareRecordsItem[]
The Cloudflare DNS records that point to the server. The list holds the A and AAAA records requested on create, and the CNAME, A and AAAA records of the generic subdomain in onbetterstack.com.
connectionTracking ServerConnectionTracking
How many connections the server has, and the most it can have. When the server goes over its budget, new connections are dropped.
createdAt string
When the server was created. For a server claimed from a server pool by another team, the time of the claim.
ddosProtection boolean
Whether DDoS protection is on. Can't be changed after the server is created.
deployKeySlug string
Slug of the deploy key's SshKey (not a stack resource: the server creates and deletes it).
deployPublicKey string
The deploy key's public half (ssh-ed25519 …).
diskSizeGb number
The size of the root disk, in GiB. After a rescale that kept the disk size, the root disk size can differ from the type's storage_gb. Disks never shrink, so a later rescale needs a type with at least this much storage.
hostKeyTrust "pinned" | "first-use"
How hostPublicKey is known. pinned: Alchemy generated the host key pair and installed it through the first-boot bootstrap, so even the first connection was verified. first-use: learned from the server on the first login (a server with your own userData, or one Alchemy took back or adopted), then required on every later connection. undefined: none known (bootstrap: false, looked-up servers): each session trusts the key it is shown.
hostPublicKey string
The server's SSH host key (ssh-ed25519 <base64>), required by every connection Cloud.Ssh / Cloud.Service make (StrictHostKeyChecking=yes against a per-session known_hosts). See "SSH host keys" above for how it was obtained: hostKeyTrust.
image string | null
The slug of the server's image, such as ubuntu-26-04, or null when the image was removed after the server was created. List the images with betterstack image list.
ipAddresses ServerIpAddressesItem[]
The server's public addresses. betterstack server-public-ip list also shows the network interface of each.
lock ServerLock | null
Our lock on the server, or null. A locked server keeps running, but its network is cut and you can't change it.
metadata ServerMetadataMap
Your own tags, as string keys and values, at most 10. An update replaces all tags, so an empty object removes every tag.
nestedVirtualization boolean
Whether the server can run its own virtual machines. Always false for a server you create.
observability boolean
Whether we installed the Better Stack collector when the server was created. Can't be changed after the server is created.
placementGroupId string | null
The ID of the placement group the server is in. Can't be changed after the server is created.
poolId string | null
The ID of the server pool that booted the server, or null for a server you created directly.
privateIps ServerPrivateIpsItem[]
The server's addresses in private networks.
privateKey Redacted<string>
The Alchemy-managed deploy key's private half (OpenSSH format), kept in state. Cloud.Ssh and Cloud.Service log in with it. undefined for bootstrap: false and for looked-up or adopted servers Alchemy did not create (until a deploy installs a new deploy key).
publicIpv4 boolean
Whether the server was created with a public IPv4 address (the API never returns it).
rescueState string | null
Whether the rescue system is ready, or null when the server isn't in rescue mode. After you start rescue mode, get the server again until it's active or null. - activating: The server is booting the rescue system. You can sign in when it's up. - active: The rescue system is up, and you can sign in.
reservedIpIds string[]
The reserved IPs this stack assigned (the API never returns them).
staleDeployKeySlugs string[]
Deploy keys of earlier servers of this resource that were deleted out of band, which the API still refused to delete (a destroyed server's record holds its keys for a while). Every later deploy retries them, and destroy fails until they are gone, so none is left behind.
subdomain boolean
Whether the server has a generic subdomain, a free name in onbetterstack.com. The subdomain's records are in cloudflare_records. An update adds or removes the subdomain.
teamId string
The ID of the team that owns the server. betterstack team list shows it.
term "monthly" | "annual"
The billing term. Defaults to monthly. The server's public IPs and add-ons are billed on the same term. A change applies at once, from monthly to annual or back. Sending the current term changes nothing. - monthly: Billed each month. - annual: Paid for a year.
updatedAt string
When the server was last updated.
vulnerabilityMonitoring boolean
Whether we scan the server daily for open ports and vulnerable versions. Get the latest findings with betterstack server security-scan.
Lookup
Section titled “Lookup”Server.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.
availabilityZone string
Zone it lives in, such as us-west-2a. Defaults to the credentials' zone.
id string
The server's ID.
name string
The server's name (unique among live servers).