Developer docs

Experiment API reference

REST API and JavaScript SDK for creating experiments, logging trial outcomes, and reading Bayesian analysis results. Works with any stack, any domain.

Two ways to get started

REST API

Trial logging via REST

Use any HTTP client to create experiments and log outcomes. Works with agents, backend services, batch pipelines, or any language.

  1. 1. Create an org and API keyin Decision Process → Settings → API Keys
  2. 2. Create an experimentPOST /api/v1/orgs/{org_id}/experiments
  3. 3. Log each trial outcomePOST /api/v1/orgs/{org_id}/experiments/{exp_id}/ingest (X-Api-Key) or /trials (JWT)
  4. 4. Read resultsGET /api/v1/orgs/{org_id}/experiments/{exp_id}/results

Web SDK

Browser A/B via JavaScript SDK

The causal.js snippet handles visitor assignment and conversion tracking for web experiments. No backend required.

  1. 1. Add the script tagone line, served from the API CDN
  2. 2. Call causal.assign(expKey)returns the variant synchronously from cache
  3. 3. Apply the variantrender the right UI branch
  4. 4. Call causal.track()when a conversion event occurs

Create, log, and read results

Create an experiment

curl -X POST https://api.dooperator.ai/api/v1/orgs/{org_id}/experiments \
  -H "Authorization: Bearer {jwt_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "My experiment",
    "hypothesis": "Treatment outperforms control on primary metric",
    "domain": "digital",
    "design_type": "ab",
    "subject_type": "session",
    "conditions": [
      { "name": "control",   "is_control": true },
      { "name": "treatment", "is_control": false }
    ],
    "outcome_metrics": ["conversion_rate"],
    "target_observations": 200
  }'

Log a trial outcome

# Machine-to-machine (agents, backend pipelines) — use an org API key
curl -X POST https://api.dooperator.ai/api/v1/orgs/{org_id}/experiments/{exp_id}/ingest \
  -H "X-Api-Key: dop_live_…" \
  -H "Content-Type: application/json" \
  -d '{
    "condition_followed": "treatment",
    "observations": {
      "conversion_rate": 1
    }
  }'

# Dashboard / server-side — use a JWT token
curl -X POST https://api.dooperator.ai/api/v1/orgs/{org_id}/experiments/{exp_id}/trials \
  -H "Authorization: Bearer {jwt_token}" \
  -H "Content-Type: application/json" \
  -d '{
    "condition_followed": "treatment",
    "observations": { "conversion_rate": 1 }
  }'

Read Bayesian results

curl https://api.dooperator.ai/api/v1/orgs/{org_id}/experiments/{exp_id}/results \
  -H "Authorization: Bearer {jwt_token}"

# Returns per-metric Bayesian analysis:
# {
#   "metric": "conversion_rate",
#   "conditions": {
#     "control":   { "mean": 0.61, "n": 104 },
#     "treatment": { "mean": 0.75, "n": 96 }
#   },
#   "prob_treatment_better": 0.967,
#   "effect_size_d": 0.72,
#   "relative_lift": 0.229
# }

Push from any source — no code required

The webhook endpoint accepts any JSON payload. Use ?condition= to set the arm and ?map=src:metric to remap field names. Works with Zapier, n8n, IFTTT, IoT sensors, and wearables.

# Works with Zapier, n8n, IFTTT, IoT sensors, wearables — any HTTP POST source
# ?condition sets the experiment arm; ?map remaps incoming JSON fields to metric names
curl -X POST "https://api.dooperator.ai/api/v1/orgs/{org_id}/experiments/{exp_id}/webhook?condition=treatment&map=reading:yield_per_acre" \
  -H "X-Api-Key: dop_live_…" \
  -H "Content-Type: application/json" \
  -d '{"reading": 4.2}'    # "reading" is mapped → yield_per_acre

# The body can contain any keys — matched fields are recorded as observations.
# Unmatched fields are stored in the trial's notes for reference.

Web A/B testing with causal.js

One script tag. Assign visitors, apply variants, and track conversions from the browser.

<script src="https://api.dooperator.ai/causal.js"></script>
<script>
  const causal = new Causal({
    apiKey: "sk_live_…",
    baseUrl: "https://api.dooperator.ai",
  });

  // Assign visitor to a variant
  causal.assign("checkout-flow-test").then(({ variant }) => {
    if (variant === "one_page_checkout") {
      renderOnePageCheckout();
    }
  });

  // Track a conversion
  causal.track("checkout-flow-test", "conversion", "purchase");
</script>

All API endpoints

POST/api/v1/orgs/{org_id}/experiments

Create a new experiment with conditions, metrics, and target observations.

GET/api/v1/orgs/{org_id}/experiments

List all experiments for an org. Filter by domain or status.

GET/api/v1/orgs/{org_id}/experiments/{exp_id}

Fetch a single experiment including conditions and metadata.

PATCH/api/v1/orgs/{org_id}/experiments/{exp_id}

Update experiment status (draft → active → paused → archived).

POST/api/v1/orgs/{org_id}/experiments/{exp_id}/ingest

Machine-to-machine trial ingest — uses X-Api-Key header. Preferred for agents, backend pipelines, and automated systems.

POST/api/v1/orgs/{org_id}/experiments/{exp_id}/trials

Log a single trial with JWT auth — use from server-side code or when acting on behalf of a signed-in user.

GET/api/v1/orgs/{org_id}/experiments/{exp_id}/trials

List logged trials. Useful for audit and debugging.

GET/api/v1/orgs/{org_id}/experiments/{exp_id}/results

Bayesian analysis — posterior means, effect sizes, and P(treatment > control) per metric.

POST/api/v1/orgs/{org_id}/experiments/{exp_id}/webhook

Generic webhook receiver — accepts any JSON body. Use ?condition= and ?map=src:metric to route and remap fields. Works with Zapier, n8n, IFTTT, IoT sensors, and wearables.

POST/api/v1/orgs/{org_id}/experiments/{exp_id}/share

Generate a read-only shareable link for stakeholders who don't have an account.

GET/api/v1/web/orgs/{org_id}/experiments/{exp_id}/assign

Assign a visitor to a web experiment variant. Used by the JS SDK.

POST/api/v1/web/orgs/{org_id}/experiments/{exp_id}/event

Track a conversion event from the browser. Used by causal.js.

Domain values for the domain field

Use the domain field to categorise experiments. It affects template suggestions in the UI but does not change the API behaviour.

digitalDigital & web
retailRetail & commerce
manufacturingManufacturing
agricultureAgriculture
agentopsAI agent policies
researchResearch & science
otherCustom / other

Running agent policy A/B tests

The same REST API works for agent policy experiments. Set domain: "agentops", define conditions as your policy versions (e.g. baseline_policy, cot_policy), and log business outcomes like resolution_rate and escalation_rate.

See the agent policy A/B guide →

Start experimenting

Create a free org, generate an API key, and log your first trial in under five minutes.