{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/run402-com/json-schema/run402-com-function-run-handle-schema.json",
  "title": "FunctionRunHandle",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/run402-com-functions-api-openapi.yml#/components/schemas/FunctionRunHandle",
  "type": "object",
  "required": [
    "run_id",
    "function_name",
    "event_type",
    "status",
    "terminal",
    "generation",
    "run_at",
    "source",
    "attempts",
    "created_at",
    "updated_at",
    "next_actions"
  ],
  "properties": {
    "run_id": {
      "type": "string",
      "pattern": "^fnrun_[A-Za-z0-9_-]{4,128}$"
    },
    "function_name": {
      "type": "string"
    },
    "event_type": {
      "type": "string"
    },
    "status": {
      "$ref": "#/$defs/FunctionRunStatus"
    },
    "terminal": {
      "type": "boolean"
    },
    "generation": {
      "type": "integer",
      "minimum": 1
    },
    "run_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "source": {
      "type": "object",
      "additionalProperties": true
    },
    "attempts": {
      "type": "object",
      "required": [
        "current",
        "max",
        "total"
      ],
      "properties": {
        "current": {
          "type": "integer",
          "minimum": 0
        },
        "max": {
          "type": "integer",
          "minimum": 1
        },
        "total": {
          "type": "integer",
          "minimum": 0
        },
        "next_attempt_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "last_attempt": {
      "type": "object",
      "properties": {
        "attempt_id": {
          "type": "string",
          "pattern": "^fnatt_[A-Za-z0-9_-]{4,128}$"
        },
        "number": {
          "type": "integer",
          "minimum": 1
        },
        "started_at": {
          "type": "string",
          "format": "date-time"
        },
        "completed_at": {
          "type": "string",
          "format": "date-time"
        },
        "duration_ms": {
          "type": "integer",
          "minimum": 0
        },
        "response_status": {
          "type": "integer",
          "minimum": 100,
          "maximum": 599
        },
        "error": {
          "$ref": "#/$defs/FunctionRunErrorInfo"
        }
      }
    },
    "last_error": {
      "$ref": "#/$defs/FunctionRunErrorInfo"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "completed_at": {
      "type": "string",
      "format": "date-time"
    },
    "deduplicated": {
      "type": "boolean"
    },
    "next_actions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    }
  },
  "$defs": {
    "FunctionRunErrorInfo": {
      "type": "object",
      "required": [
        "code",
        "message",
        "retryable"
      ],
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "retryable": {
          "type": "boolean"
        }
      }
    },
    "FunctionRunStatus": {
      "type": "string",
      "enum": [
        "scheduled",
        "queued",
        "running",
        "retrying",
        "blocked",
        "succeeded",
        "failed",
        "cancelled",
        "expired"
      ]
    }
  }
}