{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/latitude-so/main/json-schema/latitude-so-session-detail-schema.json",
  "title": "SessionDetail",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/latitude-so-openapi.json#/components/schemas/SessionDetail",
  "type": "object",
  "properties": {
    "organizationId": {
      "type": "string",
      "description": "Organization that owns this session."
    },
    "projectId": {
      "type": "string",
      "description": "Project this session belongs to."
    },
    "sessionId": {
      "type": "string",
      "description": "Session identifier set by the SDK. Groups the traces of one conversation."
    },
    "traceCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Number of traces in the session."
    },
    "traceIds": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Identifiers of the traces that make up the session."
    },
    "spanCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Total number of spans across the session's traces."
    },
    "errorCount": {
      "type": "integer",
      "minimum": 0,
      "description": "Number of spans flagged with an error status."
    },
    "startTime": {
      "type": "string",
      "description": "ISO-8601 timestamp of the session's earliest span."
    },
    "endTime": {
      "type": "string",
      "description": "ISO-8601 timestamp of the session's latest span."
    },
    "lastActivityTime": {
      "type": "string",
      "description": "ISO-8601 timestamp of the session's most recent span start."
    },
    "durationNs": {
      "type": "number",
      "description": "Active execution time of the session in nanoseconds, not wall-clock."
    },
    "timeToFirstTokenNs": {
      "type": "number",
      "description": "Nanoseconds from the start of the first LLM span to its first emitted token. `0` if not measured."
    },
    "tokensInput": {
      "type": "number",
      "description": "Total input tokens across the session's LLM spans."
    },
    "tokensOutput": {
      "type": "number",
      "description": "Total output tokens across the session's LLM spans."
    },
    "tokensCacheRead": {
      "type": "number",
      "description": "Total tokens served from the provider's prompt cache."
    },
    "tokensCacheCreate": {
      "type": "number",
      "description": "Total tokens written to the provider's prompt cache."
    },
    "tokensReasoning": {
      "type": "number",
      "description": "Total reasoning tokens reported by the model."
    },
    "tokensTotal": {
      "type": "number",
      "description": "Sum of all token counters."
    },
    "costInputMicrocents": {
      "type": "number",
      "description": "Cost of input tokens in microcents (100,000,000 per USD)."
    },
    "costOutputMicrocents": {
      "type": "number",
      "description": "Cost of output tokens in microcents (100,000,000 per USD)."
    },
    "costTotalMicrocents": {
      "type": "number",
      "description": "Total cost in microcents (100,000,000 per USD)."
    },
    "userId": {
      "type": [
        "string",
        "null"
      ],
      "description": "End-user identifier set by the SDK. `null` when absent."
    },
    "userEmail": {
      "type": [
        "string",
        "null"
      ],
      "description": "End-user email set by the SDK. `null` when absent."
    },
    "simulationId": {
      "type": [
        "string",
        "null"
      ],
      "description": "CUID of the simulation that produced this session. `null` when not a simulation."
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Free-form tags attached at ingest time."
    },
    "metadata": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      },
      "description": "Free-form metadata attached at ingest time."
    },
    "models": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Model identifiers seen across the session's LLM spans."
    },
    "providers": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "LLM-provider identifiers seen across the session's spans."
    },
    "serviceNames": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "OpenTelemetry `service.name` values seen in the session."
    },
    "agentNames": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Agent names seen across the session's spans."
    },
    "definedTools": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Tool names declared available across the session's spans."
    },
    "rootSpanId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Identifier of the session's root span. `null` when no root span has been ingested."
    },
    "rootSpanName": {
      "type": [
        "string",
        "null"
      ],
      "description": "`name` attribute of the root span. `null` when no root span has been ingested."
    },
    "latestTraceId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Identifier of the trace that produced the session's latest output. `null` when no trace produced output."
    },
    "conversation": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/GenAIMessage"
      },
      "description": "Conversation of the session, in OpenTelemetry GenAI format: the system instructions, then the messages of the session's latest LLM completion, followed by its generated output."
    }
  },
  "required": [
    "organizationId",
    "projectId",
    "sessionId",
    "traceCount",
    "traceIds",
    "spanCount",
    "errorCount",
    "startTime",
    "endTime",
    "lastActivityTime",
    "durationNs",
    "timeToFirstTokenNs",
    "tokensInput",
    "tokensOutput",
    "tokensCacheRead",
    "tokensCacheCreate",
    "tokensReasoning",
    "tokensTotal",
    "costInputMicrocents",
    "costOutputMicrocents",
    "costTotalMicrocents",
    "userId",
    "userEmail",
    "simulationId",
    "tags",
    "metadata",
    "models",
    "providers",
    "serviceNames",
    "agentNames",
    "definedTools",
    "rootSpanId",
    "rootSpanName",
    "latestTraceId",
    "conversation"
  ],
  "$defs": {
    "GenAIMessage": {
      "type": "object",
      "additionalProperties": {
        "nullable": true
      },
      "description": "Message in OpenTelemetry GenAI format (`role` + content parts + optional tool calls)."
    }
  }
}