{
  "info": {
    "name": "Chart-Output API",
    "description": "Complete API collection for testing Chart-Output. Use with the docs at /docs.\n\n**Setup:**\n1. Set `baseUrl` to your app URL (e.g. http://localhost:3000 or https://chart-output.com)\n2. For render endpoints: Set `apiKey` to your API key (from Dashboard → API Keys)\n3. For dashboard endpoints: Set `sessionToken` to your Supabase JWT (sign in, then copy from browser DevTools → Application → Cookies or Network tab)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "http://localhost:3000" },
    { "key": "apiKey", "value": "pk_test_your_api_key_here" },
    { "key": "sessionToken", "value": "your_supabase_jwt_here" }
  ],
  "item": [
    {
      "name": "Health",
      "item": [
        {
          "name": "Health Check",
          "request": {
            "method": "GET",
            "header": [],
            "url": "{{baseUrl}}/api/health",
            "description": "Check if the API is running. No auth required."
          }
        }
      ]
    },
    {
      "name": "Render (Chart API)",
      "item": [
        {
          "name": "GET Render - Simple Query",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{apiKey}}", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/render?type=line&labels=Jan,Feb,Mar,Apr,May,Jun&data=30,45,35,55,48,62&format=png&width=600&height=300",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "render"],
              "query": [
                { "key": "type", "value": "line", "description": "line, bar, pie, doughnut, radar, polarArea" },
                { "key": "labels", "value": "Jan,Feb,Mar,Apr,May,Jun" },
                { "key": "data", "value": "30,45,35,55,48,62" },
                { "key": "format", "value": "png", "description": "png, jpeg, svg, webp" },
                { "key": "width", "value": "600" },
                { "key": "height", "value": "300" },
                { "key": "title", "value": "Monthly Stats", "disabled": true }
              ]
            },
            "description": "Renders a chart from URL params. Ideal for <img src=\"...\"> embeds. Returns image binary."
          }
        },
        {
          "name": "GET Render - Bar Chart",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{apiKey}}", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/render?type=bar&labels=Q1,Q2,Q3,Q4&data=100,150,120,180&title=Revenue&format=png&width=600&height=300",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "render"],
              "query": [
                { "key": "type", "value": "bar" },
                { "key": "labels", "value": "Q1,Q2,Q3,Q4" },
                { "key": "data", "value": "100,150,120,180" },
                { "key": "title", "value": "Revenue" },
                { "key": "format", "value": "png" },
                { "key": "width", "value": "600" },
                { "key": "height", "value": "300" }
              ]
            }
          }
        },
        {
          "name": "POST Render - Full Spec",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{apiKey}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"type\": \"line\",\n  \"width\": 800,\n  \"height\": 400,\n  \"format\": \"png\",\n  \"data\": {\n    \"labels\": [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\"],\n    \"datasets\": [\n      { \"label\": \"Revenue\", \"data\": [12000, 15000, 18000, 22000, 25000, 28000] },\n      { \"label\": \"Costs\", \"data\": [8000, 9000, 10000, 11000, 12000, 13000] }\n    ]\n  },\n  \"options\": {},\n  \"brandKitId\": null\n}"
            },
            "url": "{{baseUrl}}/api/v1/render",
            "description": "Renders a chart from a full JSON spec. Returns image binary. Supports multiple datasets, brandKitId, etc."
          }
        },
        {
          "name": "GET Template Render",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{apiKey}}", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/templates/mrr-trend/render?labels=Jan,Feb,Mar,Apr,May,Jun&data=12000,15000,18000,22000,25000,28000&format=png",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "templates", "mrr-trend", "render"],
              "query": [
                { "key": "labels", "value": "Jan,Feb,Mar,Apr,May,Jun" },
                { "key": "data", "value": "12000,15000,18000,22000,25000,28000" },
                { "key": "format", "value": "png" },
                { "key": "brandKitId", "value": "", "disabled": true, "description": "UUID of brand kit" }
              ]
            },
            "description": "Renders a built-in or custom template. Built-in IDs: mrr-trend, signups-bar, plan-distribution, funnel-conversion, nps-trend, churn-rate, mrr-growth"
          }
        }
      ]
    },
    {
      "name": "API Keys",
      "item": [
        {
          "name": "List API Keys",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/api-keys",
            "description": "List all API keys. Requires session JWT (dashboard auth)."
          }
        },
        {
          "name": "Create API Key",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Production API Key\",\n  \"environment\": \"production\"\n}"
            },
            "url": "{{baseUrl}}/api/v1/api-keys",
            "description": "Create a new API key. Returns the full key once — copy it, it won't be shown again. environment: production | sandbox"
          }
        },
        {
          "name": "Revoke API Key",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/api-keys/:id",
            "description": "Permanently revoke an API key. Replace :id with the key ID from the list."
          }
        }
      ]
    },
    {
      "name": "Brand Kits",
      "item": [
        {
          "name": "List Brand Kits",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/brand-kits"
          }
        },
        {
          "name": "Create Brand Kit",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"My Brand\",\n  \"primaryColor\": \"#1A3263\",\n  \"accentColor\": \"#10b981\",\n  \"gridStyle\": \"subtle\",\n  \"rounding\": 4,\n  \"font\": \"Inter\",\n  \"isDefault\": false\n}"
            },
            "url": "{{baseUrl}}/api/v1/brand-kits"
          }
        },
        {
          "name": "Get Brand Kit",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/brand-kits/:id"
          }
        },
        {
          "name": "Update Brand Kit",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated Brand\",\n  \"primaryColor\": \"#1A3263\",\n  \"accentColor\": \"#10b981\"\n}"
            },
            "url": "{{baseUrl}}/api/v1/brand-kits/:id"
          }
        },
        {
          "name": "Delete Brand Kit",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/brand-kits/:id"
          }
        }
      ]
    },
    {
      "name": "Templates",
      "item": [
        {
          "name": "List Templates",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/templates",
            "description": "Returns built-in + user's custom templates."
          }
        },
        {
          "name": "Create Template",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"My Chart Template\",\n  \"description\": \"Custom line chart for monthly data\",\n  \"chartType\": \"line\",\n  \"spec\": {\n    \"type\": \"line\",\n    \"width\": 800,\n    \"height\": 400,\n    \"format\": \"png\",\n    \"data\": {\n      \"labels\": [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\"],\n      \"datasets\": [{ \"label\": \"Data\", \"data\": [10, 20, 30, 40, 50, 60] }]\n    }\n  }\n}"
            },
            "url": "{{baseUrl}}/api/v1/templates"
          }
        },
        {
          "name": "Get Template",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/templates/:templateId"
          }
        },
        {
          "name": "Update Template",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Updated Template\",\n  \"description\": \"Updated description\",\n  \"spec\": {}\n}"
            },
            "url": "{{baseUrl}}/api/v1/templates/:templateId"
          }
        },
        {
          "name": "Delete Template",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/templates/:templateId",
            "description": "Only user-created templates can be deleted. Built-in templates are read-only."
          }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "List Webhooks",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/webhooks"
          }
        },
        {
          "name": "Create Webhook",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://webhook.site/your-unique-id\",\n  \"events\": [\"render.success\", \"render.failed\"]\n}"
            },
            "url": "{{baseUrl}}/api/v1/webhooks",
            "description": "Creates a webhook. Returns secret once — save it for HMAC verification. Valid events: render.success, render.failed"
          }
        },
        {
          "name": "Test Webhook",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/webhooks/:id/test",
            "description": "Sends a test payload to the webhook endpoint."
          }
        },
        {
          "name": "Delete Webhook",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/webhooks/:id"
          }
        }
      ]
    },
    {
      "name": "Dashboard & Usage",
      "item": [
        {
          "name": "Get Stats",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/stats",
            "description": "Overview stats: renders this month, success rate, avg latency."
          }
        },
        {
          "name": "Get Recent Renders",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/renders?limit=10",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "renders"],
              "query": [{ "key": "limit", "value": "10" }]
            }
          }
        },
        {
          "name": "Get Usage",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/usage",
            "description": "Usage data for current billing period."
          }
        },
        {
          "name": "Get Audit Logs",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/v1/audit-logs?limit=50",
              "host": ["{{baseUrl}}"],
              "path": ["api", "v1", "audit-logs"],
              "query": [{ "key": "limit", "value": "50" }]
            }
          }
        }
      ]
    },
    {
      "name": "Billing",
      "item": [
        {
          "name": "Get Subscription",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/billing/subscription"
          }
        },
        {
          "name": "Create Checkout Session",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"plan\": \"starter\",\n  \"interval\": \"month\"\n}"
            },
            "url": "{{baseUrl}}/api/billing/create-checkout-session",
            "description": "Creates Stripe Checkout session. plan: starter | pro, interval: month | year. Requires email confirmation."
          }
        },
        {
          "name": "Get Billing Portal",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{}"
            },
            "url": "{{baseUrl}}/api/billing/portal",
            "description": "Returns Stripe Customer Portal URL for managing subscription."
          }
        }
      ]
    },
    {
      "name": "Settings",
      "item": [
        {
          "name": "Get Custom Domain",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" }
            ],
            "url": "{{baseUrl}}/api/v1/settings/custom-domain",
            "description": "Returns custom domain and project name."
          }
        },
        {
          "name": "Update Custom Domain",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"customDomain\": \"charts.yourdomain.com\",\n  \"projectName\": \"My Project\"\n}"
            },
            "url": "{{baseUrl}}/api/v1/settings/custom-domain"
          }
        },
        {
          "name": "Delete Account",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization", "value": "Bearer {{sessionToken}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"password\": \"your_password\"\n}"
            },
            "url": "{{baseUrl}}/api/v1/settings/delete-account",
            "description": "Permanently deletes account. Requires password confirmation."
          }
        }
      ]
    },
    {
      "name": "Public (No Auth)",
      "item": [
        {
          "name": "Enterprise Waitlist",
          "request": {
            "method": "POST",
            "header": [
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"email\": \"you@company.com\",\n  \"company\": \"Acme Inc\",\n  \"renderVolume\": \"100k+\",\n  \"needs\": \"Self-hosted deployment\"\n}"
            },
            "url": "{{baseUrl}}/api/v1/enterprise-waitlist",
            "description": "Join the Enterprise waitlist. No auth required."
          }
        }
      ]
    }
  ]
}
