Drop a keyspace (TypeScript)

Drops a keyspace from a database and deletes all data in that keyspace.

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

Drops the specified keyspace.

Returns a promise that resolves once the operation completes.

Parameters

Use the dropKeyspace method, which belongs to the DataAPIDbAdmin class.

Method signature
async dropKeyspace(
  keyspace: string,
  options?: {
    timeout?: number | TimeoutDescriptor,
  }
): void
Name Type Summary

keyspace

string

The name of the keyspace to drop.

options

object

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

Properties of options
Name Type Summary

blocking

boolean

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

Default: true

timeout

number | TimeoutDescriptor

Optional.

The timeout(s) to apply to this method. You can specify requestTimeoutMs and keyspaceAdminTimeoutMs.

For more information about the TimeoutDescriptor, see TypeScript client internals: TimeoutDescriptor. If you specify a number instead of a TimeoutDescriptor object, that number will be applied to both requestTimeoutMs and keyspaceAdminTimeoutMs.

Examples

The following examples demonstrate how to drop a keyspace.

import { DataAPIClient } from "@datastax/astra-db-ts";

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

// Get an admin object
const admin = database.admin();

// Drop a keyspace
(async function () {
  await admin.dropKeyspace("KEYSPACE_NAME");
})();

Client reference

For more information, see the client reference.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | 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