{"openapi": "3.1.0", "info": {"title": "DecisionIntake", "version": "1.1.0", "license": {"name": "MIT", "identifier": "MIT"}, "description": "Decides what to ask next in a US benefits screening (fifteen programmes, 2026 rules from PolicyEngine-US), how far to trust each answer, and when it knows enough to recommend or should suggest a person review. A screening estimate, not an eligibility decision. Stateless: every response carries `state`; send it back with the next call. No authentication; requests are not logged with their content."}, "paths": {"/v1/questions": {"get": {"operationId": "getQuestions", "summary": "The programmes, every question, and the starting state", "responses": {"200": {"description": "the catalogue", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Catalogue"}}}}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/v1/step": {"post": {"operationId": "step", "summary": "Record facts (any questions, asked or not) and get the next step: ask, finish or hand_off", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "properties": {"state": {"$ref": "#/components/schemas/State"}, "facts": {"type": "array", "maxItems": 40, "items": {"$ref": "#/components/schemas/Fact"}}, "already": {"type": "array", "maxItems": 20, "items": {"type": "string"}, "description": "programme ids the household already gets, replacing the state's list ([] clears it); getting SNAP is evidence (D51)"}}}, "example": {"state": "di1;state=TX;household_size=3;earned_income=~2400/month;#1396", "facts": [{"question": "children", "choice": "2"}]}}}}, "responses": {"200": {"description": "the new state, how each fact was read, and the next step", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Step"}}}}, "400": {"$ref": "#/components/responses/Error"}, "413": {"$ref": "#/components/responses/Error"}, "415": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/v1/assessment": {"post": {"operationId": "assessment", "summary": "Every programme's probability, tier and yearly value range; the facts so far", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["state"], "properties": {"state": {"$ref": "#/components/schemas/State"}, "already": {"type": "array", "maxItems": 20, "items": {"type": "string"}, "description": "programme ids the household already gets, replacing the state's list ([] clears it); getting SNAP is evidence (D51)"}}}, "example": {"state": "di1;state=TX;household_size=3;earned_income=~2400/month;#1396"}}}}, "responses": {"200": {"description": "the assessment", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FullAssessment"}}}}, "400": {"$ref": "#/components/responses/Error"}, "413": {"$ref": "#/components/responses/Error"}, "415": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/v1/explain": {"post": {"operationId": "explain", "summary": "What would change each result: every single answer, moved one step (an income bracket, yes/no), that changes a programme's tier, with the others kept", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["state"], "properties": {"state": {"$ref": "#/components/schemas/State"}}}, "example": {"state": "di1;state=TX;household_size=3;earned_income=~2400/month;#1396"}}}}, "responses": {"200": {"description": "the programmes near the line", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Explanation"}}}}, "400": {"$ref": "#/components/responses/Error"}, "413": {"$ref": "#/components/responses/Error"}, "415": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/v1/cliff": {"post": {"operationId": "cliff", "summary": "A benefits-cliff view: every option of one amount question (earned_income unless named), the other answers kept, with each programme's tier, probability and expected yearly value", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["state"], "properties": {"state": {"$ref": "#/components/schemas/State"}, "question": {"type": "string", "default": "earned_income", "description": "an amount question id"}}}, "example": {"state": "di1;state=TX;household_size=3;earned_income=~2400/month;#1396"}}}}, "responses": {"200": {"description": "one entry per option", "content": {"application/json": {"schema": {"type": "object", "properties": {"state": {"$ref": "#/components/schemas/State"}, "question": {"type": "string"}, "unit": {"type": "string"}, "options": {"type": "array", "items": {"type": "object", "properties": {"option": {"type": "string"}, "current": {"type": "boolean"}, "expected_value": {"type": "integer", "description": "dollars a year, all programmes"}, "by_group": {"type": "object", "additionalProperties": {"type": "integer"}}, "programmes": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "tier": {"type": "string", "enum": ["likely", "worth checking", "can't tell", "not recommended", "unlikely"]}, "probability": {"type": "number"}, "typical_value": {"type": "integer"}, "expected_value": {"type": "integer"}}}}}}}, "groups": {"type": "object"}, "note": {"type": "string"}}}}}}, "400": {"$ref": "#/components/responses/Error"}, "413": {"$ref": "#/components/responses/Error"}, "415": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/v1/plan": {"post": {"operationId": "plan", "summary": "The programmes worth applying for, in the order to apply (now, then, at tax time), with the federal rules by which one approval settles part of another's eligibility", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["state"], "properties": {"state": {"$ref": "#/components/schemas/State"}, "already": {"type": "array", "maxItems": 20, "items": {"type": "string"}, "description": "programme ids the household gets now: they leave the plan, and a programme whose income test they settle is added as worth checking"}}}, "example": {"state": "di1;state=TX;household_size=3;earned_income=~2400/month;#1396", "already": ["snap"]}}}}, "responses": {"200": {"description": "the steps", "content": {"application/json": {"schema": {"type": "object", "properties": {"state": {"$ref": "#/components/schemas/State"}, "note": {"type": "string"}, "already": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "programme": {"type": "string"}}}}, "steps": {"type": "array", "items": {"type": "object", "properties": {"number": {"type": "integer"}, "step": {"type": "string", "enum": ["now", "next", "tax"]}, "title": {"type": "string"}, "programmes": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "programme": {"type": "string"}, "tier": {"type": "string", "enum": ["likely", "worth checking"]}, "added_by_rule": {"type": "boolean", "description": "not recommended from the answers alone; added because a programme the household gets meets its income test"}, "links": {"type": "array", "items": {"type": "object", "properties": {"kind": {"type": "string"}, "from": {"type": "array", "items": {"type": "string"}}, "already": {"type": "array", "items": {"type": "string"}}, "text": {"type": "string"}, "source": {"type": "string", "description": "the regulation or statute"}}}}}}}, "notes": {"type": "array", "items": {"type": "object", "properties": {"kind": {"type": "string"}, "text": {"type": "string"}}}}}}}}}}}}, "400": {"$ref": "#/components/responses/Error"}, "413": {"$ref": "#/components/responses/Error"}, "415": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/v1/batch": {"post": {"operationId": "batch", "summary": "A caseload list: up to 20 records of facts so far; per record the expected yearly value of the programmes recommended now, the best next question and its worth, and the call order", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "required": ["records"], "properties": {"records": {"type": "array", "maxItems": 20, "items": {"type": "object", "properties": {"id": {"type": ["string", "integer"], "description": "your reference; never a name"}, "facts": {"type": "array", "maxItems": 40, "items": {"$ref": "#/components/schemas/Fact"}}, "already": {"type": "array", "items": {"type": "string"}, "description": "programme ids the household gets now: left out of the expected value, and used to find programmes the federal rules open"}}}}}}, "example": {"records": [{"id": "c-101", "facts": [{"question": "state", "choice": "TX"}, {"question": "children", "choice": "2"}]}]}}}}, "responses": {"200": {"description": "per record, and the order to call them in", "content": {"application/json": {"schema": {"type": "object", "properties": {"results": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": ["string", "integer"]}, "state": {"$ref": "#/components/schemas/State"}, "expected_value": {"type": "integer"}, "action": {"type": "string"}, "recommend": {"type": "array", "items": {"type": "object"}}, "next": {"type": ["object", "null"], "properties": {"id": {"type": "string"}, "text": {"type": "string"}, "worth_per_year": {"type": "integer"}}}, "expected_mistake_cost": {"type": "integer"}, "support": {"type": "string"}, "already": {"type": "array", "items": {"type": "string"}}, "opened_by_rule": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "because": {"type": "array", "items": {"type": "string"}}, "rule": {"type": "string"}}}}, "errors": {"type": "array", "items": {"$ref": "#/components/schemas/Reading"}}}}}, "call_order": {"type": "array", "items": {"type": ["string", "integer"]}}, "note": {"type": "string"}}}}}}, "400": {"$ref": "#/components/responses/Error"}, "413": {"$ref": "#/components/responses/Error"}, "415": {"$ref": "#/components/responses/Error"}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/mcp": {"post": {"operationId": "mcp", "summary": "Model Context Protocol over Streamable HTTP (JSON responses, no SSE, stateless). Revisions 2026-07-28 (no handshake; _meta plus MCP-Protocol-Version, Mcp-Method and Mcp-Name headers) and 2025-11-25, 2025-06-18, 2025-03-26 (initialize handshake). Tools: start_intake, record_facts, get_assessment, what_would_change.", "requestBody": {"required": true, "content": {"application/json": {"schema": {"type": "object", "description": "a JSON-RPC 2.0 request"}}}}, "responses": {"200": {"description": "a JSON-RPC response", "content": {"application/json": {"schema": {"type": "object"}}}}, "202": {"description": "notification accepted"}, "400": {"description": "a JSON-RPC error (bad version, header mismatch, missing _meta)", "content": {"application/json": {"schema": {"type": "object"}}}}, "403": {"description": "a browser Origin this server does not accept", "content": {"application/json": {"schema": {"type": "object"}}}}, "404": {"description": "2026-07-28: an unknown method (-32601)", "content": {"application/json": {"schema": {"type": "object"}}}}, "429": {"$ref": "#/components/responses/RateLimited"}}}}, "/healthz": {"get": {"operationId": "health", "summary": "Liveness and exactly what is deployed", "responses": {"200": {"description": "ok", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Health"}}}}}}}}, "components": {"schemas": {"State": {"type": "string", "maxLength": 2000, "example": "di1;state=TX;household_size=3;earned_income=~2400/month;#1396", "description": "Every fact recorded so far, readable, ending in a 16-bit checksum. Send the state from the most recent response with the next call; omit it (or send \"\") to start. The server keeps nothing between calls."}, "Amount": {"type": "object", "additionalProperties": false, "properties": {"value": {"type": "number", "minimum": 0, "description": "the number as the person said it"}, "low": {"type": "number", "minimum": 0}, "high": {"type": "number", "minimum": 0}, "period": {"type": "string", "enum": ["year", "month", "week", "none"], "description": "what the number is per; the engine converts to the question's unit"}, "approximate": {"type": "boolean", "description": "true for \"about\", \"around\", ranges"}}, "description": "Give value, or low and high. Do no arithmetic: send the number and its period."}, "Fact": {"type": "object", "required": ["question"], "description": "One fact the person stated: exactly one of choice, amount or dont_know. A fact for an already answered question replaces it.", "properties": {"question": {"type": "string", "description": "a question id from /v1/questions"}, "choice": {"type": ["string", "number", "boolean"], "description": "the option's text (\"yes\", \"3\", \"rent\", \"CA\"); on amount questions a range's text (\"$20,000 to $30,000\") also works"}, "amount": {"$ref": "#/components/schemas/Amount"}, "dont_know": {"type": "boolean", "const": true}}}, "Reading": {"type": "object", "required": ["question"], "properties": {"question": {"type": "string"}, "reading": {"type": "string", "description": "how the fact was understood, for the person to check"}, "replaces": {"type": "string", "description": "the earlier reading this fact replaced"}, "warning": {"type": "string", "description": "no household on record fits this with the earlier answers; check it with the person"}, "error": {"type": "string", "description": "the fact was not recorded, and how to fix it; the other facts in the call were"}}}, "Question": {"type": "object", "required": ["id", "text", "kind"], "properties": {"id": {"type": "string"}, "text": {"type": "string"}, "kind": {"type": "string", "enum": ["choice", "amount"]}, "options": {"type": "array", "items": {"type": "string"}, "description": "choice questions"}, "unit": {"type": "string", "description": "amount questions: \"dollars a year\", \"dollars a month\" or \"dollars in total\""}, "ranges": {"type": "array", "items": {"type": "string"}, "description": "amount questions: the brackets the engine reasons in"}}}, "Support": {"type": "object", "properties": {"households_like_this": {"type": "number", "description": "effective number of training households that fit the answers (a weighted count)"}, "level": {"type": "string", "enum": ["supported", "thin"], "description": "thin: fewer than 10; the model is extrapolating"}, "conflicting_answers": {"type": "integer"}}}, "Progress": {"type": "object", "properties": {"facts_recorded": {"type": "integer"}, "expected_mistake_cost": {"type": "integer", "description": "dollars a year the remaining doubt is expected to cost in wrong recommendations"}, "similar_households": {"type": "integer", "description": "effective number of households the belief rests on, after the support floor"}, "support": {"$ref": "#/components/schemas/Support"}}}, "Programme": {"type": "object", "required": ["id", "programme", "tier", "probability"], "properties": {"id": {"type": "string", "example": "snap"}, "programme": {"type": "string", "example": "SNAP (food)"}, "tier": {"type": "string", "enum": ["likely", "worth checking", "can't tell", "not recommended", "unlikely"], "description": "likely / worth checking: recommended. can't tell: too few households like this to call a negative; never present it as unlikely"}, "probability": {"type": "number", "minimum": 0, "maximum": 1}, "value_if_eligible_per_year": {"type": "array", "items": {"type": "integer"}, "minItems": 2, "maxItems": 2, "description": "[low, high] dollars a year if eligible (health coverage: its value, not cash)"}, "apply": {"type": "object", "required": ["url", "state", "checked"], "description": "where to apply in the household's state (D53): the state's own page for SNAP, Medicaid and CHIP, TANF or the state tax credits, from the federal directories and checked on the date given. Absent until the state is answered, for national programmes, and where no state link passed the check: then use the national page.", "properties": {"url": {"type": "string", "format": "uri"}, "state": {"type": "string", "example": "NC"}, "checked": {"type": "string", "format": "date"}}}}}, "Assessment": {"type": "object", "required": ["recommend", "unsure", "note"], "properties": {"recommend": {"type": "array", "items": {"$ref": "#/components/schemas/Programme"}, "description": "worth applying for, most likely first"}, "unsure": {"type": "array", "items": {"$ref": "#/components/schemas/Programme"}, "description": "always present; empty when the data covers the person"}, "note": {"type": "string", "description": "the caveat; show it with any result"}}}, "Ask": {"type": "object", "required": ["action", "question", "why", "progress"], "properties": {"action": {"const": "ask"}, "question": {"$ref": "#/components/schemas/Question"}, "progress": {"$ref": "#/components/schemas/Progress"}, "why": {"type": "object", "properties": {"worth_per_year": {"type": "integer", "description": "dollars of expected mistakes it prevents"}, "question_cost": {"type": "number", "description": "what a question costs the person, in dollars"}, "mostly_settles": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "programme": {"type": "string"}, "share": {"type": "number"}}}}, "note": {"type": "string"}}}}}, "Finish": {"allOf": [{"$ref": "#/components/schemas/Assessment"}, {"type": "object", "required": ["action", "progress"], "properties": {"action": {"const": "finish"}, "progress": {"$ref": "#/components/schemas/Progress"}}}]}, "HandOff": {"allOf": [{"$ref": "#/components/schemas/Assessment"}, {"type": "object", "required": ["action", "progress", "hand_off_reason"], "properties": {"action": {"const": "hand_off"}, "progress": {"$ref": "#/components/schemas/Progress"}, "hand_off_reason": {"type": "string", "description": "why a person should review; advice to show, not a referral"}}}]}, "Step": {"type": "object", "required": ["state", "readings", "next"], "properties": {"state": {"$ref": "#/components/schemas/State"}, "readings": {"type": "array", "items": {"$ref": "#/components/schemas/Reading"}}, "next": {"oneOf": [{"$ref": "#/components/schemas/Ask"}, {"$ref": "#/components/schemas/Finish"}, {"$ref": "#/components/schemas/HandOff"}], "discriminator": {"propertyName": "action", "mapping": {"ask": "#/components/schemas/Ask", "finish": "#/components/schemas/Finish", "hand_off": "#/components/schemas/HandOff"}}}}}, "FullAssessment": {"allOf": [{"$ref": "#/components/schemas/Assessment"}, {"type": "object", "properties": {"state": {"$ref": "#/components/schemas/State"}, "all_programmes": {"type": "array", "items": {"$ref": "#/components/schemas/Programme"}}, "facts": {"type": "array", "items": {"type": "object", "properties": {"question": {"type": "string"}, "reading": {"type": "string"}}}}, "expected_mistake_cost": {"type": "integer"}, "support": {"$ref": "#/components/schemas/Support"}}}]}, "Explanation": {"type": "object", "required": ["state", "near_the_line", "answers_tried", "note"], "properties": {"state": {"$ref": "#/components/schemas/State"}, "near_the_line": {"type": "array", "description": "programmes whose result one answer, one step different, would change; the rest would not change", "items": {"type": "object", "properties": {"id": {"type": "string"}, "programme": {"type": "string"}, "tier": {"type": "string", "enum": ["likely", "worth checking", "can't tell", "not recommended", "unlikely"]}, "probability": {"type": "number"}, "would_change": {"type": "array", "items": {"type": "object", "properties": {"question": {"type": "string"}, "kind": {"type": "string", "enum": ["amount", "household"]}, "from": {"type": "string"}, "to": {"type": "string", "description": "the neighbouring option"}, "tier": {"type": "string", "enum": ["likely", "worth checking", "can't tell", "not recommended", "unlikely"]}, "probability": {"type": "number"}, "probability_change": {"type": "number"}}}}}}}, "answers_tried": {"type": "integer"}, "note": {"type": "string", "description": "how to read it: a guide to re-checking, never advice on what to report"}}}, "Catalogue": {"type": "object", "properties": {"version": {"type": "string"}, "state": {"$ref": "#/components/schemas/State"}, "about": {"type": "object", "additionalProperties": {"type": ["string", "null"]}}, "programmes": {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string"}, "label": {"type": "string"}}}}, "questions": {"type": "array", "items": {"$ref": "#/components/schemas/Question"}}}}, "Health": {"type": "object", "properties": {"ok": {"type": "boolean"}, "version": {"type": "string"}, "engine": {"type": "string"}, "rules": {"type": ["string", "null"]}, "commit": {"type": ["string", "null"]}, "bundle_sha256": {"type": "string", "description": "first 12 hex digits of the model file's sha256"}, "rules_sha256": {"type": ["string", "null"], "description": "first 12 hex digits of the sha256 of the rules file as canonical JSON"}, "households": {"type": "integer"}, "questions": {"type": "integer"}, "programmes": {"type": "integer"}, "boot_seconds": {"type": "number"}, "uptime_seconds": {"type": "integer"}}}, "Error": {"type": "object", "required": ["error"], "properties": {"error": {"type": "object", "properties": {"code": {"type": "string", "enum": ["bad_json", "bad_request", "bad_state", "unsupported_media_type", "too_large", "not_found", "method_not_allowed", "forbidden_host", "internal"]}, "message": {"type": "string"}}}}}}, "responses": {"Error": {"description": "error", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/Error"}}}}, "RateLimited": {"description": "over 120 requests a minute from one IP address (enforced at the edge); wait a minute"}}}, "servers": [{"url": "https://decision-intake.vercel.app"}]}