JSON Schema Inference
schema.infer_json_schema
Overview
You send one or more example JSON documents and we read their structure to write a conservative JSON Schema in the 2020-12 dialect. A field counts as required when it appears in every example, and a field that holds different types across examples gets a union type plus a warning so you can decide what you actually meant. We stay deliberately plain: no conditionals, no oneOf, no $ref. Use the result as a first draft to review, not as a finished contract. Accepts file input via file_ref — no need to extract file content first.
Writing a schema by hand from a folder of sample payloads is slow, and it is easy to miss the one field that is sometimes a string and sometimes a number. You get a faithful first draft, and the disagreements are called out rather than smoothed over.
Reliability
Best-effort by design, and repeatable: the same examples in the same order always give the same schema, but the schema only reflects the documents you sent. A whole number becomes integer unless some sibling value is fractional, in which case the field becomes number. If an example is not valid JSON we return the recoverable failure JSON_MALFORMED, which you can clear by repairing the text with schema.repair_json and calling again with the same options. We reject the call outright, and an unchanged retry will not help, when neither examples nor examples_file_ref is present, when the array is empty or holds anything other than strings, when there are more than 100 examples or more than 2097152 bytes of them, or when a referenced file is missing, unreadable, or too large.
Context footprint
Inline examples and a referenced file are both capped at 2097152 bytes; the response carries one schema, so it stays far smaller than the input. A successful call costs 1 execution credit.
When to use it
When you have real payloads and want a schema to review, document, or tighten up before you enforce it.
When the schema already exists and you want documents checked against it, or when the contract needs conditional branches only a human can decide.
Scope
Non-goals
- We never check a document against a schema — that is schema.validate_json
- We never invent constraints you cannot see in the examples, such as formats or ranges
- We never write conditionals, oneOf, or $ref; you add those yourself
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
File limits
Constraints this skill applies to your input and generated files. The “Limited by” column shows the static source of each cap; none of these can be raised by upgrading your plan.
| Limit | Value | Limited by |
|---|---|---|
| Maximum size per input file | 2 MiB | Skill and platform maximum |
How we handle your data
What this means
This skill may receive sensitive content and may return submitted, transformed, extracted, or reformatted content.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- Output may reveal sensitive derived information
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| examples | array | No | Example documents, 1 through 100 JSON strings totalling at most 2097152 bytes. Required unless examples_file_ref is provided. |
| examples_file_ref | string | No | Tenant-owned examples file; a top-level array becomes one example per element. Omit it to read examples. When both are sent this one wins. |
| draft | string | No | Accepted and currently ignored; omit it. The inferred schema always declares 2020-12. |
| requiredPolicy | string | No | present_in_all marks fields seen in every sibling object; none leaves required out. Omit it for present_in_all. |
| additionalPropertiesPolicy | string | No | false closes every object; true leaves additionalProperties out. Omit it for true. |
| maxDepth | integer | No | How many nesting levels to describe; omit it for 20. Zero or negative falls back to 20. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| schema | object | Yes | Inferred JSON Schema opening with $schema and type, plus properties, optional required and additionalProperties, with at most 4096 keys. — unconstrained RFC 8259 JSON items. |
| examplesAnalyzed | integer | Yes | How many example documents were parsed, from 1 through 100. |
| warnings | array | Yes | Non-fatal advisory notices as 0 through 256 strings, each one sentence long; empty when nothing was worth flagging. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"schema.infer_json_schema","input":{"examples":["{\"name\":\"Alice\",\"age\":30}","{\"name\":\"Bob\",\"age\":25}"]}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("schema.infer_json_schema", {"examples":["{\"name\":\"Alice\",\"age\":30,\"email\":\"[email protected]\"}","{\"name\":\"Bob\",\"age\":25}"]});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
| JSON_MALFORMED | 400 | No | The request payload failed this skill's input validation. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- We never check a document against a schema — that is schema.validate_json
- We never invent constraints you cannot see in the examples, such as formats or ranges
- We never write conditionals, oneOf, or $ref; you add those yourself
- Checking documents against a schema you already have (schema.validate_json)
- Writing schemas with conditional or polymorphic branches
- Comparing two schema versions (schema.diff_json_schema)
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "schema.infer_json_schema",
"input": {
"examples": [
"{\"name\":\"Alice\",\"age\":30,\"email\":\"[email protected]\"}",
"{\"name\":\"Bob\",\"age\":25}"
]
}
}Examples
Infer from user objects
{
"examples": [
"{\"name\":\"Alice\",\"age\":30,\"email\":\"[email protected]\"}",
"{\"name\":\"Bob\",\"age\":25}"
]
}{
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"name",
"age"
],
"type": "object",
"properties": {
"name": {
"type": "string"
},
"email": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"warnings": [],
"examplesAnalyzed": 2
}Mixed types produce warning
{
"examples": [
"{\"value\":\"hello\"}",
"{\"value\":42}"
]
}{
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"required": [
"value"
],
"type": "object",
"properties": {
"value": {
"type": [
"string",
"integer"
]
}
}
},
"warnings": [
"Mixed types detected: [string, integer]"
],
"examplesAnalyzed": 2
}Recommended use cases
- Start an API contract from payloads you already have
- Describe the shape of JSON coming out of a log or an export you did not design
- Spot fields whose type is inconsistent across real-world samples
Avoid for
- Checking documents against a schema you already have (schema.validate_json)
- Writing schemas with conditional or polymorphic branches
- Comparing two schema versions (schema.diff_json_schema)
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.