Create a database
Creates a database.
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
-
Go
-
Java
-
C#
-
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.
|
The Go client is in preview. For more information, see astra-db-go. |
Creates a database and returns a AstraDatabaseAdmin struct 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 a DatabaseAdminAstra 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
-
Go
-
Java
-
C#
-
curl
Use the create_database method, which belongs to the AstraDBAdmin class.
Method signature
create_database(
name: str,
*,
definition: DatabaseDefinition,
wait_until_active: bool,
database_admin_timeout_ms: int,
request_timeout_ms: int,
timeout_ms: int,
token: str | TokenProvider,
spawn_api_options: APIOptions,
) -> AstraDBDatabaseAdmin
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 |
|---|---|---|
|
|
The name for the database. Database names must follow these rules:
|
|
The configuration for the database. If specified, you cannot separately specify See Attributes of |
|
|
|
Required unless you specify The cloud provider that should host the database.
Can be one of: |
|
|
Required unless you specify The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions. |
|
|
Optional.
You can’t specify both The name for the database’s initial keyspace. Default: default_keyspace |
|
|
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 |
|
|
Optional.
A timeout, in milliseconds, to impose on the underlying API request.
If not provided, the This parameter is aliased as |
|
|
Optional.
The token used by the resulting Default: The token used by the |
|
Optional.
A complete or partial specification of the If |
| Name | Type | Summary | ||
|---|---|---|---|---|
|
|
The cloud provider that should host the database.
Can be one of: |
||
|
|
The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions. |
||
|
|
Optional. The name for the database’s initial keyspace. Default: default_keyspace |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
||
|
|
Optional. Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, set it to
Default: vector |
||
|
|
Optional. The database tier. If specified, must be Default: serverless |
||
|
|
Optional. The number of capacity units for the database. This is unrelated to PCU group capacity. If specified, must be Default: 1 |
Use the createDatabase method, which belongs to the AstraAdmin class.
Method signature
async createDatabase(
config: {
name: string,
cloudProvider: AstraDatabaseCloudProvider,
region: string,
keyspace?: string,
pcuGroupUUID?: string,
tier?: string,
capacityUnits?: number,
dbType?: 'vector' | 'nonvector',
},
options: {
blocking?: boolean,
timeout?: number | TimeoutDescriptor,
dbOptions?: DbOptions
}
): AstraDbAdmin;
| Name | Type | Summary |
|---|---|---|
|
|
The database configuration.
See Properties of |
|
|
Optional.
The options for this operation.
See Properties of |
| Name | Type | Summary | ||
|---|---|---|---|---|
|
|
The name for the database. Database names must follow these rules:
|
||
|
|
The cloud provider that should host the database.
Can be one of: |
||
|
|
The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions. |
||
|
|
Optional. The name for the database’s initial keyspace. Default: default_keyspace |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
||
|
|
Optional. Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, set it to
Default: vector |
||
|
|
Optional. The database tier. If specified, must be Default: serverless |
||
|
|
Optional. The number of capacity units for the database. This is unrelated to PCU group capacity. If specified, must be Default: 1 |
| Name | Type | Summary |
|---|---|---|
|
|
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 |
|
|
Optional. A timeout to impose on the underlying API request. |
|
Optional.
A specification of options to override the defaults inherited from the |
|
The Go client is in preview. For more information, see astra-db-go. |
Use the CreateDatabase method, which belongs to the AstraAdmin type.
Method signature
func (a *AstraAdmin) CreateDatabase(
ctx context.Context,
name string,
params CreateDatabaseParams,
opts ...options.CreateDatabaseOption
) (*AstraDatabaseAdmin, error)
| Name | Type | Summary |
|---|---|---|
|
|
The context for the operation. |
|
|
The name for the database. Database names must follow these rules:
|
|
|
The configuration for the database. See Fields of the |
|
Optional.
A builder to generate options for this operation.
See Methods of the |
| Name | Type | Summary | ||
|---|---|---|---|---|
|
|
The cloud provider that should host the database. |
||
|
|
The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions. |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
||
|
|
Optional. Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, set it to
Default: vector |
||
|
|
Optional. The database tier. If specified, must be Default: serverless |
||
|
|
Optional. The number of capacity units for the database. This is unrelated to PCU group capacity. If specified, must be Default: 1 |
| Method | Summary |
|---|---|
|
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 |
|
Optional.
Controls how often to check the database status if Default: 10 seconds |
|
Optional. The name for the database’s initial keyspace. Default: default_keyspace |
|
Optional. General API options for this operation, including the timeout. |
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,
DatabaseDefinition definition,
CreateDatabaseOptions options
)
DatabaseAdmin createDatabase(
String name,
DatabaseDefinition definition
)
DatabaseAdmin createDatabase(
String name,
CloudProviderType cloud,
String cloudRegion
)
DatabaseAdmin createDatabase(
String name,
CloudProviderType cloud,
String cloudRegion,
boolean waitForDb
)
| Name | Type | Summary |
|---|---|---|
|
|
The name for the database. Database names must follow these rules:
|
|
|
The configuration for the database. See Methods of |
|
|
The configuration for the database. The options for this operation.
See Methods of |
|
|
The cloud provider that should host the database. Default (if you only specify the database name): |
|
|
The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions. Default (if you only specify the database name): us-east1 |
|
|
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 |
| Method | Parameters | Summary | ||
|---|---|---|---|---|
|
|
The cloud provider that should host the database.
Can be one of: |
||
|
|
The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions. |
||
|
|
Optional. The name for the database’s initial keyspace. Default: default_keyspace |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
||
|
|
Optional. Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, set it to
Default: vector |
||
|
|
Optional. The database tier. If specified, must be Default: serverless |
||
|
|
Optional. The number of capacity units for the database. This is unrelated to PCU group capacity. If specified, must be Default: 1 |
| Method | Parameters | Summary |
|---|---|---|
|
|
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 CreateDatabaseAsync method, which belongs to the AstraDatabasesAdmin class.
You can also use CreateDatabase, which is the synchronous version of the method.
Method signature
public Task<DatabaseAdminAstra> CreateDatabaseAsync(
CreateDatabaseOptions options
);
| Name | Type | Summary |
|---|---|---|
|
Optional.
Options for this operation.
For more information and examples for general options such as timeout, see Customize API interaction.
See Method-specific properties of the |
| Name | Type | Summary | ||
|---|---|---|---|---|
|
|
The name of the database. Database names must follow these rules:
|
||
|
|
The cloud provider that should host the database.
Can be one of: |
||
|
|
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. |
||
|
|
Optional. The name for the database’s initial keyspace. Default: default_keyspace |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
||
|
|
Optional. Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, set it to
Default: vector |
||
|
|
Optional. The database tier. If specified, must be Default: serverless |
||
|
|
Optional. The number of capacity units for the database. This is unrelated to PCU group capacity. If specified, must be Default: 1 |
||
|
|
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 | ||
|---|---|---|---|---|
|
|
The name for the database. Database names must follow these rules:
|
||
|
|
Optional if Default if |
||
|
|
The cloud provider that should host the database.
Can be one of: |
||
|
|
The cloud provider region in which to create the database. The available regions depend on your Astra plan and the database type. To find available regions, see Find available regions. |
||
|
|
Whether the database is a Serverless (vector) database or a Serverless (non-vector) database. To create a Serverless (vector) database, set this parameter to To create a Serverless (non-vector) database, omit this parameter.
|
||
|
|
The database tier.
Must be |
||
|
|
Must be |
||
|
|
Optional. The ID of the PCU group to use for provisioning the database. The specified PCU group must have the same cloud provider and region as the database. Only applicable for organizations that use PCU groups. Default: No PCU group |
Examples
The following examples demonstrate how to create a database.
-
Python
-
TypeScript
-
Go
-
Java
-
C#
-
curl
from astrapy import DataAPIClient
from astrapy.info import DatabaseDefinition
client = DataAPIClient("APPLICATION_TOKEN")
admin = client.get_admin()
admin.create_database(
"DATABASE_NAME",
definition=DatabaseDefinition(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",
});
})();
|
The Go client is in preview. For more information, see astra-db-go. |
package main
import (
"context"
"log"
"github.com/datastax/astra-db-go/v2/astra"
)
func main() {
ctx := context.Background()
client := astra.NewClient()
admin, err := client.Admin()
if err != nil {
log.Fatal(err)
}
admin.CreateDatabase(
ctx,
"DATABASE_NAME",
astra.CreateDatabaseParams{
CloudProvider: "gcp",
Region: "us-east1",
},
)
}
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.admin.AstraDBAdmin;
import com.datastax.astra.client.admin.definition.DatabaseDefinition;
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();
DatabaseDefinition definition =
DatabaseDefinition.builder()
.cloudProvider(CloudProviderType.GCP)
.region("us-east-1")
.build();
admin.createDatabase("DATABASE_NAME", definition, null);
}
}
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Admin;
namespace Examples;
public class Program
{
static async Task Main()
{
var client = new DataAPIClient("APPLICATION_TOKEN");
var admin = client.GetAstraDatabasesAdmin();
var databaseAdmin = await admin.CreateDatabaseAsync(
new CreateDatabaseOptions()
{
Name = "DATABASE_NAME",
CloudProvider = CloudProviderType.AWS,
Region = "us-east-2",
}
);
}
}
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
-
Go
-
Java
-
C#
-
curl
For more information, see the client reference.
For more information, see the client reference.
|
The Go client is in preview. For more information, see astra-db-go. |
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.