# 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. ## Servers - The root API resource and starting point for the App Services API.: https://services.cloud.mongodb.com/api/admin/v3.0 (The root API resource and starting point for the App Services API.) ## Authentication methods - Token auth ## Parameters ### Path parameters - **groupId** (string) An Atlas [Project/Group ID](https://docs.atlas.mongodb.com/tutorial/manage-projects/). - **appId** (string) The ObjectID of your application. [The App Services API Project and Application IDs section](#section/Project-and-Application-IDs) demonstrates how to find this value. - **datasourceId** (string) The unique `_id` value of a MongoDB data source. ### Body: application/json (object) - **database_name** (string) The name of the database that contains the collection to validate. - **collection_name** (string) The name of the collection to validate. - **from_schema** (object) The EJSON schema to validate sampled documents against. - **query** (object) A [MongoDB query](https://www.mongodb.com/zh-cn/docs/manual/tutorial/query-documents/) 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. - **limit** (number) The maximum number of documents to sample. - **sort** (object) A [MongoDB sort](https://www.mongodb.com/zh-cn/docs/manual/reference/method/cursor.sort/) for the collection. Use this to determine which end of a range query to start sampling from. ## Responses ### 200 OK #### Body: application/json (object) - **errors** (array[object]) - **total_processed_count** (number) The total number of documents that were sampled. - **total_error_count** (number) The total number of documents that failed any validation. [Powered by Bump.sh](https://bump.sh)