This walks through one study from a terminal: one question asked of 60 simulated US adults, which spends 60 answers. A new account gets 60 free answers, enough for exactly this. Using an AI agent instead? See Agent install.
Step 1: Make an API key
- Sign in at forepop.com and open Settings, API keys (
/account/api-keys). Admins and owners of a workspace can make keys. - Name the key after what will use it and press Create key.
- Copy it straight away. It starts with
fp_live_and is shown once.
Keep it in an environment variable, never in code you share:
export FOREPOP_API_KEY="fp_live_YOUR_KEY"Step 2: Check your balance
curl https://forepop.com/api/v1/balance \
-H "Authorization: Bearer $FOREPOP_API_KEY"{
"workspace": {
"id": "…",
"name": "Personal"
},
"balance": {
"answers_left": 60,
"pack_answers": 0,
"monthly_answers": 0,
"monthly_allowance": 0,
"monthly_resets_at": null,
"note": "One answer is one simulated person answering one question. …"
}
}Step 3: Check the study and its cost
The estimate runs every check a real study runs and says what it would spend. It starts nothing and spends nothing.
curl https://forepop.com/api/v1/studies/estimate \
-H "Authorization: Bearer $FOREPOP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"survey": {
"title": "Streaming price change",
"questions": [
{
"type": "single",
"text": "If your streaming plan went from $12 to $15 a month, what would you do?",
"options": [
{
"label": "Keep my plan"
},
{
"label": "Switch to a cheaper plan"
},
{
"label": "Cancel"
}
]
}
]
},
"personas": 60
}'{
"valid": true,
"answers_needed": 60,
"answers_left": 60,
"enough": true,
"personas": 60,
"questions_run": 1,
"questions_skipped": 0,
"answered_as_group": false,
"audience": null
}Step 4: Start the study
Send the same body to POST /api/v1/studies. It answers 201 with the study's id, and the answers are spent now.
curl https://forepop.com/api/v1/studies \
-H "Authorization: Bearer $FOREPOP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"survey": {
"title": "Streaming price change",
"questions": [
{
"type": "single",
"text": "If your streaming plan went from $12 to $15 a month, what would you do?",
"options": [
{
"label": "Keep my plan"
},
{
"label": "Switch to a cheaper plan"
},
{
"label": "Cancel"
}
]
}
]
},
"personas": 60
}'{
"study": {
"id": "3f6c2a1e-…",
"title": "Streaming price change",
"status": "queued",
"personas": 60,
"created_at": "2026-12-01T10:00:00.000Z",
"finished_at": null
},
"answers_spent": 60,
"answered_as_group": false,
"hourly_cap": {
"limit": 60,
"remaining": 59,
"resets_at": "2026-12-01T11:00:00.000Z"
}
}Step 5: Wait, then read the results
Check the study every few minutes until status is complete. It moves from queued to running to complete (or failed).
curl https://forepop.com/api/v1/studies/STUDY_ID \
-H "Authorization: Bearer $FOREPOP_API_KEY"curl https://forepop.com/api/v1/studies/STUDY_ID/results \
-H "Authorization: Bearer $FOREPOP_API_KEY"Each question comes back with a count and a percent for every option (percents once at least 60 answered), and error_points, our measured average error for estimates made that way. The full shape is in the API reference.
The same in Python
Standard library only. Save as forepop_quickstart.py and run python3 forepop_quickstart.py.
import json, os, sys, time, urllib.error, urllib.request
BASE = "https://forepop.com/api/v1"
KEY = os.environ["FOREPOP_API_KEY"]
STUDY = {
"survey": {
"title": "Streaming price change",
"questions": [
{
"type": "single",
"text": "If your streaming plan went from $12 to $15 a month, what would you do?",
"options": [
{
"label": "Keep my plan"
},
{
"label": "Switch to a cheaper plan"
},
{
"label": "Cancel"
}
]
}
]
},
"personas": 60
}
def call(method, path, body=None):
req = urllib.request.Request(
BASE + path,
method=method,
data=None if body is None else json.dumps(body).encode(),
headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(req) as res:
return json.load(res)
except urllib.error.HTTPError as e:
err = json.load(e).get("error", {})
sys.exit(f"{e.code} {err.get('code')}: {err.get('message')}")
est = call("POST", "/studies/estimate", STUDY)
print(f"Needs {est['answers_needed']} answers, {est['answers_left']} left")
if not est["enough"]:
sys.exit("Not enough answers left. Add more in Settings, Billing.")
study = call("POST", "/studies", STUDY)["study"]
print("Started", study["id"])
while True:
s = call("GET", "/studies/" + study["id"])["study"]
if s["status"] == "complete":
break
if s["status"] in ("failed", "cancelled"):
sys.exit("The study " + s["status"])
time.sleep(180) # every few minutes at most
results = call("GET", "/studies/" + study["id"] + "/results")
for q in results["questions"]:
print(q["text"])
for a in q["answers"]:
share = f"{a['percent']}%" if a["percent"] is not None else f"{a['count']} people"
print(f" {a['label']}: {share}")The same in JavaScript
Node 18 or later, no packages. Save as forepop-quickstart.mjs and run node forepop-quickstart.mjs.
const BASE = "https://forepop.com/api/v1";
const KEY = process.env.FOREPOP_API_KEY;
const STUDY = {
"survey": {
"title": "Streaming price change",
"questions": [
{
"type": "single",
"text": "If your streaming plan went from $12 to $15 a month, what would you do?",
"options": [
{
"label": "Keep my plan"
},
{
"label": "Switch to a cheaper plan"
},
{
"label": "Cancel"
}
]
}
]
},
"personas": 60
};
async function call(method, path, body) {
const res = await fetch(BASE + path, {
method,
headers: { Authorization: "Bearer " + KEY, "Content-Type": "application/json" },
body: body === undefined ? undefined : JSON.stringify(body),
});
const data = await res.json();
if (!res.ok) throw new Error(res.status + " " + data.error.code + ": " + data.error.message);
return data;
}
const est = await call("POST", "/studies/estimate", STUDY);
console.log("Needs " + est.answers_needed + " answers, " + est.answers_left + " left");
if (!est.enough) throw new Error("Not enough answers left. Add more in Settings, Billing.");
const { study } = await call("POST", "/studies", STUDY);
console.log("Started " + study.id);
for (;;) {
const { study: s } = await call("GET", "/studies/" + study.id);
if (s.status === "complete") break;
if (s.status === "failed" || s.status === "cancelled") throw new Error("The study " + s.status);
await new Promise((r) => setTimeout(r, 180_000)); // every few minutes at most
}
const results = await call("GET", "/studies/" + study.id + "/results");
for (const q of results.questions) {
console.log(q.text);
for (const a of q.answers) console.log(" " + a.label + ": " + (a.percent !== null ? a.percent + "%" : a.count + " people"));
}Next
- API reference: every question type, audiences, real answers to compare with, and errors.
- MCP server: the same steps as tools an agent can call.