REST API quickstart
The credentialed sandbox answers authenticated REST calls with your per-company workspace key (Authorization: Bearer $PRECISE_SANDBOX_KEY): query the sample book, run a method or a workflow, size a test, and reopen any run by its id. The unified Access server serves decisions, deals, spend plans and proofs to both API clients and the Precise app.
On this page
- Part one: the sandbox
- Check the service and read the catalog
- Query the book
- Read orders and the track record
- Size a test, run a method, run a workflow
- Reopen a run
- Two errors a first caller meets
- Part two: the Precise app API
- Home in one call
- One decision in four rows
- The list of operations
- Errors and events
- Related
| Capability | Runtime | Status |
|---|---|---|
| Query the public synthetic buying book over REST | Sandbox | Live |
| Discover the deployment-specific operation catalog and change stream on configured public-test Access | Sandbox | Preview |
Every figure on this page comes from sample data.
Part one: the sandbox
The base address is https://sandbox.precise.ai. Requests and answers are JSON. An error is {"error": "...", "code": "..."} with an HTTP status.
Check the service and read the catalog
GET /healthcurl -sS --fail-with-body https://sandbox.precise.ai/healthimport json, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen("https://sandbox.precise.ai/health") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch("https://sandbox.precise.ai/health");
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);GET /api/catalog lists what the Gateway serves: 64 methods and 5 workflows. Add ?name=power/holdout for one method's input and output schema.
GET /api/catalogcurl -sS --fail-with-body https://sandbox.precise.ai/api/catalogimport json, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen("https://sandbox.precise.ai/api/catalog") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch("https://sandbox.precise.ai/api/catalog");
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "run_analysis",
"arguments": {
"list_contracts": true
}
}
}curl -sS --fail-with-body https://sandbox.precise.ai/api/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "run_analysis",
"arguments": {
"list_contracts": true
}
}
}'GET /api/guide says what the tables, measures, methods and workflows mean, under one digest that every figure names. Add ?section= for one part. This one returns the two kinds of holdout.
GET /api/guidecurl -sS --fail-with-body 'https://sandbox.precise.ai/api/guide?section=holdouts'import json, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen("https://sandbox.precise.ai/api/guide?section=holdouts") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch("https://sandbox.precise.ai/api/guide?section=holdouts");
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_guide",
"arguments": {
"section": "holdouts"
}
}
}curl -sS --fail-with-body https://sandbox.precise.ai/api/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_guide",
"arguments": {
"section": "holdouts"
}
}
}'Query the book
POST /api/sql/run takes one read-only SELECT. This one returns three rows, measured on the sample book, led by online video at $9,262,672.56 of media spend. The answer carries a run_id and a result_digest.
POST /api/sql/runSELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESCcurl -sS --fail-with-body https://sandbox.precise.ai/api/sql/run \
-H 'content-type: application/json' \
-d '{
"sql": "SELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESC"
}'import json, sys, urllib.error, urllib.request
SQL = """
SELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESC
"""
request = urllib.request.Request(
"https://sandbox.precise.ai/api/sql/run",
data=json.dumps({"sql": SQL}).encode(),
headers={"content-type": "application/json"},
method="POST",
)
try:
with urllib.request.urlopen(request) as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(answer["run_id"], answer["result_digest"])
for row in answer["rows"]:
print(row)const sql = `
SELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESC
`;
const response = await fetch("https://sandbox.precise.ai/api/sql/run", {
method: "POST",
headers: {"content-type":"application/json"},
body: JSON.stringify({ sql }),
});
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer.run_id, answer.result_digest);
console.table(answer.rows);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "query",
"arguments": {
"sql": "SELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESC"
}
}
}curl -sS --fail-with-body https://sandbox.precise.ai/api/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "query",
"arguments": {
"sql": "SELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESC"
}
}
}'-- Paste into the duckdb shell. It reads the same public Parquet files the sandbox reads.
CREATE OR REPLACE VIEW gold_daily_cube AS SELECT * FROM read_parquet('https://sandbox.precise.ai/data/parquet/gold_daily_cube.parquet');
SELECT format, ROUND(SUM(media_spend_usd), 2) AS media_spend_usd, SUM(impressions) AS impressions FROM gold_daily_cube GROUP BY format ORDER BY media_spend_usd DESC;| Rule | Detail |
|---|---|
| One statement | A single read-only SELECT, or WITH ... SELECT, over the pinned catalog's tables |
| Your own rows | Sent through run_analysis in a workspace. A VALUES list in a query is refused |
| Personal data | A query that names a personal-data field such as email, ip_address or user_id is refused |
| Size | At most 20,000 characters |
max_rows | 1 to 200. A longer result sets truncated and reports total_rows |
timeout_ms | 100 to 120,000. A query still running answers 504 query_pending with its run_id |
A structured join goes to the same route as join_spec. This one counts line items by format: 72, 36 and 60.
POST /api/sql/runcurl -sS --fail-with-body https://sandbox.precise.ai/api/sql/run \
-H 'content-type: application/json' \
-d '{
"join_spec": {
"kind": "relational",
"left": "orders",
"right": "line_items",
"on": [
[
"order_id",
"order_id"
]
],
"group_by": [
"r.format"
],
"aggregates": [
{
"op": "count",
"column": "r.line_item_id",
"as": "line_items"
}
]
}
}'import json, sys, urllib.error, urllib.request
BODY = {
"join_spec": {
"kind": "relational",
"left": "orders",
"right": "line_items",
"on": [["order_id", "order_id"]],
"group_by": ["r.format"],
"aggregates": [{"op": "count", "column": "r.line_item_id", "as": "line_items"}],
},
}
request = urllib.request.Request(
"https://sandbox.precise.ai/api/sql/run",
data=json.dumps(BODY).encode(),
headers={"content-type": "application/json"},
method="POST",
)
try:
with urllib.request.urlopen(request) as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const body = {
"join_spec": {
"kind": "relational",
"left": "orders",
"right": "line_items",
"on": [
[
"order_id",
"order_id"
]
],
"group_by": [
"r.format"
],
"aggregates": [
{
"op": "count",
"column": "r.line_item_id",
"as": "line_items"
}
]
}
};
const response = await fetch("https://sandbox.precise.ai/api/sql/run", {
method: "POST",
headers: {"content-type":"application/json"},
body: JSON.stringify(body),
});
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "query",
"arguments": {
"join_spec": {
"kind": "relational",
"left": "orders",
"right": "line_items",
"on": [
[
"order_id",
"order_id"
]
],
"group_by": [
"r.format"
],
"aggregates": [
{
"op": "count",
"column": "r.line_item_id",
"as": "line_items"
}
]
}
}
}
}curl -sS --fail-with-body https://sandbox.precise.ai/api/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "query",
"arguments": {
"join_spec": {
"kind": "relational",
"left": "orders",
"right": "line_items",
"on": [
[
"order_id",
"order_id"
]
],
"group_by": [
"r.format"
],
"aggregates": [
{
"op": "count",
"column": "r.line_item_id",
"as": "line_items"
}
]
}
}
}
}'Read orders and the track record
GET /api/campaigns lists the book's 84 orders, 25 at a time. It takes query, format, campaign_id, holdout, limit and offset. Twelve orders are CTV.
GET /api/campaignscurl -sS --fail-with-body 'https://sandbox.precise.ai/api/campaigns?format=ctv&limit=3'import json, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen("https://sandbox.precise.ai/api/campaigns?format=ctv&limit=3") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch("https://sandbox.precise.ai/api/campaigns?format=ctv&limit=3");
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);GET /api/campaigns/ORD-012 returns one order in full: its line items, delivery, auction sample, outcomes and invoices.
GET /api/calls lists the Decisions on record with their scores. On the sample book 31 are scored, 27 landed inside their range, 4 landed outside, 4 are open and 1 had no measurable outcome. It takes status, order_id, campaign_id and limit.
GET /api/callscurl -sS --fail-with-body 'https://sandbox.precise.ai/api/calls?limit=3'import json, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen("https://sandbox.precise.ai/api/calls?limit=3") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch("https://sandbox.precise.ai/api/calls?limit=3");
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);Size a test, run a method, run a workflow
POST /api/holdout/size sizes an Audience Holdout from an order's own test. For ORD-067 the verdict is underpowered: 48 units per arm can detect a lift of 13.8 percentage points, and the target of 0.40 points needs 57,487 units per arm.
POST /api/holdout/sizecurl -sS --fail-with-body https://sandbox.precise.ai/api/holdout/size \
-H 'content-type: application/json' \
-d '{"order_id":"ORD-067"}'import json, sys, urllib.error, urllib.request
BODY = {"order_id": "ORD-067"}
request = urllib.request.Request(
"https://sandbox.precise.ai/api/holdout/size",
data=json.dumps(BODY).encode(),
headers={"content-type": "application/json"},
method="POST",
)
try:
with urllib.request.urlopen(request) as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const body = {
"order_id": "ORD-067"
};
const response = await fetch("https://sandbox.precise.ai/api/holdout/size", {
method: "POST",
headers: {"content-type":"application/json"},
body: JSON.stringify(body),
});
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "size_holdout",
"arguments": {
"order_id": "ORD-067"
}
}
}curl -sS --fail-with-body https://sandbox.precise.ai/api/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "size_holdout",
"arguments": {
"order_id": "ORD-067"
}
}
}'POST /api/gateway/run runs one Gateway method on an order of the book. This check reads ORD-012's holdout: 4,516,160 units assigned to treatment and 4,523,200 held back, with a verdict of clean.
POST /api/gateway/runcurl -sS --fail-with-body https://sandbox.precise.ai/api/gateway/run \
-H 'content-type: application/json' \
-d '{"method":"comparison/holdout-integrity","order_id":"ORD-012"}'import json, sys, urllib.error, urllib.request
BODY = {"method": "comparison/holdout-integrity", "order_id": "ORD-012"}
request = urllib.request.Request(
"https://sandbox.precise.ai/api/gateway/run",
data=json.dumps(BODY).encode(),
headers={"content-type": "application/json"},
method="POST",
)
try:
with urllib.request.urlopen(request) as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const body = {
"method": "comparison/holdout-integrity",
"order_id": "ORD-012"
};
const response = await fetch("https://sandbox.precise.ai/api/gateway/run", {
method: "POST",
headers: {"content-type":"application/json"},
body: JSON.stringify(body),
});
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);POST /api/workflow/run runs one workflow. design-the-test runs five steps, each with its own run_id, and says which steps read the order you named.
POST /api/workflow/runcurl -sS --fail-with-body https://sandbox.precise.ai/api/workflow/run \
-H 'content-type: application/json' \
-d '{"workflow":"design-the-test","order_id":"ORD-012"}'import json, sys, urllib.error, urllib.request
BODY = {"workflow": "design-the-test", "order_id": "ORD-012"}
request = urllib.request.Request(
"https://sandbox.precise.ai/api/workflow/run",
data=json.dumps(BODY).encode(),
headers={"content-type": "application/json"},
method="POST",
)
try:
with urllib.request.urlopen(request) as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const body = {
"workflow": "design-the-test",
"order_id": "ORD-012"
};
const response = await fetch("https://sandbox.precise.ai/api/workflow/run", {
method: "POST",
headers: {"content-type":"application/json"},
body: JSON.stringify(body),
});
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);Your own aggregated input to a method or a workflow needs a workspace key.
Reopen a run
GET /api/runs/{run_id} reopens a verified run: its method, its output and its digests. Read the ID from your own successful answer. A different instance may return 404 for an earlier run. Repeat the query on that instance and use its returned ID. The query evaluator normalizes outer whitespace; the stored input and result digest identify this computation.
set -e
base=https://sandbox.precise.ai
run_id=$(curl -fsS "$base/api/sql/run" -H 'content-type: application/json' -d '{"sql":"SELECT COUNT(*) AS orders FROM orders"}' | jq -er '.run_id')
curl -fsS "$base/api/runs/$run_id"Two errors a first caller meets
| Status and code | Meaning | What to do |
|---|---|---|
422 query_failed | The query is not a single read-only SELECT, or it names a table, a column or a function the catalog does not have | Fix the SQL. The message quotes the engine |
429 query_busy | Queries take turns: one running and two waiting for each caller | Wait the number of seconds in the Retry-After header, repeated in the body as retry_after_seconds, then send it again |
The limits and the error codes are in Limits and errors.
Part two: the Precise app API
Set PRECISE_URL to the Access origin. A local public-test deployment normally listens on http://127.0.0.1:8787. Its /openapi.json and /api/v1/operations describe the enabled profile. The downloadable OpenAPI document captures the public-test server with the optional native ratio worker. Set the accessOrigin server variable to your deployment when generating a client.
| Deployment | Caller scope and headers |
|---|---|
| Credentialed sandbox | Every data, SQL, MCP, and write call requires a per-company bearer workspace key (penv_...). Discovery metadata, /health, and /docs stay public. |
| Unified public test | Each published operation uses the server's public tenant. Precise-Workspace is unnecessary and cannot grant a tenant or select a different principal. |
| Tenant read or spend capable | The bearer credential establishes the authenticated principal. The deployment exposes only operations that its profile and grants permit. Approval routes bind the tenant and frozen action. |
The docs relay preserves an explicitly supplied Precise-Workspace for older hosts that require it. A host that enforces this header on a route must mark it required in that host's schema. Import the OpenAPI served by the profile you will call. The public-test catalog below has 34 tools. Without the native ratio worker it has 33.
| HTTP operation | MCP tool |
|---|---|
GET /api/v1/overview | get_overview |
GET /api/v1/decisions | list_decisions |
GET /api/v1/decisions/{decision_id} | get_decision |
GET /api/v1/scorekeeper | get_scorekeeper |
GET /api/v1/scorekeeper/money-map | get_money_map |
GET /api/v1/scorekeeper/deals | list_deals |
GET /api/v1/authority | get_authority |
GET /api/v1/holdouts/{order_id}/sizing | size_holdout |
GET /api/v1/governance/plan | get_spend_plan |
GET /api/v1/connections | list_connections |
GET /api/v1/clouds/{cloud}/probe | see_what_precise_can_read |
GET /api/v1/cleanroom/partners | list_partner_tables |
POST /api/v1/cleanroom/preflight | check_match_formats |
POST /api/v1/cleanroom/run | run_partner_match |
GET /api/v1/checks/sql | list_sql_checks |
GET /api/v1/checks/sql/{check_id} | get_sql_check |
GET /api/v1/activation/targets | list_platform_targets |
POST /api/v1/execution/simulate | trace_auction |
GET /api/v1/proofs | list_proof_files |
GET /api/v1/proofs/{proof_id} | get_proof_file |
POST /api/v1/proof/verify | verify_proof_file |
POST /api/v1/ask | ask |
GET /api/v1/runtime | get_runtime |
GET /api/v1/operations | list_operations |
GET /api/v1/connections/public-book | connect_public_book |
GET /api/v1/pins/{pin} | inspect_snapshot |
POST /api/v1/query | query_pinned_book |
GET /api/v1/runs/{run_id} | open_run_rows |
POST /api/v1/size | size_pinned_holdout |
POST /api/v1/tools/get_guide | get_guide |
POST /api/v1/tools/get_figures | get_figures |
POST /api/v1/tools/inspect_audit | inspect_audit |
POST /api/v1/tools/get_changes | get_changes |
POST /api/v1/tools/ratio_shapley | ratio_shapley |
Home in one call
September sample, with the headline and reconciliation fields selected from the response.
GET /api/v1/overviewcurl -sS --fail-with-body "$PRECISE_URL/api/v1/overview"import json, os, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen(os.environ["PRECISE_URL"] + "/api/v1/overview") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch(`${process.env.PRECISE_URL}/api/v1/overview`);
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_overview",
"arguments": {}
}
}curl -sS --fail-with-body "$PRECISE_URL/api/mcp" \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_overview","arguments":{}}}'Example answerSample Book · Synthetic Data
{
"headline": {
"label": "Proven so far (Sep 2026)",
"value": 59997,
"unit": "usd",
"basis": "Net result of 5 tested changes that closed in September 2026, each against its BAU line. 1 overlapping result is left out, so no day on one line item counts twice."
},
"reconciliation": {
"decision_ids": [
"D-014",
"D-021",
"D-024",
"D-032",
"D-033"
],
"total_usd": 59997
}
}One decision in four rows
This excerpt shows what changes, the expectation, the comparison and the costs. The full response includes the recorded routes and the exposure.
GET /api/v1/decisions/D-035curl -sS --fail-with-body "$PRECISE_URL/api/v1/decisions/D-035"import json, os, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen(os.environ["PRECISE_URL"] + "/api/v1/decisions/D-035") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch(`${process.env.PRECISE_URL}/api/v1/decisions/D-035`);
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_decision",
"arguments": {
"decision_id": "D-035"
}
}
}curl -sS --fail-with-body "$PRECISE_URL/api/mcp" \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "get_decision",
"arguments": {
"decision_id": "D-035"
}
}
}'Example answerSample Book · Synthetic Data
{
"decision_id": "D-035",
"state": "Approval required",
"rows": {
"changes": {
"sentence": "Shade open-exchange bids to each impression's value.",
"where": "ORD-006, line LI-006-A in Beeswax"
},
"expect": {
"sentence": "$26,947, with an 80% range of $22,127 to $31,767."
},
"compared_with": {
"sentence": "Your BAU line keeps running beside the test. The result is one against the other.",
"held_line": "LI-006-A (BAU Control Line)",
"risk_budget_pct": 2,
"how_it_works": "Two live line items swap setups on a random schedule."
},
"costs": {
"sentence": "Every route shows its fees in one table, Precise's included."
}
},
"applied": {
"state": "none",
"sentence": "Approval required",
"counted_usd": 0
}
}The list of operations
Open the registry on the deployment you will use. The excerpt selects fields from its first entry. Each returned operation supplies its HTTP method, path, MCP tool and example snippets.
GET /api/v1/operationscurl -sS --fail-with-body "$PRECISE_URL/api/v1/operations"import json, os, sys, urllib.error, urllib.request
try:
with urllib.request.urlopen(os.environ["PRECISE_URL"] + "/api/v1/operations") as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
print(f"HTTP {error.code}: {error.read().decode(errors='replace')}", file=sys.stderr)
sys.exit(1)
if isinstance(answer, dict) and (answer.get("error") or (isinstance(answer.get("result"), dict) and answer["result"].get("isError"))):
print(json.dumps(answer, indent=2), file=sys.stderr)
sys.exit(1)
print(json.dumps(answer, indent=2))const response = await fetch(`${process.env.PRECISE_URL}/api/v1/operations`);
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
const answer = JSON.parse(text);
if (answer?.error || answer?.result?.isError) throw new Error(text);
console.log(answer);{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "list_operations",
"arguments": {}
}
}curl -sS --fail-with-body "$PRECISE_URL/api/mcp" \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "list_operations",
"arguments": {}
}
}'Example answerSample Book · Synthetic Data
{
"operations": [
{
"id": "overview",
"method": "GET",
"path": "/api/v1/overview",
"tool": "get_overview"
}
]
}Errors and events
An unknown decision returns HTTP 404.
{
"error": {
"code": "REFERENCE_NOT_FOUND",
"message": "no decision 'D-999'",
"recovery": "correctable"
}
}A query missing its pin and SQL returns HTTP 400.
{
"error": {
"code": "INVALID_REQUEST",
"message": "data must have required property 'sql', data must have required property 'pin'",
"recovery": "correctable"
}
}The tenant change stream sends events as changes become available. Resume with Last-Event-ID or ?after= using the cursor from the last event. A quiet tenant can keep an open stream without sending a change.
curl -NsS "$PRECISE_URL/api/v1/events" -H "Accept: text/event-stream"Related
MCP and A2A · AdCP governance and buying · API and MCP playground