import weflayr
from weflayr.openapi.models import SetKeyMetricsInput
client = weflayr.client() # reads WEFLAYR_API_KEY
client.set_key_metrics(body=SetKeyMetricsInput.from_dict({
"rows": [
{"user_name": "u_123", "metric_name": "Meetings booked", "amount": 3, "month": "2026-06"},
{"user_name": "u_456", "metric_name": "Meetings booked", "amount": 7, "month": "2026-06"},
]
}))
const weflayr = require('weflayr');
const client = weflayr.client(); // reads WEFLAYR_API_KEY
await weflayr.api.setKeyMetrics({
client,
throwOnError: true,
body: {
rows: [
{ userName: 'u_123', metricName: 'Meetings booked', amount: 3, month: '2026-06' },
{ userName: 'u_456', metricName: 'Meetings booked', amount: 7, month: '2026-06' },
],
},
});
curl -X POST https://app.weflayr.com/api/key-metrics/ \
-H "Authorization: Bearer $WEFLAYR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{"user_name": "u_123", "metric_name": "Meetings booked", "amount": 3, "month": "2026-06"},
{"user_name": "u_456", "metric_name": "Meetings booked", "amount": 7, "month": "2026-06"}
]
}'
{"ok": true, "rows_inserted": 2}
Key metrics
Set key metrics
Book key-metric values per user and month.
POST
/
api
/
key-metrics
/
import weflayr
from weflayr.openapi.models import SetKeyMetricsInput
client = weflayr.client() # reads WEFLAYR_API_KEY
client.set_key_metrics(body=SetKeyMetricsInput.from_dict({
"rows": [
{"user_name": "u_123", "metric_name": "Meetings booked", "amount": 3, "month": "2026-06"},
{"user_name": "u_456", "metric_name": "Meetings booked", "amount": 7, "month": "2026-06"},
]
}))
const weflayr = require('weflayr');
const client = weflayr.client(); // reads WEFLAYR_API_KEY
await weflayr.api.setKeyMetrics({
client,
throwOnError: true,
body: {
rows: [
{ userName: 'u_123', metricName: 'Meetings booked', amount: 3, month: '2026-06' },
{ userName: 'u_456', metricName: 'Meetings booked', amount: 7, month: '2026-06' },
],
},
});
curl -X POST https://app.weflayr.com/api/key-metrics/ \
-H "Authorization: Bearer $WEFLAYR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{"user_name": "u_123", "metric_name": "Meetings booked", "amount": 3, "month": "2026-06"},
{"user_name": "u_456", "metric_name": "Meetings booked", "amount": 7, "month": "2026-06"}
]
}'
{"ok": true, "rows_inserted": 2}
Key metrics belong to an internal project. On a revenue-linked project, use the Revenue API instead.
A user can have several lines of the same metric in the same month (they add up):
Each object inside
Parameters
array of row objects
required
The key-metric lines to book, described below. Up to 1,000 per call.
boolean
default:"false"
If a row’s
metric_id already exists (c.f. rows parameters below), overwrite it instead of throwing an error.rows accepts:
string
required
The user the value belongs to.
string
required
Name of the key metric. The first time you post a new one, it’s automatically added to the project’s key metrics.
number
required
The value to book.
"YYYY-MM"
The calendar month the value belongs to. Required unless you set
month_start and month_end instead."YYYY-MM"
Bill over a multi-month period (e.g. quarterly) instead of a single
month. amount is split evenly over the period. Set either month, or both month_start and month_end, never both forms on the same row.string
An id for the key-metric row over which uniqueness is checked, typically from your own tracking system.
API values are their own key-metric source, alongside CSV uploads. Sources add up: if you post a value for a user-month that also has a CSV upload, Weflayr assumes it is the sum. We recommend using one source only to avoid double counting.
import weflayr
from weflayr.openapi.models import SetKeyMetricsInput
client = weflayr.client() # reads WEFLAYR_API_KEY
client.set_key_metrics(body=SetKeyMetricsInput.from_dict({
"rows": [
{"user_name": "u_123", "metric_name": "Meetings booked", "amount": 3, "month": "2026-06"},
{"user_name": "u_456", "metric_name": "Meetings booked", "amount": 7, "month": "2026-06"},
]
}))
const weflayr = require('weflayr');
const client = weflayr.client(); // reads WEFLAYR_API_KEY
await weflayr.api.setKeyMetrics({
client,
throwOnError: true,
body: {
rows: [
{ userName: 'u_123', metricName: 'Meetings booked', amount: 3, month: '2026-06' },
{ userName: 'u_456', metricName: 'Meetings booked', amount: 7, month: '2026-06' },
],
},
});
curl -X POST https://app.weflayr.com/api/key-metrics/ \
-H "Authorization: Bearer $WEFLAYR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{"user_name": "u_123", "metric_name": "Meetings booked", "amount": 3, "month": "2026-06"},
{"user_name": "u_456", "metric_name": "Meetings booked", "amount": 7, "month": "2026-06"}
]
}'
{"ok": true, "rows_inserted": 2}