Get a database admin

The Data API clients use the Database Admin class to perform administrative operations, like managing keyspaces, within a specific database.

To perform administrative actions outside of a specific database, see Get an Astra DB admin instead.

The Database Admin class name varies by client:

  • Python: AstraDBDatabaseAdmin

  • TypeScript: AstraDbAdmin

  • Java: DatabaseAdmin

You need an application token with permission to interact with the target database, such as the Database Administrator role.

For more information, see Get endpoint and token.

Result

  • Python

  • TypeScript

  • Java

  • curl

Returns an AstraDBDatabaseAdmin object that can perform administrative actions on the specified database.

Returns an AstraDbAdmin object that can perform administrative actions on the specified database.

Returns a DatabaseAdmin object that can perform administrative actions on the specified database.

This method has no literal equivalent in HTTP. Instead, you provide an application token with sufficient permissions to perform the requested operations.

Parameters

  • Python

  • TypeScript

  • Java

  • curl

Use the get_database_admin method from the Database class.

Method signature
get_database_admin(
  *,
  token: str | TokenProvider,
  spawn_api_options: APIOptions,
) -> DatabaseAdmin
Name Type Summary

token

str | TokenProvider

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

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

spawn_api_options

APIOptions

Optional. A complete or partial specification of ttimeouts.

If APIOptions is passed together with a named parameter such as a timeout, the latter takes precedence over the corresponding spawn_api_options setting. 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.

Alternatively, use the get_database_admin method from the AstraDBAdmin class.

Alternative method signature and parameters
get_database_admin(
  api_endpoint_or_id: str,
  *,
  api_endpoint: str,
  id: str,
  region: str,
  token: str | TokenProvider,
  spawn_api_options: APIOptions,
) -> AstraDBDatabaseAdmin
Name Type Summary

api_endpoint_or_id

str

An alternative to the endpoint or id parameters

api_endpoint

str

The database’s API endpoint, typically formatted as \https://DATABASE_ID-REGION.apps.astra.datastax.com.

If specified, you cannot specify id and region.

id

str

The database’s ID.

If specified, you must also specify region and cannot specify api_endpoint.

region

str

The database’s region.

If specified, you must also specify id and cannot specify api_endpoint.

token

str | TokenProvider

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

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

spawn_api_options

APIOptions

Optional. A complete or partial specification of ttimeouts.

If APIOptions is passed together with a named parameter such as a timeout, the latter takes precedence over the corresponding spawn_api_options setting. 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 admin method, which belongs to the Db class.

Method signature
admin(
  options?: AdminOptions & {
    environment?: "astra"
  }
): AstraDbAdmin
Name Type Summary

environment

DataAPIEnvironment

Optional. Only for the admin method of the Db class.

The database’s environment. Must be astra or unspecified.

options

DbOptions

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

Alternatively, use the dbAdmin method, which belongs to the AstraDbAdmin class.

Alternative method signature and parameters
dbAdmin(
  endpoint: string,
  options?: DbOptions
): AstraDbAdmin
dbAdmin(
  id: string,
  region: string,,
  options?: DbOptions
): AstraDbAdmin
Name Type Summary

endpoint

string

The database’s API endpoint, typically formatted as \https://DATABASE_ID-REGION.apps.astra.datastax.com.

id

string

The database’s ID.

region

string

The database’s region.

options

DbOptions

Optional. A specification of options to override the inherited defaults. 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 getDatabaseAdmin method from the com.datastax.astra.client.Database class.

Method signature
DatabaseAdmin getDatabaseAdmin()
DatabaseAdmin getDatabaseAdmin(String superUserToken)
DatabaseAdmin getDatabaseAdmin(AdminOptions adminOptions)
Name Type Summary

superUserToken

String

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

If not specified, the resulting object will use the token used by the object that called this method.

adminOptions

AdminOptions

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

Alternatively, use the getDatabaseAdmin method from the com.datastax.astra.client.admin.AstraDBAdmin class.

Alternative method signature and parameters
AstraDBDatabaseAdmin getDatabaseAdmin(UUID databaseId)
Name Type Summary

databaseId

UUID

The ID of the database for which to create an admin object.

This method has no literal equivalent in HTTP. Instead, you provide an application token with sufficient permissions to perform the requested operations.

Examples

The following examples demonstrate how to get a database admin object.

Get a database admin from a database

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient

# Get a database object
client = DataAPIClient()
database = client.get_database(
    "API_ENDPOINT",
    token="APPLICATION_TOKEN",
)

# Get a database admin object
database_admin = database.get_database_admin()
import { DataAPIClient } from "@datastax/astra-db-ts";

// Get a database object
const client = new DataAPIClient();
const database = client.db("API_ENDPOINT", {
  token: "APPLICATION_TOKEN",
});

// Get a database admin object
const databaseAdmin = database.admin();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.admin.DatabaseAdmin;
import com.datastax.astra.client.databases.Database;

public class Example {

  public static void main(String[] args) {
    // Get a database object
    Database database = new DataAPIClient("APPLICATION_TOKEN").getDatabase("API_ENDPOINT");

    // Get a database admin object
    DatabaseAdmin databaseAdmin = database.getDatabaseAdmin();
  }
}

This method has no literal equivalent in HTTP. Instead, you provide an application token with sufficient permissions to perform the requested operations.

Get a database admin from an admin

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient

# Get an admin object
client = DataAPIClient("APPLICATION_TOKEN")
admin = client.get_admin()

# Get a database admin object
database_admin = admin.get_database_admin(api_endpoint="API_ENDPOINT")
import { DataAPIClient } from "@datastax/astra-db-ts";

// Get an admin object
const client = new DataAPIClient("APPLICATION_TOKEN");
const admin = client.admin();

// Get a database admin object
const databaseAdmin = admin.dbAdmin("API_ENDPOINT");
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.admin.AstraDBAdmin;
import com.datastax.astra.client.admin.AstraDBDatabaseAdmin;
import java.util.UUID;

public class Example {
  public static void main(String[] args) {
    // Get an admin object
    DataAPIClient client = new DataAPIClient("APPLICATION_TOKEN");
    AstraDBAdmin admin = client.getAdmin();

    // Get a database admin object
    AstraDBDatabaseAdmin databaseAdmin = admin.getDatabaseAdmin(UUID.fromString("DATABASE_ID"));
  }
}

This method has no literal equivalent in HTTP. Instead, you provide an application token with sufficient permissions to perform the requested operations.

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