Skip to content

API Documentation

Everything you need to integrate InstantFocus into your application. RESTful JSON API with Bearer token authentication.

Quick start

terminal
# Install the SDK
npm install @instantfocus/sdk

# Or use the REST API directly
curl -X POST https://api.instantfocus.dev/v1/evaluate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"study_type":"concept_test","stimulus":"Your concept here","audience":{"size":50}}'

Bearer token

All authenticated endpoints require a Bearer token in the Authorization header. API keys are prefixed with if_ for easy identification.

headers
{
  "Authorization": "Bearer if_live_abc123...",
  "Content-Type": "application/json"
}
POST/v1/evaluate

Run a synthetic panel study. This is the primary endpoint.

Request body

FieldTypeRequiredDescription
study_typestringYesOne of: concept_test, sentiment, nps, survey, ab_test
stimulusstringYesThe product description, copy, or concept to evaluate (max 2000 chars)
stimulus_bstringab_test onlySecond variant for A/B comparison
questionsstring[]survey onlyArray of up to 10 open-ended questions
audienceobjectNoPanel configuration (see below). Defaults to 100 personas, US national.

Audience object (optional)

FieldTypeDefaultDescription
sizenumber100Number of personas (10–10,000)
age_range[min, max][18, 80]Age range for the panel
genderstring"all"all | male | female | nonbinary
regionstring"us_national"Geographic region
income_bracketstring"all"all | low | middle | upper_middle | high
educationstring"all"all | high_school | bachelors | graduate
tech_adoptionstring"all"innovator | early_adopter | early_majority | laggard
GET/v1/health

Service health check. No authentication required.

response
{ "status": "ok", "version": "1.0.0" }
GET/v1/usage

Check current credit balance and usage. Requires Bearer token.

response
{
  "credits_remaining": 4900,
  "credits_used": 100,
  "plan": "free",
  "reset_date": "2026-05-01T00:00:00Z"
}

Envelope

All successful responses follow this envelope. Error responses include ok: false and an error object.

success response
{
  "ok": true,
  "data": { /* study-type-specific results */ },
  "meta": {
    "request_id": "a1b2c3d4-e5f6-...",
    "study_type": "concept_test",
    "panel_size": 100,
    "credits_used": 100,
    "credits_remaining": 4900,
    "latency_ms": 3420,
    "_meta": { "generated_by": "ai" }
  }
}

Status codes

CodeMeaning
200Success
400Invalid request body — check study_type and required fields
401Missing or invalid API key
402Insufficient credits
429Rate limit exceeded — wait and retry
500Internal server error — retry with exponential backoff