Dark Mode

  • Manage application token.
  • After generating an authorization token, run the following request to get all available keyspacesand verify that the keyspace you wish to use is listed in the results:

For example, we'll use users_keyspace as the keyspace.If the keyspace is not listed, go to your Astra DB dashboard and add the keyspace.

  • Optional: A header line using a undefined , a randomly-generated UUID thatis unique for the authorization request, can be included in the previous commandby adding the following line:
  • 1

Send a POST request to /api/rest/v2/schemas/keyspaces/undefined/tables to create a table.Set the table name and column definitions in the JSON body in the --data .

The name of our example table is users .This table column definition includes:

Notice that each column must have a data type specified.

Information about primary keys (partition keys and clustering keys) are found in theCassandra Query Language (CQL) reference.

  • Optional: Table options can be set.The two options are:
  • 1

Data types

Many common data types are supported by the REST API, such as text, integer,decimal, date and time.In addition, collections (set, list, map) and tuples are supported.Collections can be specified as frozen collections, meaning that the entirecollection must be matched in the query to retrieve the collection data.User-defined types (UDTs) can be defined using CQL or GraphQL and then usedwhen a table is created. Make UDTs before defining a table that uses one.

You can also nest any of the data types available.For example, a LIST of TUPLES , or a UDT that uses a MAP is possible.

All columns must be set with a data type in the original table creation.If columns are added after table creation,a data type is also required.For more examples of specifying columns of various data types, seeAdd columns to your table.

To check if a table exists, execute aREST API query with cURL to find all the tables:

In this case, we only have one table in the keyspace.

To get a particular table, specify the table in the URL:

Although this command is slightly different, because we have only one table,the command to get all tables and this command to just get the table users returnthe same information.