# Create a ClickHouse instance

Create a ClickHouse instance. A new instance comes with the `admin` user and the `defaultdb` database.

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

[[body_param]]
name = "name"
required = true
type = "string"
description = "The instance's name, up to 255 characters. Must differ from the names of the organization's other ClickHouse instances, except `failed` and `destroyed` ones."

[[body_param]]
name = "type"
required = true
type = "string"
description = "The instance's plan, such as `CH2`. Get the plans via `betterstack clickhouse-type list`. To change it later, rescale the instance."

[[body_param]]
name = "team_id"
required = true
type = "string"
description = "The ID of the team that owns the instance. `betterstack team list` shows it. Can't be changed after the instance is created."

[[body_param]]
name = "engine_version"
type = "string"
description = "The ClickHouse LTS version, such as `26.8`. Get the versions via `betterstack clickhouse-version list`. Defaults to the latest version. To change it later, upgrade the instance."

[[body_param]]
name = "timezone"
default = "UTC"
type = "string"
description = "The default time zone for date and time functions, `UTC` or an IANA name such as `Europe/Prague`. A change applies to connections opened after it."

[[body_param]]
name = "public_access"
default = "false"
type = "boolean"
description = "Whether the instance accepts connections on a public IP. The TLS ports `9440` and `8443` are public. The ports without TLS stay on private networks."

[[body_param]]
name = "network_ids"
type = "array of strings"
description = "The IDs of the private networks attached to the instance. Must be in the instance's team. To change them later, attach or detach a network. Order doesn't matter."

[[body_param]]
name = "firewall_ids"
type = "array of strings"
description = "The IDs of the firewalls attached to the instance, at most one. Order doesn't matter."

[[body_param]]
name = "term"
default = "monthly"
type = "string"
description = "The billing term. A change applies at once, from `monthly` to `annual` or back. Billing ends the current term and starts the new one. Sending the current term changes nothing.<br/>Valid values:<br/>`monthly`: Billed every month.<br/>`annual`: Paid for a year."

[[body_param]]
name = "metadata"
type = "object"
description = "Your own tags as string pairs, at most 10. An update replaces all tags, so an empty object removes every tag. Accepts any keys."

[[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 newly created ClickHouse instance."
body = '''
{
  "id": "example",
  "name": "Example ClickHouse instance",
  "type": "CH1",
  "usable_disk_gb": 1,
  "max_concurrent_queries": 1,
  "engine_version": "1.4.2",
  "engine_patch_version": "1.4.2",
  "available_engine_versions": [
    "1.4.2"
  ],
  "status": "provisioning",
  "status_message": "example",
  "timezone": "UTC",
  "public_access": false,
  "endpoint": {
    "hostname": "proxy.example.com",
    "public_hostname": "proxy.example.com",
    "ports": {
      "native": 1,
      "native_tls": 1,
      "http": 1,
      "https": 1
    },
    "private_ips": [
      {
        "network_id": "123456789",
        "ip_address": "example"
      }
    ],
    "public_ips": [
      {
        "ip": "example",
        "type": "example"
      }
    ]
  },
  "members": [
    {
      "id": "example",
      "role": "primary",
      "status": "provisioning",
      "disk_used_bytes": 1,
      "private_ips": [
        {
          "network_id": "123456789",
          "ip_address": "example"
        }
      ],
      "created_at": "2026-07-01T12:00:00.000Z"
    }
  ],
  "network_ids": [
    "123456789"
  ],
  "firewall_ids": [
    "123456789"
  ],
  "latest_snapshot_at": "2026-07-01T12:00:00.000Z",
  "term": "monthly",
  "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 organization has reached its quota of ClickHouse instances."

[[response]]
status = 404
description = "The team, plan, network or firewall doesn't exist, or the token can't access it."

[[response]]
status = 409
description = "The resource's state doesn't allow the request, such as starting a running server or removing a placement group that still has servers."

[[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 = "Another create in the organization is in progress, or we couldn't create the instance. Try again in a moment."
[/responses]

[params]
title = "Response attributes"

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

[[param]]
name = "name"
type = "string"
description = "The instance's name, up to 255 characters."

[[param]]
name = "type"
type = "string"
description = "The instance's plan, such as `CH2`. Get the plans via `betterstack clickhouse-type list`."

[[param]]
name = "usable_disk_gb"
type = "integer"
description = "Storage for your data, in GiB."

[[param]]
name = "max_concurrent_queries"
type = "integer"
description = "The most queries the plan runs at the same time. A query over this limit fails at once."

[[param]]
name = "engine_version"
type = "string"
description = "The ClickHouse LTS version, such as `26.8`. Get the versions via `betterstack clickhouse-version list`."

[[param]]
name = "engine_patch_version"
type = "string or null"
description = "The exact ClickHouse version the instance runs, or `null` until the instance's first upgrade."

[[param]]
name = "available_engine_versions"
type = "array of strings"
description = "The versions you can upgrade the instance to now. Holds the next LTS version once we offer it, and is empty until then."

[[param]]
name = "status"
type = "string"
description = "The instance's state.<br/>Valid values:<br/>`provisioning`: We're creating the instance.<br/>`running`: The instance is ready.<br/>`degraded`: The instance works, but needs attention. `status_message` says why.<br/>`rescaling`: We're changing the plan. When the change doesn't complete, the instance returns to `running` with a `status_message`.<br/>`upgrading`: We're upgrading the ClickHouse version. The upgrade is done when the instance is `running` on the new `engine_version`. When the instance is `running` on the old version with a `status_message`, the upgrade failed.<br/>`restoring`: We're restoring a snapshot onto the instance. The instance is `running` again once ClickHouse responds to queries.<br/>`failed`: The instance couldn't be created or recovered. A failed instance stays in this state.<br/>`destroyed`: The instance is deleted."

[[param]]
name = "status_message"
type = "string or null"
description = "Why the instance failed or is degraded, or why an operation didn't complete."

[[param]]
name = "timezone"
type = "string"
description = "The default time zone for date and time functions, `UTC` or an IANA name such as `Europe/Prague`."

[[param]]
name = "public_access"
type = "boolean"
description = "Whether the instance accepts connections on a public IP. The TLS ports `9440` and `8443` are public. The ports without TLS stay on private networks."

[[param]]
name = "endpoint"
type = "object"
description = "Where to connect to the instance."

[[param]]
name = "endpoint.hostname"
type = "string"
description = "The hostname to connect to from your private networks. The hostname resolves to the instance's addresses in those networks."

[[param]]
name = "endpoint.public_hostname"
type = "string or null"
description = "The hostname to connect to from the internet, or `null` when `public_access` is `false`. The hostname resolves to the instance's public IP addresses."

[[param]]
name = "endpoint.ports"
type = "object"
description = "The ports the instance listens on."

[[param]]
name = "endpoint.ports.native"
type = "integer"
description = "The native protocol port, `9000`."

[[param]]
name = "endpoint.ports.native_tls"
type = "integer"
description = "The native protocol port with TLS, `9440`."

[[param]]
name = "endpoint.ports.http"
type = "integer"
description = "The HTTP port, `8123`."

[[param]]
name = "endpoint.ports.https"
type = "integer"
description = "The HTTPS port, `8443`."

[[param]]
name = "endpoint.private_ips"
type = "array of objects"
description = "The instance's addresses in the private networks attached to it."

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

[[param]]
name = "endpoint.private_ips[].ip_address"
type = "string"
description = "The instance's IP address in that network."

[[param]]
name = "endpoint.public_ips"
type = "array of objects"
description = "The instance's public IP addresses. Empty when `public_access` is `false`."

[[param]]
name = "endpoint.public_ips[].ip"
type = "string"
description = "The public IP address."

[[param]]
name = "endpoint.public_ips[].type"
type = "string"
description = "The address type, `ipv4` or `ipv6`."

[[param]]
name = "members"
type = "array of objects"
description = "The node that runs the instance. An instance has one."

[[param]]
name = "members[].id"
type = "string"
description = "The member's ID."

[[param]]
name = "members[].role"
type = "string"
description = "The member's role, always `primary`. Possible values: `primary`."

[[param]]
name = "members[].status"
type = "string"
description = "The member's state.<br/>Valid values:<br/>`provisioning`: We're creating the member.<br/>`running`: The member is up.<br/>`down`: The member doesn't respond."

[[param]]
name = "members[].disk_used_bytes"
type = "integer"
description = "The disk space the member uses, in bytes."

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

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

[[param]]
name = "members[].private_ips[].ip_address"
type = "string"
description = "The member's IP address in that network."

[[param]]
name = "members[].created_at"
type = "datetime"
description = "When the member was created. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

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

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

[[param]]
name = "latest_snapshot_at"
type = "datetime or null"
description = "When the newest available snapshot was created, or `null` when the instance has no snapshot. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "term"
type = "string"
description = "The billing term.<br/>Valid values:<br/>`monthly`: Billed every month.<br/>`annual`: Paid for a year."

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

[[param]]
name = "updated_at"
type = "datetime"
description = "When the instance 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 instance. `betterstack team list` shows it."

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