BrainGap API
Build adaptive assessments with psychometric precision. Two endpoints for the core loop, dozens more when you need them.
https://api.braingap.io/v1
Authentication
All requests require two headers:
Authorization: Bearer sk_live_xxxxx X-User-Id: your_user_identifier
Quickstart
The complete assessment loop in two API calls.
curl -X POST https://api.braingap.io/v1/assess/next \ -H "Authorization: Bearer $API_KEY" \ -H "X-User-Id: user_123" \ -H "Content-Type: application/json" \ -d '{"blueprint": "aws-solutions-architect"}'
curl -X POST https://api.braingap.io/v1/assess/respond \ -H "Authorization: Bearer $API_KEY" \ -H "X-User-Id: user_123" \ -H "Content-Type: application/json" \ -d '{"interactionId": "uuid", "response": "B"}'
Item Formats
BrainGap supports multiple question formats. Some are scored instantly (deterministic), others use AI scoring for open-ended responses.
multiple_choice
options[] array.true_false
matching
pairs[] with left/right sides.ordering
options[] to reorder.short_answer
teach_back
Response format by type
// multiple_choice: option letter or index { "response": "B" } // true_false { "response": "false" } // matching: comma-separated pair indices (left-right) { "response": "0-2,1-0,2-1" } // ordering: comma-separated sequence { "response": "2,0,3,1" } // short_answer / teach_back: free text { "response": "VPCs provide network isolation..." }
itemFormats: ["multiple_choice", "true_false"] in /assess/next to get only instant-scoring formats./v1/assess/next
Get the optimal next question using Maximum Fisher Information selection.
Request Body
| blueprint | string | Required. Blueprint ID or slug. |
| focusTopic | string | Optional. Restrict to a specific topic. |
| focusConcepts | array | Optional. Array of concept IDs to focus on. |
Response
{ "interaction": { "id": "550e8400-e29b-41d4-a716-446655440000", "conceptName": "VPC Subnet Design", "type": "multiple_choice", "prompt": "A company needs to design...", "options": ["A) ...", "B) ..."] }, "meta": { "readinessScore": 0.72, "conceptsMastered": 46, "suggestedStopReason": null } }
/v1/assess/respond
Submit the user's answer. Returns score immediately for deterministic types, or pending for LLM-scored.
Request Body
| interactionId | string | Required. From /next response. |
| response | string | Required. The user's answer. |
| responseTimeMs | integer | Optional. Time spent in milliseconds. |
Response
{ "resultId": "650e8400-e29b-41d4-a716-446655440001", "score": 1.0, "scoring": "complete", "explanation": "Correct! Creating subnets...", "masterySnapshot": { "previousScore": 0.62, "newScore": 0.67 } }
/v1/assess/skip
Skip the current question and get a new one. Returns the same shape as /next.
Request Body
| interactionId | string | Required. ID of interaction being skipped. |
| blueprint | string | Required. Same as /next. |
| reason | string | Optional. "too_hard", "unclear", "already_know". |
curl -X POST https://api.braingap.io/v1/assess/skip \ -H "Authorization: Bearer $API_KEY" \ -H "X-User-Id: user_123" \ -H "Content-Type: application/json" \ -d '{"interactionId": "550e8400-...", "blueprint": "aws-solutions-architect", "reason": "unclear"}'
Response
{ "interaction": { "id": "660e8400-e29b-41d4-a716-446655440002", "conceptName": "IAM Role Policies", "type": "multiple_choice", "prompt": "Which IAM policy type...", "options": ["A) ...", "B) ..."] }, "meta": {...} }
/v1/assess/feedback
Submit thumbs up/down feedback on a scored interaction. Used to improve question quality.
Request Body
| resultId | string | Required. From /respond response. |
| rating | string | Required. "up" or "down". |
| comment | string | Optional. User's comment. |
curl -X POST https://api.braingap.io/v1/assess/feedback \ -H "Authorization: Bearer $API_KEY" \ -H "X-User-Id: user_123" \ -H "Content-Type: application/json" \ -d '{"resultId": "650e8400-...", "rating": "down", "comment": "Answer was ambiguous"}'
Response
{ "acknowledged": true }
Attempts
Group interactions into formal assessment sessions with defined start/end.
/v1/attempts
Create a new assessment attempt. All subsequent /next and /respond calls are associated with this attempt.
curl -X POST https://api.braingap.io/v1/attempts \ -H "Authorization: Bearer $API_KEY" \ -H "X-User-Id: user_123" \ -H "Content-Type: application/json" \ -d '{"blueprint": "aws-solutions-architect", "maxItems": 20, "timeLimitMinutes": 30}'
{ "attemptId": "att_abc123", "status": "in_progress", "blueprint": "aws-solutions-architect", "startedAt": "2024-01-15T10:30:00Z", "maxItems": 20, "timeLimitMinutes": 30 }
/v1/attempts/{id}
Get attempt details including progress and results.
{ "attemptId": "att_abc123", "status": "completed", "itemsCompleted": 20, "score": 0.78, "theta": 0.92, "standardError": 0.31, "startedAt": "2024-01-15T10:30:00Z", "completedAt": "2024-01-15T10:52:00Z" }
/v1/attempts
List all attempts for user
/v1/attempts/{id}/close
Close attempt early (abandoned/timeout)
/v1/users/{userId}/gaps
Priority-ranked gap analysis comparing mastery to blueprint requirements.
{ "summary": { "overallReadiness": 0.72, "conceptsMastered": 46, "conceptsWithGaps": 22 }, "gaps": [ { "conceptName": "VPC Subnet Design", "gapSize": 0.45, "importance": "required" } ] }
/v1/users/{userId}/mastery
Full mastery profile with IRT ability estimates per concept. Use this for raw measurement data.
curl https://api.braingap.io/v1/users/user_123/mastery?blueprint=aws-solutions-architect \ -H "Authorization: Bearer $API_KEY"
{ "overallProficiency": 0.72, "precision": "high", "interactionCount": 45, "concepts": [ { "conceptId": "vpc-subnet-design", "conceptName": "VPC Subnet Design", "theta": 0.85, "standardError": 0.32, "proficiencyScore": 0.80, "state": "progressing" } ] }
/v1/users/{userId}/progress
Progress summary over time
/v1/users/{userId}
Delete user data (GDPR compliance)
Blueprints
Knowledge definitions that assessments run against. Each blueprint contains topics and concepts.
/v1/blueprints
Create a new blueprint. Choose a decomposition mode based on your needs.
Decomposition Modes
Provide a description or source material and let AI decompose it into topics and concepts. Fast setup for certifications, courses, and general knowledge domains.
Define every topic and concept yourself. Full control for academic research, psychometric validation, or when you have existing curriculum structures.
curl -X POST https://api.braingap.io/v1/blueprints \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "AWS Solutions Architect Associate", "slug": "aws-saa", "mode": "ai", "source": { "type": "description", "content": "AWS SAA-C03 certification covering compute, storage, networking, databases, security, and cost optimization on AWS." } }'
curl -X POST https://api.braingap.io/v1/blueprints \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Cognitive Psychology 101", "slug": "psych-101", "mode": "manual", "topics": [ { "name": "Memory Systems", "concepts": [ { "name": "Working Memory", "description": "..." }, { "name": "Long-term Potentiation", "description": "..." } ] } ] }'
{ "slug": "aws-saa", "status": "decomposing", "estimatedCompletion": "2024-01-15T10:35:00Z", "webhookOnComplete": true }
description - text description of the domainurl - link to syllabus, exam guide, or course outlinedocument - uploaded PDF or text file (base64)
List & Get Blueprints
/v1/blueprints
List all blueprints available to your account.
{ "blueprints": [ { "slug": "aws-solutions-architect", "name": "AWS Solutions Architect Associate", "topicCount": 12, "conceptCount": 68, "visibility": "public" }, { "slug": "logical-fallacies", "name": "Logical Fallacies", "topicCount": 6, "conceptCount": 24, "visibility": "public" } ] }
/v1/blueprints/{slug}
Get blueprint details including topic/concept structure.
{ "slug": "aws-solutions-architect", "name": "AWS Solutions Architect Associate", "description": "AWS SAA-C03 exam preparation", "topics": [ { "name": "Networking", "concepts": ["VPC Subnet Design", "Route Tables", "..."] } ] }
Manage Concepts
Add, update, or remove concepts from a blueprint. Useful for refining AI-generated structures or maintaining manual blueprints.
/v1/blueprints/{slug}/concepts
Add concepts to a topic
/v1/blueprints/{slug}/concepts/{id}
Update concept details
/v1/blueprints/{slug}/concepts/{id}
Remove a concept
curl -X POST https://api.braingap.io/v1/blueprints/aws-saa/concepts \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "topicId": "networking", "name": "Transit Gateway", "description": "Centralized hub for connecting VPCs and on-premises networks", "prerequisites": ["vpc-basics", "route-tables"] }'
prerequisites to create learning paths. BrainGap will assess prerequisite concepts first and use warm-start propagation to seed ability estimates for dependent concepts.Cohorts
Analyze groups of users together. Identify common gaps, track team progress, detect item bias.
/v1/cohorts/gaps
Find common knowledge gaps across a group of users.
curl -X POST https://api.braingap.io/v1/cohorts/gaps \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"userIds": ["user_1", "user_2", "user_3"], "blueprint": "aws-solutions-architect"}'
{ "cohortSize": 3, "commonGaps": [ { "conceptName": "VPC Peering", "affectedUsers": 3, "avgGapSize": 0.52 }, { "conceptName": "IAM Policies", "affectedUsers": 2, "avgGapSize": 0.38 } ] }
/v1/cohorts/progress
Aggregate progress tracking
/v1/cohorts/dif
Differential Item Functioning analysis
/v1/cohorts/compare
Compare two cohorts head-to-head
Management
Create and manage proprietary blueprints, concepts, and interactions. Enterprise only.
/v1/manage/blueprints
Create a new blueprint. AI automatically decomposes it into topics and concepts.
curl -X POST https://api.braingap.io/v1/manage/blueprints \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Company Onboarding", "description": "Internal policies and procedures", "sourceUrl": "https://wiki.company.com/onboarding", "visibility": "private" }'
{ "slug": "company-onboarding", "status": "decomposing", "message": "Blueprint queued for decomposition" }
Blueprint Management
/v1/manage/blueprints/{slug}
Get with full concept tree
/v1/manage/blueprints/{slug}/refresh
Regenerate all interactions
Concept Operations
/v1/manage/concepts/{id}/split
Split into multiple concepts
/v1/manage/concepts/merge
Merge duplicate concepts
Interaction Management
/v1/manage/concepts/{id}/interactions
List all items for concept
/v1/manage/concepts/{id}/interactions
Create custom interaction
/v1/manage/interactions/{id}
Update interaction content
/v1/manage/interactions/{id}
Remove interaction
Webhooks
Get notified when async events complete. All payloads include HMAC signature for verification.
/v1/webhooks
curl -X POST https://api.braingap.io/v1/webhooks \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"url": "https://your-app.com/webhooks", "events": ["scoring.complete"]}'
{ "webhookId": "wh_abc123", "secret": "whsec_xxxxxxxx", "events": ["scoring.complete"] }
Example Payload
{ "event": "scoring.complete", "timestamp": "2024-01-15T10:32:00Z", "data": { "resultId": "650e8400-...", "userId": "user_123", "score": 0.85, "explanation": "Strong understanding of..." } }
Available Events
| scoring.complete | LLM scoring finished for short answer/teach-back |
| attempt.completed | Assessment attempt finished |
| blueprint.ready | Blueprint decomposition complete |
/v1/webhooks
List registered webhooks
/v1/webhooks/{id}
Remove webhook
Errors
All errors follow a consistent format.
{ "error": { "code": "blueprint_not_found", "message": "Blueprint 'xyz' not found" } }
| 400 | Bad request - malformed input |
| 401 | Missing or invalid API key |
| 403 | Insufficient permissions |
| 404 | Resource not found |
| 429 | Rate limited |
| 500 | Server error |
AI Detection
Coming SoonDetect when users are using AI assistants to answer questions instead of demonstrating genuine knowledge.
Assessments only work when responses reflect actual knowledge. If users copy questions into ChatGPT, your mastery data becomes meaningless. AI detection flags suspicious patterns so you can trust your results.
How it works
We analyze multiple behavioral and linguistic signals across each assessment session:
AI-assisted answers show distinctive timing patterns. Too fast for the complexity, or suspiciously consistent delays that suggest copy-paste workflows.
LLM outputs have telltale patterns: hedging phrases, certain structural quirks, vocabulary choices that differ from natural human responses.
Real knowledge shows natural variation. AI-assisted users often show impossible consistency, or wild swings between expert and novice responses.
Tab switching patterns, focus events, paste detection, and other browser signals that indicate external tool usage.
Planned API
AI detection scores will be included in assessment results:
{ "resultId": "650e8400-...", "score": 0.85, "aiDetection": { "confidence": 0.12, "flag": "unlikely", "signals": [] } }
{ "resultId": "650e8400-...", "score": 0.95, "aiDetection": { "confidence": 0.87, "flag": "likely", "signals": [ "response_timing_anomaly", "linguistic_pattern_match", "paste_event_detected" ] } }
Questions? hello@braingap.io