Resources / Guides

JSON Schema for APIs and AI tools: a practical guide

Why JSON Schema matters for APIs and AI agent tools, the fields that matter, and examples you can copy.

JSON Schema describes the shape of JSON: which fields exist, their types, which are required. For APIs it's documentation and validation in one; for AI tools it's how the model knows what to send.

The fields that matter

An example

{
  "type": "object",
  "properties": {
    "city": { "type": "string", "description": "City name, e.g. Paris" },
    "units": { "type": "string", "enum": ["metric", "imperial"] }
  },
  "required": ["city"]
}

Tips for AI tools

Describe every field as if to a new colleague, prefer enums over free text, and keep inputs flat. A clear schema reduces wrong calls more than any prompt tweak.

In Wisp

Every endpoint can declare an input and an output schema. The assistant writes them with the code, they validate requests, and they become the tool definition when the project is used as an MCP server.

Try it: JSON to JSON Schema converter

Build it with Wisp — describe an API, get it live.

Related