# Restore a snapshot

Create a new server from the snapshot. The original server stays as it is. The new server gets the original's team, size and attachments. The new server gets new IP addresses unless you send reserved IPs. To restore a snapshot taken in another zone, call this zone and send that zone in `from_availability_zone`.

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

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

[[body_param]]
name = "name"
type = "string"
description = "The new server's name. Defaults to a name made from the snapshot's name."

[[body_param]]
name = "from_availability_zone"
type = "string"
description = "The zone the snapshot was taken in, when it isn't this zone. The new server is created in the zone you call."

[[body_param]]
name = "reserved_ip_ids"
type = "array of strings"
description = "The IDs of reserved IPs to give the new server. Each reserved IP must be unassigned, in the zone you call and in the snapshot's team."

[[body_param]]
name = "public_ipv4"
type = "boolean"
description = "Whether the new server gets a public IPv4 address. Leave it out to use the snapshot's setting. When you leave it out and send a reserved IPv4 address in `reserved_ip_ids`, the new server gets a public IPv4 address."

[[body_param]]
name = "ddos_protection"
type = "boolean"
description = "Whether the new server has DDoS protection. Leave it out to use the snapshot's setting."

[[body_param]]
name = "ai_engineer_access"
type = "boolean"
description = "Whether AI Engineer can sign in to the new server over SSH. Leave it out to use the snapshot's setting. A snapshot without a setting allows it."

[[body_param]]
name = "vulnerability_monitoring"
type = "boolean"
description = "Whether we scan the new server for vulnerabilities every day. Leave it out to use the snapshot's setting."

[[body_param]]
name = "root_password"
type = "boolean"
description = "Whether to set a new root password and return it once. Send `false` or leave it out to keep the passwords from the snapshot."

[[body_param]]
name = "subdomain"
default = "true"
type = "boolean"
description = "Whether the new server gets its own subdomain, made from its name. Defaults to `true`. The original server keeps its subdomain."

[[body_param]]
name = "cloudflare_records"
type = "array of objects"
description = "Cloudflare DNS records to point at the new server. Each entry creates an A record and an AAAA record named `cloudflare_a_record` in the Cloudflare zone `cloudflare_domain`."

[[body_param]]
name = "cloudflare_records[].cloudflare_account_id"
required = true
type = "string"
description = "The ID of the Cloudflare account that holds the zone. Connect the account to your team first, under **Integrations** → **Cloudflare** in the web app."

[[body_param]]
name = "cloudflare_records[].cloudflare_domain"
required = true
type = "string"
description = "The Cloudflare zone to add the records to, such as `example.com`."

[[body_param]]
name = "cloudflare_records[].cloudflare_a_record"
required = true
type = "string"
description = "The record name, such as `www`."

[[body_param]]
name = "cloudflare_records[].cloudflare_proxied"
default = "false"
type = "boolean"
description = "Whether Cloudflare proxies traffic to the server. Defaults to `false`."

[[body_param]]
name = "cloudflare_records[].cloudflare_a_record_ttl"
type = "integer"
description = "The records' TTL in seconds, from `60` to `86400`, or `1` for automatic. A proxied record must use `1`. Defaults to automatic."

[[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 = '''
{
  "root_password": "example"
}
'''

[[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 organization has reached its quota of servers. The error code is `quota_exceeded`."

[[response]]
status = 404
description = "The snapshot isn't in this zone, or the token can't access it. For a snapshot taken in another zone, send that zone in `from_availability_zone`. A `cloudflare_account_id` whose Cloudflare account isn't connected to your team also returns 404."

[[response]]
status = 409
description = "The snapshot can't be restored because it's still being taken or it failed. The error code is `snapshot_not_restorable`."

[[response]]
status = 422
description = "A value is missing or invalid. Or you must connect the Cloudflare account again. Or the `cloudflare_domain` isn't a zone of the account in `cloudflare_account_id`. The error code is `validation_failed`."

[[response]]
status = 423
description = "The snapshot is locked."

[[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 = 502
description = "We couldn't get the snapshot from the zone it was taken in. The error code is `cross_az_unavailable`."

[[response]]
status = 503
description = "We have no room for the new server, and the error code is `no_capacity`. Or we couldn't create it, and the error code is `orchestration_failed`."

[[response]]
status = 504
description = "Getting the snapshot from the zone it was taken in timed out. The error code is `cross_az_timeout`."
[/responses]

[params]
title = "Response attributes"

[[param]]
name = "root_password"
type = "string"
description = "The new server's root password. Returned once, when you send `root_password` set to `true`, so save it then."
[/params]
