Navigation

Add a Managed Namespace

Info With Circle IconCreated with Sketch.Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project ID. For existing groups, your group/project ID remains the same. The resource and corresponding endpoints use the term groups.

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.

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

Add a managed namespace to a Global Cluster. For more information about managed namespaces, see Global Clusters.

POST /groups/{GROUP-ID}/clusters/{CLUSTER-NAME}/globalWrites/managedNamespaces
Path ElementRequired/OptionalDescription
GROUP-IDRequired.The unique identifier for the project that contains the Global Cluster.
CLUSTER-NAMERequired.The name of the Global Cluster.

The following query parameters are optional:

Query ParameterTypeDescriptionDefault
prettybooleanDisplays response in a prettyprint format.false
envelopebooleanSpecifies whether or not to wrap the response in an envelope.false
NameTypeDescription
collectionstringThe name of the collection associated with the managed namespace.
customShardKeystringThe custom shard key for the collection. Global Clusters require a compound shard key consisting of a location field and a user-selected second key, the custom shard key.
dbstringThe name of the database containing the collection.
NameTypeDescription
customZoneMappingdocumentA comma-separated list of all custom zone mappings defined for the Global Cluster. Atlas automatically maps each location code to the closest geographical zone. Custom zone mappings allow administrators to override these automatic mappings. If your Global Cluster does not have any custom zone mappings, this document is empty.
managedNamespacesarray of documentsEach document specifies a namespace for a Global Cluster managed by Atlas.
managedNamespaces[n].collectionstringThe name of the collection associated with the managed namespace.
managedNamespaces[n].customShardKeystringThe custom shard key for the collection. Global Clusters require a compound shard key consisting of a location field and a user-selected second key, the custom shard key.
managedNamespaces[n].dbstringThe name of the database containing the collection.
curl -X POST -i --digest --user "{PUBLIC-KEY}:{PRIVATE-KEY}" -H "Content-Type: application/json" \
"https://cloud.mongodb.com/api/atlas/v1.0/groups/6c391af480eef519ea5deeb1/clusters/Cluster1/globalWrites/managedNamespaces?pretty=true" \
--data '{
"db":"mydata",
"collection":"publishers",
"customShardKey":"city"
}'
{
"customZoneMapping" : {
"AF" : "5b48f5a780eef5236f689f94",
"AL" : "5b48f5a780eef5236f689f94",
"AU" : "5b48f5cddff5220000f7f375",
"AU-ACT" : "5b48f5cddff5220000f7f375",
"AU-NSW" : "5b48f5cddff5220000f7f375",
"AU-NT" : "5b48f5cddff5220000f7f375",
"AU-QLD" : "5b48f5cddff5220000f7f375",
"AU-SA" : "5b48f5cddff5220000f7f375",
"AU-TAS" : "5b48f5cddff5220000f7f375",
"AU-VIC" : "5b48f5cddff5220000f7f375",
"AU-WA" : "5b48f5cddff5220000f7f375",
"DZ" : "5b48f5a780eef5236f689f94"
},
"managedNamespaces" : [ {
"collection" : "publishers",
"customShardKey" : "city",
"db" : "mydata"
},{
"collection" : "stores",
"customShardKey" : "store_number",
"db" : "mydata"
} ]
}
Give Feedback