Sample & Validate Documents

POST /groups/{groupId}/apps/{appId}/services/{datasourceId}/commands/validate_documents

Query a subset of documents in a collection and validate each match against a schema.

Path parameters

application/json

Body Required

  • database_name string Required

    The name of the database that contains the collection to validate.

  • collection_name string Required

    The name of the collection to validate.

  • from_schema object Required

    The EJSON schema to validate sampled documents against.

  • query object

    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).

  • limit number

    The maximum number of documents to sample.

    Default value is 10000.

  • sort object

    A MongoDB sort for the collection. Use this to determine which end of a range query to start sampling from.

    Default value is {} (empty).

Responses

POST /groups/{groupId}/apps/{appId}/services/{datasourceId}/commands/validate_documents
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":{}}'
Request examples
{
  "database_name": "string",
  "collection_name": "string",
  "from_schema": {},
  "query": {},
  "limit": 10000,
  "sort": {}
}
Response examples (200)
{
  "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
}