{
  "openapi": "3.1.0",
  "info": {
    "title": "LeadRM Agent API",
    "version": "1.0.0",
    "description": "LeadRM gives AI agents the skill to find verified B2B leads and decision-makers. The agent authenticates with a LeadRM API key (generated in LeadRM → Settings → Integrations → MCP server access) as a Bearer token, then calls this endpoint to search the user's saved lead database by industry, city, and email availability. Use this skill whenever the user asks for leads, prospects, local businesses, or decision-makers for outreach. Returned leads include company, contact name, email verification status, phone, website, location, and — when already enriched — the decision-maker's name, title, email, phone, and LinkedIn URL. Results come from the user's own LeadRM lead pool (live directory extractions from Google Maps, Yelp, Trustpilot, G2, Product Hunt, and Google Play), so every lead belongs to the calling user."
  },
  "servers": [
    {
      "url": "https://leadrm.app",
      "description": "LeadRM production"
    }
  ],
  "paths": {
    "/api/v1/agent/leads": {
      "get": {
        "operationId": "searchLeads",
        "summary": "Search the user's saved LeadRM leads",
        "description": "Searches the calling user's LeadRM lead database and returns up to 50 matching leads. Use industry for the business niche or category (e.g. 'hvac', 'dentist', 'roofing'), city for the market (e.g. 'Austin' or 'Austin, TX'), and has_email to restrict results to leads that already have an email address on file. Call this skill when the user asks you to find leads, build a prospect list, or look up businesses in a niche or city. If the result set is empty, suggest running a new directory scrape from the LeadRM app or MCP trigger_directory_scrape tool.",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "industry",
            "in": "query",
            "required": false,
            "description": "Business niche or category to match, case-insensitive substring (e.g. 'hvac', 'plumber', 'saas'). Matches the lead's category/niche fields.",
            "schema": { "type": "string" }
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "description": "City or market to match, case-insensitive substring (e.g. 'Los Angeles'). Matches the lead's city/location fields.",
            "schema": { "type": "string" }
          },
          {
            "name": "has_email",
            "in": "query",
            "required": false,
            "description": "When true, only return leads with a non-empty email address. When false, only return leads missing an email. Omit to return both.",
            "schema": { "type": "boolean" }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of leads to return (1–50). Defaults to 25.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 50, "default": 25 }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching leads. 'count' is the number returned; 'scanned' is how many leads were evaluated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["count", "leads"],
                  "properties": {
                    "count": { "type": "integer" },
                    "scanned": { "type": "integer" },
                    "leads": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/Lead" }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid LEADRM_API_KEY Bearer token.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "403": {
            "description": "The account is disabled.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "LeadRM API key (lrmk_…) generated in LeadRM → Settings → Integrations → MCP server access. Send as 'Authorization: Bearer lrmk_…'."
      }
    },
    "schemas": {
      "Lead": {
        "type": "object",
        "description": "A saved LeadRM lead: a business plus, when enriched, its decision-maker contact.",
        "properties": {
          "id": { "type": "string", "description": "Lead document id — pass to enrich endpoints." },
          "company": { "type": "string" },
          "name": { "type": "string", "description": "Primary contact name, if known." },
          "email": { "type": "string" },
          "verification_status": { "type": "string", "description": "'Valid', 'No Email', 'unverified', etc." },
          "phone": { "type": "string" },
          "website": { "type": "string" },
          "category": { "type": "string", "description": "Business niche/category." },
          "city": { "type": "string" },
          "state": { "type": "string" },
          "address": { "type": "string" },
          "decision_maker": {
            "type": "object",
            "description": "Present only on enriched leads.",
            "properties": {
              "first_name": { "type": "string" },
              "last_name": { "type": "string" },
              "title": { "type": "string" },
              "email": { "type": "string" },
              "phone": { "type": "string" },
              "linkedin_url": { "type": "string" }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" }
        }
      }
    }
  }
}
