{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/weavz-io/json-schema/weavz-io-approval-request-schema.json",
  "title": "ApprovalRequest",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/weavz-io-openapi.json#/components/schemas/ApprovalRequest",
  "type": "object",
  "required": [
    "id",
    "orgId",
    "source",
    "status",
    "integrationName",
    "actionName",
    "inputHash",
    "inputPreview",
    "redactedPaths",
    "riskReasons",
    "defaultOnTimeout",
    "approvalAccessMode",
    "expiresAt",
    "createdAt",
    "updatedAt"
  ],
  "properties": {
    "reviewAccess": {
      "$ref": "#/$defs/ApprovalReviewAccess",
      "description": "Current caller decision access, supplied by the approval detail endpoint."
    },
    "id": {
      "type": "string",
      "description": "Approval request ID."
    },
    "policyId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "orgId": {
      "type": "string"
    },
    "workspaceId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "endUserId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "source": {
      "type": "string",
      "enum": [
        "rest",
        "sdk",
        "mcp_tools",
        "mcp_code",
        "playground",
        "trigger"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "approved",
        "rejected",
        "expired",
        "canceled",
        "consumed"
      ]
    },
    "mcpServerId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "mcpMode": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "TOOLS",
        "CODE",
        null
      ]
    },
    "mcpAuthMode": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "oauth",
        "bearer",
        "oauth_and_bearer",
        null
      ]
    },
    "workspaceIntegrationId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "integrationName": {
      "type": "string"
    },
    "integrationAlias": {
      "type": [
        "string",
        "null"
      ]
    },
    "actionName": {
      "type": "string"
    },
    "connectionStrategy": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "fixed",
        "per_user",
        "per_user_with_fallback",
        null
      ]
    },
    "connectionScopeSummary": {
      "type": [
        "string",
        "null"
      ]
    },
    "partialIds": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "enforcedKeys": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "inputHash": {
      "type": "string",
      "description": "Hash of the exact resolved input and execution context."
    },
    "inputPreview": {
      "type": "object",
      "additionalProperties": true,
      "description": "Redacted preview of the final resolved input. For MCP Code Mode batch approvals, `json.type` is `mcp_code_batch_run` and includes deterministic summaries, predicted tools, code hash, and tool-surface hash."
    },
    "redactedPaths": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "riskReasons": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "riskScore": {
      "type": [
        "number",
        "null"
      ]
    },
    "riskCategory": {
      "type": [
        "string",
        "null"
      ]
    },
    "approverSpec": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "defaultOnTimeout": {
      "type": "string",
      "enum": [
        "reject",
        "expire"
      ],
      "description": "Final automatic decision when the pending request reaches expiresAt without a human decision."
    },
    "approvalAccessMode": {
      "type": "string",
      "enum": [
        "dashboard_only",
        "dashboard_and_hosted_link",
        "hosted_link_only"
      ],
      "description": "Access mode captured from the matched policy when this request was created."
    },
    "approvalUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Approval URL allowed by the policy access mode."
    },
    "hostedApprovalUrl": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri"
    },
    "externalCorrelationId": {
      "type": [
        "string",
        "null"
      ]
    },
    "idempotencyKey": {
      "type": [
        "string",
        "null"
      ]
    },
    "requestedByType": {
      "type": [
        "string",
        "null"
      ]
    },
    "requestedById": {
      "type": [
        "string",
        "null"
      ]
    },
    "decidedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "consumedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "expiresAt": {
      "type": "string",
      "format": "date-time"
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "webhookDeliveries": {
      "type": "array",
      "description": "Recent lifecycle webhook delivery attempts, included on approval detail responses when webhook approvers are configured.",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "eventType": {
            "type": "string"
          },
          "callbackUrl": {
            "type": "string",
            "format": "uri"
          },
          "attempt": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "success",
              "failed",
              "retrying"
            ]
          },
          "httpStatus": {
            "type": [
              "integer",
              "null"
            ]
          },
          "errorMessage": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "deliveredAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      }
    }
  },
  "$defs": {
    "ApprovalReviewAccess": {
      "type": "object",
      "required": [
        "canDecide"
      ],
      "properties": {
        "canDecide": {
          "type": "boolean"
        },
        "reason": {
          "type": "string",
          "description": "Explanation when the current caller cannot decide this request."
        },
        "code": {
          "type": "string"
        }
      }
    }
  }
}