KPI Trust

API reference

KPI Trust API Integration Guide (v1)

An API for sending actuals (daily numbers, and numbers finalized each month) to KPI Trust from other systems and spreadsheets. Numbers you already have in Google Analytics, sales management, accounting software, or your own systems can go into KPI Trust without being re-entered by hand.

Version
v1 (2026-11-22)
Base URL
https://kpitrust.com/api/v1
Machine-readable spec (OpenAPI 3.1)
/api/v1/openapi.yaml
Authentication
Bearer token
Contents
  1. Overview
  2. Getting started
  3. Authentication
  4. GETList KPIs
  5. POSTWrite actuals
  6. Errors
  7. Limits
  8. Examples
  9. Versioning policy and changelog

Overview

What you can do

What you can do Endpoint
Read the list of KPIs that have an external key (also used to check that a token works) GET /api/v1/kpis
Write and delete actuals (daily and monthly) POST /api/v1/actuals

Which numbers are a good fit

The API is a good fit for result measures (RI and KRI) and for process measures (PI) that another system counts automatically. For KPIs (the action numbers your team moves every day), entering the number by hand is itself the point, so we recommend keeping them as manual entry.

KPI Trust doesn't pull data from other services

KPI Trust only receives the numbers sent to it. For services like Google Analytics, where the numbers only come out when you go and fetch them, fetch them with one of the following and send them to this API.

  • Apps Script in Google Sheets (a GA4 template is available; see Examples)
  • The "Webhook / HTTP request" action in integration tools such as Zapier, Make, or n8n
  • A scheduled job in your own system (cron, for example)

Getting started

  1. Issue a token: An Organization Owner issues an API token under “Settings → Integrations.” The token is shown only once, when it's issued.
  2. Set the KPI to API integration: On the karte of each KPI you want to send numbers to, set “Data source” to “API integration.”
  3. Assign an external key: Under “External keys” in “Settings → Integrations,” an Organization Owner gives the KPI a name (for example, web_sessions). The API refers to the KPI by this name.
  4. Verify: Call GET /api/v1/kpis and confirm that the KPIs you want to send to come back with "writable": true.

API integration is available on paid plans.

Rules for external keys

  • Starts with a lowercase letter and contains only lowercase letters, digits, and _. Up to 64 characters (regular expression ^[a-z][a-z0-9_]{0,63}$)
  • Unique within the organization
  • If you change it later, integrations still sending with the old external key will fail with unknown_key

Authentication

Include the following header with every request.

  • A token is kpt_live_ followed by 32 hexadecimal digits.
  • A single token can write to every “API integration” KPI in the organization. If you issue a separate token for each integration, you can revoke just the one you want to stop, and the change history shows which integration wrote what.
  • Treat tokens like passwords. If you put one in a spreadsheet, be careful about who it's shared with. If a token leaks, revoke it right away under “Settings → Integrations” and issue a new one.
  • KPI Trust stores only a hash of each token. If you miss it when it's shown at issue time, issue a new one.
Headerhttp
Authorization: Bearer kpt_live_0123456789abcdef0123456789abcdef

List KPIs

GEThttps://kpitrust.com/api/v1/kpis

Returns the KPIs that have an external key.

Field Contents
organization.time_zone The organization's time zone. Send date as a date in this time zone
organization.today Today's date in the organization's time zone
key The external key
type Type (KRI / RI / PI / KPI)
format Number format (count / percent / time / currency)
aggregation How values are aggregated (sum total / average average / last end-of-period value / ratio ratio / formula sum of children)
frequency Frequency (daily / weekly / monthly). Send month for monthly KPIs
data_source Data source (manual manual entry / api API integration / csv CSV import)
lifecycle Status (trial Trial / active Active / rejected Rejected / retired Retired)
writable Whether this API can write to it. true when the data source is api, the KPI isn't a ratio, and it's in Trial or Active
Requestbash
curl https://kpitrust.com/api/v1/kpis \
  -H "Authorization: Bearer $KPITRUST_TOKEN"
Responsejson
{
  "ok": true,
  "organization": { "name": "Sample Corp.", "time_zone": "Asia/Tokyo", "today": "2026-11-22" },
  "kpis": [
    {
      "key": "web_sessions",
      "name": "Web sessions",
      "type": "PI",
      "format": "count",
      "unit_label": "sessions",
      "aggregation": "sum",
      "frequency": "daily",
      "data_source": "api",
      "lifecycle": "active",
      "writable": true
    }
  ]
}

Write actuals

POSThttps://kpitrust.com/api/v1/actuals

Request body

Field Type Contents
values Array (1–500 items) The actuals to write
values[].key String The KPI's external key
values[].date String YYYY-MM-DD For daily and weekly KPIs. The date of the actual, in the organization's time zone
values[].month String YYYY-MM For monthly KPIs (instead of date). The month of the actual
values[].value Number or null The actual for that day (or month). null deletes the API actual for that day (or month)

Each item takes exactly one of date or month. Which one to use is determined by the KPI's frequency (frequency in GET /api/v1/kpis).

Rules

  • Values overwrite; they don't add up. Resending the same KPI and date replaces the value you sent before. For services whose numbers change after the fact (Google Analytics changes for 1–2 days), resend the last few days every time. You get the same result no matter how many times you send.
  • Valid values are written; only invalid ones are returned. Even if some items have errors (those in the validation_failed table under Errors), the other values are written and you get 200. Values that didn't pass go in rejected and rejected_items. Retiring a KPI or changing an external key doesn't stop sends to other KPIs.
    • Check rejected even when ok: true. If rejected is 1 or more, those values weren't written. They'll fail for the same reason every time until fixed, so send them to a notification or log where a person can fix them.
    • Once you've fixed the errors, it's fine to resend everything (values overwrite, so nothing is duplicated).
    • If no value passes, nothing is written and you get 422 validation_failed.
    • For errors in the shape of the body (invalid_json, invalid_request, too_many_items, payload_too_large), or errors with the token, plan, or rate, nothing is written.
  • If the same KPI and date (or month) appear twice in one send, neither is written. There's no way to tell which one is correct (duplicate_item).
  • Send daily values. Send the value for that one day, not a running total. KPI Trust calculates monthly totals and averages according to the aggregation method.
  • Dates you can send run from today in the organization's time zone back to 400 days ago. You can't send future dates.
  • You can't send to ratio KPIs. Send to the numerator and denominator KPIs separately. KPI Trust calculates the ratio as numerator ÷ denominator.
  • API values are kept separate from manual entries. Values sent through the API go in a different row from manually entered values, and the screens show them added together. “API integration” KPIs can't be entered manually on the entry screen. To correct a value, resend it.
  • Every actual written is recorded in the actuals change history along with which token wrote it.

Monthly KPIs (accounting figures and the like)

Numbers that are only finalized after the month closes, such as operating profit, should be set up as KPIs with a frequency of “Monthly” and sent with month.

JSON
{ "values": [{ "key": "operating_profit", "month": "2026-10", "value": 3100000 }] }
  • Send the value for that whole month. KPI Trust stores it as the actual for the last day of that month.
  • If there are corrections after the close (such as adjusting entries), resend the same month. It overwrites. When sending from accounting software, resending the last three months every time is the safe approach.
  • Months you can send run from the current month in the organization's time zone back to 400 days ago. You can send values partway through the current month, but KPI Trust doesn't score the month until it closes.
  • If the previous month's value hasn't arrived by the organization's “Monthly close” (which business day of the following month; 10 by default), it shows as “Stopped” under “API integration status” in KPI Trust.
  • If all you need is to enter accounting figures once a month, you don't need the API: you can paste the monthly trend report from your accounting software into the “Accounting trend report” in KPI Trust's “Targets & Actuals” to import it. Any accounting software works. Keep KPIs sent through the API separate from KPIs imported from the trend report (if a KPI receives values from both, they're added together on screen).

Breakdowns (counts by traffic source and the like)

When you want to send one KPI's number split into parts, for example inquiries split by traffic source, create “Breakdowns” on the parent KPI in KPI Trust and send each breakdown separately (to create breakdowns, see “Split with breakdowns” in the help article Read a KPI Karte).

JSON
{ "values": [
  { "key": "inquiry_exhibition", "date": "2026-11-23", "value": 3 },
  { "key": "inquiry_google_ads", "date": "2026-11-23", "value": 5 },
  { "key": "inquiry_catalog", "date": "2026-11-23", "value": 0 }
] }
  • Assign an external key to each breakdown. Set the breakdown to “API integration” and assign the key under “External keys” in “Settings → Integrations.” In the list, breakdowns appear as “Parent name › Breakdown name.”
  • You can't send to the parent KPI. KPI Trust calculates the parent's actual as the sum of its breakdowns. A KPI with breakdowns can't have an external key or the “API integration” data source, so it doesn't appear in GET /api/v1/kpis. If you were previously sending a total with the parent's external key, creating breakdowns moves that external key to a breakdown called “Uncategorized (earlier data).” If you keep sending after removing it, those values come back in rejected_items as unknown_key and aren't written (the other values are written). Stop sending the total.
  • Send 0 for breakdowns with no count that day. A breakdown you don't send is added to the parent's total as 0, but “API integration status” can't tell it apart from “not received.” Send every breakdown every day, and it can correctly tell whether a feed has stopped.
  • Adding, renaming, or removing breakdowns doesn't change the external keys of the other breakdowns. Assign an external key to a new breakdown before sending to it (sending before assigning gives unknown_key).
  • Remaining counts (“end-of-period value” KPIs) can also be sent by breakdown. When you create breakdowns on a KPI that represents how many there are at a point in time, such as open tickets or inventory, the breakdowns' aggregation becomes last. What you send is each breakdown's count at the end of the day (not how many were added that day). The parent's monthly value is the sum of the breakdowns on the last day of the month. Send every breakdown every day (including breakdowns with zero, as 0). On a day when only some breakdowns arrive, the missing ones are added as 0, so the parent's value comes out lower by that amount.

Response values

Field Contents
written The number of values written (newly added or overwritten)
deleted The number deleted with null (days that had no value to begin with aren't counted)
rejected The number that didn't pass and weren't written. 0 if everything passed
rejected_items The values that didn't pass: which item (index, zero-based) and why (code and message). The contents and code are the same as items under Errors. Up to 100 items

Example of a partial failure (the second item's external key doesn't exist):

The API currently returns message in Japanese. Here it means "There is no KPI with the external key 'web_cvv'." Use code to handle errors in your program.

Requestbash
curl -X POST https://kpitrust.com/api/v1/actuals \
  -H "Authorization: Bearer $KPITRUST_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "values": [
      { "key": "web_sessions", "date": "2026-11-21", "value": 1234 },
      { "key": "web_cv",       "date": "2026-11-21", "value": 18 }
    ]
  }'
Responsejson
{ "ok": true, "written": 2, "deleted": 0, "rejected": 0, "rejected_items": [] }
Partial failurejson
{
  "ok": true,
  "written": 1,
  "deleted": 0,
  "rejected": 1,
  "rejected_items": [
    { "index": 1, "code": "unknown_key", "message": "外部キー「web_cvv」の KPI がありません" }
  ]
}

Errors

On failure, the response takes the following form.

message is in Japanese by default. If the Accept-Language header includes English (en) and not Japanese (ja), it's returned in English. code is the same in every language, so use code when your program needs to tell errors apart.

The example above shows the default Japanese message values. In English they read "None of the values you sent passed. Nothing was written" and "There's no KPI with the external key “web_cvv”."

HTTP code Meaning and what to do
400 invalid_json The body can't be parsed as JSON
400 invalid_request The body has the wrong shape (values is missing, empty, or not an array)
400 too_many_items You sent 501 or more items. Split them into batches of 500
401 invalid_token The token is missing, malformed, or doesn't exist
401 token_revoked The token has been revoked. Issue a new token
403 plan_required The organization isn't on a paid plan
413 payload_too_large The body exceeds 256 KB
422 validation_failed No value passed. items lists which item (index, zero-based) and why. Nothing was written. If only some values fail, you get 200 and they go in rejected_items
429 rate_limited Too many requests. Wait the number of seconds in retry_after and the Retry-After header, then resend
500 internal_error A server problem. Wait a while and resend
503 not_configured API integration isn't available in this environment yet

items[].code for validation_failed (the same as rejected_items[].code in a 200 response):

code Meaning
invalid_item key or value is missing, the item doesn't have exactly one of date and month, or a type is wrong
invalid_date date isn't YYYY-MM-DD, or the date doesn't exist
invalid_month month isn't YYYY-MM
date_out_of_range A future date (or month), or a date (or month) more than 400 days ago
period_mismatch Sent date to a monthly KPI, or month to a daily KPI
invalid_value value is neither a number nor null (strings such as "5" aren't accepted either)
unknown_key The organization has no KPI with that external key
not_api_source The KPI's data source isn't “API integration”
ratio_kpi A ratio KPI. Send to the numerator and denominator KPIs
retired_kpi A Retired or Rejected KPI
duplicate_item The same key and date (or month) appear twice in one send. Neither is written

items and rejected_items hold up to 100 items (rejected is the full count).

Error formatjson
{
  "ok": false,
  "error": {
    "code": "validation_failed",
    "message": "送った値がどれも通りませんでした。何も書いていません",
    "items": [
      { "index": 0, "code": "unknown_key", "message": "外部キー「web_cvv」の KPI がありません" }
    ]
  }
}

Limits

Limit Value
Request rate 60 per minute per token (GET counts too)
Items per request 500 items
Body size 256 KB
Active tokens 20 per organization (revoked tokens don't count)

If you send once a day for the previous day (and the last few days), you'll never hit these limits. When sending past data in bulk, split it into batches of 500.

Examples

Google Analytics 4 (spreadsheet template)

For services like GA4, where the numbers only come out when you fetch them, use Apps Script in Google Sheets to fetch them and send them. A template for GA4 is available: ga4-to-kpitrust.gs

The template's menus and sheet names are currently in Japanese. The steps below give each one as it appears, with its meaning in English.

  1. In KPI Trust, set the KPIs you want to send to “API integration,” assign external keys under “Settings → Integrations,” and issue an API token.
  2. Create a new Google Sheets spreadsheet and open “Extensions → Apps Script.” Paste in the contents of the template and save.
  3. Under “Services” on the left side of Apps Script, click “+” and add the “Google Analytics Data API.”
  4. Reopen the spreadsheet and click シートを用意する (Set up sheets) in the “KPI Trust” menu.
  5. Enter the GA4 property ID in cell B1 of the 設定 (Settings) sheet, and in the 対応表 (Mapping) sheet, enter GA4 metric names (such as sessions, activeUsers, and keyEvents) and their external keys. If one GA4 property covers several sites, you can send each site separately.
  6. Enter your token with “KPI Trust → トークンを入れる (Enter token).” The token is stored in the script properties and doesn't stay in the sheet.
  7. Test with 接続を確かめる (Check connection), followed by 今すぐ送る (Send now). The first time, Google asks you to confirm permissions.
  8. Click 毎朝の送信を有効にする (Turn on daily sending). Every morning between 7 and 8 a.m., it sends the last three days (through yesterday).
  • GA4 numbers change for 1–2 days, so the last three days are resent every time. Values overwrite, so nothing is duplicated.
  • Dates are in the time zone of the GA4 property. Match it to the time zone of your KPI Trust organization.
  • Results are recorded in the 記録 (Log) sheet. If a run fails, Google also sends you an email. If only some external keys fail, the values that passed are written, the run is still marked as failed, and you get an email.
  • The script runs under the Google account of the person who set it up. If that person loses access to GA4, it stops. You can see that it has stopped under “API integration status” in KPI Trust's “On-Time Entry Rate.”

Sending each site separately

When one GA4 property covers several sites (such as www.example.com and shop.example.com), you can filter by host name and send each site to a separate KPI.

  1. Click “KPI Trust → ホスト名の内訳を見る (View host name breakdown).” Sessions for the last 28 days are shown by host name.
  2. In column C of the 対応表 (Mapping) sheet, enter the host name to filter that row by. You can list the same metric name in as many rows as you like, each with a different host name.
GA4 metric name KPI Trust external key Host name
sessions web_sessions www.example.com
sessions shop_sessions shop.example.com
  • Rows with an empty column C are filtered by the host name in cell B3 of the 設定 (Settings) sheet. If B3 is also empty, the numbers for the whole property are sent (as before).
  • Host names are matched exactly. www.example.com and example.com are different host names.
  • The per-site numbers don't necessarily add up to the number for the whole property. A single visit that crosses sites can be counted on each site.

To send from other services with Apps Script, write the sending part like this.

JS
function sendToKpiTrust(values) {
  const token = PropertiesService.getScriptProperties().getProperty('KPITRUST_TOKEN');
  const response = UrlFetchApp.fetch('https://kpitrust.com/api/v1/actuals', {
    method: 'post',
    contentType: 'application/json',
    headers: { Authorization: 'Bearer ' + token },
    payload: JSON.stringify({ values: values }),
    muteHttpExceptions: true,
  });
  if (response.getResponseCode() !== 200) {
    throw new Error('KPI Trust: ' + response.getContentText());
  }
  const result = JSON.parse(response.getContentText());
  // Values that passed were written. Throw on the ones that didn't, so someone notices
  if (result.rejected > 0) {
    throw new Error('KPI Trust: ' + result.rejected + ' item(s) did not pass ' + JSON.stringify(result.rejected_items));
  }
}

// Example: sendToKpiTrust([{ key: 'web_sessions', date: '2026-11-21', value: 1234 }]);

Zapier, Make, and n8n

Use a “Webhook” or “HTTP request” action and send as follows.

  • Method: POST
  • URL: https://kpitrust.com/api/v1/actuals
  • Headers: Authorization: Bearer <token>, Content-Type: application/json
  • Body: {"values":[{"key":"<external key>","date":"<YYYY-MM-DD>","value":<number>}]}

Use "the date the number belongs to" in the organization's time zone. If you send the previous day's numbers in the morning, that's the previous day's date.

Your own system

The basic pattern is to send the previous day's numbers once a day. To guard against missed sends, resending the last three days every time is the safe approach (values overwrite, so nothing is duplicated).

Versioning policy and changelog

  • Within /api/v1, we may add fields, but we won't change the meaning of or remove existing fields. Clients should ignore fields they don't recognize.
  • Breaking changes will be released as /api/v2, and /api/v1 will remain available alongside it for some time.
Date Change
2026-11-22 Released v1 (GET /api/v1/kpis, POST /api/v1/actuals). Released the GA4 template
2026-11-22 Monthly KPIs can now be sent with month. Added frequency to GET /api/v1/kpis
2026-11-22 POST /api/v1/actuals now supports partial success. Valid values are written, and invalid ones are returned in rejected and rejected_items with 200 (previously, a single error meant nothing was written). 422 only when no value passes. When the same KPI and date appear twice, neither is written
2026-11-23 Documented how to send breakdowns (sending a parent KPI's number in parts). No change to API behavior
2026-11-25 Breakdowns can now be created on “end-of-period value” KPIs too (remaining counts can be sent per breakdown). The breakdowns' aggregation becomes last. No change to how existing breakdowns behave
2026-11-29 The GA4 template can now filter by host name and send per site (column C of the 対応表 (Mapping) sheet, cell B3 of the 設定 (Settings) sheet, and ホスト名の内訳を見る (View host name breakdown)). No change to API behavior