# Stop a server

Stop a running server, gracefully unless you cut the power.

[endpoint]
method = "POST"
base_url = "https://{availability_zone}.betterstackcloud.com"
path = "/v1/servers/{id}/stop"

[[path_param]]
name = "id"
required = true
type = "string"
description = "The ID of the server to stop."

[[body_param]]
name = "force"
default = "false"
type = "boolean"
description = "Whether to cut the power instead of shutting the server down gracefully."

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"

[[header]]
name = "Content-Type"
description = "application/json"
required = false
type = "string"
[/endpoint]

[responses]
[[response]]
status = 202
description = "Returns the server."
body = '''
{
  "id": "example",
  "name": "Example server",
  "status": "starting",
  "rescue_state": "activating",
  "server_type": "AM1",
  "term": "monthly",
  "disk_size_gb": 1,
  "image": "ubuntu-26-04",
  "network_ids": [
    "123456789"
  ],
  "firewall_ids": [
    "123456789"
  ],
  "placement_group_id": "123456789",
  "pool_id": "123456789",
  "claimed_at": "2026-07-01T12:00:00.000Z",
  "ssh_keys": [
    "example"
  ],
  "ip_addresses": [
    {
      "id": "example",
      "ip": "example",
      "type": "example",
      "reserved_ip": false,
      "ptr_record": "example"
    }
  ],
  "private_ips": [
    {
      "id": "example",
      "network_id": "123456789",
      "ip": "example"
    }
  ],
  "cloudflare_records": [
    {
      "id": "example",
      "type": "example",
      "domain": "example",
      "a_record": "example",
      "proxied": false,
      "ttl": 1,
      "status": "up"
    }
  ],
  "subdomain": true,
  "ddos_protection": false,
  "ai_engineer_access": true,
  "vulnerability_monitoring": false,
  "observability": false,
  "nested_virtualization": false,
  "connection_tracking": {
    "budget": 1,
    "entries": 1,
    "measured_at": "2026-07-01T12:00:00.000Z",
    "over_budget": false
  },
  "lock": {
    "reason": "fraud",
    "details": "example",
    "locked_at": "2026-07-01T12:00:00.000Z"
  },
  "created_at": "2026-07-01T12:00:00.000Z",
  "updated_at": "2026-07-01T12:00:00.000Z",
  "team_id": "t123",
  "metadata": {
    "example": "value"
  }
}
'''

[[response]]
status = 400
description = "The body isn't valid JSON."
body = '''
{
  "error": {
    "message": "Malformed JSON body.",
    "code": "bad_request"
  }
}
'''

[[response]]
status = 401
description = "The API token is missing or invalid."
body = '''
{
  "error": {
    "message": "Missing or invalid token.",
    "code": "unauthorized"
  }
}
'''

[[response]]
status = 402
description = "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."
body = '''
{
  "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"
  }
}
'''

[[response]]
status = 403
description = "The request would go over a quota, with the code `quota_exceeded`. Or a read-only token tried to make a change, with the code `read_only_token`. Or a rule of the resource forbids it."
body = '''
{
  "error": {
    "message": "This token is read-only and cannot be used for write operations.",
    "code": "read_only_token"
  }
}
'''

[[response]]
status = 404
description = "The resource doesn't exist, it's in another zone, or your token can't access it."
body = '''
{
  "error": {
    "message": "Resource not found.",
    "code": "not_found"
  }
}
'''

[[response]]
status = 409
description = "The server's state doesn't allow a stop, with the code `server_not_stoppable`. Or it's a Kubernetes worker node, with the code `kubernetes_managed`."

[[response]]
status = 422
description = "A value isn't valid, with the code `validation_failed`. The error's `details` list the messages for each field. A create or rescale that names a deprecated type with a replacement returns the code `type_deprecated`. The error's `details` then name the field, the deprecated type and its `replacement`."

[[response]]
status = 423
description = "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."

[[response]]
status = 429
description = "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."

[[response]]
status = 500
description = "An unexpected, temporary error on our side, with the code `internal_error`. Try again."
body = '''
{
  "error": {
    "message": "The request could not be completed right now. Please try again in a few moments.",
    "code": "internal_error"
  }
}
'''

[[response]]
status = 503
description = "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."
[/responses]

[params]
title = "Response attributes"

[[param]]
name = "id"
type = "string"
description = "The server's ID, a UUID."

[[param]]
name = "name"
type = "string"
description = "The server's name, unique among the organization's servers that aren't destroyed or terminated."

[[param]]
name = "status"
type = "string"
description = "The server's power and lifecycle status. While work is in progress, get the server again until the status settles.<br/>Valid values:<br/>`starting`: The server is booting.<br/>`running`: The server is running.<br/>`stopping`: The server is shutting down.<br/>`stopped`: The server is stopped.<br/>`pooled`: The server is a warm server in a server pool, booted and billed, and no claim has taken it yet.<br/>`snapshotting`: We're creating a snapshot of the server.<br/>`migrating`: We're moving the server to another host.<br/>`rescuing`: The server is in rescue mode.<br/>`restoring`: We're restoring the server from a snapshot.<br/>`rescaling`: We're changing the server's type.<br/>`destroyed`: The server is destroyed.<br/>`terminating`: We're ending a spot server.<br/>`terminated`: We've ended a spot server."

[[param]]
name = "rescue_state"
type = "string or null"
description = "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`.<br/>Valid values:<br/>`activating`: The server is booting the rescue system. You can sign in when it's up.<br/>`active`: The rescue system is up, and you can sign in."

[[param]]
name = "server_type"
type = "string"
description = "The name of the server type, such as `AM4`, which sets the server's size. List the types with `betterstack server-type list`."

[[param]]
name = "term"
type = "string"
description = "The billing term. Defaults to `monthly`. The server's public IPs and add-ons are billed on the same term.<br/>Valid values:<br/>`monthly`: Billed each month.<br/>`annual`: Paid for a year."

[[param]]
name = "disk_size_gb"
type = "integer"
description = "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."

[[param]]
name = "image"
type = "string or null"
description = "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`."

[[param]]
name = "network_ids"
type = "array of strings"
description = "The IDs of the private networks attached to the server. Order doesn't matter."

[[param]]
name = "firewall_ids"
type = "array of strings"
description = "The ID of the firewall attached to the server, at most one. Order doesn't matter."

[[param]]
name = "placement_group_id"
type = "string or null"
description = "The ID of the placement group the server is in."

[[param]]
name = "pool_id"
type = "string or null"
description = "The ID of the server pool that booted the server, or `null` for a server you created directly."

[[param]]
name = "claimed_at"
type = "datetime or null"
description = "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. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "ssh_keys"
type = "array of strings"
description = "The slugs of the server's SSH keys. We install them at the first boot. Order doesn't matter."

[[param]]
name = "ip_addresses"
type = "array of objects"
description = "The server's public addresses. `betterstack server-public-ip list` also shows the network interface of each."

[[param]]
name = "ip_addresses[].id"
type = "string"
description = "The ID of the address on the server."

[[param]]
name = "ip_addresses[].ip"
type = "string"
description = "The address."

[[param]]
name = "ip_addresses[].type"
type = "string"
description = "Whether it's an `ipv4` or `ipv6` address."

[[param]]
name = "ip_addresses[].reserved_ip"
type = "boolean"
description = "Whether it's a reserved IP."

[[param]]
name = "ip_addresses[].ptr_record"
type = "string or null"
description = "The reverse DNS name, or `null`."

[[param]]
name = "private_ips"
type = "array of objects"
description = "The server's addresses in private networks."

[[param]]
name = "private_ips[].id"
type = "string"
description = "The ID of the address on the server."

[[param]]
name = "private_ips[].network_id"
type = "string"
description = "The ID of the network."

[[param]]
name = "private_ips[].ip"
type = "string"
description = "The address in that network."

[[param]]
name = "cloudflare_records"
type = "array of objects"
description = "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`."

[[param]]
name = "cloudflare_records[].id"
type = "string"
description = "The record's ID."

[[param]]
name = "cloudflare_records[].type"
type = "string"
description = "The record type, `A`, `AAAA` or `CNAME`."

[[param]]
name = "cloudflare_records[].domain"
type = "string"
description = "The Cloudflare zone of the record."

[[param]]
name = "cloudflare_records[].a_record"
type = "string"
description = "The record's name."

[[param]]
name = "cloudflare_records[].proxied"
type = "boolean"
description = "Whether Cloudflare proxies the record."

[[param]]
name = "cloudflare_records[].ttl"
type = "integer or null"
description = "The record's TTL in seconds. `1` means automatic."

[[param]]
name = "cloudflare_records[].status"
type = "string"
description = "Whether we've created the record, `pending`, `created` or `failed`."

[[param]]
name = "subdomain"
type = "boolean"
description = "Whether the server has a generic subdomain, a free name in `onbetterstack.com`. The subdomain's records are in `cloudflare_records`."

[[param]]
name = "ddos_protection"
type = "boolean"
description = "Whether DDoS protection is on."

[[param]]
name = "ai_engineer_access"
type = "boolean"
description = "Whether the Better Stack AI Engineer can SSH into the server."

[[param]]
name = "vulnerability_monitoring"
type = "boolean"
description = "Whether we scan the server daily for open ports and vulnerable versions. Get the latest findings with `betterstack server security-scan`."

[[param]]
name = "observability"
type = "boolean"
description = "Whether we installed the Better Stack collector when the server was created."

[[param]]
name = "nested_virtualization"
type = "boolean"
description = "Whether the server can run its own virtual machines. Always `false` for a server you create."

[[param]]
name = "connection_tracking"
type = "object"
description = "How many connections the server has, and the most it can have. When the server goes over its `budget`, new connections are dropped."

[[param]]
name = "connection_tracking.budget"
type = "integer"
description = "The most connections the server can have at once, 60,000 per vCPU of its type."

[[param]]
name = "connection_tracking.entries"
type = "integer or null"
description = "How many connections the server had at the last count, or `null` before the first count."

[[param]]
name = "connection_tracking.measured_at"
type = "datetime or null"
description = "When we last counted the connections. We count once a minute. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "connection_tracking.over_budget"
type = "boolean"
description = "Whether the server has more connections than its `budget`. New connections are dropped until it's back under the budget."

[[param]]
name = "lock"
type = "object or null"
description = "Our lock on the server, or `null`. A locked server keeps running, but its network is cut and you can't change it."

[[param]]
name = "lock.reason"
type = "string"
description = "Why we locked the server. Possible values: `fraud`, `non_payment`, `abuse`, `legal`, `security`, `maintenance`, `other`."

[[param]]
name = "lock.details"
type = "string or null"
description = "More about the lock, or `null`."

[[param]]
name = "lock.locked_at"
type = "datetime"
description = "When we locked the server. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "created_at"
type = "datetime"
description = "When the server was created. For a server claimed from a server pool by another team, the time of the claim. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "updated_at"
type = "datetime"
description = "When the server was last updated. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "team_id"
type = "string"
description = "The ID of the team that owns the server. `betterstack team list` shows it."

[[param]]
name = "metadata"
type = "object"
description = "Your own tags, as string keys and values, at most 10."
[/params]
