Document IDs

_id field

Documents in a collection are always identified by an ID that is unique within the collection. This identifier is stored in the reserved field _id.

Default document IDs

When you create a collection, you can specify the default ID type for documents in the collection. The Data API supports Object IDs, version 4 UUIDs, version 6 UUIDs, and version 7 UUIDs. If you don’t specify the default ID type, the default type is a string form of a version 4 UUID.

If you don’t explicitly set the _id field when you insert a document into the collection, the Data API will automatically generate the _id field based on the default ID type for the collection.

For more information about setting the default ID type, see Create a collection.

Specifying document IDs

DataStax recommends using the automatically generated document ID instead of specifying the ID. This ensures uniqueness across the database and reduces the complexity of your code. However, you can use the reserved _id field to specify a document ID when you insert a document.

Other document identifiers

Regardless of the collection’s default ID type, you can use document identifiers of any type outside of the reserved _id field. The Data API does not force uniqueness across identifiers outside of the _id field.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax | 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: +1 (650) 389-6000, info@datastax.com