Alter a user-defined type (UDT) (HTTP)

Adds and renames fields in a user-defined type (UDT).

This command can’t rename the user-defined type itself or drop fields from the user-defined type. Instead, you must drop the user-defined type and then re-create the user-defined type with the desired name and fields.

Ready to write code? See the examples for this method to get started.

Result

Adds and renames fields in a user-defined type.

If the command succeeds, the response indicates the success.

Example response:

{
  "status": {
    "ok": 1
  }
}

Signature

Use the alterType command.

curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "alterType": {
    "name": STRING,
    "rename": {
      "fields": {
          OLD_FIELD_NAME: NEW_FIELD_NAME,
          OLD_FIELD_NAME: NEW_FIELD_NAME
      }
    },
    "add": {
      "fields": {
          FIELD_NAME: FIELD_TYPE,
          FIELD_NAME: FIELD_TYPE
      }
    },
  }
}'

Parameters

Name Type Summary

name

string

The name of the user-defined type to alter.

rename.fields

object

A JSON object that describes the fields to rename. Each key is an existing field name and each value is the new name for the field.

See the examples for usage.

add.fields

object

A JSON object that defines the fields to add to the user-defined type. Each key is a field name and each value is the field’s data type. You can use any supported data type, except for maps, lists, sets, or other user-defined types.

See the examples for usage.

Examples

The following examples demonstrate how to alter a user-defined type.

Rename fields

curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "alterType": {
    "name": "member",
    "rename": {
      "fields": {
          "name": "first_name",
          "is_active": "is_member"
      }
    }
  }
}'

Add fields

curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "alterType": {
    "name": "member",
    "add": {
      "fields": {
          "email": "text",
          "credits": "int"
      }
    }
  }
}'

Rename and add fields

You may rename and add fields in the same call. However, if one alteration fails, all subsequent operations are aborted.

curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "alterType": {
    "name": "member",
    "rename": {
      "fields": {
          "name": "first_name",
          "is_active": "is_member"
      }
    },
    "add": {
      "fields": {
          "email": "text",
          "credits": "int"
      }
    }
  }
}'

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