{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/klanexai-com/json-schema/klanexai-com-execution-schema.json",
  "title": "Execution",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/klanexai-com-openapi.yml#/components/schemas/Execution",
  "type": "object",
  "properties": {
    "execution_id": {
      "type": "string"
    },
    "status": {
      "$ref": "#/$defs/ExecutionStatus"
    },
    "attempts": {
      "type": "integer"
    },
    "max_attempts": {
      "type": "integer"
    },
    "target": {
      "$ref": "#/$defs/Target"
    },
    "callback_url": {
      "type": "string"
    },
    "result": {
      "$ref": "#/$defs/ExecutionResult"
    },
    "error": {
      "$ref": "#/$defs/ExecError"
    },
    "replay_of": {
      "type": "string"
    },
    "requires_approval": {
      "type": "boolean"
    },
    "approval": {
      "$ref": "#/$defs/Approval"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time",
      "description": "When the execution becomes eligible for deletion — submission time plus the plan's retention window (Free 7 days, Starter 30, Pro 90).\n"
    }
  },
  "$defs": {
    "Approval": {
      "type": "object",
      "properties": {
        "decision": {
          "type": "string",
          "enum": [
            "approved",
            "rejected"
          ]
        },
        "reason": {
          "type": "string"
        },
        "decided_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "ErrorCode": {
      "type": "string",
      "enum": [
        "SCHEMA_INVALID",
        "TARGET_TIMEOUT",
        "TARGET_RATE_LIMITED",
        "TARGET_UNAVAILABLE",
        "TARGET_REJECTED",
        "CIRCUIT_OPEN",
        "ATTEMPTS_EXHAUSTED",
        "APPROVAL_REJECTED",
        "CONNECTION_UNAUTHORIZED",
        "INTERNAL"
      ]
    },
    "ExecError": {
      "type": "object",
      "properties": {
        "code": {
          "$ref": "#/$defs/ErrorCode"
        },
        "message": {
          "type": "string"
        },
        "llm_hint": {
          "type": "string",
          "description": "Paste into the agent's context for self-correction."
        }
      }
    },
    "ExecutionResult": {
      "type": "object",
      "properties": {
        "status_code": {
          "type": "integer"
        },
        "body": {
          "type": "string",
          "description": "Target response body, truncated to 64 KiB."
        }
      }
    },
    "ExecutionStatus": {
      "type": "string",
      "enum": [
        "PENDING_APPROVAL",
        "QUEUED",
        "RUNNING",
        "RETRYING",
        "SUCCEEDED",
        "FAILED"
      ]
    },
    "Target": {
      "type": "object",
      "required": [
        "url"
      ],
      "properties": {
        "method": {
          "type": "string",
          "enum": [
            "GET",
            "POST",
            "PUT",
            "PATCH",
            "DELETE"
          ],
          "default": "POST"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Absolute http(s) URL of the third-party API."
        },
        "headers": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Your third-party credentials. Encrypted at rest; values are REDACTED in all reads.\n"
        },
        "connection_id": {
          "type": "string",
          "description": "Reference a vault connection; its managed token is injected at execution time instead of passing credentials in headers.\n"
        },
        "timeout_ms": {
          "type": "integer",
          "default": 30000,
          "maximum": 120000,
          "description": "Per-attempt timeout."
        }
      }
    }
  }
}