Navigation

Create a Rolling Index

The Atlas API authenticates using HTTP Digest Authentication. Provide a programmatic API public key and corresponding private key as the username and password when constructing the HTTP request.

To learn how to configure API access for an Atlas project, see Configure Atlas API Access.

Base URL: https://cloud.mongodb.com/api/atlas/v1.0

Syntax

POST /groups/{GROUP-ID}/clusters/{CLUSTER-NAME}/index

Required Roles

You must have one of the following roles to successfully call this resource:

Request Path Parameters

Path Element Required/Optional Description
GROUP-ID Required. Unique identifier of the project which holds the cluster on which to create an index.
CLUSTER-NAME Required. The name of the cluster on which to create an index.

Request Query Parameters

This endpoint has no request query parameters.

Request Body Parameters

Name Type Description Required
db string The name of the database that holds the collection on which to create an index. Required
collection string The name of the collection on which to create an index. Required
keys array of objects

An array containing one or more objects in which the key is the field to be indexed and the value is the type of the index. For more information on index creation syntax, see the createIndex() shell method.

Important

If you want to create a multikey index, you must list each field in its own object within the keys object array. JSON does not guarantee item order, so if you list multiple fields in the same object, the index may not build correctly.

Required
options object A document that contains a set of options that controls the creation of the index. See Index Options for more information. Optional
collation object A document that contains a set of options to control index collation. See Collation Options for more information. Optional

Response

This endpoint returns an empty document.

Example

Request

curl -u "{PUBLIC-KEY}:{PRIVATE-KEY}" --digest \
 --header "Accept: application/json" \
 --header "Content-Type: application/json" \
 --request POST "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/clusters/{CLUSTER-NAME}/index" \
 --data '{
           "db": "test",
           "collection": "myCollection",
           "keys": [{ "myField": 1 }],
           "collation": { "locale": "us", "strength": 2 }
         }'

Response

{}