Create a database

Creates a database.

If your organization requires new databases to belong to a PCU group, you cannot use the clients to create databases because these tools don’t support PCU group assignment with database creation. However, you can call the DevOps API directly, as shown on the curl tab.

To replicate a database to additional datacenters, see Deploy an Astra DB Serverless database to multiple regions.

You need an application token with permission to create and configure databases, such as the Organization Administrator role.

For more information, see Get endpoint and token.

Result

  • Python

  • TypeScript

  • Java

  • curl

Creates a database and returns an AstraDBDatabaseAdmin object that can perform administrative actions on the newly-created database.

Creates a database and returns a promise that resolves to an AstraDbAdmin object that can perform administrative actions on the newly-created database.

Creates a database and returns a DatabaseAdmin object that can perform administrative actions on the newly-created database.

Creates a database and returns 201 Created and the database ID.

It takes several minutes for the database to initialize and reach ACTIVE status.

Parameters

  • Python

  • TypeScript

  • Java

  • curl

Use the create_database method, which belongs to the AstraDBAdmin class.

Method signature
create_database(
  name: str,
  *,
  cloud_provider: str,
  region: str,
  keyspace: str,
  wait_until_active: bool,
  database_admin_timeout_ms: int,
  request_timeout_ms: int,
  timeout_ms: int,
  token: str | TokenProvider,
  spawn_api_options: APIOptions,
) -> AstraDBDatabaseAdmin
Name Type Summary

name

str

The name for the database.

Database names must follow these rules:

  • Must start and end with a letter or number

  • Can contain letters, numbers, and the special characters & + - _ ( ) < > . , @

  • Cannot exceed 50 characters

cloud_provider

str

The cloud provider that should host the database. Can be one of: aws, gcp, azure.

region

str

The cloud provider region in which to create the database.

The available regions depend on your subscription plan and the database type. To find available regions, see Find available regions.

keyspace

str

Optional. The name for the database’s initial keyspace.

Default: default_keyspace

wait_until_active

bool

Optional. Whether to wait for the database to become active before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active.

Default: true

database_admin_timeout_ms

int

Optional. A timeout, in milliseconds, to impose on the underlying API request. If not provided, the AstraDBAdmin defaults apply.

This parameter is aliased as request_timeout_ms and timeout_ms for convenience.

token

str | TokenProvider

Optional. The token used by the resulting AstraDBDatabaseAdmin object. The token should have sufficient permissions to perform the desired downstream operations.

Default: The token used by the AstraDBAdmin object that called this method.

spawn_api_options

APIOptions

Optional. A complete or partial specification of the APIOptions to override the defaults inherited from the AstraDBAdmin. Use this to customize the interaction of the Python client with the database admin. For example, you can change the default timeouts.

If APIOptions is passed together with a named parameter such as a timeout, the latter takes precedence over the corresponding spawn_api_options setting.

Use the createDatabase method, which belongs to the AstraAdmin class.

Method signature
async createDatabase(
  config: {
    name: string,
    cloudProvider: AstraDatabaseCloudProvider,
    region: string,
    keyspace?: string,
  },
  options: {
    blocking?: boolean,
    timeout?: number | TimeoutDescriptor,
    dbOptions?: DbOptions
  }
): AstraDbAdmin;
Name Type Summary

config

object

The database configuration. See Properties of config for more details.

options

object

Optional. The options for this operation. See Properties of options for more details.

Properties of config
Name Type Summary

name

string

The name for the database.

Database names must follow these rules:

  • Must start and end with a letter or number

  • Can contain letters, numbers, and the special characters & + - _ ( ) < > . , @

  • Cannot exceed 50 characters

cloudProvider

AstraDatabaseCloudProvider

The cloud provider that should host the database. Can be one of: AWS, GCP, AZURE.

region

string

The cloud provider region in which to create the database.

The available regions depend on your subscription plan and the database type. To find available regions, see Find available regions.

keyspace

string

Optional. The name for the database’s initial keyspace.

Default: default_keyspace

Properties of options
Name Type Summary

blocking

boolean

Optional. Whether to wait for the database to become active before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active.

Default: true

timeout

number | TimeoutDescriptor

Optional. A timeout to impose on the underlying API request.

options

DbOptions

Optional. A specification of options to override the defaults inherited from the AstraAdmin. Use this to customize the interaction of the client with the database admin. For example, you can change the default timeouts or token.

Use the createDatabase method, which belongs to the com.datastax.astra.client.admin.AstraDBAdmin class.

Method signature
DatabaseAdmin createDatabase(String name)
DatabaseAdmin createDatabase(
  String name,
  CloudProviderType cloud,
  String cloudRegion
)
DatabaseAdmin createDatabase(
  String name,
  CloudProviderType cloud,
  String cloudRegion,
  boolean waitForDb
)
Name Type Summary

name

String

The name for the database.

Database names must follow these rules:

  • Must start and end with a letter or number

  • Can contain letters, numbers, and the special characters & + - _ ( ) < > . , @

  • Cannot exceed 50 characters

cloud

CloudProviderType

The cloud provider that should host the database. Can be one of: aws, gcp, azure.

Default (if you only specify the database name): gcp

cloudRegion

String

The cloud provider region in which to create the database.

The available regions depend on your subscription plan and the database type. To find available regions, see Find available regions.

Default (if you only specify the database name): us-east1

waitForDb

boolean

Optional. Whether to wait for the database to become active before returning. If false, the method returns immediately after issuing the creation request, but you cannot work with the database until it becomes active.

Default: true

Use the DevOps API to create a database.

The application token must have sufficient permissions to perform the requested operations, such as the Organization Administrator role.

Command signature
curl -sS -L -X POST "https://api.astra.datastax.com/v2/databases" \
--header "Authorization: Bearer APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "name": "STRING",
  "keyspace": "STRING",
  "cloudProvider": "STRING",
  "region": "STRING",
  "dbType": "STRING",
  "tier": "serverless",
  "capacityUnits": INTEGER,
  "pcuGroupUUID": "STRING"
}'
Name Type Summary

name

string

The name for the database.

Database names must follow these rules:

  • Must start and end with a letter or number

  • Can contain letters, numbers, and the special characters & + - _ ( ) < > . , @

  • Cannot exceed 50 characters

keyspace

string

Optional if dbType is vector. The name for the database’s initial keyspace.

Default if dbType is vector: default_keyspace

cloudProvider

string

The cloud provider that should host the database. Can be one of: aws, gcp, azure.

region

string

The cloud provider region in which to create the database.

The available regions depend on your subscription plan and the database type. To find available regions, see Find available regions.

dbType

string

Whether the database is a Serverless (Vector) database or a Serverless (Non-Vector) database. To create a Serverless (Vector) database, set this parameter to vector. To create a Serverless (Non-Vector) database, omit this parameter.

Serverless (Non-Vector) databases are not compatible with the Data API for downstream operations.

tier

string

Must be serverless.

capacityUnits

integer

Must be 1. This is unrelated to PCU group capacity.

pcuGroupUUID

string

The ID of the PCU group to assign the database to. The specified PCU group must have the same cloudProvider and region as the database. Only applicable for organizations that use PCU groups.

Examples

The following examples demonstrate how to create a database.

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient

client = DataAPIClient("APPLICATION_TOKEN")

admin = client.get_admin()

admin.create_database("DATABASE_NAME", cloud_provider="gcp", region="us-east1")
import { DataAPIClient } from "@datastax/astra-db-ts";

const client = new DataAPIClient("APPLICATION_TOKEN");

const admin = client.admin();

(async function () {
  await admin.createDatabase({
    name: "DATABASE_NAME",
    cloudProvider: "GCP",
    region: "us-east1",
  });
})();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.admin.AstraDBAdmin;
import com.dtsx.astra.sdk.db.domain.CloudProviderType;

public class Example {
  public static void main(String[] args) {
    DataAPIClient client = new DataAPIClient("APPLICATION_TOKEN");

    AstraDBAdmin admin = client.getAdmin();

    admin.createDatabase("DATABASE_NAME", CloudProviderType.GCP, "us-east1");
  }
}
curl -sS -L -X POST "https://api.astra.datastax.com/v2/databases" \
--header "Authorization: Bearer APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "name": "DATABASE_NAME",
  "keyspace": "",
  "cloudProvider": "gcp",
  "region": "us-east1",
  "dbType": "vector",
  "tier": "serverless",
  "capacityUnits": 1
}'

Client reference

  • Python

  • TypeScript

  • Java

  • curl

For more information, see the client reference.

For more information, see the client reference.

For more information, see the client reference.

Client reference documentation is not applicable for HTTP.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2025 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM