{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/geoapify/json-schema/geoapify-calculate-route-matrix-tool-call-response-schema.json",
  "title": "CalculateRouteMatrixToolCallResponse",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/geoapify-routing-api-openapi.yml#/components/schemas/CalculateRouteMatrixToolCallResponse",
  "oneOf": [
    {
      "$ref": "#/$defs/CalculateRouteMatrixToolCallSuccessResponse"
    },
    {
      "$ref": "#/$defs/ToolCallErrorResponse"
    },
    {
      "$ref": "#/$defs/JsonRpcErrorResponse"
    }
  ],
  "$defs": {
    "CalculateRouteMatrixOutput": {
      "type": "object",
      "description": "Resolved matrix locations and source-to-target travel costs.",
      "required": [
        "sources",
        "targets",
        "sources_to_targets",
        "units",
        "distance_units",
        "time_units"
      ],
      "properties": {
        "sources": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "A resolved location in latitude/longitude form.",
            "required": [
              "lat",
              "lon"
            ],
            "properties": {
              "lat": {
                "type": "number",
                "minimum": -90,
                "maximum": 90
              },
              "lon": {
                "type": "number",
                "minimum": -180,
                "maximum": 180
              }
            }
          },
          "description": "Resolved source locations."
        },
        "targets": {
          "type": "array",
          "items": {
            "type": "object",
            "description": "A resolved location in latitude/longitude form.",
            "required": [
              "lat",
              "lon"
            ],
            "properties": {
              "lat": {
                "type": "number",
                "minimum": -90,
                "maximum": 90
              },
              "lon": {
                "type": "number",
                "minimum": -180,
                "maximum": 180
              }
            }
          },
          "description": "Resolved target locations."
        },
        "sources_to_targets": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "distance",
                "time",
                "source_index",
                "target_index"
              ],
              "properties": {
                "distance": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "time": {
                  "type": [
                    "number",
                    "null"
                  ]
                },
                "source_index": {
                  "type": "integer"
                },
                "target_index": {
                  "type": "integer"
                }
              }
            }
          },
          "description": "Rows correspond to sources and columns correspond to targets."
        },
        "units": {
          "type": "string",
          "enum": [
            "metric",
            "imperial"
          ],
          "description": "Requested unit system."
        },
        "distance_units": {
          "type": "string",
          "enum": [
            "meters",
            "miles"
          ],
          "description": "Unit used by matrix distance values."
        },
        "time_units": {
          "type": "string",
          "enum": [
            "seconds"
          ],
          "description": "Unit used by matrix time values."
        }
      }
    },
    "CalculateRouteMatrixToolCallSuccessResponse": {
      "type": "object",
      "description": "Successful JSON-RPC response with tool-specific structured content.",
      "required": [
        "jsonrpc",
        "id",
        "result"
      ],
      "properties": {
        "jsonrpc": {
          "const": "2.0"
        },
        "id": {
          "$ref": "#/$defs/JsonRpcId"
        },
        "result": {
          "type": "object",
          "required": [
            "content",
            "structuredContent",
            "isError"
          ],
          "properties": {
            "content": {
              "type": "array",
              "description": "JSON text representation of structuredContent.",
              "items": {
                "type": "object",
                "required": [
                  "type",
                  "text"
                ],
                "properties": {
                  "type": {
                    "const": "text"
                  },
                  "text": {
                    "type": "string",
                    "description": "JSON-encoded copy of structuredContent."
                  }
                }
              }
            },
            "structuredContent": {
              "$ref": "#/$defs/CalculateRouteMatrixOutput"
            },
            "isError": {
              "const": false
            }
          }
        }
      }
    },
    "JsonRpcError": {
      "type": "object",
      "description": "JSON-RPC error object.",
      "required": [
        "code",
        "message"
      ],
      "properties": {
        "code": {
          "type": "integer",
          "description": "JSON-RPC error code, such as -32600 for an invalid request, -32601 for an unknown method, or -32602 for invalid parameters."
        },
        "message": {
          "type": "string",
          "description": "Human-readable JSON-RPC error message."
        },
        "data": {
          "description": "Optional machine-readable error details."
        }
      }
    },
    "JsonRpcErrorResponse": {
      "type": "object",
      "description": "JSON-RPC error response returned for invalid requests or unknown methods.",
      "required": [
        "jsonrpc",
        "id",
        "error"
      ],
      "properties": {
        "jsonrpc": {
          "const": "2.0"
        },
        "id": {
          "$ref": "#/$defs/JsonRpcId"
        },
        "error": {
          "$ref": "#/$defs/JsonRpcError"
        }
      }
    },
    "JsonRpcId": {
      "description": "JSON-RPC request identifier. The server echoes this value in the response.",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ]
    },
    "ToolCallErrorResponse": {
      "type": "object",
      "description": "JSON-RPC tools/call response when tool execution fails.",
      "required": [
        "jsonrpc",
        "id",
        "result"
      ],
      "properties": {
        "jsonrpc": {
          "const": "2.0"
        },
        "id": {
          "$ref": "#/$defs/JsonRpcId"
        },
        "result": {
          "type": "object",
          "required": [
            "content",
            "isError"
          ],
          "properties": {
            "content": {
              "type": "array",
              "description": "Tool error details represented as JSON text.",
              "items": {
                "type": "object",
                "required": [
                  "type",
                  "text"
                ],
                "properties": {
                  "type": {
                    "const": "text"
                  },
                  "text": {
                    "type": "string",
                    "description": "JSON-encoded GatewayError with statusCode, error, and message fields."
                  }
                }
              }
            },
            "isError": {
              "const": true
            }
          }
        }
      }
    }
  }
}