{
  "openapi": "3.1.0",
  "info": {
    "title": "K-Work Trust API",
    "version": "0.1.0",
    "description": "Korean business data validation, normalization, and workflow trust checks for external agents."
  },
  "servers": [
    {
      "url": "https://k-work-trust-api.fly.dev",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "apiKeyAuth": []
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "security": [],
        "responses": {
          "200": {
            "description": "Service is healthy"
          }
        }
      }
    },
    "/v1/agent/readiness": {
      "get": {
        "summary": "Agent deployment readiness",
        "description": "Public machine-readable deployment readiness for autonomous or invited agent use. Does not expose API keys or secrets.",
        "security": [],
        "responses": {
          "200": {
            "description": "Deployment readiness summary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentReadiness"
                }
              }
            }
          }
        }
      }
    },
    "/v1/auth/whoami": {
      "get": {
        "summary": "Inspect the current API key",
        "description": "Verifies an API key and returns trust level, rate limit, monthly quota usage, and official-source policy without consuming monthly quota.",
        "responses": {
          "200": {
            "description": "Authenticated API key status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentWhoami"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/tools": {
      "get": {
        "summary": "List available tools",
        "responses": {
          "200": {
            "description": "Tool list"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/tools/call": {
      "post": {
        "summary": "Call any K-Work Trust tool",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "tool"
                ],
                "properties": {
                  "tool": {
                    "type": "string",
                    "examples": [
                      "validate_vendor_onboarding"
                    ]
                  },
                  "arguments": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/ToolResponse"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "description": "Unsupported tool"
          },
          "422": {
            "description": "Invalid tool input"
          }
        }
      }
    },
    "/v1/vendor-onboarding/validate": {
      "post": {
        "summary": "Validate a Korean vendor onboarding record",
        "description": "Best first endpoint for external agents. Combines business registration, company name, address, phone, and evidence checks into one workflow decision.",
        "requestBody": {
          "$ref": "#/components/requestBodies/VendorRecord"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/ToolResponse"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "description": "Invalid vendor record"
          }
        }
      }
    },
    "/v1/invoice-readiness/validate": {
      "post": {
        "summary": "Validate invoice readiness",
        "requestBody": {
          "$ref": "#/components/requestBodies/VendorRecord"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/ToolResponse"
          }
        }
      }
    },
    "/v1/payment-or-invoice-release/validate": {
      "post": {
        "summary": "Validate payment or invoice release",
        "description": "Use before an agent releases a payment, invoice, settlement, purchase order, or other money-adjacent workflow step. Returns allow/review/block style decisions, amount policy, required fixes, and a human review packet.",
        "requestBody": {
          "$ref": "#/components/requestBodies/VendorRecord"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/ToolResponse"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/crm-company-record/clean": {
      "post": {
        "summary": "Clean a CRM company record",
        "requestBody": {
          "$ref": "#/components/requestBodies/VendorRecord"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/ToolResponse"
          }
        }
      }
    },
    "/v1/record-risk/score": {
      "post": {
        "summary": "Score record risk",
        "requestBody": {
          "$ref": "#/components/requestBodies/VendorRecord"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/ToolResponse"
          }
        }
      }
    },
    "/v1/evidence-report/generate": {
      "post": {
        "summary": "Generate evidence report",
        "requestBody": {
          "$ref": "#/components/requestBodies/VendorRecord"
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/ToolResponse"
          }
        }
      }
    },
    "/.well-known/k-work-trust-agent.json": {
      "get": {
        "summary": "Agent discovery manifest",
        "security": [],
        "responses": {
          "200": {
            "description": "Machine-readable agent manifest"
          }
        }
      }
    },
    "/skill.md": {
      "get": {
        "summary": "Agent skill instructions",
        "security": [],
        "responses": {
          "200": {
            "description": "Markdown instructions for AI agents"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "summary": "Remote MCP Streamable HTTP endpoint",
        "description": "Accepts single JSON-RPC MCP requests for initialize, tools/list, and tools/call. initialize and tools/list are public for discovery. tools/call uses the same API key, quota, official-source, and abuse-guard policies as protected REST workflow calls.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC MCP response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/AgentError"
          },
          "429": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      },
      "get": {
        "summary": "Remote MCP SSE stream status",
        "description": "Returns 405 because this deployment currently supports JSON-response Streamable HTTP POST only.",
        "responses": {
          "405": {
            "description": "SSE streams are not enabled"
          }
        }
      }
    },
    "/v1/agent/signup/challenge": {
      "get": {
        "summary": "Create an agent self-signup proof-of-work challenge",
        "security": [],
        "parameters": [
          {
            "name": "email",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "email"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentChallenge"
          },
          "404": {
            "$ref": "#/components/responses/AgentError"
          },
          "422": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/v1/agent/signup/status": {
      "get": {
        "summary": "Agent signup status and public policy",
        "security": [],
        "responses": {
          "200": {
            "description": "Machine-readable public signup status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentSignupStatus"
                }
              }
            }
          }
        }
      }
    },
    "/v1/agent/signup/provisional/challenge": {
      "get": {
        "summary": "Create an email-less provisional agent proof-of-work challenge",
        "security": [],
        "parameters": [
          {
            "name": "agent_label",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "One of agent_label, agent_id, or agent_url is required."
          },
          {
            "name": "agent_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "agent_url",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "$ref": "#/components/responses/AgentChallenge"
          },
          "404": {
            "$ref": "#/components/responses/AgentError"
          },
          "422": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/v1/agent/signup/provisional": {
      "post": {
        "summary": "Issue an ultra-low-quota provisional key without email",
        "security": [],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentProvisionalIssue"
        },
        "responses": {
          "201": {
            "description": "Provisional key issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentProvisionalIssueResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AgentError"
          },
          "409": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/v1/agent/signup/provisional/upgrade/request-code": {
      "post": {
        "summary": "Request an email verification code to upgrade a provisional key",
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentProvisionalUpgrade"
        },
        "responses": {
          "202": {
            "description": "Verification code sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentVerificationSentResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/v1/agent/signup/provisional/upgrade/verify": {
      "post": {
        "summary": "Verify email code and upgrade the same provisional key",
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentCodeVerify"
        },
        "responses": {
          "200": {
            "description": "Provisional key upgraded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentUpgradeResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/v1/agent/signup/request-code": {
      "post": {
        "summary": "Request an email verification code using a solved proof-of-work",
        "security": [],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentEmailRequestCode"
        },
        "responses": {
          "202": {
            "description": "Verification code sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentVerificationSentResponse"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    },
    "/v1/agent/signup/verify": {
      "post": {
        "summary": "Verify email code and issue a low-quota agent API key",
        "security": [],
        "requestBody": {
          "$ref": "#/components/requestBodies/AgentCodeVerify"
        },
        "responses": {
          "201": {
            "description": "Agent key issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgentKeyIssuedResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/AgentError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "requestBodies": {
      "VendorRecord": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/VendorRecord"
            }
          }
        }
      },
      "AgentProvisionalIssue": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentProvisionalIssueRequest"
            }
          }
        }
      },
      "AgentEmailRequestCode": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentEmailRequestCodeRequest"
            }
          }
        }
      },
      "AgentProvisionalUpgrade": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentProvisionalUpgradeRequest"
            }
          }
        }
      },
      "AgentCodeVerify": {
        "required": true,
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentCodeVerifyRequest"
            }
          }
        }
      }
    },
    "schemas": {
      "VendorRecord": {
        "type": "object",
        "properties": {
          "registration_number": {
            "type": "string",
            "description": "Korean 10-digit business registration number."
          },
          "company_name": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "phone_number": {
            "type": "string"
          },
          "representative_name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "vendor_id": {
            "type": "string"
          },
          "vendor_status": {
            "type": "string",
            "description": "Optional current vendor approval state, such as approved, active, needs_review, blocked, or inactive."
          },
          "vendor_last_verified_at": {
            "type": "string",
            "description": "Optional ISO date/time when the vendor was last verified."
          },
          "invoice_amount": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "default": "KRW"
          },
          "invoice_email": {
            "type": "string"
          },
          "payment_due_date": {
            "type": "string"
          },
          "payment_purpose": {
            "type": "string"
          },
          "purchase_order_id": {
            "type": "string"
          },
          "bank_account_holder": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "ToolEnvelope": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "tool": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "retry_after_seconds": {
                "type": "integer"
              },
              "quota": {
                "type": "object",
                "additionalProperties": true
              },
              "failure_mode": {
                "$ref": "#/components/schemas/AgentFailureMode"
              },
              "retry": {
                "type": "string"
              },
              "agent_next_action": {
                "type": "string"
              },
              "escalation": {
                "type": "string"
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "AgentReadiness": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ready_for_agent_testing",
              "ready_for_invited_agents",
              "needs_operator_setup"
            ]
          },
          "service": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "auth": {
            "type": "object",
            "additionalProperties": true
          },
          "self_serve_signup": {
            "type": "object",
            "additionalProperties": true
          },
          "official_sources": {
            "type": "object",
            "additionalProperties": true
          },
          "storage": {
            "type": "object",
            "additionalProperties": true
          },
          "recommended_flow": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "first_call": {
            "type": "object",
            "additionalProperties": true
          },
          "response_contract": {
            "$ref": "#/components/schemas/AgentResponseContract"
          },
          "failure_modes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentFailureMode"
            }
          },
          "operator_actions_needed": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": true
      },
      "AgentWhoami": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "authenticated",
              "anonymous_access_allowed"
            ]
          },
          "service": {
            "type": "string"
          },
          "client": {
            "type": "object",
            "additionalProperties": true
          },
          "limits": {
            "type": "object",
            "additionalProperties": true
          },
          "official_sources": {
            "type": "object",
            "additionalProperties": true
          },
          "auth": {
            "type": "object",
            "additionalProperties": true
          },
          "recommended_next_call": {
            "type": "object",
            "additionalProperties": true
          },
          "response_contract": {
            "$ref": "#/components/schemas/AgentResponseContract"
          },
          "failure_modes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentFailureMode"
            }
          }
        },
        "additionalProperties": true
      },
      "AgentFailureMode": {
        "type": "object",
        "required": [
          "code",
          "category",
          "retry",
          "agent_next_action",
          "escalation"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "applies_to": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "http_status": {
            "type": "integer"
          },
          "category": {
            "type": "string"
          },
          "retry": {
            "type": "string"
          },
          "agent_next_action": {
            "type": "string"
          },
          "escalation": {
            "type": "string"
          },
          "safe_to_log": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "do_not_log": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": true
      },
      "AgentResponseContract": {
        "type": "object",
        "properties": {
          "success_fields": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "decision_meanings": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "failure_mode_field": {
            "type": "string"
          },
          "escalation_contract": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "AgentProof": {
        "type": "object",
        "required": [
          "challenge",
          "solution"
        ],
        "properties": {
          "challenge": {
            "type": "string",
            "description": "Opaque signed challenge returned by a signup challenge endpoint."
          },
          "solution": {
            "type": "string",
            "maxLength": 160,
            "description": "Candidate proof-of-work solution."
          }
        },
        "additionalProperties": false
      },
      "AgentProofOfWorkContract": {
        "type": "object",
        "required": [
          "algorithm",
          "digest_encoding",
          "input_template",
          "difficulty_rule",
          "solution_field",
          "challenge_field",
          "max_solution_length"
        ],
        "properties": {
          "algorithm": {
            "type": "string",
            "enum": [
              "sha256"
            ]
          },
          "digest_encoding": {
            "type": "string",
            "enum": [
              "hex"
            ]
          },
          "input_template": {
            "type": "string",
            "examples": [
              "${nonce}:${subject}:${solution}"
            ]
          },
          "difficulty_rule": {
            "type": "string"
          },
          "solution_field": {
            "type": "string",
            "examples": [
              "proof.solution"
            ]
          },
          "challenge_field": {
            "type": "string",
            "examples": [
              "proof.challenge"
            ]
          },
          "max_solution_length": {
            "type": "integer",
            "minimum": 1,
            "examples": [
              160
            ]
          },
          "challenge_ttl_seconds": {
            "type": "integer",
            "minimum": 1
          },
          "email_signup_difficulty_hex_prefix_zeros": {
            "type": "integer",
            "minimum": 1
          },
          "provisional_signup_difficulty_hex_prefix_zeros": {
            "type": "integer",
            "minimum": 1
          }
        },
        "additionalProperties": true
      },
      "AgentChallengeResponse": {
        "type": "object",
        "required": [
          "status",
          "algorithm",
          "challenge",
          "nonce",
          "subject",
          "difficulty_hex_prefix_zeros",
          "proof_input_template",
          "proof_digest_prefix",
          "proof_max_solution_length",
          "proof_of_work",
          "request_endpoint"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "challenge"
            ]
          },
          "algorithm": {
            "type": "string",
            "enum": [
              "sha256"
            ]
          },
          "challenge": {
            "type": "string"
          },
          "nonce": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "difficulty_hex_prefix_zeros": {
            "type": "integer",
            "minimum": 1
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "proof_input_template": {
            "type": "string",
            "examples": [
              "${nonce}:${subject}:${solution}"
            ]
          },
          "proof_digest_prefix": {
            "type": "string",
            "examples": [
              "0000"
            ]
          },
          "proof_max_solution_length": {
            "type": "integer",
            "examples": [
              160
            ]
          },
          "proof_of_work": {
            "$ref": "#/components/schemas/AgentProofOfWorkContract"
          },
          "solution_format": {
            "type": "string"
          },
          "request_endpoint": {
            "type": "string"
          },
          "request_code_endpoint": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "AgentProvisionalIssueRequest": {
        "type": "object",
        "required": [
          "agent_label",
          "proof"
        ],
        "properties": {
          "agent_label": {
            "type": "string",
            "description": "Human-readable agent label."
          },
          "agent_id": {
            "type": "string",
            "description": "Stable machine-readable agent identifier."
          },
          "agent_url": {
            "type": "string",
            "description": "Agent profile, card, or manifest URL."
          },
          "use_case": {
            "type": "string"
          },
          "source_channel": {
            "type": "string",
            "examples": [
              "moltbook"
            ]
          },
          "campaign": {
            "type": "string"
          },
          "proof": {
            "$ref": "#/components/schemas/AgentProof"
          }
        },
        "additionalProperties": true
      },
      "AgentProvisionalIssueResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "issued"
            ]
          },
          "signup_mode": {
            "type": "string",
            "enum": [
              "agent_provisional"
            ]
          },
          "trust_level": {
            "type": "string",
            "enum": [
              "provisional"
            ]
          },
          "api_key": {
            "type": "string",
            "description": "Plaintext key returned once. Store securely and never expose publicly."
          },
          "client_id": {
            "type": "string"
          },
          "base_url": {
            "type": "string"
          },
          "auth_header": {
            "type": "string"
          },
          "rate_limit_rpm": {
            "type": "integer"
          },
          "monthly_request_quota": {
            "type": "integer"
          },
          "first_endpoint": {
            "type": "string"
          },
          "warning": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "AgentEmailRequestCodeRequest": {
        "type": "object",
        "required": [
          "email",
          "proof"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "agent_label": {
            "type": "string"
          },
          "use_case": {
            "type": "string"
          },
          "proof": {
            "$ref": "#/components/schemas/AgentProof"
          }
        },
        "additionalProperties": true
      },
      "AgentProvisionalUpgradeRequest": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "agent_label": {
            "type": "string"
          },
          "use_case": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "AgentCodeVerifyRequest": {
        "type": "object",
        "required": [
          "email",
          "code"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "code": {
            "type": "string",
            "pattern": "^[0-9]{6}$"
          }
        },
        "additionalProperties": false
      },
      "AgentVerificationSentResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "verification_sent"
            ]
          },
          "signup_mode": {
            "type": "string"
          },
          "verify_endpoint": {
            "type": "string"
          }
        },
        "additionalProperties": true
      },
      "AgentKeyIssuedResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "issued"
            ]
          },
          "signup_mode": {
            "type": "string"
          },
          "api_key": {
            "type": "string",
            "description": "Plaintext key returned once. Store securely and never expose publicly."
          },
          "client_id": {
            "type": "string"
          },
          "rate_limit_rpm": {
            "type": "integer"
          },
          "monthly_request_quota": {
            "type": "integer"
          },
          "discovery": {
            "type": "object",
            "additionalProperties": true
          },
          "agent_first_call": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "AgentUpgradeResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "upgraded"
            ]
          },
          "signup_mode": {
            "type": "string",
            "enum": [
              "agent_provisional_upgrade"
            ]
          },
          "trust_level": {
            "type": "string",
            "enum": [
              "email_verified"
            ]
          },
          "client_id": {
            "type": "string"
          },
          "auth_header": {
            "type": "string",
            "examples": [
              "Authorization: Bearer <same provisional key>"
            ]
          },
          "rate_limit_rpm": {
            "type": "integer"
          },
          "monthly_request_quota": {
            "type": "integer"
          }
        },
        "additionalProperties": true
      },
      "AgentSignupStatus": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          },
          "service": {
            "type": "string"
          },
          "base_url": {
            "type": "string"
          },
          "generated_at": {
            "type": "string",
            "format": "date-time"
          },
          "mode": {
            "type": "string"
          },
          "readiness_endpoint": {
            "type": "string"
          },
          "whoami_endpoint": {
            "type": "string"
          },
          "proof_secret_configured": {
            "type": "boolean"
          },
          "proof_of_work": {
            "$ref": "#/components/schemas/AgentProofOfWorkContract"
          },
          "rate_limits": {
            "type": "object",
            "additionalProperties": true
          },
          "provisional": {
            "type": "object",
            "additionalProperties": true
          },
          "email_verified": {
            "type": "object",
            "additionalProperties": true
          },
          "key_policy": {
            "type": "object",
            "additionalProperties": true
          },
          "failure_modes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AgentFailureMode"
            }
          }
        },
        "additionalProperties": true
      }
    },
    "responses": {
      "ToolResponse": {
        "description": "Tool call envelope",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ToolEnvelope"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "AgentChallenge": {
        "description": "Proof-of-work challenge",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AgentChallengeResponse"
            }
          }
        }
      },
      "AgentError": {
        "description": "Signup error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      }
    }
  }
}