Restore a PostgreSQL instance's snapshot
Restore an available snapshot into a new PostgreSQL instance in the same team and zone. The new instance gets new IDs, a new hostname, a new certificate and a new password for every SQL user. The new instance keeps the snapshot's type, settings, databases, users and networks. The new instance's public_access starts off.
The ID of the PostgreSQL instance the snapshot was taken from. The snapshot must belong to this instance.
The ID of the PostgreSQL snapshot to restore.
Bearer $TOKEN
application/json
The new instance's name. Defaults to the source instance name followed by -restored- and a random suffix.
How many replicas the new instance has, from 0 to 2. Defaults to the count when the snapshot was taken.
{
"id": "example",
"name": "Example PostgreSQL instance",
"type": "PG1",
"usable_storage_gb": 1,
"max_connections": 1,
"max_pooled_connections": 1,
"engine_version": "1.4.2",
"engine_patch_version": "1.4.2",
"available_engine_versions": [
"1.4.2"
],
"status": "provisioning",
"status_message": "example",
"statement_timeout": 0,
"idle_in_transaction_session_timeout": 0,
"work_mem_mb": 4,
"log_min_duration_statement": -1,
"public_access": false,
"replica_count": 0,
"read_only": false,
"endpoint": {
"hostname": "proxy.example.com",
"public_hostname": "proxy.example.com",
"port": 443,
"pooled_port": 443,
"private_ips": [
{
"network_id": "123456789",
"ip_address": "example"
}
],
"public_ips": [
{
"ip": "example",
"type": "example"
}
]
},
"members": [
{
"id": "example",
"role": "primary",
"status": "provisioning",
"replication_lag_seconds": 1.5,
"disk_used_bytes": 1,
"private_ips": [
{
"network_id": "123456789",
"ip_address": "example"
}
],
"created_at": "2026-07-01T12:00:00.000Z"
}
],
"databases": [
"example"
],
"users": [
{
"id": "example",
"username": "example",
"default_user": false,
"privileges": {
"key": "value"
},
"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"
}
}
{
"error": {
"message": "Malformed JSON body.",
"code": "bad_request"
}
}
{
"error": {
"message": "Missing or invalid token.",
"code": "unauthorized"
}
}
{
"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"
}
}
{
"error": {
"message": "This token is read-only and cannot be used for write operations.",
"code": "read_only_token"
}
}
{
"error": {
"message": "Resource not found.",
"code": "not_found"
}
}
{
"error": {
"message": "The request could not be completed right now. Please try again in a few moments.",
"code": "internal_error"
}
}
Returns the PostgreSQL instance.
The body isn't valid JSON.
The API token is missing or invalid.
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.
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.
The resource doesn't exist, it's in another zone, or your token can't access it.
The resource's state doesn't allow the request, such as starting a running server or removing a placement group that still has servers.
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.
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.
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.
An unexpected, temporary error on our side, with the code internal_error. Try again.
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.
The instance's ID, a UUID.
The instance's name, at most 255 characters.
The PostgreSQL type, which sets the instance's size. List the types with betterstack postgres-type list.
The disk space for your data, in GiB.
The most direct connections to PostgreSQL at once.
The most client connections to PgBouncer at once.
The PostgreSQL major version, such as 19. List the versions with betterstack postgres-version list.
The exact PostgreSQL version the instance runs, such as 19.0, or null until we know it.
The major versions you can upgrade the instance to. An upgrade can't be undone.
The instance's status. After you create or restore an instance, get it until its status is running. A failed or destroyed instance stays that way.
Valid values:provisioning: We're setting up the instance.running: The instance is ready.degraded: A member is down, replication is broken or the disk is nearly full. status_message says which.rescaling: We're changing the instance's type.upgrading: We're upgrading PostgreSQL to a new major version.restoring: We're restoring the instance from a snapshot.failed: Setting up the instance failed. status_message says why.destroyed: The instance is destroyed.
More about the status, such as why the instance failed or is degraded, a replica being rebuilt or an action that didn't finish.
How long a statement can run before PostgreSQL cancels it, in milliseconds, from 0 to 3600000. Set it to 0 for no limit.
How long a session can stay idle inside a transaction before PostgreSQL ends it, in milliseconds, from 0 to 86400000. Set it to 0 for no limit.
The memory each sort or hash operation can use, in MiB, from 1 to 256.
How long a statement must run before we log it, in milliseconds, from -1 to 600000. Set it to -1 to log none.
Whether the direct and pooled endpoints are also reachable from the internet. Connections use TLS.
How many read replicas the instance has, from 0 to 2.
Whether we've made PostgreSQL read-only because its disk is nearly full.
Where to connect to the instance. Connect directly on port, or through PgBouncer on pooled_port.
The hostname to connect to from your networks, which resolves to the primary's addresses in your networks.
The hostname to connect to from the internet, which resolves to the primary's public addresses. public_hostname is null when public_access is off.
The port for direct connections, 5432.
The port for connections through PgBouncer, 6432.
The primary's addresses in your networks.
The ID of the network.
The address in that network.
The public addresses, when public_access is on.
The public address.
Whether it's an ipv4 or ipv6 address.
The primary and the replicas that run the instance.
The member's ID.
Whether the member is the primary or a replica.
Valid values:primary: The member that accepts writes.replica: A read-only copy that follows the primary.
The member's status. Possible values: provisioning, syncing, running, down.
How far the replica is behind the primary, in seconds, or null on the primary.
The disk space the member uses, in bytes.
The member's addresses in your networks.
The ID of the network.
The address in that network.
When the member was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The names of the instance's databases, sorted. Add and remove them with betterstack postgres-database.
The instance's SQL users. Add and remove users and get their passwords with betterstack postgres-user.
The id.
The username.
The default user.
The privileges.
In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The IDs of your networks attached to every member. Order doesn't matter.
The ID of the firewall attached to every member, at most one. Order doesn't matter.
When the newest available snapshot was taken. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The billing term. Defaults to monthly.
Valid values:monthly: The instance is billed each month.annual: The instance is paid for a year at a time.
When the instance was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
When the instance was last updated. In ISO 8601 format, such as 2026-07-01T12:00:00Z.
The ID of the team that owns the instance. betterstack team list shows it.
Your own tags, as string keys and values.