Claude API Tool Use Schema Definition Guide
Defining a tool schema for Claude's API means describing a function Claude can call using a JSON Schema object nested inside a tools array in your request. Claude reads the tool's name, description, and input_schema to decide when to invoke it and what arguments to pass. Get the schema wrong — vague descriptions, missing required fields, incorrect types — and Claude either skips the tool, hallucinates arguments, or sends malformed JSON your code can't parse.
This article covers the exact structure Claude expects, the fields that matter most for reliable tool calls, and the mistakes that cause tool use to fail silently or produce bad arguments.
The basic shape of a tool definition
Every tool in the tools array needs three top-level fields:
{
"name": "get_weather",
"description": "Get the current weather for a specific city and country. Returns temperature in Celsius and a short condition summary.",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city name, e.g. 'Berlin'"
},
"country_code": {
"type": "string",
"description": "Two-letter ISO country code, e.g. 'DE'"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "Temperature unit for the response"
}
},
"required": ["city", "country_code"]
}
}
input_schema is a standard JSON Schema object — type, properties, required, enum, and nested objects all behave the way you'd expect from any JSON Schema validator. Claude doesn't validate the schema itself before calling the tool; it uses the schema to generate arguments that should conform to it, so the quality of your descriptions directly affects the quality of the output.
Why descriptions matter more than types
The type field tells Claude the data shape, but the description field tells Claude when and why to use the field. A schema with correct types and empty descriptions will still produce bad tool calls because Claude has no context for what the field represents.
Weak:
{ "type": "string", "description": "id" }
Strong:
{ "type": "string", "description": "The internal order ID, formatted as 'ORD-' followed by 6 digits, e.g. 'ORD-004521'. Do not use the customer-facing tracking number here." }
The same logic applies to the top-level tool description. Treat it as documentation for a model, not a human skimming an API reference — spell out edge cases, formatting rules, and what the tool returns.
Required fields and optional parameters
List every field Claude must always supply in required. Fields not listed there are treated as optional, and Claude will omit them unless the user's request clearly implies a value. If a parameter has a sensible default, say so in the description rather than marking it required:
"page_size": {
"type": "integer",
"description": "Number of results per page. Defaults to 20 if not specified.",
"minimum": 1,
"maximum": 100
}
Adding minimum/maximum/enum constraints where applicable reduces out-of-range values reaching your backend, even though Claude isn't guaranteed to always respect them — your server-side validation should still be the final gate.
Nested objects and arrays
Tool schemas support nested objects and arrays of objects, which is useful for tools that take structured payloads:
"input_schema": {
"type": "object",
"properties": {
"recipients": {
"type": "array",
"items": {
"type": "object",
"properties": {
"email": { "type": "string", "description": "Recipient email address" },
"name": { "type": "string", "description": "Recipient display name" }
},
"required": ["email"]
}
}
},
"required": ["recipients"]
}
Keep nesting shallow where possible. Deeply nested schemas (objects inside arrays inside objects, three levels deep) increase the chance Claude flattens or misplaces a field, especially on longer conversations where the schema has to compete with a lot of context.
Handling the tool_use response
When Claude decides to call a tool, the response content includes a block like:
{
"type": "tool_use",
"id": "toolu_01A2...",
"name": "get_weather",
"input": { "city": "Lisbon", "country_code": "PT" }
}
Your code executes the function, then sends the result back as a tool_result block referencing the same id, in a follow-up message. This round trip — define schema, receive tool_use, execute, return tool_result — is the full loop, and it's the same whether you're calling Claude directly or through a proxy.
If you're routing requests through SubToAPI, the tool definition format and the tool_use/tool_result flow are unchanged — you keep writing standard Claude-compatible JSON Schema tool definitions, and SubToAPI handles authentication with your sub_live_... key, streaming, and usage logging on top. See the tool use docs for request examples, or the messages reference if you're combining tool calls with regular message turns.
Common mistakes to avoid
- Vague names.
handle_requesttells Claude nothing.cancel_subscriptiondoes. - Missing enum constraints. If a field only accepts three values, declare them with
enuminstead of describing them in prose — Claude is far more reliable at respecting an enum than a sentence. - Overlapping tools. Two tools with similar names and descriptions (
search_usersandfind_users) cause Claude to pick inconsistently. Merge them or make the distinction explicit in both descriptions. - No description on the schema's top-level object. Add a sentence to
input_schemaitself when the tool's overall purpose isn't obvious fromnamealone. - Ignoring
required. Leaving everything optional makes Claude guess which fields actually matter.
Testing your schema
Before shipping a tool definition, run it through a few adversarial prompts — ambiguous requests, requests missing obvious parameters, requests that could match two different tools. If Claude calls the wrong tool or omits a required argument, that's a signal to tighten the description, not necessarily add more constraints. If you're testing against SubToAPI, the quickstart guide walks through sending your first tool-enabled request and inspecting the response.
FAQ
What's the difference between description and input_schema description fields?
The top-level description tells Claude when to use the tool as a whole. Descriptions inside input_schema.properties tell Claude how to fill in each individual argument. Both matter — a tool can have a perfect top-level description and still receive bad arguments if its parameter descriptions are thin.
Does Claude validate input_schema automatically?
No. Claude generates arguments that aim to match the schema, but it doesn't run a validator against its own output before sending the tool_use block. Your application code should still validate incoming arguments before executing the tool.
Can I use JSON Schema features like oneOf or anyOf?
Basic JSON Schema constructs like type, enum, required, nested object/array, and numeric bounds work reliably. More exotic constructs like oneOf/anyOf are less consistently honored — if you need conditional logic, it's usually more reliable to split the behavior into two separate, clearly-named tools instead.