Skip to main content

POST /v1/repair

Fix malformed JSON in a single request. Use this for complete LLM outputs where you have the full string. For token-by-token repair, use streaming endpoints.

Request

Headers

Body

Parameters

raw_output (string, required)
  • The malformed JSON string from your LLM
  • Max size: 5MB
  • Can include markdown fences, trailing commas, truncated objects
schema (JSONSchema, optional)
  • JSON Schema for validation and type coercion
  • Shim will coerce types ("30"30)
  • Detect missing required fields
  • Remove extra fields in strict mode
mode (string, optional)
  • "strict": Remove extra fields not in schema (default)
  • "lenient": Keep extra fields

Response

Always returns HTTP 200 with structured envelope. Check success field.

Fields

success (boolean)
  • true: Repair succeeded, use repaired object
  • false: Unrecoverable error, check metadata.errors
repaired (object | null)
  • The fixed JSON object
  • null if repair failed
metadata.confidence (string)
  • "high": Only structural fixes (safe)
  • "medium": Schema repairs or warnings
  • "low": Ambiguous repairs, review carefully
  • "n/a": Reserved (not currently emitted; perfect input returns "high")
metadata.was_repaired (boolean)
  • true: Shim made changes
  • false: Input was already valid
metadata.syntax_repairs (array)
  • Structural fixes: missing brackets, trailing commas, markdown fences
  • Always safe
metadata.schema_repairs (array)
  • Type coercion, field validation
  • Review these if confidence is "medium" or "low"
metadata.warnings (array)
  • Non-critical issues
  • Repair succeeded but review recommended
metadata.errors (array)
  • Critical failures
  • Repair failed if this is non-empty

Examples

Basic Repair

cURL
Response

With Schema Validation

cURL
Response

Failed Repair

cURL
Response

Error Codes

See Error Codes Reference for full list. Common errors:
  • INVALID_REQUEST: Missing or invalid parameters
  • PAYLOAD_TOO_LARGE: Input exceeds 5MB
  • UNRECOVERABLE_SYNTAX_ERROR: JSON too malformed to repair
  • SCHEMA_VALIDATION_FAILED: Repaired JSON doesn’t match schema

Rate Limits

See Rate Limits Guide for details.

Next Steps

Streaming Endpoints

Repair JSON token-by-token

Response Object

Full response schema

Error Codes

Complete error reference

TypeScript SDK

Use the official SDK