{
    "openapi": "3.1.0",
    "info": {
        "title": "Berks Insulation AI API",
        "version": "1.0.0",
        "description": "Search site content and submit consented enquiries. Rate limited.",
        "contact": {
            "email": "info@berksinsulation.com",
            "url": "https://berksinsulation.com/for-ai-agents/"
        }
    },
    "servers": [
        {
            "url": "https://berksinsulation.com/wp-json/berks-ai/v1"
        }
    ],
    "paths": {
        "/leads": {
            "post": {
                "operationId": "submitEnquiry",
                "summary": "Submit an enquiry on behalf of a user who has consented to be contacted.",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "minLength": 2,
                                        "maxLength": 100,
                                        "description": "Full name of the person to be contacted."
                                    },
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "description": "Email address of the person."
                                    },
                                    "phone": {
                                        "type": "string",
                                        "description": "UK phone number the person can be called on."
                                    },
                                    "postcode": {
                                        "type": "string",
                                        "description": "UK postcode of the property, e.g. SL2 5DT."
                                    },
                                    "service": {
                                        "type": "string",
                                        "description": "Service or topic of interest.",
                                        "enum": [
                                            "Loft Insulation",
                                            "Cavity Wall Insulation",
                                            "External Wall Insulation",
                                            "Underfloor Insulation",
                                            "Draught Proofing",
                                            "Condensing Boiler Installation",
                                            "Non-Condensing Boiler Replacement",
                                            "Back Boiler Replacement",
                                            "Smart Heating Controls",
                                            "Hot Water Cylinder Upgrade",
                                            "Energy Assessment",
                                            "Decarbonisation Turnkey Provider",
                                            "Grant / funding eligibility check",
                                            "Heat pump / solar",
                                            "Other"
                                        ]
                                    },
                                    "message": {
                                        "type": "string",
                                        "maxLength": 2000,
                                        "description": "Short description of what the person needs."
                                    },
                                    "consent": {
                                        "type": "boolean",
                                        "description": "Must be true: the person has explicitly agreed to be contacted by Berks Insulation about this enquiry."
                                    },
                                    "agent": {
                                        "type": "string",
                                        "maxLength": 80,
                                        "description": "Name of the AI assistant submitting (e.g. ChatGPT, Claude)."
                                    }
                                },
                                "required": [
                                    "name",
                                    "email",
                                    "phone",
                                    "postcode",
                                    "consent"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Enquiry received",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "status": {
                                            "type": "string"
                                        },
                                        "reference": {
                                            "type": "string"
                                        },
                                        "message": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error"
                    },
                    "429": {
                        "description": "Rate limit exceeded"
                    }
                }
            }
        },
        "/search": {
            "get": {
                "operationId": "searchSite",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "any",
                                "page",
                                "post"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "maximum": 25
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Matching pages"
                    }
                }
            }
        },
        "/mcp": {
            "post": {
                "operationId": "mcp",
                "summary": "Model Context Protocol (JSON-RPC 2.0)",
                "responses": {
                    "200": {
                        "description": "JSON-RPC response"
                    }
                }
            }
        }
    }
}