REST API and JavaScript SDK for creating experiments, logging trial outcomes, and reading Bayesian analysis results. Works with any stack, any domain.
Quick-start
REST API
Use any HTTP client to create experiments and log outcomes. Works with agents, backend services, batch pipelines, or any language.
Web SDK
The causal.js snippet handles visitor assignment and conversion tracking for web experiments. No backend required.
REST API examples
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
# }Webhook ingestion
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.JavaScript SDK
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>Endpoint reference
Experiment domains
domain fieldUse the domain field to categorise experiments. It affects template suggestions in the UI but does not change the API behaviour.
digitalDigital & webretailRetail & commercemanufacturingManufacturingagricultureAgricultureagentopsAI agent policiesresearchResearch & scienceotherCustom / otherUse case
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.
Create a free org, generate an API key, and log your first trial in under five minutes.