Get an Astra DB admin

The Data API clients use the Astra DB Admin and Database Admin classes to perform administrative operations.

The Astra DB Admin class works at the database level. You need an Astra DB Admin object to perform operations such as database creation and termination.

The Astra DB Admin object name varies by client language:

  • Python and Java: AstraDBAdmin

  • TypeScript: AstraAdmin

To create an Astra DB Admin object, you need a client instance.

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

Returns:

AstraDBAdmin - An object used for database-level administrative tasks.

Result
AstraDBAdmin(FullAPIOptions(...))

Returns:

AstraAdmin - An object used for database-management-level administrative tasks.

Returns:

AstraDBAdmin - An object used for database-level administrative tasks in Astra DB Serverless.

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 client, a DataAPIClient instance, to get an AstraDBAdmin object that uses the client’s token:

admin = client.get_admin()

Parameters:

Name Type Summary

token

str | TokenProvider

If supplied, is passed to the Astra DB Admin instead of the client token (default). This may be useful when switching to a more powerful, admin-capable permission set. You can pass either a plain string or an instance of TokenProvider.

spawn_api_options

APIOptions

A complete or partial specification of the APIOptions to override the defaults inherited from the Data API client. This allows customizing the interaction with the Astra DB Admin: for example, changing the timeout settings.

Use client, a DataAPIClient instance, to get an AstraAdmin object that uses the client’s token:

const admin = client.admin();

Parameters:

Name Type Summary

options?

AdminOptions

The options to use for the admin

Options (AdminOptions):

Name Type Summary

adminToken?

string

Application token, in the form of 'AstraCS:…​', to use for the admin. The default is the client’s token.

monitorCommands?

boolean

Whether to monitor admin commands through AdminCommandEvents, using the client as an event emitter. Defaults to false.

endpointUrl?

string

Base URL for the DevOps API

Use client, a DataAPIClient instance, to get an AstraDBAdmin object that uses the client’s token:

AstraDBAdmin admin = client.getAdmin();

Get an AstraDBAdmin object that uses a different token than the client’s token:

AstraDBAdmin admin = client.getAdmin("APPLICATION_TOKEN");

Get an AstraDBAdmin object and specify the token and options for the client:

AdminOptions adminOptions = new AdminOptions("APPLICATION_TOKEN", new DataAPIClientOptions().logRequests());
AstraDBAdmin admin = client.getAdmin(adminOptions);

Parameters:

Name Type Summary

token

String

If provided, this optional token is passed to the Astra DB Admin instead of the client’s token. You can use this to switch to a different permission set than that offered by the client’s token.

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 an Astra DB admin.

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient
client = DataAPIClient("TOKEN")
admin = client.get_admin()
databases = admin.list_databases()
databases[0].name
# 'my_original_db'
new_db_admin = admin.create_database(
    "the_other_database",
    cloud_provider="AWS",
    region="eu-west-1",
)
new_db_admin.list_keyspaces()
# ['default_keyspace', 'that_other_one']
import { DataAPIClient } from '@datastax/astra-db-ts'

const client = new DataAPIClient('TOKEN');

// Spawn an AstraAdmin instance
const admin = client.admin();

(async function () {
  // List all non-terminated databases
  console.log(await admin.listDatabases());

  // Create an actual new database
  const newDbAdmin = await admin.createDatabase({
    name: 'the_other_database',
    cloudProvider: 'aws',
    region: 'eu-west-1',
  });

  // Prints ['default_keyspace']
  console.log(await newDbAdmin.listKeyspaces());
})();
package com.datastax.astra.client;


import com.datastax.astra.client.admin.AstraDBAdmin;

import static com.dtsx.astra.sdk.db.domain.CloudProviderType.GCP;

public class ConnectingAdmin {
    public static void main(String[] args) {
        // Default Initialization
        DataAPIClient client = new DataAPIClient("TOKEN");

        // Accessing admin providing a new token possibly with stronger permissions
        AstraDBAdmin astradbAdmin = client.getAdmin("SUPER_USER_TOKEN");

        // Create a Database
        astradbAdmin.createDatabase("db-demo", GCP, "us-east-1").listKeyspaceNames();
    }
}

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