Sample & Validate Documents
Query a subset of documents in a collection and validate each match against a schema.
Path parameters
-
An Atlas Project/Group ID.
-
The ObjectID of your application. The App Services API Project and Application IDs section demonstrates how to find this value.
-
The unique
_id
value of a MongoDB data source.
Body
Required
-
The name of the database that contains the collection to validate.
-
The name of the collection to validate.
-
The EJSON schema to validate sampled documents against.
-
A MongoDB query that matches documents in the collection. The result of running this query is the sample population. Use this to narrow the sample to a subset of documents in the collection.
Default value is
{}
(empty). -
The maximum number of documents to sample.
Default value is
10000
. -
A MongoDB sort for the collection. Use this to determine which end of a range query to start sampling from.
Default value is
{}
(empty).
curl \
--request POST 'https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/services/{datasourceId}/commands/validate_documents' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"database_name":"string","collection_name":"string","from_schema":{},"query":{},"limit":10000,"sort":{}}'
{
"database_name": "string",
"collection_name": "string",
"from_schema": {},
"query": {},
"limit": 10000,
"sort": {}
}
{
"errors": [
{
"": "false",
"error_count": 42.0,
"field": "(root)._id",
"failed_ids": [
"string"
],
"failed_documents_query": {}
}
],
"total_processed_count": 42.0,
"total_error_count": 42.0
}