API & MCP
Case Study Writer turns your Ounie brain into cited customer case studies. Everything the dashboard does is a REST endpoint and an MCP tool, so an agent can drive it end to end — spending your shared Ounie credits, never able to overdraw.
Authentication
Two credentials work everywhere — send either as a bearer token, or (for MCP clients that can’t set headers) as an ?api_key= query parameter.
| Key | What it can do |
|---|---|
csw_live_… | This app’s own key. Mint up to 5 in the dashboard. Can list, read, export, and publish. Cannot reach your brains, so a generation call with it is refused (see below). |
ounie_live_… | Your fleet master key— an ounie.com developer key with “use across Ounie apps” enabled (ounie.com → Settings → API keys). It forwards upstream to ounie.com, so it grounds generations in your private brain and cites them. Draws the same shared wallet. |
The browser dashboard authenticates with the shared .ounie.com session cookie; the same routes accept a bearer key. A bad or missing token returns 401 (never a redirect).
# header form curl https://case-study.ounie.com/api/studies -H "Authorization: Bearer ounie_live_…" # query form (for hosts that can't set headers) curl "https://case-study.ounie.com/api/studies?api_key=csw_live_…"
csw_live_ key has no upstream credential, so a POST /api/studies (or regenerate) with one returns 403 use_master_key — you were not charged. Reads, listing, and export all work with a csw_live_ key.Credits & billing
Usage draws your shared Ounie credit wallet (1 credit = 1¢), the same balance every Ounie product spends. Generating (or regenerating) one case study costs a flat 8 credits. If your brain holds nothing on the topic, you’re refunded in full and get a 422 thin_material. Listing, reading, export, publishing, and public views are free forever.
When the wallet is short, a generate returns 402 with a buy_credits_url — an agent can never overdraw. Buy credits at ounie.com.
REST endpoints
Base URL https://case-study.ounie.com. All routes accept the cookie or a bearer key.
/api/brainsList the Ounie brains you can build a case study from. Needs a cookie or the master key (it proxies ounie.com).
{ "brains": [ { "id": "…", "name": "…", "sourceCount": 12 } ] }/api/studiesGenerate one cited case study. Bills 8 credits (thin → full refund). Grounded → requires the master key.
{
"brain_ids": ["<uuid>", "..."], // 1–5 brains
"brief": "how Acme cut onboarding 60%" // optional angle
}{ "ok": true, "study_id": "<uuid>",
"grounded": true, "credits_spent": 8 }
// 403 use_master_key — per-app key, no brain access (not charged)
// 402 insufficient_credits { required_credits, balance_credits, buy_credits_url }
// 422 thin_material — no brain pages matched (not charged)/api/studiesList your case studies (newest first).
{ "studies": [ { "id", "title", "status", "share_slug", … } ] }/api/studies/{id}Fetch one study you own — full narrative, metrics, quotes, citations.
{ "study": { "title", "challenge", "solution", "results",
"metrics": [...], "quotes": [...], "citations": [...], … } }/api/studies/{id}Free edit of any field — title, subtitle, the narrative sections, metrics, quotes.
{ "title": "…", "results": "…", "metrics": [ { "label", "value", "detail" } ] }{ "ok": true }/api/studies/{id}/regenerateRe-compose from fresh retrieval over the same brains. Re-bills 8 credits. Keeps the share slug + publish state. Requires the master key.
{ "brief": "optional new angle" }{ "ok": true, "grounded": true, "credits_spent": 8 }/api/studies/{id}/publishPublish or unpublish the public share page (free). Publishing makes /p/<slug> live.
{ "publish": true }{ "ok": true, "status": "published", "share_slug": "…" }/api/studies/{id}/exportDownload the study as a polished DOCX (free — a read of already-paid work).
200 application/vnd.openxmlformats-officedocument.wordprocessingml.document
MCP server
One endpoint speaks the Model Context Protocol to any host — Claude, Cursor, ChatGPT, the AI SDK, and the Ounie AI Team. Tools are discovered automatically.
Endpoint https://case-study.ounie.com/api/mcp (Streamable HTTP; legacy SSE at /api/sse)
Auth Authorization: Bearer csw_live_… (or ounie_live_… to ground)
or https://case-study.ounie.com/api/mcp?api_key=… (headerless hosts)| Tool | Credits | What it does |
|---|---|---|
list_brains | free | Your brains (master key only) |
list_studies | free | Your library |
get_study | free | One study, full body + citations |
export_study | free | Study as clean Markdown |
generate_case_study | 8 | Compose a cited study (master key) |
regenerate_case_study | 8 | Re-compose (master key) |
publish_study | free | Publish/unpublish the /p page |
get_credit_balance | free | Spendable Ounie credits |
get_pricing | free | Public — no auth required |
whoami | free | Owner + key metadata |
Connect the Ounie AI Team (TabTab)
The AI Team’s HTTP-MCP entries can’t set an Authorization header, so ride the key on the URL. Add an MCP server with this URL and the AI Team can generate and publish case studies for you:
https://case-study.ounie.com/api/mcp?api_key=ounie_live_… # use ounie_live_ (your fleet master key) so it can reach your brains. # a csw_live_ app key connects too, but can only read/list/export/publish.
x402 (pay-per-call)
Case Study Writer does notship an x402 rail: every generation is grounded in your own private Ounie brain, which a keyless payer can’t access — so agent access is API keys / MCP (credits) only.
Mint a csw_live_ key in the dashboard, or enable your fleet master key on ounie.com to ground in your brains.