{
  "openapi": "3.1.0",
  "info": {
    "title": "Imladri Customer API",
    "version": "2026-06-12",
    "description": "Customer workspace API for Profile readiness, trial usage, policy dry runs, agent activity, runtime evidence, scanner uploads, SDK certification uploads, external evidence imports, proof export, proof sharing, and scoped authority records."
  },
  "servers": [
    {
      "url": "https://imladri-beta-api.imladri.workers.dev",
      "description": "Hosted customer Worker"
    }
  ],
  "security": [
    {
      "CustomerBearer": []
    }
  ],
  "tags": [
    {
      "name": "Catalog"
    },
    {
      "name": "Profile"
    },
    {
      "name": "Agent Evidence"
    },
    {
      "name": "Proof"
    },
    {
      "name": "Authority"
    }
  ],
  "paths": {
    "/api/customer/api": {
      "get": {
        "tags": [
          "Catalog"
        ],
        "summary": "Read the public customer API catalog",
        "security": [],
        "responses": {
          "200": {
            "description": "Catalog response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerApiCatalog"
                }
              }
            }
          }
        }
      }
    },
    "/api/customer/profile": {
      "get": {
        "tags": [
          "Profile"
        ],
        "summary": "Read the signed-in customer profile workspace",
        "responses": {
          "200": {
            "$ref": "#/components/responses/ProfileResponse"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/customer/readiness": {
      "get": {
        "tags": [
          "Profile"
        ],
        "summary": "Read customer readiness checks and next actions",
        "responses": {
          "200": {
            "description": "Readiness response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/customer/sdk-keys": {
      "get": {
        "tags": [
          "Profile"
        ],
        "summary": "List SDK key metadata without raw key values",
        "responses": {
          "200": {
            "description": "SDK key metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SdkKeysResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/customer/sdk-key/rotate": {
      "post": {
        "tags": [
          "Profile"
        ],
        "summary": "Rotate the customer SDK key",
        "responses": {
          "200": {
            "description": "One-time SDK key response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SdkKeyRotateResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/activity": {
      "get": {
        "tags": [
          "Agent Evidence"
        ],
        "summary": "Read recent monitored activity for an agent",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Activity response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActivityResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/runtime-test": {
      "post": {
        "tags": [
          "Agent Evidence"
        ],
        "summary": "Run a Profile-driven allowed and blocked runtime proof",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RuntimeTestRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Runtime test result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/runtime-evidence": {
      "get": {
        "tags": [
          "Agent Evidence"
        ],
        "summary": "Read latest normalized runtime evidence",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Runtime evidence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Agent Evidence"
        ],
        "summary": "Upload terminal/API runtime evidence to Profile",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "security": [
          {
            "SdkKey": []
          },
          {
            "CustomerBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EvidenceUpload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Evidence accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/policy-simulate": {
      "post": {
        "tags": [
          "Agent Evidence"
        ],
        "summary": "Dry-run an action against the Profile policy",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PolicySimulationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Policy simulation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          },
          "429": {
            "description": "Trial quota reached"
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/boundary-scan": {
      "post": {
        "tags": [
          "Agent Evidence"
        ],
        "summary": "Upload a scanner proof artifact",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "security": [
          {
            "SdkKey": []
          },
          {
            "CustomerBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ScannerUpload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Scanner artifact accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/sdk-certification": {
      "post": {
        "tags": [
          "Agent Evidence"
        ],
        "summary": "Upload an SDK/adopter certification artifact",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "security": [
          {
            "SdkKey": []
          },
          {
            "CustomerBearer": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SdkCertificationUpload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Certification artifact accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/external-evidence": {
      "get": {
        "tags": [
          "Proof"
        ],
        "summary": "List imported red-team or third-party evidence",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "responses": {
          "200": {
            "description": "External evidence list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Proof"
        ],
        "summary": "Import red-team or third-party evidence into the proof packet",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "security": [
          {
            "CustomerBearer": []
          },
          {
            "SdkKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExternalEvidenceUpload"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "External evidence imported",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericSuccess"
                }
              }
            }
          },
          "429": {
            "description": "Trial quota reached"
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/proof-export": {
      "get": {
        "tags": [
          "Proof"
        ],
        "summary": "Export the active proof packet",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "markdown",
                "pdf"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Proof packet export",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofExport"
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/proof-share": {
      "get": {
        "tags": [
          "Proof"
        ],
        "summary": "List proof shares for an agent",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Proof shares",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofShareList"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Proof"
        ],
        "summary": "Create a redacted buyer/auditor proof share",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateProofShareRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created proof share",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProofShare"
                }
              }
            }
          }
        }
      }
    },
    "/api/customer/agents/{agentId}/authority-tokens": {
      "get": {
        "tags": [
          "Authority"
        ],
        "summary": "List scoped MCP or tool-host authority records",
        "parameters": [
          {
            "$ref": "#/components/parameters/AgentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Authority token metadata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorityTokensResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "CustomerBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Customer session access token."
      },
      "SdkKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-imladri-sdk-key",
        "description": "Customer SDK key. Store only server-side."
      }
    },
    "parameters": {
      "AgentId": {
        "name": "agentId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Missing or invalid customer session."
      },
      "ProfileResponse": {
        "description": "Customer Profile workspace",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ProfileResponse"
            }
          }
        }
      }
    },
    "schemas": {
      "GenericSuccess": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          }
        },
        "required": [
          "success"
        ],
        "additionalProperties": true
      },
      "CustomerApiCatalog": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "version": {
            "type": "string"
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "method": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                },
                "auth": {
                  "type": "string"
                }
              },
              "required": [
                "id"
              ],
              "additionalProperties": true
            }
          },
          "rateLimits": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "success",
          "endpoints"
        ],
        "additionalProperties": true
      },
      "ProfileResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "user": {
            "type": "object",
            "additionalProperties": true
          },
          "apiAccess": {
            "$ref": "#/components/schemas/ApiAccess"
          },
          "plan": {
            "type": "object",
            "additionalProperties": true
          },
          "agentInventory": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "blastRadius": {
            "type": "object",
            "additionalProperties": true
          },
          "agents": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "success"
        ],
        "additionalProperties": true
      },
      "ApiAccess": {
        "type": "object",
        "properties": {
          "workspaceId": {
            "type": "string"
          },
          "accountId": {
            "type": "string"
          },
          "activeAgentId": {
            "type": "string"
          },
          "catalogPath": {
            "type": "string",
            "const": "/api/customer/api"
          },
          "readinessPath": {
            "type": "string",
            "const": "/api/customer/readiness"
          },
          "agents": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "workspaceId",
          "activeAgentId"
        ],
        "additionalProperties": true
      },
      "ReadinessResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "ready": {
            "type": "boolean"
          },
          "summary": {
            "type": "object",
            "properties": {
              "requiredReady": {
                "type": "integer"
              },
              "requiredTotal": {
                "type": "integer"
              }
            },
            "additionalProperties": true
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "nextActions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "success",
          "ready"
        ],
        "additionalProperties": true
      },
      "SdkKeysResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "sdkKeys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SdkKeyMetadata"
            }
          }
        },
        "required": [
          "success",
          "sdkKeys"
        ],
        "additionalProperties": true
      },
      "SdkKeyMetadata": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "fingerprint": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "revoked": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "fingerprint",
          "active",
          "revoked"
        ],
        "additionalProperties": true
      },
      "SdkKeyRotateResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "sdkKey": {
            "type": "string",
            "description": "One-time raw key. Do not log or expose publicly."
          },
          "metadata": {
            "$ref": "#/components/schemas/SdkKeyMetadata"
          }
        },
        "required": [
          "success",
          "sdkKey"
        ],
        "additionalProperties": true
      },
      "ActivityResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "activity": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "success",
          "activity"
        ],
        "additionalProperties": true
      },
      "RuntimeTestRequest": {
        "type": "object",
        "properties": {
          "stack": {
            "type": "string"
          },
          "riskyAction": {
            "type": "string"
          },
          "proofNeed": {
            "type": "string"
          },
          "openProof": {
            "type": "boolean"
          }
        },
        "additionalProperties": true
      },
      "PolicySimulationRequest": {
        "type": "object",
        "properties": {
          "actionType": {
            "type": "string",
            "description": "Action id to evaluate against the agent policy."
          }
        },
        "required": [
          "actionType"
        ],
        "additionalProperties": true
      },
      "EvidenceUpload": {
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "proof": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "ScannerUpload": {
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "findings": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "ci": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "SdkCertificationUpload": {
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "adopter": {
            "type": "string"
          },
          "lanes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "ci": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "ExternalEvidenceUpload": {
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "string",
            "default": "imladri.external-evidence.v1"
          },
          "source": {
            "type": "string"
          },
          "evidenceType": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "info",
              "low",
              "medium",
              "high",
              "critical"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "recorded",
              "passed",
              "review",
              "blocked",
              "failed"
            ]
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "artifactUrl": {
            "type": "string"
          }
        },
        "required": [
          "title",
          "summary"
        ],
        "additionalProperties": true
      },
      "ProofExport": {
        "type": "object",
        "properties": {
          "schemaVersion": {
            "type": "string"
          },
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "agent": {
            "type": "object",
            "additionalProperties": true
          },
          "hashChain": {
            "type": "object",
            "additionalProperties": true
          },
          "proofSignature": {
            "type": "object",
            "additionalProperties": true
          },
          "evidenceCounts": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "CreateProofShareRequest": {
        "type": "object",
        "properties": {
          "redaction": {
            "type": "string",
            "enum": [
              "buyer",
              "auditor"
            ],
            "default": "buyer"
          },
          "expiresInSeconds": {
            "type": "integer",
            "minimum": 300
          }
        },
        "additionalProperties": true
      },
      "ProofShare": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "success"
        ],
        "additionalProperties": true
      },
      "ProofShareList": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "proofShares": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProofShare"
            }
          }
        },
        "required": [
          "success",
          "proofShares"
        ],
        "additionalProperties": true
      },
      "AuthorityTokensResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "authorityTokens": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "success"
        ],
        "additionalProperties": true
      }
    }
  }
}
