Customize Report Charts via API

Swap any chart type, hide sections, rename titles, or reorder cards in your analysis reports, instantly, with one API call. No rebuild, no Docker run, no cost. Your customizations persist across sessions and apply to every shareable report link you've generated.

Instant Persistent No rebuild

The Problem

You ran an analysis. The bar chart for "Attrition Rate by Segment" came out with the department names overlapping on the x-axis because they're too long. You want to flip it to a horizontal bar so the labels have room. In most analytics platforms, this means re-running the full analysis: 25 minutes of Docker time, tokens burned, and a new report URL to re-share with your team.

MCP Analytics separates how the data looks from what the data is. The R analysis still produces the same numbers. You override the visual resolver step that turns those numbers into charts. The override is a single API call. It saves to your account, applies on the next render, and every shared link of that report picks it up automatically. No rebuild.

One PATCH to Rule Them All

The core endpoint is PATCH /api/v1/user/modules/{module_name}/cards. Send a list of card overrides; the server replaces your current layout with them:

curl -X PATCH https://api.mcpanalytics.ai/api/v1/user/modules/analytics__hr__employees__attrition_drivers/cards \
  -H "X-API-Key: $YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cards": [
      {
        "card_id": "comparison_bar",
        "kind": "horizontal_bar",
        "title_override": "Attrition Rate by Department, Role, and Level"
      },
      { "card_id": "preprocessing", "visible": false },
      { "card_id": "effect_bar", "options": { "sort_by": "odds_ratio" } }
    ]
  }'

Response: {"success": true, "saved": 3}. The next time you view a report for this module, whether you re-run the tool yourself or someone clicks a shareable link you already sent them. The new layout is live.

Can an Agent Do This?

Not through MCP today. Our MCP server has no card override tools. Card overrides are set through the REST endpoints on this page, with your API key in the X-API-Key header. An agent that can make HTTP calls can send the same PATCH request for you.

What You Can Override

FieldTypeWhat it does
kindstringChart type: must be compatible with the card's data shape. A scatter (needs 2 numerics) can become a line but not a pie.
visiblebooleanfalse hides the card; true or omitted shows it.
positioninteger0-indexed order, lower sorts earlier. Cards without a position fall through to the default order.
title_overridestringReplaces the card's default title.
optionsobjectPass-through chart options (sort_by, facet_by, top_n, etc.) specific to the target kind.

Valid chart kinds

bar, horizontal_bar, grouped_bar, stacked_bar, line, line_with_band, scatter, scatter3d, histogram, box, violin, heatmap, contour, table, pie, donut, treemap, sunburst, sankey, gauge, radar, waterfall, funnel, lollipop, dot.

Endpoints (Full Reference)

All five endpoints are at /api/v1/user/modules/{module_name}/cards, authenticated via X-API-Key.

MethodPathPurpose
GET/cardsRead the caller's saved layout
PATCH/cardsReplace the full layout with a list of overrides
POST/cards/{card_id}Upsert a single card without touching the others
DELETE/cards/{card_id}Revert one card to the module default
DELETE/cardsReset all overrides for this module

How Shared Links Work

When you run an analysis and get a shareable link like https://api.mcpanalytics.ai/rpt/rpt_abc123, the link renders with your current card overrides, not a frozen snapshot from when you generated the link. Edit your layout once: every outstanding share link updates automatically on next view.

If you need a frozen point-in-time version, use the PDF export: /rpt/{token}/pdf. PDFs are immune to later edits.

Design rationale: Token views follow the owner's live customizations by design. This supports the "polish a report and ship every shared link at once" workflow without doubling storage. The PDF export is the frozen-snapshot escape hatch.

Debugging

When an override isn't taking effect, walk this checklist in order:

  1. Is the override in the database? Call GET /cards and confirm the card is listed with your settings.
  2. Which render path are you hitting? Overrides load on /api/v1/reports/{id}/cards/data, /rpt/{token}, and the account-dashboard card endpoints. Other paths (like a raw card thumbnail fetch) may not apply them.
  3. Does the card ID exist in the module? The resolver silently ignores overrides for unknown card IDs. Use GET /api/v1/reports/{id}/cards on a real report to see the actual card IDs.
  4. Is the target chart kind compatible? A card whose data has 1 numeric and 1 categorical column works fine as bar or horizontal_bar but will produce an empty chart if you try scatter (which needs 2 numerics). Try a sibling kind from the same family first.

Reproducibility

Card overrides change presentation, not analysis. The underlying R code, the numbers, the methodology, all unchanged and always visible in the report's "Show the Code" appendix. You're choosing how to display results that remain bit-for-bit reproducible. This is the core differentiator: same inputs, same answer, same code, but the presentation layer is yours to tailor.

Try It Now

Get an API key from your account page, pick any deployed module from our catalog, run it once, then customize the cards. The quick start has the full onboarding flow.