Get a database admin (Go)

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 (Go) instead.

The Database Admin class name varies by client. The Go client uses AstraDatabaseAdmin.

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

Returns an AstraDatabaseAdmin struct that can perform administrative actions on the specified database.

Parameters

Use the DatabaseAdmin method, which belongs to the Db type.

Method signature
func (d *Db) DatabaseAdmin() (AstraDatabaseAdmin, error)

This method does not accept any parameters.

Alternatively, use the DatabaseAdminFromEndpoint method, which belongs to the AstraAdmin type.

Alternative method signature and parameters
func (a *AstraAdmin) DatabaseAdminFromEndpoint(
  endpoint string,
  opts ...options.APIOption
) *AstraDatabaseAdmin
Name Type Summary

endpoint

string

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

opts

…​options.APIOption

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

Examples

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

Get a database admin from a database

package main

import (
	"log"

	"github.com/datastax/astra-db-go/v2/astra"
	"github.com/datastax/astra-db-go/v2/astra/options"
)

func main() {
	// Get a database
	client := astra.NewClient()

	database := client.Database(
		"API_ENDPOINT",
		options.API().SetToken("APPLICATION_TOKEN"),
	)

	// Get a database admin
	_, err := database.DatabaseAdmin()

	if err != nil {
		log.Fatal(err)
	}
}

Get a database admin from an admin

package main

import (
	"log"

	"github.com/datastax/astra-db-go/v2/astra"
	"github.com/datastax/astra-db-go/v2/astra/options"
)

func main() {
	client := astra.NewClient(
		options.API().SetToken("APPLICATION_TOKEN"),
	)

	// Get an admin
	admin, err := client.Admin()

	if err != nil {
		log.Fatal(err)
	}

	// Get a database admin
	_ = admin.DatabaseAdminFromEndpoint("API_ENDPOINT")
}

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