PreciseDocs

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
CapabilityRuntimeStatus
Query the public synthetic buying book over RESTSandboxLive
Discover the deployment-specific operation catalog and change stream on configured public-test AccessSandboxPreview

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

Runtime: SandboxStatus: LiveGET /health
curl -sS --fail-with-body https://sandbox.precise.ai/health

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.

Runtime: SandboxStatus: LiveGET /api/catalog
curl -sS --fail-with-body https://sandbox.precise.ai/api/catalog

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.

Runtime: SandboxStatus: LiveGET /api/guide
curl -sS --fail-with-body 'https://sandbox.precise.ai/api/guide?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.

Runtime: SandboxStatus: LivePOST /api/sql/run
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
RuleDetail
One statementA single read-only SELECT, or WITH ... SELECT, over the pinned catalog's tables
Your own rowsSent through run_analysis in a workspace. A VALUES list in a query is refused
Personal dataA query that names a personal-data field such as email, ip_address or user_id is refused
SizeAt most 20,000 characters
max_rows1 to 200. A longer result sets truncated and reports total_rows
timeout_ms100 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.

Runtime: SandboxStatus: LivePOST /api/sql/run
curl -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"
      }
    ]
  }
}'

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.

Runtime: SandboxStatus: LiveGET /api/campaigns
curl -sS --fail-with-body 'https://sandbox.precise.ai/api/campaigns?format=ctv&limit=3'

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.

Runtime: SandboxStatus: LiveGET /api/calls
curl -sS --fail-with-body 'https://sandbox.precise.ai/api/calls?limit=3'

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.

Runtime: SandboxStatus: LivePOST /api/holdout/size
curl -sS --fail-with-body https://sandbox.precise.ai/api/holdout/size \
  -H 'content-type: application/json' \
  -d '{"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.

Runtime: SandboxStatus: LivePOST /api/gateway/run
curl -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"}'

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.

Runtime: SandboxStatus: LivePOST /api/workflow/run
curl -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"}'

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.

Shell
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 codeMeaningWhat to do
422 query_failedThe query is not a single read-only SELECT, or it names a table, a column or a function the catalog does not haveFix the SQL. The message quotes the engine
429 query_busyQueries take turns: one running and two waiting for each callerWait 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.

DeploymentCaller scope and headers
Credentialed sandboxEvery data, SQL, MCP, and write call requires a per-company bearer workspace key (penv_...). Discovery metadata, /health, and /docs stay public.
Unified public testEach 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 capableThe 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 operationMCP tool
GET /api/v1/overviewget_overview
GET /api/v1/decisionslist_decisions
GET /api/v1/decisions/{decision_id}get_decision
GET /api/v1/scorekeeperget_scorekeeper
GET /api/v1/scorekeeper/money-mapget_money_map
GET /api/v1/scorekeeper/dealslist_deals
GET /api/v1/authorityget_authority
GET /api/v1/holdouts/{order_id}/sizingsize_holdout
GET /api/v1/governance/planget_spend_plan
GET /api/v1/connectionslist_connections
GET /api/v1/clouds/{cloud}/probesee_what_precise_can_read
GET /api/v1/cleanroom/partnerslist_partner_tables
POST /api/v1/cleanroom/preflightcheck_match_formats
POST /api/v1/cleanroom/runrun_partner_match
GET /api/v1/checks/sqllist_sql_checks
GET /api/v1/checks/sql/{check_id}get_sql_check
GET /api/v1/activation/targetslist_platform_targets
POST /api/v1/execution/simulatetrace_auction
GET /api/v1/proofslist_proof_files
GET /api/v1/proofs/{proof_id}get_proof_file
POST /api/v1/proof/verifyverify_proof_file
POST /api/v1/askask
GET /api/v1/runtimeget_runtime
GET /api/v1/operationslist_operations
GET /api/v1/connections/public-bookconnect_public_book
GET /api/v1/pins/{pin}inspect_snapshot
POST /api/v1/queryquery_pinned_book
GET /api/v1/runs/{run_id}open_run_rows
POST /api/v1/sizesize_pinned_holdout
POST /api/v1/tools/get_guideget_guide
POST /api/v1/tools/get_figuresget_figures
POST /api/v1/tools/inspect_auditinspect_audit
POST /api/v1/tools/get_changesget_changes
POST /api/v1/tools/ratio_shapleyratio_shapley

Home in one call

September sample, with the headline and reconciliation fields selected from the response.

Runtime: SandboxStatus: PreviewGET /api/v1/overview
curl -sS --fail-with-body "$PRECISE_URL/api/v1/overview"

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.

Runtime: SandboxStatus: PreviewGET /api/v1/decisions/D-035
curl -sS --fail-with-body "$PRECISE_URL/api/v1/decisions/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.

Runtime: SandboxStatus: PreviewGET /api/v1/operations
curl -sS --fail-with-body "$PRECISE_URL/api/v1/operations"

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.

JSON
{
  "error": {
    "code": "REFERENCE_NOT_FOUND",
    "message": "no decision 'D-999'",
    "recovery": "correctable"
  }
}

A query missing its pin and SQL returns HTTP 400.

JSON
{
  "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.

Shell
curl -NsS "$PRECISE_URL/api/v1/events" -H "Accept: text/event-stream"

MCP and A2A · AdCP governance and buying · API and MCP playground

↑↓ to move↵ to open

Connect an agent

Precise Sandbox speaks MCP over Streamable HTTP with a per-company workspace key (penv_...). Request a private sandbox key at sandbox.precise.ai.

https://sandbox.precise.ai/api/mcp/<YOUR_SANDBOX_KEY>

Set PRECISE_SANDBOX_KEY to your per-company workspace key (penv_...), then run once in a terminal.

claude mcp add --transport http precise-sandbox https://sandbox.precise.ai/api/mcp --header "Authorization: Bearer $PRECISE_SANDBOX_KEY"