{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/markifact-com/json-schema/markifact-com-log-schema.json",
  "title": "Log",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/markifact-com-openapi.json#/components/schemas/Log",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Log ID."
    },
    "operation_id": {
      "type": "string",
      "description": "Markifact operation that ran."
    },
    "operation_version": {
      "type": [
        "integer",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "success",
        "error",
        "skipped",
        "stop",
        "start"
      ]
    },
    "source": {
      "$ref": "#/$defs/LogSource"
    },
    "user": {
      "$ref": "#/$defs/LogUser"
    },
    "started_at": {
      "type": "integer",
      "format": "int64",
      "description": "Start time in Unix seconds."
    },
    "completed_at": {
      "type": [
        "integer",
        "null"
      ],
      "format": "int64",
      "description": "Completion time in Unix seconds. Null while the operation is still running."
    },
    "credits_used": {
      "type": "integer"
    },
    "cache_hit": {
      "type": "boolean",
      "description": "Whether the result came from cache instead of the provider."
    },
    "input": {
      "description": "Input the operation ran with. Shape depends on the operation."
    },
    "output": {
      "description": "Result the operation returned, or the error payload when status is error. Shape depends on the operation."
    },
    "metadata": {
      "type": "object",
      "additionalProperties": true,
      "description": "Extra context. Keys depend on the source: node_id, node_label, and retry_attempts for workflows, tool_name for MCP."
    }
  },
  "required": [
    "id",
    "operation_id",
    "status",
    "source",
    "user",
    "started_at",
    "credits_used",
    "cache_hit",
    "metadata"
  ],
  "$defs": {
    "LogSource": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "mcp",
            "agent",
            "workflow"
          ],
          "description": "What ran the operation."
        },
        "id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Parent object ID: the MCP server, agent conversation, or workflow."
        },
        "run_id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Single execution ID. Set on workflow logs, null otherwise."
        },
        "name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Current parent name, falling back to the name captured at log time if the parent was deleted."
        }
      },
      "required": [
        "type"
      ]
    },
    "LogUser": {
      "type": "object",
      "properties": {
        "id": {
          "type": [
            "string",
            "null"
          ],
          "description": "Markifact user ID."
        },
        "email": {
          "type": [
            "string",
            "null"
          ],
          "description": "Email of the team member who ran the operation."
        }
      }
    }
  }
}