Ktrl API Documentation

Read-only HTTP API and MCP server for Ktrl marketing analytics: your apps, spend recommendations, and cohort performance reports.

Machine-readable: openapi.json · api.md · mcp.md · llms.txt

Ktrl MCP Server

Model Context Protocol server exposing the same data to LLM clients such as Claude Code and Cursor. Every tool is read-only; the server cannot change anything in Ktrl.

Endpoint

https://api.kohort.io/api/v1/mcp

Transport: Streamable HTTP. Every call is an ordinary HTTP POST with a JSON-RPC 2.0 body — there is no session to open or keep alive, so each request stands on its own. GET and DELETE return 405. The 2025 protocol revisions are served to every client; clients that declare the MCP Apps extension (`io.modelcontextprotocol/ui`) in their requests are served protocol 2026-07-28 as well. Rate limit: 60 requests per minute per company, shared with the REST API.

Authentication

  • API key — Send Authorization: Bearer kht_<your-api-key> on every request. Create a key in the Ktrl platform under Settings → API Keys.

Your Ktrl user is connected to your company the first time you log in. Every tool call only returns data for the apps that company can access.

Required headers

HeaderRequiredDescription
AuthorizationRequiredBearer kht_<your-api-key>.
Content-TypeRequiredapplication/json
AcceptRequiredMust include both application/json and text/event-stream. Sending only one is the most common reason the connection fails.

Client setup

Claude Code

Run this once — Claude Code remembers the server and your key.

claude mcp add --transport http ktrl https://api.kohort.io/api/v1/mcp --header "Authorization: Bearer kht_<your-api-key>"

Cursor

Add this to ~/.cursor/mcp.json, then reload Cursor.

{
  "mcpServers": {
    "ktrl": {
      "url": "https://api.kohort.io/api/v1/mcp",
      "headers": {
        "Authorization": "Bearer kht_<your-api-key>"
      }
    }
  }
}

MCP Inspector

The official tool for trying tools out before wiring them into a client. Start it, choose the Streamable HTTP transport, paste in the endpoint URL, then add an `Authorization: Bearer kht_<your-api-key>` header.

npx @modelcontextprotocol/inspector

Any client (curl)

Nothing here is specific to one client — anything that can POST with headers works. This example lists the available tools.

curl -X POST "https://api.kohort.io/api/v1/mcp" \
  -H "Authorization: Bearer kht_<your-api-key>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Tools

ktrl_list_appsList apps

Lists the live apps in your Ktrl account, with the id each takes as appId. Call it when the user asks to see their apps or has not said which app they mean; when they gave an app id or name, pass that to the other ktrl tools directly instead. In hosts that show interactive views, it also shows the apps as cards the user can pick from.

Takes no arguments.

ktrl_get_recommendationsGet spend recommendations

Latest marketing spend recommendations for an app. Each row has an action (SCALE, HOLD or REDUCE), daily spend, installs, CPI, confidence score and current vs target ROAS per campaign (or per campaign+country). Rows are capped by limit; the response says if it was truncated. In hosts that show interactive views, it also shows the recommendations as cards like the Ktrl web app; picking a card asks for the cohort report of that campaign, and each card links to Ktrl where the chat allows it.

ArgumentTypeRequiredDescriptionDefault
appIdintegerOptionalApp id, when the user gave one or an earlier result returned it; pass it as is, without calling ktrl_list_apps to check it. Otherwise pass appName, or leave both out when the account has one live app—
appNamestringOptionalApp name as the user said it, when the id isn't known; matched case-insensitively, a partial name is fine. Several matches or none come back as an error naming the live apps—
granularity'campaign' | 'campaign_geo'Optional'campaign' = one row per campaign with all geos aggregated; 'campaign_geo' = one row per campaign+country (can return many rows)campaign
countriesstring[]OptionalCountry code filter, e.g. ['US', 'GB']. Only valid with granularity 'campaign_geo'—
platformsstring[]OptionalPlatform filter: 'IOS', 'ANDROID', 'WEB' and/or 'PC'—
networksstring[]OptionalAd network filter, e.g. Facebook, Google—
limitintegerOptionalMaximum number of rows to return. Rows are sorted by spend, so the top rows matter most100

ktrl_get_reportGet cohort report

Cohort performance report for an app: spend, installs, CPI, LTV and ROAS per install cohort, broken down by campaign (optionally by country). Rows are capped by limit and come newest cohort first; the response says if it was cut — for older cohorts ask again for an earlier window, and for apps with many campaigns group weekly (installGrouping WEEKLY) or filter to fewer campaigns. In hosts that show interactive views, it also shows the rows as a chart the user can switch between metrics, filter and download.

ArgumentTypeRequiredDescriptionDefault
appIdintegerOptionalApp id, when the user gave one or an earlier result returned it; pass it as is, without calling ktrl_list_apps to check it. Otherwise pass appName, or leave both out when the account has one live app—
appNamestringOptionalApp name as the user said it, when the id isn't known; matched case-insensitively, a partial name is fine. Several matches or none come back as an error naming the live apps—
granularity'campaign' | 'campaign_geo'Optional'campaign' = one row per install cohort + campaign; 'campaign_geo' also splits by country (can return many rows)campaign
metrics('spend' | 'installs' | 'cpi' | 'ltv' | 'roas')[]OptionalMetrics to include. 'ltv' and 'roas' add one column per roasType x revenueType x dsiValue. cpi and ltv are null when installs are 0, and roas is null when spend is 0: undefined, not 0["spend","installs","cpi"]
roasTypes('PAID' | 'INCREMENTAL_BLENDED' | 'FULL_BLENDED')[]OptionalPAID = paid traffic only; INCREMENTAL_BLENDED / FULL_BLENDED include organic attribution["PAID"]
revenueTypes('GROSS' | 'NET')[]OptionalGROSS is before fees; NET is net of fees, taxes and refunds["GROSS"]
dsiValuesinteger[]OptionalDays-since-install horizons for ltv/roas metrics (max 5). Only used and validated when metrics include 'ltv' or 'roas'; invalid values are rejected with the list of available ones[7,365]
startDatestringOptionalInstall cohort start date, YYYY-MM-DD. Default: 30 days before endDate—
endDatestringOptionalInstall cohort end date, YYYY-MM-DD. Default: the app's latest data date—
countriesstring[]OptionalCountry code filter, e.g. ['US', 'GB']. Only valid with granularity 'campaign_geo'—
platformsstring[]OptionalPlatform filter: 'IOS', 'ANDROID', 'WEB' and/or 'PC'—
networksstring[]OptionalAd network filter, e.g. Facebook, Google—
campaignsstring[]OptionalCampaign name filter (exact match, case-sensitive)—
installGrouping'DAILY' | 'WEEKLY' | 'MONTHLY'OptionalHow install cohorts are bucketed. Default: WEEKLY for apps that require weekly aggregation, DAILY otherwise. Weeks start on the company's reporting week start day (Monday unless changed in company settings), and each weekly cohort is labelled with its first day—
limitintegerOptionalMaximum number of rows to return. The response size budget usually cuts first; lower it only to keep a result small500

ktrl_export_reportExport report file

Builds the full cohort report as a CSV or Parquet file, with no row limit (the same file the REST /v1/report endpoint returns), and replies with a download link that works for 15 minutes. Use it when the user wants the report as a file, and give them the link. For rows to read in the conversation, use ktrl_get_report.

ArgumentTypeRequiredDescriptionDefault
appIdintegerOptionalApp id, when the user gave one or an earlier result returned it; pass it as is, without calling ktrl_list_apps to check it. Otherwise pass appName, or leave both out when the account has one live app—
appNamestringOptionalApp name as the user said it, when the id isn't known; matched case-insensitively, a partial name is fine. Several matches or none come back as an error naming the live apps—
granularity'campaign' | 'campaign_geo'Optional'campaign' = one row per install cohort + campaign; 'campaign_geo' also splits by country (can return many rows)campaign
metrics('spend' | 'installs' | 'cpi' | 'ltv' | 'roas')[]OptionalMetrics to include. 'ltv' and 'roas' add one column per roasType x revenueType x dsiValue. cpi and ltv are null when installs are 0, and roas is null when spend is 0: undefined, not 0["spend","installs","cpi"]
roasTypes('PAID' | 'INCREMENTAL_BLENDED' | 'FULL_BLENDED')[]OptionalPAID = paid traffic only; INCREMENTAL_BLENDED / FULL_BLENDED include organic attribution["PAID"]
revenueTypes('GROSS' | 'NET')[]OptionalGROSS is before fees; NET is net of fees, taxes and refunds["GROSS"]
dsiValuesinteger[]OptionalDays-since-install horizons for ltv/roas metrics (max 5). Only used and validated when metrics include 'ltv' or 'roas'; invalid values are rejected with the list of available ones[7,365]
startDatestringOptionalInstall cohort start date, YYYY-MM-DD. Default: 30 days before endDate—
endDatestringOptionalInstall cohort end date, YYYY-MM-DD. Default: the app's latest data date—
countriesstring[]OptionalCountry code filter, e.g. ['US', 'GB']. Only valid with granularity 'campaign_geo'—
platformsstring[]OptionalPlatform filter: 'IOS', 'ANDROID', 'WEB' and/or 'PC'—
networksstring[]OptionalAd network filter, e.g. Facebook, Google—
campaignsstring[]OptionalCampaign name filter (exact match, case-sensitive)—
installGrouping'DAILY' | 'WEEKLY' | 'MONTHLY'OptionalHow install cohorts are bucketed. Default: WEEKLY for apps that require weekly aggregation, DAILY otherwise. Weeks start on the company's reporting week start day (Monday unless changed in company settings), and each weekly cohort is labelled with its first day—
format'parquet' | 'csv'OptionalCSV opens in spreadsheets; Parquet is smaller and keeps column types, better for large filescsv

ktrl_get_roas_historyGet ROAS history

How each install cohort's predicted ROAS changed as the cohort aged — a proxy for model stability. Each row is one cohort (per campaign or campaign+country at finer granularities) with roas_age_N = predicted ROAS at the requested DSI when the cohort was N days old; ages with no data are omitted. Start at 'app' granularity, then filter to specific campaigns or countries. Rows are capped by limit and response size; the response says if it was truncated. For bulk data use the /v1/roas-history file export.

ArgumentTypeRequiredDescriptionDefault
appIdintegerOptionalApp id, when the user gave one or an earlier result returned it; pass it as is, without calling ktrl_list_apps to check it. Otherwise pass appName, or leave both out when the account has one live app—
appNamestringOptionalApp name as the user said it, when the id isn't known; matched case-insensitively, a partial name is fine. Several matches or none come back as an error naming the live apps—
granularity'app' | 'campaign' | 'campaign_geo'Optional'app' = one row per install cohort (start here); 'campaign' / 'campaign_geo' split by campaign (and country), only for campaigns in the latest successful recommendation run, and can return many rowsapp
dsiintegerOptionalDays-since-install horizon the ROAS is measured at. Default: the app's target DSI. Invalid values are rejected with the list of available ones—
roasType'PAID' | 'INCREMENTAL_BLENDED' | 'FULL_BLENDED'OptionalPAID = paid traffic only; INCREMENTAL_BLENDED / FULL_BLENDED include organic attribution. Default: the app's target ROAS type—
revenueType'GROSS' | 'NET'OptionalGROSS is before fees; NET is net of fees, taxes and refunds. Default: the app's target revenue type—
installGrouping'DAILY' | 'WEEKLY' | 'MONTHLY'OptionalHow install cohorts are bucketed. DAILY is rejected for apps that require weekly aggregation. Weeks start on the company's reporting week start day (Monday unless changed in company settings)WEEKLY
startDatestringOptionalInstall cohort start date, YYYY-MM-DD. Default: 90 days before endDate. Max range 455 days—
endDatestringOptionalInstall cohort end date, YYYY-MM-DD. Default: the app's latest data date—
countriesstring[]OptionalCountry code filter, e.g. ['US', 'GB']. Not valid with granularity 'campaign'—
platformsstring[]OptionalPlatform filter: 'IOS', 'ANDROID', 'WEB' and/or 'PC'—
networksstring[]OptionalAd network filter, e.g. Facebook, Google—
campaignsstring[]OptionalCampaign name filter (exact match, case-sensitive)—
limitintegerOptionalMaximum number of rows to return. Large responses are also cut by size50

ktrl_get_alertsGet alerts

Alerts Ktrl raised about an app's campaigns — what changed and what to do about it. Each row has the alert title, a one-line summary, the campaign, network, platform and country it concerns, the daily spend affected, a fuller explanation and a recommended action. Returns the latest alert run by default; pass startDate for history. Rows are capped by limit; the response says if it was truncated.

ArgumentTypeRequiredDescriptionDefault
appIdintegerOptionalApp id, when the user gave one or an earlier result returned it; pass it as is, without calling ktrl_list_apps to check it. Otherwise pass appName, or leave both out when the account has one live app—
appNamestringOptionalApp name as the user said it, when the id isn't known; matched case-insensitively, a partial name is fine. Several matches or none come back as an error naming the live apps—
alertGroups('BIDS' | 'ANALYTICS')[]OptionalAlert group filter. 'BIDS' = live bid more than ±5% off the paced recommendation; 'ANALYTICS' = performance, confidence and custom-rule alerts. Omit for both—
countriesstring[]OptionalCountry codes, e.g. ['US', 'GB'], or 'GLOBAL' for campaign-level alerts (all analytics alerts, plus bid alerts not split by country). Omit for all—
platformsstring[]OptionalPlatform filter: 'IOS', 'ANDROID', 'WEB' and/or 'PC'—
networksstring[]OptionalAd network filter, e.g. Facebook, Google—
campaignsstring[]OptionalCampaign name filter, exact match—
startDatestringOptionalStart of the alert date range (YYYY-MM-DD, UTC, inclusive). Omit both dates to get only the latest run, as shown in the Ktrl inbox—
endDatestringOptionalEnd of the alert date range (YYYY-MM-DD, UTC, inclusive). Defaults to today; requires startDate—
limitintegerOptionalMaximum number of rows to return. Rows are sorted newest run first, then by daily spend, so the top rows matter most100

ktrl_get_profileGet profile

Identifies the Ktrl account these credentials belong to: a stable id, plus the name and email of the signed-in user when connected through a login rather than an API key.

Takes no arguments.

Tools that return rows take a limit, 500 at most; ktrl_get_report defaults to the maximum and the other row tools to less. ktrl_get_report and ktrl_get_roas_history also cut large responses by size. If more rows matched than you got back, the response sets truncated: true; the rows are the newest cohorts, so for older ones ask for an earlier window, or add filters.

Errors

StatusMeaningResolution
401Your key is missing, malformed, or expired.Check you are sending Authorization: Bearer kht_<your-api-key>.
403Your key is valid, but it cannot reach the app you asked for — or your user is not connected to a company yet.Call ktrl_list_apps to see which apps this key can read.
405You sent a GET or DELETE to the MCP endpoint.Use POST — every MCP call is a POST.
429You have gone over the rate limit.Wait for the current minute to pass and retry. The limit is 60 requests per minute.
isError resultThe call reached the tool, but the tool rejected one of your arguments — an unsupported dsiValue, for example, or a countries filter used with campaign granularity.Read the error message. It names the argument at fault and, where it can, lists the values you can use instead.