{
  "openapi": "3.1.0",
  "info": {
    "title": "Rapid Reports API",
    "version": "1.0.0",
    "description": "Programmatic access to Rapid Reports (rpdreports.com): check account credits, run instant Quick Ballpark roof estimates, order full LiDAR-measured 3D CAD roof reports + 6-page PDF takeoffs + CSV material exports, and retrieve structured roof measurements and shareable 3D links.",
    "contact": {
      "name": "Rapid Reports Support",
      "url": "https://rpdreports.com/developers.php",
      "email": "support@rpdreports.com"
    }
  },
  "servers": [
    {
      "url": "https://rpdreports.com/api/v1",
      "description": "Production REST API"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Personal API key (rr_live_...) generated from your Rapid Reports Dashboard under API / MCP."
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "code": {
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "ok",
          "error"
        ]
      },
      "ReportSummary": {
        "type": "object",
        "properties": {
          "report_id": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "processing",
              "ready",
              "failed"
            ]
          },
          "stage": {
            "type": "string"
          },
          "progress_pct": {
            "type": "integer"
          },
          "address": {
            "type": "string"
          },
          "lat": {
            "type": "number"
          },
          "lng": {
            "type": "number"
          },
          "created_at": {
            "type": "string"
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "summary": {
            "type": "object",
            "properties": {
              "area_sqft": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "squares": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "predominant_pitch": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "facets": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          },
          "links": {
            "type": "object",
            "properties": {
              "client_3d_url": {
                "type": "string",
                "format": "uri"
              },
              "pdf_url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "csv_url": {
                "type": "string",
                "format": "uri"
              },
              "aerial_url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/account": {
      "get": {
        "operationId": "getAccountBalance",
        "summary": "Get account credit balance and Quick Ballpark quota",
        "responses": {
          "200": {
            "description": "Current account balance, Quick Ballpark quota, active queue count, and pack pricing."
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/ballpark": {
      "post": {
        "operationId": "quickBallpark",
        "summary": "Run a 1-second Quick Ballpark roof estimate",
        "description": "Returns approximate roof squares, sq ft, predominant pitch, and facet count before ordering a full 3D report.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "type": "string",
                    "example": "1601 Coffee Rd, Modesto, CA 95355"
                  },
                  "lat": {
                    "type": "number",
                    "example": 37.66564,
                    "description": "Your own map pin, for developers. When an address is also sent it must be on the same building (within 15 m of the address match) or nothing is ordered and a pick_link is returned."
                  },
                  "lng": {
                    "type": "number",
                    "example": -120.97567,
                    "description": "Your own map pin, for developers. When an address is also sent it must be on the same building (within 15 m of the address match) or nothing is ordered and a pick_link is returned."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Instant roof ballpark returned."
          },
          "429": {
            "description": "Free daily/trial limit reached — buy a ballpark pack or report credits."
          }
        }
      }
    },
    "/reports": {
      "get": {
        "operationId": "listRoofReports",
        "summary": "List recent roof reports for the authenticated account",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "processing",
                "ready",
                "failed"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of recent roof reports."
          }
        }
      },
      "post": {
        "operationId": "orderRoofReport",
        "summary": "Order a full LiDAR 3D roof report + 6-page PDF + CSV (1 credit)",
        "description": "Deducts 1 report credit ($10) and queues a complete 3D CAD roof report (5-30 min turnaround, 24/7). Max 4 concurrent active orders per account.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "address": {
                    "type": "string",
                    "example": "1601 Coffee Rd, Modesto, CA 95355"
                  },
                  "lat": {
                    "type": "number",
                    "description": "Your own map pin, for developers. When an address is also sent it must be on the same building (within 15 m of the address match) or nothing is ordered and a pick_link is returned."
                  },
                  "lng": {
                    "type": "number",
                    "description": "Your own map pin, for developers. When an address is also sent it must be on the same building (within 15 m of the address match) or nothing is ordered and a pick_link is returned."
                  },
                  "webhook_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Optional public https:// URL to receive a POST notification when the report finishes."
                  },
                  "pick_on_map": {
                    "type": "boolean",
                    "description": "Set true when the address may hold more than one building. Nothing is ordered and no credit is used; the response has pick_link, a page where the person picks the exact building on a map and orders it."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Report queued successfully."
          },
          "402": {
            "description": "Insufficient report credits."
          },
          "429": {
            "description": "Concurrent active job limit (4) reached."
          }
        }
      }
    },
    "/reports/{report_id}": {
      "get": {
        "operationId": "getRoofReport",
        "summary": "Get roof report status, structured measurements JSON, PDF, CSV & 3D links",
        "parameters": [
          {
            "name": "report_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Full report status and (when ready) measurements JSON + direct PDF/CSV/3D viewer links."
          },
          "404": {
            "description": "Report not found."
          }
        }
      }
    },
    "/estimates": {
      "get": {
        "operationId": "listEstimates",
        "summary": "List your estimates and invoices",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "sent",
                "viewed",
                "signed",
                "invoiced",
                "paid"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Recent estimates and invoices, newest first."
          }
        }
      },
      "post": {
        "operationId": "createEstimate",
        "summary": "Write a draft estimate",
        "description": "Saves a DRAFT estimate in the account. Nothing is sent to the customer: the contractor reviews it at edit_link and sends customer_link themselves. At most 200 new estimates per account per 24 hours.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "customer_name"
                ],
                "properties": {
                  "customer_name": {
                    "type": "string",
                    "example": "Dana Whitfield"
                  },
                  "address": {
                    "type": "string",
                    "description": "Job address. Required unless report_id is given.",
                    "example": "418 Maple St, Springfield, IL 62704"
                  },
                  "customer_email": {
                    "type": "string"
                  },
                  "customer_phone": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string",
                    "example": "Roof Replacement"
                  },
                  "scope": {
                    "type": "string",
                    "description": "Scope of work in plain words."
                  },
                  "line_items": {
                    "type": "array",
                    "description": "Priced rows. When given, the subtotal is their exact sum and `price` is ignored.",
                    "items": {
                      "type": "object",
                      "required": [
                        "description",
                        "unit_price"
                      ],
                      "properties": {
                        "description": {
                          "type": "string"
                        },
                        "quantity": {
                          "type": "number",
                          "default": 1
                        },
                        "unit_price": {
                          "type": "number",
                          "description": "US dollars"
                        }
                      }
                    }
                  },
                  "price": {
                    "type": "number",
                    "description": "One total price in US dollars before tax (used only when line_items is empty)."
                  },
                  "tax_rate_percent": {
                    "type": "number",
                    "description": "0 to 25. Default: the account's saved rate."
                  },
                  "deposit": {
                    "type": "number",
                    "description": "Deposit due at signing, US dollars."
                  },
                  "report_id": {
                    "type": "integer",
                    "description": "Roof report this estimate is for; attaches the 3D roof."
                  },
                  "expires_on": {
                    "type": "string",
                    "format": "date"
                  },
                  "private_notes": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new estimate, with customer_link (read, e-sign, pay) and edit_link."
          },
          "422": {
            "description": "A required field is missing (customer_name, or an address / report_id)."
          },
          "429": {
            "description": "Daily limit reached."
          }
        }
      }
    },
    "/estimates/{estimate_id}": {
      "get": {
        "operationId": "getEstimate",
        "summary": "Get one estimate or invoice: status, signed, paid, balance due",
        "parameters": [
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The estimate or invoice with its line items and links."
          },
          "404": {
            "description": "Estimate not found."
          }
        }
      },
      "patch": {
        "operationId": "updateEstimate",
        "summary": "Change a draft estimate (send only the fields that change)",
        "parameters": [
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "description": "Any of the create fields. line_items replaces all rows; price replaces the rows with one price."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed estimate. Signed estimates only accept phone, email and private notes."
          },
          "404": {
            "description": "Estimate not found."
          }
        }
      },
      "delete": {
        "operationId": "deleteEstimate",
        "summary": "Delete a draft estimate",
        "parameters": [
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted."
          },
          "404": {
            "description": "Estimate not found."
          },
          "409": {
            "description": "Signed or paid: kept as a record."
          }
        }
      }
    },
    "/estimates/{estimate_id}/invoice": {
      "post": {
        "operationId": "estimateToInvoice",
        "summary": "Turn an estimate into an invoice",
        "description": "Does not message the customer and does not take a payment.",
        "parameters": [
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice."
          },
          "404": {
            "description": "Estimate not found."
          },
          "422": {
            "description": "The estimate has no price yet."
          }
        }
      }
    },
    "/purchases": {
      "post": {
        "operationId": "buyCredits",
        "summary": "Buy report credits or a Quick Ballpark pack",
        "description": "Returns purchased=false with pay_link (nothing charged; the account owner taps the link and pays) unless the owner has switched on \"Let my assistant buy for me\" on their dashboard, in which case their saved card is charged at once, inside their monthly limit, and purchased=true. This cannot be switched on or changed through the API.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "product": {
                    "type": "string",
                    "enum": [
                      "reports",
                      "quick_ballparks"
                    ],
                    "default": "reports"
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 25,
                    "description": "Report credits. Ignored for quick_ballparks (one pack of 50)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "purchased true (charged, balances returned) or false (pay_link returned)."
          },
          "422": {
            "description": "Bad quantity."
          }
        }
      }
    }
  }
}
