{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/observeinc/json-schema/observeinc-tag-list-response-schema.json",
  "title": "TagListResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/observeinc-tags-api-openapi.yml#/components/schemas/Tag-ListResponse",
  "type": "object",
  "required": [
    "tags",
    "meta"
  ],
  "properties": {
    "tags": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Tag-Resource"
      }
    },
    "meta": {
      "$ref": "#/$defs/Meta"
    }
  },
  "$defs": {
    "Dataset-FieldPath": {
      "title": "FieldPath",
      "type": "object",
      "required": [
        "field",
        "path"
      ],
      "properties": {
        "field": {
          "type": "string"
        },
        "path": {
          "type": "string"
        }
      }
    },
    "DatasetBrief": {
      "title": "DatasetBrief",
      "type": "object",
      "description": "Brief record fields for a DatasetRef (label, description, iconUrl, contentType). Field naming mirrors ObjectBrief in this same file (iconUrl, not icon) for consistency across reference-brief pairs.\n",
      "required": [
        "label",
        "description",
        "iconUrl",
        "contentType"
      ],
      "properties": {
        "label": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "iconUrl": {
          "type": "string"
        },
        "contentType": {
          "$ref": "#/$defs/DatasetContentType",
          "description": "The type of data the referenced dataset contains — Resource, Log,\nMetric, OTelSpan, OTelTrace, or Unknown. Derived from the dataset's\nkind and interface bindings.\n"
        }
      }
    },
    "DatasetContentType": {
      "title": "DatasetContentType",
      "type": "string",
      "description": "The type of data a dataset contains. For Resource datasets, this is\ndetermined by the dataset kind. For other kinds, it is derived from the\ndataset's interface bindings. Returns Unknown if no recognized interface\nis found.\n",
      "enum": [
        "Unknown",
        "Resource",
        "Log",
        "Metric",
        "OTelSpan",
        "OTelTrace"
      ]
    },
    "DatasetRef": {
      "title": "DatasetRef",
      "type": "object",
      "description": "A reference to a dataset. Always carries the id; the optional `record` field carries the brief metadata, populated when expand=true. Mirrors ObjectRef (see ObjectRef / ObjectBrief in this file).\n",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/ObjectId"
        },
        "record": {
          "$ref": "#/$defs/DatasetBrief"
        }
      }
    },
    "Meta": {
      "description": "List Response Metadata",
      "type": "object",
      "required": [
        "totalCount"
      ],
      "properties": {
        "totalCount": {
          "description": "The total number of resources available, independent of pagination.\nThe API may return -1 if the total count is unknown or cannot be computed\nin reasonable time.\n",
          "type": "integer",
          "format": "int64"
        }
      }
    },
    "ObjectId": {
      "type": "string",
      "format": "ObjectId"
    },
    "Tag-Mapping": {
      "title": "TagMapping",
      "type": "object",
      "description": "A single per-dataset definition of a tag.\n",
      "required": [
        "dataset",
        "path",
        "origin",
        "discoveryRuleAlias",
        "createdBy"
      ],
      "properties": {
        "dataset": {
          "$ref": "#/$defs/DatasetRef"
        },
        "path": {
          "$ref": "#/$defs/Dataset-FieldPath"
        },
        "origin": {
          "anyOf": [
            {
              "$ref": "#/$defs/DatasetRef"
            },
            {
              "type": "null"
            }
          ],
          "description": "The dataset in which this mapping was originally declared. When\nthe tag was declared directly on `dataset`, `origin.id` equals\n`dataset.id`. When the tag was inherited from an upstream\ndataset, `origin` points to that upstream dataset. Only\nmeaningful for `kind=Correlation`; always `null` for\n`kind=Metric`. Mirrors the GraphQL `TagSourceInfo.origin`\nconvention.\n"
        },
        "discoveryRuleAlias": {
          "type": [
            "string",
            "null"
          ],
          "description": "The discovery rule alias that created this mapping, or `null` when\nthe mapping was not created by a discovery rule. Only meaningful\nfor `kind=Correlation`; always `null` for `kind=Metric`. If the tag\nis inherited from an upstream dataset, this field points to the\ndiscovery rule alias that created the mapping on the origin\ndataset.\n"
        },
        "createdBy": {
          "anyOf": [
            {
              "$ref": "#/$defs/User"
            },
            {
              "type": "null"
            }
          ],
          "description": "User who declared this mapping on `origin`. Only meaningful for\n`kind=Correlation`; always `null` for `kind=Metric`.\n"
        }
      }
    },
    "Tag-Resource": {
      "title": "TagObject",
      "type": "object",
      "description": "A tag (correlation or metric) along with every dataset that defines\nit. Tags are identified by `(name, kind)`; there is no ObjectId for\na tag — `name` is the natural identifier within a kind.\n",
      "required": [
        "name",
        "kind",
        "datasetCount",
        "mappings"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Tag name. Natural identifier within `kind`."
        },
        "kind": {
          "$ref": "#/$defs/TagKind"
        },
        "datasetCount": {
          "type": "integer",
          "format": "int64",
          "description": "Number of distinct datasets in which this tag is defined."
        },
        "mappings": {
          "type": "array",
          "description": "Per-dataset definitions of the tag. Always populated; use the\n`mappings.exists(m, m.dataset.id == ...)` CEL quantifier to\nfilter tags scoped to a specific dataset.\n\nLimited to 20 entries.\n",
          "items": {
            "$ref": "#/$defs/Tag-Mapping"
          }
        },
        "sampleValues": {
          "type": "array",
          "description": "Up to 20 sample values observed for this tag, scoped to the\ndatasets the caller can view. Present only when the request sets\n`sampleValues=true`. This is a bounded, non-paginated sample, NOT\nthe full value set; it may be empty or absent when values could\nnot be retrieved. Use `GET /v1/tags/values` to search values.\n",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "TagKind": {
      "title": "TagKind",
      "type": "string",
      "enum": [
        "Metric",
        "Correlation"
      ],
      "description": "Kind of tag."
    },
    "User": {
      "title": "User",
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "title": "User Identifier",
          "$ref": "#/$defs/ObjectId"
        },
        "label": {
          "title": "User Label",
          "type": "string"
        },
        "timezone": {
          "type": "string"
        },
        "locale": {
          "type": "string"
        }
      }
    }
  }
}