---
title: "Generate a JSON schema from sample"
method: POST
path: "/groups/{groupId}/apps/{appId}/services/{serviceId}/commands/generate_schema"
tags: ["services"]
---

# Generate a JSON schema from sample

`POST /groups/{groupId}/apps/{appId}/services/{serviceId}/commands/generate_schema`

## Request

- Base URL: `https://services.cloud.mongodb.com/api/admin/v3.0`
- URL: `https://services.cloud.mongodb.com/api/admin/v3.0/groups/{groupId}/apps/{appId}/services/{serviceId}/commands/generate_schema`
- Auth: HTTP bearer

Sample a subset of documents in a collection to generate a JSON schema.

## Request body

- object
  - `database_name` string, required: The name of the database that contains the collection.
  - `collection_name` string, required: The name of the collection to sample and generate a schema for.
  - `limit` integer, required: The maximum number of documents to include in the sample.

## Response `200`

Successfully generated schema

- object
  - `schema` object: The generated JSON schema

---

[API](https://skmtc.dev/mongodb/apis/mongodb-atlas-app-services-admin-api.md) - [All operations](https://skmtc.dev/mongodb/apis/mongodb-atlas-app-services-admin-api/llms.txt) - [OpenAPI document](https://skmtc.dev/mongodb/apis/mongodb-atlas-app-services-admin-api/revisions/1365ab72bc03?raw)
