{
    "openapi": "3.0.3",
    "info": {
        "title": "MyRentalSpot API",
        "version": "1.0.0",
        "description": "Read your portfolio (properties, units, leases, payments, work orders, leads), create & update leads, and receive signed webhooks. JSON over HTTPS."
    },
    "servers": [
        {
            "url": "https://mail.myrentalspot.net/api/v1"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "description": "A MyRentalSpot API key. Read keys can GET; write keys can POST/PATCH."
            }
        },
        "schemas": {
            "Property": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 128
                    },
                    "name": {
                        "type": "string",
                        "example": "56 Longridge Rd"
                    },
                    "city": {
                        "type": "string"
                    },
                    "state": {
                        "type": "string"
                    },
                    "postal_code": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "example": "active"
                    },
                    "units_count": {
                        "type": "integer",
                        "example": 3
                    }
                }
            },
            "Unit": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 198
                    },
                    "property_id": {
                        "type": "integer",
                        "example": 128
                    },
                    "name": {
                        "type": "string",
                        "example": "Unit 2"
                    },
                    "beds": {
                        "type": "integer"
                    },
                    "baths": {
                        "type": "integer"
                    },
                    "rent": {
                        "type": "number",
                        "example": 2400
                    },
                    "is_occupied": {
                        "type": "boolean"
                    }
                }
            },
            "Lease": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 5567
                    },
                    "unit_id": {
                        "type": "integer",
                        "example": 198
                    },
                    "status": {
                        "type": "string",
                        "example": "active"
                    },
                    "check_in": {
                        "type": "string",
                        "format": "date"
                    },
                    "monthly_rent": {
                        "type": "number",
                        "example": 2400
                    },
                    "primary_resident": {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string"
                            },
                            "email": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "Payment": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 90211
                    },
                    "unit_id": {
                        "type": "integer",
                        "example": 198
                    },
                    "category": {
                        "type": "string",
                        "example": "Payment"
                    },
                    "amount": {
                        "type": "number",
                        "example": 2400
                    },
                    "status": {
                        "type": "string",
                        "example": "succeeded"
                    },
                    "due_date": {
                        "type": "string",
                        "format": "date"
                    }
                }
            },
            "WorkOrder": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 771
                    },
                    "title": {
                        "type": "string",
                        "example": "Leaking faucet"
                    },
                    "priority": {
                        "type": "string",
                        "example": "high"
                    },
                    "status": {
                        "type": "string",
                        "example": "in_progress"
                    },
                    "cost_estimate": {
                        "type": "number",
                        "example": 180
                    }
                }
            },
            "Lead": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "example": 1201
                    },
                    "name": {
                        "type": "string",
                        "example": "Jane Doe"
                    },
                    "email": {
                        "type": "string"
                    },
                    "phone": {
                        "type": "string"
                    },
                    "stage": {
                        "type": "string",
                        "enum": [
                            "new",
                            "contacted",
                            "touring",
                            "applied",
                            "leased",
                            "lost"
                        ]
                    },
                    "source": {
                        "type": "string"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    }
                }
            },
            "Error": {
                "type": "object",
                "properties": {
                    "message": {
                        "type": "string"
                    },
                    "errors": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "responses": {
            "Unauthorized": {
                "description": "Missing or invalid API key",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "Forbidden": {
                "description": "Key lacks the write ability",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "NotFound": {
                "description": "Resource not found or not yours",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "Validation": {
                "description": "Validation failed",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "RateLimited": {
                "description": "Rate limit exceeded (60/min per key)"
            }
        }
    },
    "paths": {
        "/properties": {
            "get": {
                "summary": "List Properties",
                "tags": [
                    "Properties"
                ],
                "x-scope": "read",
                "parameters": [
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 25
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Property"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/properties/{id}": {
            "get": {
                "summary": "Retrieve one Property",
                "tags": [
                    "Property"
                ],
                "x-scope": "read",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Property"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    }
                }
            }
        },
        "/units": {
            "get": {
                "summary": "List Units",
                "tags": [
                    "Units"
                ],
                "x-scope": "read",
                "parameters": [
                    {
                        "name": "property_id",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 25
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Unit"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/leases": {
            "get": {
                "summary": "List Leases",
                "tags": [
                    "Leases"
                ],
                "x-scope": "read",
                "parameters": [
                    {
                        "name": "unit_id",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 25
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Lease"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/payments": {
            "get": {
                "summary": "List Payments",
                "tags": [
                    "Payments"
                ],
                "x-scope": "read",
                "parameters": [
                    {
                        "name": "unit_id",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "status",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "category",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 25
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Payment"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/work-orders": {
            "get": {
                "summary": "List Work orders",
                "tags": [
                    "Work orders"
                ],
                "x-scope": "read",
                "parameters": [
                    {
                        "name": "priority",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 25
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/WorkOrder"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            }
        },
        "/leads": {
            "get": {
                "summary": "List Leads",
                "tags": [
                    "Leads"
                ],
                "x-scope": "read",
                "parameters": [
                    {
                        "name": "stage",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "source",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 25
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Lead"
                                            }
                                        },
                                        "meta": {
                                            "type": "object"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorized"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    }
                }
            },
            "post": {
                "summary": "Create a lead",
                "tags": [
                    "Leads"
                ],
                "x-scope": "write",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string"
                                    },
                                    "phone": {
                                        "type": "string"
                                    },
                                    "message": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Lead"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            }
        },
        "/leads/{id}": {
            "patch": {
                "summary": "Update a lead",
                "tags": [
                    "Leads"
                ],
                "x-scope": "write",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "stage": {
                                        "type": "string",
                                        "enum": [
                                            "new",
                                            "contacted",
                                            "touring",
                                            "applied",
                                            "leased",
                                            "lost"
                                        ]
                                    },
                                    "next_follow_up_at": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "notes": {
                                        "type": "string"
                                    },
                                    "move_in_date": {
                                        "type": "string",
                                        "format": "date"
                                    },
                                    "target_rent": {
                                        "type": "number"
                                    },
                                    "lost_reason": {
                                        "type": "string"
                                    },
                                    "name": {
                                        "type": "string"
                                    },
                                    "email": {
                                        "type": "string"
                                    },
                                    "phone": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Updated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Lead"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "404": {
                        "$ref": "#/components/responses/NotFound"
                    },
                    "422": {
                        "$ref": "#/components/responses/Validation"
                    }
                }
            }
        }
    }
}