# Discover JSON field paths and types for a mongo.changes collection

`POST /metrics/solution/schema/discover`

Infer JSON field paths and ClickHouse types from recent `mongo.changes` data (last 7 days). Useful for `contextual:*` collections. For `native-object:*` collections, prefer the platform object-type JSON Schema. Details: [Solution Metrics AI Reference](https://github.com/ContextualIO/observability-api/blob/main/docs/solution-metrics-api.md#schema-discovery--post-solutionschema-discover)

[Observability API guide](https://docs.contextual.io/tenants/tenant-apis/observability-api.md)

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "Observability API",
    "description": "Query logs, metrics, traces, and solution analytics against ClickHouse. See **Solution Metrics** endpoints and external docs for the AI reference guide.",
    "version": "1.7.7"
  },
  "security": [
    {
      "jwt": []
    }
  ],
  "servers": [
    {
      "url": "https://observability.{tenantId}.my.contextual.io/api/v1",
      "variables": {
        "tenantId": {
          "default": "YOUR-TENANT-ID"
        }
      }
    }
  ],
  "paths": {
    "/metrics/solution/schema/discover": {
      "post": {
        "tags": [
          "Solution Metrics"
        ],
        "summary": "Discover JSON field paths and types for a mongo.changes collection",
        "description": "Infer JSON field paths and ClickHouse types from recent `mongo.changes` data (last 7 days). Useful for `contextual:*` collections. For `native-object:*` collections, prefer the platform object-type JSON Schema. Details: [Solution Metrics AI Reference](https://github.com/ContextualIO/observability-api/blob/main/docs/solution-metrics-api.md#schema-discovery--post-solutionschema-discover)",
        "parameters": [],
        "deprecated": false,
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "coll_name": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "coll_name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$SolutionSchemaDiscoverResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {}
          },
          "401": {
            "description": "Missing or invalid authorization header",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Invalid permissions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/$ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "$SolutionSchemaDiscoverResponse": {
        "type": "object",
        "properties": {
          "db_name": {
            "type": "string"
          },
          "coll_name": {
            "type": "string"
          },
          "total_paths": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "schema": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "type": {
                  "type": "string"
                },
                "is_numeric": {
                  "type": "boolean"
                },
                "is_aggregatable": {
                  "type": "boolean"
                },
                "is_groupable": {
                  "type": "boolean"
                }
              },
              "required": [
                "path",
                "type",
                "is_numeric",
                "is_aggregatable",
                "is_groupable"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "db_name",
          "coll_name",
          "total_paths",
          "schema"
        ],
        "additionalProperties": false
      },
      "$ErrorResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": [
              "string",
              "number"
            ]
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {}
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      }
    }
  }
}
```