POST /v1/measures/try
Run a draft or recorded measure for a given inclusive window (from, through) and optional holder (pipeline or party), returning each declared column’s whole-number value or why it failed without recording anything.
All operations · Reusable schemas
Complete operation contract
{
"operationId": "measures.try",
"description": "Run a draft or recorded measure for a given inclusive window (from, through) and optional holder (pipeline or party), returning each declared column's whole-number value or why it failed without recording anything.",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"required": [
"id",
"from",
"through"
],
"not": {
"required": [
"pipeline",
"party"
]
},
"properties": {
"id": {
"type": "string",
"pattern": "^msr_[0-9A-HJKMNP-TV-Z]{26}$"
},
"version": {
"type": "integer",
"minimum": 1
},
"from": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
"description": "Window start calendar date (YYYY-MM-DD), inclusive."
},
"through": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
"description": "Window end calendar date (YYYY-MM-DD), inclusive."
},
"pipeline": {
"type": "string",
"pattern": "^[a-z][a-z0-9_-]{0,63}$",
"description": "Existing pipeline key bound to :pipeline (mutually exclusive with party)."
},
"party": {
"type": "string",
"minLength": 1,
"description": "Existing party id bound to :party (mutually exclusive with pipeline)."
}
}
},
{
"type": "object",
"additionalProperties": false,
"required": [
"definition",
"from",
"through"
],
"not": {
"required": [
"pipeline",
"party"
]
},
"properties": {
"definition": {
"type": "object",
"additionalProperties": false,
"description": "A named, versioned read-only SQL measure over the report schema that returns one row of whole numbers for a window. Allowed named parameters: :from, :through, :pipeline and :party (at most one holder parameter).",
"properties": {
"spec": {
"const": "economico.measure/1"
},
"report_schema": {},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 120
},
"description": {
"type": "string",
"minLength": 1
},
"sql": {
"type": "string",
"minLength": 1
},
"columns": {
"type": "array",
"minItems": 1,
"maxItems": 12,
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
"description": "Result column name selected by sql."
},
"unit": {
"anyOf": [
{
"const": "number"
},
{
"const": "percent"
},
{
"type": "string",
"pattern": "^[A-Z]{3}$"
}
],
"description": "\"number\" for plain whole numbers (counts, ratios), \"percent\" for percentages (with optional decimals, e.g. decimals 2 and value 1500 mean 15.00%), or an ISO 4217 currency code (e.g. \"USD\") for minor units."
},
"decimals": {
"type": "integer",
"minimum": 1,
"maximum": 6,
"description": "Optional, unit \"number\" or \"percent\" only: the column's whole number is scaled by ten to this power (decimals 2 and value 120 mean 1.20 or 1.20%). Omit it for a whole-number column; 0 is the default and is refused when written."
},
"estimate_for": {
"type": "string",
"pattern": "^[A-Za-z_][A-Za-z0-9_]{0,63}$",
"description": "Optional: marks this column as the open-pipeline estimate for another declared column of the same unit (its decimals may differ)."
}
},
"required": [
"name",
"unit"
]
}
}
},
"required": [
"spec",
"report_schema",
"name",
"sql",
"columns"
]
},
"from": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
"description": "Window start calendar date (YYYY-MM-DD), inclusive."
},
"through": {
"type": "string",
"pattern": "^\\d{4}-\\d{2}-\\d{2}$",
"description": "Window end calendar date (YYYY-MM-DD), inclusive."
},
"pipeline": {
"type": "string",
"pattern": "^[a-z][a-z0-9_-]{0,63}$",
"description": "Existing pipeline key bound to :pipeline (mutually exclusive with party)."
},
"party": {
"type": "string",
"minLength": 1,
"description": "Existing party id bound to :party (mutually exclusive with pipeline)."
}
}
}
]
}
}
}
},
"responses": {
"200": {
"description": "Evaluation result for the window and holder, with per-column outcomes or a query-level validation error.",
"content": {
"application/json": {
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "object",
"properties": {
"spec": {
"type": "string",
"const": "economico.measure-try/1"
},
"ok": {
"type": "boolean",
"const": true
},
"id": {
"type": "string"
},
"version": {
"type": "number"
},
"name": {
"type": "string"
},
"window": {
"type": "object",
"properties": {
"from": {
"type": "string"
},
"through": {
"type": "string"
}
},
"required": [
"from",
"through"
],
"additionalProperties": false
},
"holder": {
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "company"
}
},
"required": [
"kind"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "pipeline"
},
"pipeline": {
"type": "string"
}
},
"required": [
"kind",
"pipeline"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "party"
},
"party": {
"type": "string"
}
},
"required": [
"kind",
"party"
],
"additionalProperties": false
}
]
},
"head": {
"anyOf": [
{
"type": "object",
"properties": {
"event_id": {
"type": "number"
},
"cid": {
"type": "string"
}
},
"required": [
"event_id",
"cid"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"columns": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"unit": {
"anyOf": [
{
"type": "string",
"const": "number"
},
{
"type": "string",
"const": "percent"
},
{
"type": "string",
"pattern": "^[A-Z]{3}$"
}
],
"description": "\"number\", \"percent\", or an uppercase 3-letter ISO 4217 currency code (e.g. \"USD\")."
},
"decimals": {
"description": "Present when the column's whole number is scaled: divide by ten to this power to place the decimal point. Absent means a whole number.",
"type": "integer",
"minimum": 1,
"maximum": 6
},
"estimate_for": {
"type": "string"
},
"ok": {
"type": "boolean",
"const": true
},
"value": {
"type": "string"
}
},
"required": [
"name",
"unit",
"ok",
"value"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"unit": {
"anyOf": [
{
"type": "string",
"const": "number"
},
{
"type": "string",
"const": "percent"
},
{
"type": "string",
"pattern": "^[A-Z]{3}$"
}
],
"description": "\"number\", \"percent\", or an uppercase 3-letter ISO 4217 currency code (e.g. \"USD\")."
},
"decimals": {
"description": "Present when the column's whole number is scaled: divide by ten to this power to place the decimal point. Absent means a whole number.",
"type": "integer",
"minimum": 1,
"maximum": 6
},
"estimate_for": {
"type": "string"
},
"ok": {
"type": "boolean",
"const": false
},
"reason": {
"type": "string"
}
},
"required": [
"name",
"unit",
"ok",
"reason"
],
"additionalProperties": false
}
]
}
}
},
"required": [
"spec",
"ok",
"name",
"window",
"holder",
"head",
"columns"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"spec": {
"type": "string",
"const": "economico.measure-try/1"
},
"ok": {
"type": "boolean",
"const": false
},
"id": {
"type": "string"
},
"version": {
"type": "number"
},
"name": {
"type": "string"
},
"window": {
"type": "object",
"properties": {
"from": {
"type": "string"
},
"through": {
"type": "string"
}
},
"required": [
"from",
"through"
],
"additionalProperties": false
},
"holder": {
"anyOf": [
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "company"
}
},
"required": [
"kind"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "pipeline"
},
"pipeline": {
"type": "string"
}
},
"required": [
"kind",
"pipeline"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"kind": {
"type": "string",
"const": "party"
},
"party": {
"type": "string"
}
},
"required": [
"kind",
"party"
],
"additionalProperties": false
}
]
},
"head": {
"anyOf": [
{
"type": "object",
"properties": {
"event_id": {
"type": "number"
},
"cid": {
"type": "string"
}
},
"required": [
"event_id",
"cid"
],
"additionalProperties": false
},
{
"type": "null"
}
]
},
"error": {
"type": "object",
"properties": {
"code": {
"type": "string",
"const": "validation"
},
"message": {
"type": "string"
}
},
"required": [
"code",
"message"
],
"additionalProperties": false
}
},
"required": [
"spec",
"ok",
"name",
"window",
"holder",
"head",
"error"
],
"additionalProperties": false
}
]
}
}
}
},
"400": {
"description": "Invalid envelope, query or domain input; also `missing_rates`, a foreign-currency command whose exchange rates the shared store could not supply (`details.missing_rates: [{ base, quote, date }]`, plus `details.refusal: { code, message }` when the command also refused), answered by stating an evidenced `exchangeRate`.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Missing or invalid bearer token. Follow the WWW-Authenticate resource_metadata URL.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
},
"headers": {
"WWW-Authenticate": {
"schema": {
"type": "string"
}
}
}
},
"402": {
"description": "plan_required: the command needs a platform plan this business is not on, or would record more events than its allowance has left. The refusal writes nothing (a retry may keep its idempotency key). `details.reason` names which, and each reason has its own details schema: `solo_limit` (Solo's monthly allowance), `plan_cancelled` (a cancel caps each period at `allowed` until `endsAt`), `usage_settled` (a kept plan's period was settled at the cancel), `feature` (a feature the plan lacks) and `member_limit` (Founders' people limit). Counts are decimal strings and instants are UTC. Any new paid plan starts only once every invoice from Economico is paid; until then the billing page says so. Reads, exports and payment setup stay available, and so does upgrading unless the business is set to close (`closesAt`). Where the platform_purchase tool is offered (an owner's full-access agent while paid plans are on sale), its action billing reads the plan's end, cap and at-cancel charge before a refusal; otherwise the owner's billing page shows them.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PlanRequired"
}
}
}
},
"403": {
"description": "Membership revoked, business unavailable for writes, or command credential requirements not met (browser-only commands refuse all OAuth tokens). `demo_business`: the business is a demo (`demo: true` on the business read: fictional, its owner's alone) and the command would reach someone else, send a message (support included, for now), publish it, take a plan or make it look like a real company, or the demo has recorded the 2,000 events it may record; tell the user, who can create their own business to do this.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Referenced measure, version, pipeline or party not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"405": {
"description": "Method not supported.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
},
"headers": {
"Allow": {
"schema": {
"type": "string"
}
}
}
},
"408": {
"description": "Request body transfer timed out (code `upload_timeout`): it took over 30 s, or paused over 5 s between chunks; retry the same request.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "Domain or idempotency conflict.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"411": {
"description": "Length required (code `length_required`): a JSON body larger than 256 KiB must send Content-Length.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"413": {
"description": "Payload too large (code `payload_too_large`): the request body exceeds the admitted byte limit.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"415": {
"description": "JSON body required.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"429": {
"description": "Address rate budget exhausted. Wait for Retry-After seconds before retrying.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
},
"headers": {
"Retry-After": {
"schema": {
"type": "string",
"pattern": "^[0-9]+$"
}
}
}
},
"500": {
"description": "Internal failure.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"503": {
"description": "Busy (code `busy`): the business is still receiving other document uploads or serving other large documents, and did not start this request. Retry the same request after Retry-After seconds.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
},
"headers": {
"Retry-After": {
"schema": {
"type": "string"
}
}
}
}
},
"parameters": [
{
"name": "X-Economico-Business",
"in": "header",
"required": true,
"description": "Explicit business slug for this request; must be approved by the connection and token.",
"schema": {
"type": "string"
}
}
]
}