{
  "openapi": "3.1.0",
  "info": {
    "title": "Brute Brothers Agent Intake API",
    "version": "1.0.0",
    "summary": "Public API for AI agents to create anonymized wallet-recovery evaluation drafts on behalf of users.",
    "description": "AI agents can POST a structured intake draft on behalf of a user. The server returns a `review_url` that the user must open in their browser; a case is only created after the user passes Cloudflare Turnstile verification, reviews the draft, and submits it. The agent never sees seed phrases, private keys, passwords, or wallet files. Those are only collected through the human-facing claim flow.",
    "contact": {
      "name": "Brute Brothers",
      "email": "help@brutebrothers.com",
      "url": "https://brutebrothers.com"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://brutebrothers.com",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Agent instructions and operating rules",
    "url": "https://brutebrothers.com/agent-instructions.md"
  },
  "tags": [
    {
      "name": "Agent Intake",
      "description": "Create, claim, and submit agent-originated intake drafts."
    },
    {
      "name": "Status",
      "description": "Service health."
    }
  ],
  "paths": {
    "/agent/intake-drafts": {
      "post": {
        "tags": ["Agent Intake"],
        "summary": "Create an anonymized intake draft",
        "description": "Submit a structured intake draft on behalf of a user. The response includes a `review_url` to give to the user.",
        "operationId": "createAgentIntakeDraft",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "https://brutebrothers.com/agent-intake-schema.json"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Draft created. Give `review_url` to the user.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["draft_id", "review_url", "expires_at", "status"],
                  "properties": {
                    "draft_id": { "type": "string" },
                    "review_url": { "type": "string", "format": "uri" },
                    "expires_at": { "type": "string", "format": "date-time" },
                    "status": { "type": "string", "const": "created_by_agent" },
                    "instructions": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation failed. Body is unsafe (contains secrets) or malformed.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "429": {
            "description": "Rate limited (20 per IP per 15 minutes)."
          }
        }
      }
    },
    "/agent/intake-drafts/{id}/claim": {
      "post": {
        "tags": ["Agent Intake"],
        "summary": "Claim a draft for human review",
        "description": "Called from the user's browser at `/agent-intake/{id}`. Requires the secret token embedded in the `review_url` fragment. Rate-limited per IP.",
        "operationId": "claimAgentIntakeDraft",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["token"],
                "properties": {
                  "token": { "type": "string", "description": "Secret token from review_url fragment." }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Draft claimed. Includes a one-time `claim_token` for the subsequent submit call.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["status", "draft_id", "claim_token", "payload"],
                  "properties": {
                    "status": { "type": "string" },
                    "draft_id": { "type": "string" },
                    "expires_at": { "type": "string", "format": "date-time" },
                    "claim_token": { "type": "string" },
                    "payload": { "$ref": "https://brutebrothers.com/agent-intake-schema.json" }
                  }
                }
              }
            }
          },
          "403": { "description": "Invalid or expired token." },
          "404": { "description": "Draft not found." },
          "429": { "description": "Rate limited (30 per IP per 15 minutes)." }
        }
      }
    },
    "/agent/intake-drafts/{id}/submit": {
      "post": {
        "tags": ["Agent Intake"],
        "summary": "Submit a claimed draft as a real case",
        "description": "Final user-confirmed submission. Requires the `claim_token` returned by `/claim` and a valid Cloudflare Turnstile token.",
        "operationId": "submitAgentIntakeDraft",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["claim_token", "turnstile_token"],
                "properties": {
                  "claim_token": { "type": "string" },
                  "turnstile_token": { "type": "string" },
                  "payload": { "$ref": "https://brutebrothers.com/agent-intake-schema.json" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Case created." },
          "400": { "description": "Validation failed." },
          "403": { "description": "Invalid claim token or Turnstile failure." },
          "404": { "description": "Draft not found." },
          "429": { "description": "Rate limited (5 per IP per 15 minutes)." }
        }
      }
    },
    "/health": {
      "get": {
        "tags": ["Status"],
        "summary": "Liveness probe",
        "operationId": "healthCheck",
        "responses": {
          "200": {
            "description": "Service is healthy.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "details": { "type": "array", "items": { "type": "string" } },
          "safetyMatches": { "type": "array", "items": { "type": "string" } }
        }
      }
    }
  }
}
