About this endpoint
What it does
Converts the provided raw JSON input into a generated Mongoose schema source string, and returns inference metadata alongside warnings, assumptions, and a confidence score.
Query Parameter(s)
| Attribute | Type | Mandatory | Description |
|---|---|---|---|
| strict | Boolean | No | Enable Mongoose strict mode. Default: true. |
| timestamps | Boolean | No | Add timestamps: true to schema options. Default: true. |
| versionKey | Boolean | No | Include the __v version key field. Default: false. |
| detectEnums | Boolean | No | Auto-detect enum fields from multiple samples. Default: false. |
| rootModelName | String | No | Name for the root Mongoose model. First character is uppercased. Example: User. |
| useTypescript | Boolean | No | Generate TypeScript output with typed interfaces. Default: false. |
| detectObjectId | Boolean | No | Auto-detect ObjectId fields by name pattern and value format. Default: true. |
Request Body
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| json | Object | Yes | The JSON data to convert. Must be a non-empty object or array of objects. |
| config | Object | No | Configuration options for schema generation. When embedded in the request body, these fields override the corresponding query parameters. |
| config.strict | Boolean | No | Enable Mongoose strict mode. Default: true. |
| config.timestamps | Boolean | No | Add timestamps: true to schema options. Default: true. |
| config.versionKey | Boolean | No | Include the __v version key field. Default: false. |
| config.detectEnums | Boolean | No | Auto-detect enum fields from multiple samples. Default: false. |
| config.rootModelName | String | No | Name for the root Mongoose model. First character is uppercased. Example: User. |
| config.useTypescript | Boolean | No | Generate TypeScript output with typed interfaces. Default: false. |
| config.detectObjectId | Boolean | No | Auto-detect ObjectId fields by name pattern and value format. Default: true. |
Response
Returns a JSON object with schema as a string, warnings as a string array, assumptions as a string array, confidence as a number, and meta as an object. The meta object contains fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| schema | String | Yes | The generated Mongoose schema source code (JavaScript or TypeScript). |
| warnings | String Array | Yes | Human-readable warnings about inference quality, ambiguous fields, missing constraints, or recommendations for manual review. |
| assumptions | String Array | Yes | List of type inference decisions made automatically, such as a field inferred as Date or ObjectId. |
| confidence | Number | Yes | Estimated confidence score for the generated schema. Range: 0.30–0.95. |
| meta | Object | Yes | Metadata about the generated schema structure. |
| meta.fieldCount | Integer | Yes | Total number of fields processed across all nesting levels. |
| meta.nestedLevels | Integer | Yes | Maximum nesting depth encountered (1 = flat, 2 = one level of nesting, etc.). |
| meta.hasArrays | Boolean | Yes | Whether any array fields were detected in the input. |
| meta.hasMixedTypes | Boolean | Yes | Whether any fields were emitted as Schema.Types.Mixed due to null, conflicting types, or empty arrays. |
| meta.sourceSampleSize | Integer | Yes | Number of sample objects used for inference. 1 when a single object was provided; higher when an array of objects was passed. |
Notes
Body-level config values override the matching query parameters when both are provided. The json field accepts either a single object or an array of objects, so the inferred meta.sourceSampleSize can be greater than 1 when multiple samples are supplied.