apyhub
DEVELOPER TOOLS · SMART GENERATION

Convert JSON to Mongoose Schema API

What it does

JSON to Mongoose Schema converts a JSON object, array of objects, or uploaded JSON file into Mongoose schema source code. Send raw JSON or a JSON URL, and get back a generated schema ready to review and use in a Node.js project.

Use the raw endpoints when you want the schema as structured output with inference metadata, warnings, assumptions, and a confidence score. The result includes the generated schema string plus meta such as field count, nesting depth, array detection, mixed-type detection, and sample size. That makes it easier to audit what was inferred before you commit it to your models.

If you prefer a file, the file endpoints return a downloadable .js or .ts schema. You can also fetch JSON from a public URL or upload a JSON file directly. Query and body config options let you control strict, timestamps, versionKey, detectEnums, rootModelName, useTypescript, and detectObjectId so the generated output matches your project conventions.

JSON to Mongoose Schema is useful when you need to turn sample API responses, imported records, or fixture data into a starting model without hand-writing every field. It speeds up schema scaffolding, while still leaving room for manual validation rules and application-specific constraints.

▣ ENDPOINT 01 / 09
POST
Convert raw JSON body to Mongoose schema (JSON result object)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-raw

QUICKSTART

GUIDE

Quickstart

Send a JSON object with the raw data you want converted into a Mongoose schema.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-raw" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","age":30}'

What you'll get back

Returns a JSON object with these top-level fields: schema (string), warnings (array of strings), assumptions (array of strings), confidence (number), and meta (object). meta includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

{
  "schema": "const mongoose = require('mongoose');\n...",
  "warnings": [],
  "assumptions": [],
  "confidence": 0.62,
  "meta": {
    "fieldCount": 5,
    "nestedLevels": 2,
    "hasArrays": false,
    "hasMixedTypes": false,
    "sourceSampleSize": 1
  }
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
body*
Any valid non-empty JSON object (or array of objects) as the raw body.

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)

AttributeTypeMandatoryDescription
strictBooleanNoEnable Mongoose strict mode. Default: true.
timestampsBooleanNoAdd timestamps: true to schema options. Default: true.
versionKeyBooleanNoInclude the __v version key field. Default: false.
detectEnumsBooleanNoAuto-detect enum fields from multiple samples. Default: false.
rootModelNameStringNoName for the root Mongoose model. First character is uppercased. Example: User.
useTypescriptBooleanNoGenerate TypeScript output with typed interfaces. Default: false.
detectObjectIdBooleanNoAuto-detect ObjectId fields by name pattern and value format. Default: true.

Request Body

ParameterTypeMandatoryDescription
jsonObjectYesThe JSON data to convert. Must be a non-empty object or array of objects.
configObjectNoConfiguration options for schema generation. When embedded in the request body, these fields override the corresponding query parameters.
config.strictBooleanNoEnable Mongoose strict mode. Default: true.
config.timestampsBooleanNoAdd timestamps: true to schema options. Default: true.
config.versionKeyBooleanNoInclude the __v version key field. Default: false.
config.detectEnumsBooleanNoAuto-detect enum fields from multiple samples. Default: false.
config.rootModelNameStringNoName for the root Mongoose model. First character is uppercased. Example: User.
config.useTypescriptBooleanNoGenerate TypeScript output with typed interfaces. Default: false.
config.detectObjectIdBooleanNoAuto-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.

ParameterTypeMandatoryDescription
schemaStringYesThe generated Mongoose schema source code (JavaScript or TypeScript).
warningsString ArrayYesHuman-readable warnings about inference quality, ambiguous fields, missing constraints, or recommendations for manual review.
assumptionsString ArrayYesList of type inference decisions made automatically, such as a field inferred as Date or ObjectId.
confidenceNumberYesEstimated confidence score for the generated schema. Range: 0.300.95.
metaObjectYesMetadata about the generated schema structure.
meta.fieldCountIntegerYesTotal number of fields processed across all nesting levels.
meta.nestedLevelsIntegerYesMaximum nesting depth encountered (1 = flat, 2 = one level of nesting, etc.).
meta.hasArraysBooleanYesWhether any array fields were detected in the input.
meta.hasMixedTypesBooleanYesWhether any fields were emitted as Schema.Types.Mixed due to null, conflicting types, or empty arrays.
meta.sourceSampleSizeIntegerYesNumber 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.

Query parameters

Name
Type
Description
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
any
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
▣ ENDPOINT 02 / 09
POST
Convert raw JSON body to Mongoose schema (downloadable file)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-file

QUICKSTART

GUIDE

Quickstart

Convert a JSON object into a downloadable Mongoose schema file.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-file" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","age":30}'

What you'll get back

Returns a binary file containing the generated Mongoose schema. The output is a downloadable schema file (.ts when useTypescript=true, otherwise .js).

TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
body*
Any valid non-empty JSON object (or array of objects) as the raw body.

About this endpoint

What it does

Converts the supplied JSON payload into a Mongoose schema file and returns it as a downloadable binary response. You can provide the JSON either as the raw request body or in a wrapped { json, config } body, and generation options can also be passed in query parameters.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoDefault: sample-output. Output file name / label for the generated schema file.
strictBooleanNoDefault: true. Enable Mongoose strict mode.
timestampsBooleanNoDefault: true. Add timestamps: true to schema options.
versionKeyBooleanNoDefault: false. Include the __v version key field.
detectEnumsBooleanNoDefault: false. Auto-detect enum fields from multiple samples.
rootModelNameStringNoExample: User. Name for the root Mongoose model. First character is uppercased.
useTypescriptBooleanNoDefault: false. Generate TypeScript output with typed interfaces.
detectObjectIdBooleanNoDefault: true. Auto-detect ObjectId fields by name pattern and value format.

Request Body

ParameterTypeMandatoryDescription
jsonObjectNoThe JSON data to convert. Must be a non-empty object or array of objects.
configObjectNoConfiguration options for schema generation. When provided in the wrapped request body, these fields override the corresponding query parameters. Supported fields: strict, timestamps, versionKey, detectEnums, rootModelName, useTypescript, detectObjectId.

Response

Returns a binary file containing the generated Mongoose schema. The response is a downloadable file (string with binary format); when useTypescript=true, the file is .ts, otherwise it is .js.

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
any
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
▣ ENDPOINT 03 / 09
POST
Convert JSON from URL to Mongoose schema (downloadable file)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-file

QUICKSTART

GUIDE

Quickstart

Convert a JSON file URL into a downloadable Mongoose schema file.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-file?output=my-schema&strict=true&timestamps=true&versionKey=false&detectEnums=false&useTypescript=false&detectObjectId=true" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.json"}'

What you'll get back

Returns a downloadable file as the response body. The output schema is a binary string, so the response is the generated Mongoose schema file itself (.js by default, or .ts when useTypescript=true).

TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Publicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: `application/json`, `text/plain`, `application/octet-stream`, `binary/octet-stream`. Alternatively, the URL path or Content-Disposition header must include `.json`. Timeouts after 30 seconds.

About this endpoint

What it does

Converts a JSON file fetched from a publicly accessible URL into a downloadable Mongoose schema file. The generated file is returned as binary content, with the file format depending on whether useTypescript is enabled.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput file name. Default: sample-output.
strictBooleanNoMongoose strict option. Default: true.
timestampsBooleanNoMongoose timestamps option. Default: true.
versionKeyBooleanNoMongoose versionKey option. Default: false.
detectEnumsBooleanNoDetect enum-like values when generating the schema. Default: false.
rootModelNameStringNoRoot model name. Example: User.
useTypescriptBooleanNoGenerate a TypeScript schema file instead of JavaScript. Default: false.
detectObjectIdBooleanNoDetect ObjectId-like values when generating the schema. Default: true.

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL pointing to a JSON resource. The response Content-Type must be one of application/json, text/plain, application/octet-stream, or binary/octet-stream. Alternatively, the URL path or Content-Disposition header must include .json. Timeouts after 30 seconds.

Response

Returns a binary downloadable file containing the generated Mongoose schema. The file is returned as a string with binary format, and the extension is .ts when useTypescript=true, otherwise .js.

ParameterTypeMandatoryDescription
binary contentStringYesDownloadable Mongoose schema file. The file format is .ts when useTypescript=true, otherwise .js.

Notes

The endpoint only accepts a public JSON source URL and requires the remote response to either use an allowed JSON-related Content-Type or include .json in the URL path or Content-Disposition header. The fetch times out after 30 seconds.

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object
▣ ENDPOINT 04 / 09
POST
Convert JSON from URL to Mongoose schema (return S3 signed URL)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-url

QUICKSTART

GUIDE

Quickstart

Convert a JSON file at a public URL into a Mongoose schema file.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-url?output=my-schema" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.json"}'

What you'll get back

Returns a JSON object with a data string field containing a pre-signed S3 URL to download the generated schema file.

{
  "data": "https://s3.amazonaws.com/bucket/uuid_my-schema.js?X-Amz-Signature=..."
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Publicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: `application/json`, `text/plain`, `application/octet-stream`, `binary/octet-stream`. Alternatively, the URL path or Content-Disposition header must include `.json`. Timeouts after 30 seconds.

About this endpoint

What it does

Converts a JSON document fetched from a public URL into a Mongoose schema file and returns a pre-signed S3 URL where the generated file can be downloaded. The generation behavior can be adjusted with query parameters such as schema name, timestamps, version key, enum detection, TypeScript output, and ObjectId detection.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput schema name. Default: sample-output.
strictBooleanNoControls Mongoose strict mode. Default: true.
timestampsBooleanNoAdds Mongoose timestamps. Default: true.
versionKeyBooleanNoIncludes the Mongoose version key. Default: false.
detectEnumsBooleanNoDetects and maps enum-like values. Default: false.
rootModelNameStringNoRoot model name. Example: User.
useTypescriptBooleanNoGenerates a TypeScript schema file instead of JavaScript. Default: false.
detectObjectIdBooleanNoDetects ObjectId-like fields. Default: true.

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: application/json, text/plain, application/octet-stream, binary/octet-stream. Alternatively, the URL path or Content-Disposition header must include .json. Times out after 30 seconds.

Response

Returns a JSON object with a data string field containing a pre-signed S3 URL to download the generated schema file. The URL points to a .js or .ts file depending on useTypescript.

AttributeTypeMandatoryDescription
dataStringYesPre-signed S3 URL to download the generated schema file (.js or .ts depending on useTypescript).

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object
▣ ENDPOINT 05 / 09
POST
Convert uploaded JSON file to Mongoose schema (return S3 signed URL)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-url

QUICKSTART

GUIDE

Quickstart

Upload a JSON file to generate a Mongoose schema file.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-url" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/file.json" \
  -F "output=my-schema"

What you'll get back

Returns a JSON object with a data string field containing a pre-signed S3 URI where you can download the generated schema file.

{
  "data": "https://s3.amazonaws.com/bucket/uuid_my-schema.js?X-Amz-Signature=..."
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
A JSON file to upload. The file MIME type must be `application/json`. The JSON content must be a non-empty object or array of objects.

About this endpoint

What it does

Uploads a JSON file and generates a Mongoose schema from its contents, then returns a pre-signed S3 URL where the generated schema file can be downloaded. The output file format is .js or .ts depending on the useTypescript query parameter.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput name used when generating the file. Default: sample-output.
strictBooleanNoMongoose strict option. Default: true.
timestampsBooleanNoMongoose timestamps option. Default: true.
versionKeyBooleanNoMongoose versionKey option. Default: false.
detectEnumsBooleanNoEnables enum detection. Default: false.
rootModelNameStringNoRoot model name to use for the generated schema. Example: User.
useTypescriptBooleanNoGenerates a TypeScript schema file when true. Default: false.
detectObjectIdBooleanNoEnables ObjectId detection. Default: true.

Request Body

ParameterTypeMandatoryDescription
fileStringYesA JSON file to upload. The file MIME type must be application/json. The JSON content must be a non-empty object or an array of objects.

Response

Returns a JSON object with a data string field containing a pre-signed S3 URL for downloading the generated schema file. The URL points to the generated .js or .ts file depending on useTypescript.

ParameterTypeMandatoryDescription
dataStringYesPre-signed S3 URL to download the generated schema file (.js or .ts depending on useTypescript).

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 06 / 09
POST
Convert raw JSON body to Mongoose schema (return S3 signed URL)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-url

QUICKSTART

GUIDE

Quickstart

Convert JSON into a downloadable Mongoose schema file by sending your JSON data in the request body.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-raw-mongoose-url" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"John","age":30}'

What you'll get back

Returns a JSON object with a data string field containing a pre-signed URL to download the generated schema file.

{
  "data": "https://s3.amazonaws.com/bucket/uuid_my-schema.js?X-Amz-Signature=..."
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
body*
Any valid non-empty JSON object (or array of objects) as the raw body.

About this endpoint

What it does

Converts raw JSON input into a Mongoose schema and returns a pre-signed S3 download URL for the generated file. The request can be sent either as plain JSON in the body or in the wrapped { json, config } format, and the endpoint can also take generation options via query parameters.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput filename/base name. Default: sample-output.
strictBooleanNoEnable Mongoose strict mode. Default: true.
timestampsBooleanNoAdd timestamps: true to schema options. Default: true.
versionKeyBooleanNoInclude the __v version key field. Default: false.
detectEnumsBooleanNoAuto-detect enum fields from multiple samples. Default: false.
rootModelNameStringNoName for the root Mongoose model. First character is uppercased.
useTypescriptBooleanNoGenerate TypeScript output with typed interfaces. Default: false.
detectObjectIdBooleanNoAuto-detect ObjectId fields by name pattern and value format. Default: true.

Request Body

ParameterTypeMandatoryDescription
jsonObjectYes (if using wrapped format)The JSON data to convert. Must be a non-empty object or array of objects.
configObjectNoConfiguration options for schema generation. When provided in the wrapped format, these values override the corresponding query parameters. Supported fields: strict, timestamps, versionKey, detectEnums, rootModelName, useTypescript, detectObjectId.

Response

Returns a JSON object with a required data string field. The data value is a URI pointing to a pre-signed S3 URL for downloading the generated schema file, which is .js or .ts depending on useTypescript.

ParameterTypeMandatoryDescription
dataStringYesPre-signed S3 URL to download the generated schema file (.js or .ts depending on useTypescript).

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
any
The request body can be either: **Plain object** — the entire body is treated as the JSON data to convert: ```json { "name": "John", "age": 30 } ``` **Wrapped format** — use `json` for data and `config` for inline generation options. The body must have exactly the keys `json` and (optionally) `config`, where `json` is an object or array: ```json { "json": { "name": "John", "age": 30 }, "config": { "rootModelName": "User", "useTypescript": true } } ``` Body `config` values are merged with query parameters; body config takes precedence.
▣ ENDPOINT 07 / 09
POST
Convert JSON from URL to Mongoose schema (JSON result object)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-raw

QUICKSTART

GUIDE

Quickstart

Convert a JSON file URL into a Mongoose schema by sending the source URL in the request body.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-url-mongoose-raw?strict=true&timestamps=true&versionKey=false&detectEnums=false&useTypescript=false&detectObjectId=true" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://assets.apyhub.com/samples/sample.json"}'

What you'll get back

Returns a JSON object with schema, warnings, assumptions, confidence, and meta fields.

  • schema is a string containing the generated Mongoose schema source code.
  • warnings and assumptions are arrays of strings.
  • confidence is a number.
  • meta is an object with fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.
{
  "schema": "const mongoose = require('mongoose');\n...",
  "warnings": ["Schema generated from a single JSON sample — field types and optionality may be incomplete"],
  "assumptions": ["Field 'createdAt' inferred as Date from ISO string"],
  "confidence": 0.62,
  "meta": {
    "fieldCount": 5,
    "nestedLevels": 2,
    "hasArrays": false,
    "hasMixedTypes": false,
    "sourceSampleSize": 1
  }
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
Publicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: `application/json`, `text/plain`, `application/octet-stream`, `binary/octet-stream`. Alternatively, the URL path or Content-Disposition header must include `.json`. Timeouts after 30 seconds.

About this endpoint

What it does

Converts JSON fetched from a publicly accessible URL into a generated Mongoose schema. The request sends the source URL plus optional inference flags, and the response returns the generated schema source code along with metadata, warnings, assumptions, and a confidence score.

Query Parameter(s)

AttributeTypeMandatoryDescription
strictBooleanNoDefault: true
timestampsBooleanNoDefault: true
versionKeyBooleanNoDefault: false
detectEnumsBooleanNoDefault: false
rootModelNameStringNoExample: User
useTypescriptBooleanNoDefault: false
detectObjectIdBooleanNoDefault: true

Request Body

ParameterTypeMandatoryDescription
urlStringYesPublicly accessible URL pointing to a JSON resource. The response Content-Type must be one of: application/json, text/plain, application/octet-stream, binary/octet-stream. Alternatively, the URL path or Content-Disposition header must include .json. Timeouts after 30 seconds. Format: URI. Example: https://assets.apyhub.com/samples/sample.json.

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 includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

ParameterTypeMandatoryDescription
schemaStringYesThe generated Mongoose schema source code (JavaScript or TypeScript).
warningsString ArrayYesHuman-readable warnings about inference quality, ambiguous fields, missing constraints, or recommendations for manual review.
assumptionsString ArrayYesList of type inference decisions made automatically, such as a field inferred as Date or ObjectId.
confidenceNumberYesEstimated confidence score for the generated schema, constrained to 0.30–0.95.
metaObjectYesMetadata about the generated schema structure. Includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.
meta.fieldCountIntegerYesTotal number of fields processed across all nesting levels.
meta.nestedLevelsIntegerYesMaximum nesting depth encountered, where 1 = flat and 2 = one level of nesting.
meta.hasArraysBooleanYesWhether any array fields were detected in the input.
meta.hasMixedTypesBooleanYesWhether any fields were emitted as Schema.Types.Mixed due to null, conflicting types, or empty arrays.
meta.sourceSampleSizeIntegerYesNumber of sample objects used for inference. 1 when a single object was provided; higher when an array of objects was passed.

Query parameters

Name
Type
Description
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object
▣ ENDPOINT 08 / 09
POST
Convert uploaded JSON file to Mongoose schema (JSON result object)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-raw

QUICKSTART

GUIDE

Quickstart

Upload a JSON file to generate a raw Mongoose schema from its contents.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-raw" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/input.json;type=application/json"

What you'll get back

Returns a JSON object with schema (string), warnings (array of strings), assumptions (array of strings), confidence (number), and meta (object).

  • schema is the generated Mongoose schema source code.
  • warnings lists human-readable inference warnings.
  • assumptions lists automatic type-inference decisions.
  • confidence is the estimated confidence score.
  • meta includes fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.
{
  "schema": "const mongoose = require('mongoose');\n...",
  "warnings": ["Schema generated from a single JSON sample"],
  "assumptions": ["Field 'createdAt' inferred as Date from ISO string"],
  "confidence": 0.62,
  "meta": {
    "fieldCount": 5,
    "nestedLevels": 2,
    "hasArrays": false,
    "hasMixedTypes": false,
    "sourceSampleSize": 1
  }
}
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
A JSON file to upload. The file MIME type must be `application/json`. The JSON content must be a non-empty object or array of objects.

About this endpoint

What it does

Converts an uploaded JSON file into a generated Mongoose schema and returns the result as a JSON object. You can control several inference options through query parameters, including timestamps, version key generation, enum detection, TypeScript output, and ObjectId detection.

Query Parameter(s)

AttributeTypeMandatoryDescription
strictBooleanNoDefault: true. Controls whether the generated schema uses strict mode.
timestampsBooleanNoDefault: true. Controls whether timestamps are included in the generated schema options.
versionKeyBooleanNoDefault: false. Controls whether the version key is included in the generated schema options.
detectEnumsBooleanNoDefault: false. Controls whether repeated values are inferred as enums.
rootModelNameStringNoExample: User. Sets the root model name used in the generated code.
useTypescriptBooleanNoDefault: false. Controls whether the generated output is TypeScript.
detectObjectIdBooleanNoDefault: true. Controls whether ObjectId-like values are inferred as ObjectId types.

Request Body

ParameterTypeMandatoryDescription
fileStringYesA JSON file to upload. The file MIME type must be application/json. The JSON content must be a non-empty object or array of objects.

Response

Returns a JSON object with five required top-level fields: 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 fields.

ParameterTypeMandatoryDescription
schemaStringYesThe generated Mongoose schema source code (JavaScript or TypeScript).
warningsString ArrayYesHuman-readable warnings about inference quality, ambiguous fields, missing constraints, or recommendations for manual review.
assumptionsString ArrayYesList of type inference decisions made automatically, such as a field inferred as Date or ObjectId.
confidenceNumberYesEstimated confidence score for the generated schema. The schema constrains this to a float between 0.3 and 0.95.
metaObjectYesMetadata about the generated schema structure. Contains fieldCount, nestedLevels, hasArrays, hasMixedTypes, and sourceSampleSize.

Query parameters

Name
Type
Description
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ ENDPOINT 09 / 09
POST
Convert uploaded JSON file to Mongoose schema (downloadable file)
https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-file

QUICKSTART

GUIDE

Quickstart

Upload a JSON file to generate a Mongoose schema file.

curl -X POST "https://api.eu.apyverse.com/apyhub/convert-json-to-mongoose-schema/json-file-mongoose-file" \
  -H "apy-token: $APY_TOKEN" \
  -F "file=@/path/to/file.json"

What you'll get back

Returns a downloadable Mongoose schema file as binary content. The schema describes a .ts file when useTypescript=true, otherwise a .js file.

(binary file)
TRY ITLIVE · 50 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.
body*
A JSON file to upload. The file MIME type must be `application/json`. The JSON content must be a non-empty object or array of objects.

About this endpoint

What it does

Converts an uploaded JSON file into a downloadable Mongoose schema file. The uploaded file must be application/json, and its JSON content must be a non-empty object or an array of objects.

Query Parameter(s)

AttributeTypeMandatoryDescription
outputStringNoOutput file name. Default: sample-output.
strictBooleanNoMongoose strict mode. Default: true.
timestampsBooleanNoAdds timestamps to the generated schema. Default: true.
versionKeyBooleanNoIncludes the version key. Default: false.
detectEnumsBooleanNoDetects enum-like values in the source JSON. Default: false.
rootModelNameStringNoRoot Mongoose model name. Example: User.
useTypescriptBooleanNoGenerates a TypeScript schema file when true. Default: false.
detectObjectIdBooleanNoDetects ObjectId-like values in the source JSON. Default: true.

Request Body

ParameterTypeMandatoryDescription
fileStringYesA JSON file to upload. The file MIME type must be application/json. The JSON content must be a non-empty object or an array of objects.

Response

Returns a downloadable Mongoose schema file as a binary string. The file is .ts when useTypescript=true, otherwise .js.

ParameterTypeMandatoryDescription
fileStringYesBinary response body containing the generated Mongoose schema file.

Query parameters

Name
Type
Description
outputOPTIONAL
string
DEFAULT sample-output
strictOPTIONAL
boolean
DEFAULT true
timestampsOPTIONAL
boolean
DEFAULT true
versionKeyOPTIONAL
boolean
DEFAULT false
detectEnumsOPTIONAL
boolean
DEFAULT false
rootModelNameOPTIONAL
string
useTypescriptOPTIONAL
boolean
DEFAULT false
detectObjectIdOPTIONAL
boolean
DEFAULT true

Body

Name
Type
Description
bodyREQUIRED
object

Max 100MB total per request (all files combined). Larger? Use this API's URL-based endpoint instead, if it has one.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.