# ROI Calculator API Reference

> Platform documentation snapshot. Access, charging and provider requirements remain operation-specific; examples do not execute requests.

### What it does

Produce a quantified business case for a specific prospect: modeled savings or revenue impact, payback period and assumptions, framed for cold outreach rather than assuming an existing relationship.

### Use cases

- Attach a numeric business case to a proposal to shorten procurement review.
- Give a champion internal ammunition to defend the purchase to finance.
- Power a public value-calculator page on your marketing site that captures leads.

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `target_domain` | string | Prospect's domain to analyze (required) |
| `your_domain` | string | Your company domain — used to understand your offering and tailor the business case (optional) |
| `your_product_description` | string | Brief description of your product/service for context (optional) |
| `investment_amount` | string | Estimated annual cost of your solution in dollars for ROI calculations (optional) |
| `contact_email` | string | Optional decision-maker email for person-level enrichment |
| `contact_linkedin` | string | Optional LinkedIn profile URL for person-level enrichment |
| `contact_name` | string | Optional contact name for personalizing the report and outreach copy |
| `cta_link` | string | Optional CTA URL (e.g. Calendly link) added as a button on the public report page |

### Response Schema

_Complete documented fields for this section, with nested notation preserved. Endpoint-specific envelopes, availability and additional fields are described under each endpoint below._

| Field | Notes |
|-------|-------|
| slug — unique identifier for the public report URL | |
| url — full shareable URL for the ROI report | |
| outreach → linkedin_message, email_subject, email_body | |
| result → company_name, industry, executive_summary | |
| result → current_state → challenges[] → challenge, impact, severity | |
| result → roi_projections → timeframe, total_roi_percentage, total_savings, payback_period, metrics[] → category, current_cost, projected_cost, annual_savings, improvement_percentage, explanation | |
| result → implementation_timeline[] → phase, title, duration, milestones[], description | |
| result → risk_mitigation[] → risk, mitigation, likelihood | |
| result → competitive_advantage, recommendation → title, summary, next_steps[] | |
| result → key_stats[] → value, label | |
| result → contact_enrichment → full_name, job_title, seniority, department, email, phone (null if no match) | |
| credits_used | |

**Illustrative Example Response (synthetic, not a complete endpoint schema):**

```json
{
  "data": {
    "slug — unique identifier for the public report URL": "https://example.com",
    "url — full shareable URL for the ROI report": "https://example.com",
    "credits_used": "string",
    "outreach": {
      "linkedin_message": "string",
      "email_subject": "user@example.com",
      "email_body": "user@example.com"
    },
    "result": {
      "contact_enrichment → full_name": "string",
      "job_title": "string",
      "seniority": "string",
      "department": "string",
      "email": "user@example.com",
      "phone (null if no match)": "+14155551234"
    }
  }
}
```

### POST /v1/apps/roi-calculator — Generate ROI Report

Generate a personalized ROI projection and business case for a prospect. Crawls their website, enriches company data, and uses AI to produce quantified savings projections, implementation timelines, and risk analysis. The report is saved with a shareable public URL and includes AI-generated LinkedIn and email outreach copy. Optionally provide contact details for decision-maker enrichment. Costs 10 credits.

Returns:
- Shareable public URL (slug + url)
- Executive summary tailored to the prospect
- Current state analysis with severity-ranked challenges
- ROI projections with per-category savings and improvement percentages
- Implementation timeline with phases and milestones
- Risk mitigation strategies
- Competitive advantage analysis
- Recommendation with next steps
- AI-generated outreach copy (LinkedIn message + email subject/body)
- Contact enrichment (when contact_email or contact_linkedin provided)

**Example Request Body:**

```json
{
  "target_domain": "prospect.com",
  "your_domain": "yourdomain.com",
  "your_product_description": "AI-powered sales automation platform",
  "investment_amount": "50000",
  "contact_email": "cfo@prospect.com",
  "contact_linkedin": "linkedin.com/in/johndoe",
  "contact_name": "John Doe",
  "cta_link": "https://calendly.com/your-link"
}
```

**cURL Example:**

```bash
curl -X POST 'https://bvjmtgaxijpyasjtaqiv.supabase.co/functions/v1/api-gateway' \
  -H 'Content-Type: application/json' \
  -H 'x-amz-security-token: YOUR-API-KEY' \
  -d '{
  "path": "/v1/apps/roi-calculator",
  "method": "POST",
  "body": {
    "target_domain": "prospect.com",
    "your_domain": "yourdomain.com",
    "your_product_description": "AI-powered sales automation platform",
    "investment_amount": "50000",
    "contact_email": "cfo@prospect.com",
    "contact_linkedin": "linkedin.com/in/johndoe",
    "contact_name": "John Doe",
    "cta_link": "https://calendly.com/your-link"
  }
}'
```

