Skip to main content

Create Collection (V2)

This operation creates a collection in a specified cluster.

POST/v2/vectordb/collections/create
Connection Endpoint

The base URL for this API is in the following format:

https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530

📘Notes
  • Use the cluster endpoint if you are using serving clusters.
    • Free & Serverless

      https://{cluster-id}.serverless.{region}.vectordb.zillizcloud.com

    • Dedicated

      https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530

  • You need to fill in ${CLUSTER_ENDPOINT} with that of your Zilliz Cloud cluster.
  • To get the endpoint, use the Describe Cluster V2 API to extract the values from the responses.
export CLUSTER_ENDPOINT="https://{cluster-id}.{region}.vectordb.zillizcloud.com:19530"
Parameters
Authorizationstringheaderrequired

The authentication token should be an API key with appropriate privileges or a pair of colon-joined username and password, like username:password. If you are using a project endpoint, only a valid API key with sufficient permissions applies.

Example Value: Bearer {{TOKEN}}
Request Bodyapplication/json
dbNamestring

The name of the database.

collectionNamestringrequired

The name of the collection to create.

dimensionintegerrequired

The number of dimensions a vector value should have. This is required if dtype of this field is set to DataType.FLOAT_VECTOR or DataType.Binary_VECTOR.

metricTypestring

The metric type applied to this operation.

idTypestring

The data type of the primary field. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.

autoIDboolean

Whether the primary field automatically increments. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.

primaryFieldNamestring

The name of the primary field. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.

vectorFieldNamestring

The name of the vector field. This parameter is designed for the quick-setup of a collection and will be ignored if schema is defined.

descriptionstring

The description of the current collection.

paramsobject

Extra parameters for the collection.

max_lengthinteger

The maximum number of bytes allowed in the primary field. This parameter is available only when the primary field is a string field.

enableDynamicFieldboolean

Whether to enable the dynamic field feature.

consistencyLevelstring

The consistency level of the collection.

ttlSecondsinteger

The time-to-live (TTL) period of the collection. If set, the collection is to be dropped once the period ends.

mmap.enabledboolean

Specifies whether to enable memory mapping for the collection.

ttlFieldstring

The name of the field to use for TTL-based expiration.

warmup.scalarFieldboolean

Whether to preload scalar field data into memory on load.

warmup.scalarIndexboolean

Whether to preload scalar index data into memory on load.

warmup.vectorFieldboolean

Whether to preload vector field data into memory on load.

warmup.vectorIndexboolean

Whether to preload vector index data into memory on load.

dbNamestring

The name of the database.

collectionNamestring

The name of the collection to create.

schemaundefined

The schema is responsible for organizing data in the target collection. A valid schema should have multiple fields, which must include a primary key, a vector field, and several scalar fields. Setting this parameter means that dimension, idType, autoID, primaryFieldName, and vectorFieldName will be ignored.

indexParamsarray

The parameters that apply to the index-building process.

[]indexParamsobject

An index Schema object.

metricTypestringrequired

The similarity metric type used to build the index. For more information, refer to Similarity Metrics Explained](/docs/search-metrics-explained).

fieldNamestringrequired

The name of the target field on which an index is to be created.

indexNamestringrequired

The name of the index to create. The value defaults to the target field name.

paramsobject

The index type and related settings. For Zilliz Cloud clusters, you should always set index_type to AUTOINDEX.

index_typestringrequired

The type of the index to create

paramsobject

Extra parameters for the collection.

consistencyLevelstring

The consistency level of the collection.

partitionsNuminteger

The number of partitions to create along with the current collection. This parameter is mandatory if one field of the collection has been designated as the partition key.

ttlSecondsinteger

The time-to-live (TTL) period of the collection. If set, the collection is to be dropped once the period ends.

partitionKeyIsolationboolean

Specifies whether to enable partition key isolation for the collection.

mmap.enabledboolean

Specifies whether to enable memory mapping for the collection.

ttlFieldstring

The name of the field to use for TTL-based expiration.

warmup.scalarFieldboolean

Whether to preload scalar field data into memory on load.

warmup.scalarIndexboolean

Whether to preload scalar index data into memory on load.

warmup.vectorFieldboolean

Whether to preload vector field data into memory on load.

warmup.vectorIndexboolean

Whether to preload vector index data into memory on load.

descriptionstring

The description of the current collection.

dbNamestring

The name of the database.

collectionNamestring

The name of the collection to create.

schemaundefined

The schema for an external collection. Must include fields with externalField mappings, plus externalSource and externalSpec.

indexParamsarray

The parameters that apply to the index-building process.

[]indexParamsobject

An index Schema object.

metricTypestringrequired

The similarity metric type used to build the index. For more information, refer to Similarity Metrics Explained](/docs/search-metrics-explained).

fieldNamestringrequired

The name of the target field on which an index is to be created.

indexNamestringrequired

The name of the index to create. The value defaults to the target field name.

paramsobject

The index type and related settings. For Zilliz Cloud clusters, you should always set index_type to AUTOINDEX.

index_typestringrequired

The type of the index to create

paramsobject

Extra parameters for the collection.

consistencyLevelstring

The consistency level of the collection.

partitionsNuminteger

The number of partitions to create along with the current collection. This parameter is mandatory if one field of the collection has been designated as the partition key.

ttlSecondsinteger

The time-to-live (TTL) period of the collection. If set, the collection is to be dropped once the period ends.

partitionKeyIsolationboolean

Specifies whether to enable partition key isolation for the collection.

mmap.enabledboolean

Specifies whether to enable memory mapping for the collection.

ttlFieldstring

The name of the field to use for TTL-based expiration.

warmup.scalarFieldboolean

Whether to preload scalar field data into memory on load.

warmup.scalarIndexboolean

Whether to preload scalar index data into memory on load.

warmup.vectorFieldboolean

Whether to preload vector field data into memory on load.

warmup.vectorIndexboolean

Whether to preload vector index data into memory on load.

descriptionstring

The description of the current collection.

export TOKEN="db_admin:xxxxxxxxxxxxx"

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/create" \
--header "Authorization: Bearer ${TOKEN}". \
--header "Request-Timeout: 10" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "test_collection",
"dimension": 5
}'
export TOKEN="db_admin:xxxxxxxxxxxxx"

curl --request POST \
--url "${CLUSTER_ENDPOINT}/v2/vectordb/collections/create" \
--header "Authorization: Bearer ${TOKEN}". \
--header "Request-Timeout: 10" \
--header "Content-Type: application/json" \
-d '{
"collectionName": "custom_quick_setup",
"dimension": 5,
"primaryFieldName": "my_id",
"idType": "VarChar",
"vectorFieldName": "my_vector",
"metric_type": "L2",
"autoId": true,
"params": {
"max_length": "512"
}
}'
Responses200 - application/json
codeinteger

Response code.

dataobject

Returns an error message.

codeinteger

Response code.

messagestring

Error message.

{
"code": 0,
"data": {}
}