Tool Use & Function Calling

How do you define nested objects in Claude's tool schema?

QUICK ANSWER

Define nested structures by nesting object properties inside properties in your tool definition, matching the JSON Schema Draft 4 specification.

Nested Schema Example

{
  "name": "update_user_profile",
  "description": "Updates profile details.",
  "input_schema": {
    "type": "object",
    "properties": {
      "user_id": { "type": "string" },
      "profile": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "email": { "type": "string" }
        },
        "required": ["name"]
      }
    },
    "required": ["user_id", "profile"]
  }
}
Verified against: Anthropic API Tool Use v1