{
  "openapi": "3.1.0",
  "info": {
    "title": "MindPulse API",
    "description": "Global mental health intelligence API. Evidence-based guidance on therapy platform matching, mental health assessment, burnout, psychiatric medication context, coping techniques, sleep disorders (CBT-I), grief, relationship dynamics, and workplace mental health. Backed by current clinical research via real-time search. Serves users in 100+ countries \u2014 respond in any language via ?lang=. Pricing: $0.05\u2013$0.10 USDC/call via x402 micropayment on Base mainnet. Crisis endpoint (/api/mind/crisis) is always free.",
    "version": "1.2.0",
    "contact": {
      "url": "https://mindpulse-lilac.vercel.app"
    }
  },
  "servers": [
    {
      "url": "https://mindpulse-lilac.vercel.app",
      "description": "MindPulse production server"
    }
  ],
  "x-payment": {
    "protocol": "x402",
    "network": "eip155:8453",
    "asset": "USDC",
    "contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0x50ab2018c06c6E4eAA9BA52057Eb55eD284912fc"
  },
  "paths": {
    "/api/mind/match": {
      "get": {
        "summary": "Therapy platform matching",
        "description": "Recommends the right therapy modality (CBT, DBT, ACT, coaching, psychiatry) and specific platforms (BetterHelp, Talkspace, Alma, Open Path) based on concerns, budget, and insurance status. Returns structured platform comparison with affiliate links.",
        "x-price-usd": 0.1,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Start here for any new user seeking care; follow with /api/mind/technique for immediate skill while awaiting therapy; pairs with MindPulse /api/mind/medication if pharmacotherapy is indicated",
        "parameters": [
          {
            "name": "concerns",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Mental health concerns (e.g., depression,anxiety,trauma)"
          },
          {
            "name": "budget",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Monthly budget in USD (e.g., 60, 100, 200)"
          },
          {
            "name": "modality",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Preferred therapy modality (CBT, DBT, ACT, coaching)"
          },
          {
            "name": "insurance",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Insurance carrier or 'self-pay'"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language (e.g., es, fr, de, ja)"
          }
        ],
        "responses": {
          "200": {
            "description": "Therapy platform recommendations with comparison and affiliate links"
          },
          "402": {
            "description": "Payment required \u2014 include PAYMENT-SIGNATURE header with signed x402 payment"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/assessment": {
      "get": {
        "summary": "Mental health self-assessment",
        "description": "Mental health screening using PHQ-9 and GAD-7 validated frameworks. Returns severity level, clinical interpretation, recommended level of care (self-help, therapy, psychiatry, crisis), and next steps.",
        "x-price-usd": 0.1,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Run before /api/mind/match to determine appropriate care level; follow with /api/mind/burnout if work stress is a primary theme; pairs with /api/mind/technique for immediate relief",
        "parameters": [
          {
            "name": "concerns",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Presenting concerns (e.g., low+mood,loss+of+interest,sleep+problems)"
          },
          {
            "name": "duration",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "How long symptoms have been present (e.g., 3+months)"
          },
          {
            "name": "impact",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "How symptoms impact daily function (mild/moderate/severe)"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Mental health assessment with severity level and care recommendations"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/burnout": {
      "get": {
        "summary": "Burnout assessment and recovery protocol",
        "description": "Burnout assessment using Maslach Burnout Inventory framework \u2014 emotional exhaustion, depersonalization, and reduced personal accomplishment. Returns burnout severity, root cause analysis, staged recovery protocol (acute vs. chronic), and professional referral guidance.",
        "x-price-usd": 0.1,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Follow with /api/mind/workplace for systemic changes; pairs with /api/mind/match if burnout has progressed to clinical depression or anxiety requiring therapy",
        "parameters": [
          {
            "name": "situation",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Describe the burnout situation (e.g., 5+years+ICU+nursing)"
          },
          {
            "name": "duration",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "How long burnout has been present"
          },
          {
            "name": "role",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Job role or profession"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Burnout severity assessment with staged recovery protocol"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/medication": {
      "get": {
        "summary": "Psychiatric medication context",
        "description": "Psychiatric medication context \u2014 what the medication does mechanically, typical onset timeline, common side effects by frequency, how it compares to alternatives in its class, what to monitor during the first 30 days, and specific questions for the prescribing physician. Not a recommendation \u2014 a tool for informed conversations with providers.",
        "x-price-usd": 0.1,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Use after /api/mind/assessment confirms moderate-severe symptoms; always pair with /api/mind/match \u2014 medication alone without therapy is less effective; not a substitute for prescriber consultation",
        "parameters": [
          {
            "name": "drug",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Medication name (generic or brand \u2014 e.g., sertraline, Zoloft, quetiapine)"
          },
          {
            "name": "condition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Condition it is prescribed for"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Psychiatric medication context with mechanism, side effects, and prescriber questions"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/technique": {
      "get": {
        "summary": "Evidence-based coping technique guide",
        "description": "Evidence-based coping technique matched to a specific concern. Covers CBT thought records, DBT TIPP and PLEASE skills, ACT defusion exercises, mindfulness protocols, somatic techniques, and behavioral activation. Returns step-by-step instructions, when to use, and expected timeline for effect.",
        "x-price-usd": 0.08,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Highest-volume endpoint \u2014 chain as immediate relief after any assessment; pairs with /api/mind/sleep for bedtime techniques; can be called repeatedly for different situations and concerns",
        "parameters": [
          {
            "name": "concern",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Mental health concern to address (e.g., panic+attacks, rumination, anger)"
          },
          {
            "name": "situation",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Specific situation triggering the concern"
          },
          {
            "name": "approach_preference",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Preferred approach type (CBT, DBT, ACT, mindfulness, somatic)"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Step-by-step evidence-based coping technique with implementation guide"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/sleep": {
      "get": {
        "summary": "Sleep disorder guidance (CBT-I protocol)",
        "description": "Sleep disorder guidance using CBT-I (Cognitive Behavioral Therapy for Insomnia) \u2014 the gold-standard first-line treatment. Covers sleep restriction therapy, stimulus control, sleep hygiene optimization, cognitive restructuring for sleep anxiety, and when medication is appropriate. Covers insomnia, sleep apnea recognition, RLS, and circadian rhythm disruption.",
        "x-price-usd": 0.08,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Follow with /api/mind/technique for bedtime CBT-I exercises; pairs with FitPulse /api/fit/recover for athletes whose performance is affected by poor sleep; supplement suggestion: /api/mind/medication for chronic insomnia context",
        "parameters": [
          {
            "name": "concern",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Sleep concern (insomnia, sleep+apnea, RLS, nightmares, circadian)"
          },
          {
            "name": "duration",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "How long sleep problems have been present"
          },
          {
            "name": "severity",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Severity description (e.g., unable+to+fall+asleep, waking+frequently)"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "CBT-I sleep protocol with personalized recommendations"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/grief": {
      "get": {
        "summary": "Grief and loss support",
        "description": "Grief and loss support \u2014 stages of grief framework (not prescriptive), cultural considerations in grief expression, practical coping strategies, the distinction between normal grief and complicated grief (prolonged grief disorder), when professional support is warranted, and global grief support resources.",
        "x-price-usd": 0.08,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Use alone \u2014 grief has its own timeline; pairs with /api/mind/match for complex grief requiring professional support; follow with /api/mind/technique for acute moments of overwhelm",
        "parameters": [
          {
            "name": "situation",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Describe the loss situation"
          },
          {
            "name": "time_since_loss",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Time since the loss (e.g., 2+weeks, 3+months)"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Type of loss (spousal, parent, child, pet, relationship, identity, health)"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Grief support guidance with cultural context and professional referral thresholds"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/relationship": {
      "get": {
        "summary": "Relationship and communication guidance",
        "description": "Relationship guidance \u2014 attachment theory framework (secure, anxious, avoidant, disorganized), Gottman Method communication principles, conflict resolution strategies, healthy boundary-setting, and when couples therapy is indicated. Covers romantic relationships, family dynamics, and friendship boundaries.",
        "x-price-usd": 0.1,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Follow with /api/mind/match if relationship issues are affecting mental health clinically; pairs with /api/mind/workplace when professional relationships are involved",
        "parameters": [
          {
            "name": "situation",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Describe the relationship situation"
          },
          {
            "name": "relationship_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Type of relationship (romantic, family, friendship, work)"
          },
          {
            "name": "concern",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Primary concern (communication, trust, conflict, boundaries, intimacy)"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Relationship guidance with evidence-based communication strategies"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/workplace": {
      "get": {
        "summary": "Workplace mental health guidance",
        "description": "Workplace mental health \u2014 burnout early warning signs, employer accommodation requests (ADA framework for US, Equality Act for UK), conflict resolution with managers and colleagues, strategies for toxic workplace environments, and when to escalate to HR vs. EEOC vs. finding a new role. Includes remote work isolation guidance.",
        "x-price-usd": 0.08,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Follow with /api/mind/burnout for severity assessment; pairs with /api/mind/technique for in-the-moment workplace techniques; follow with CareerPulse for role/career transition if workplace situation is unsalvageable",
        "parameters": [
          {
            "name": "situation",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Describe the workplace situation"
          },
          {
            "name": "role",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Job role or employment type"
          },
          {
            "name": "jurisdiction",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Country/jurisdiction for legal framework (US, UK, CA, AU)"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Workplace mental health guidance with jurisdiction-specific accommodation framework"
          },
          "402": {
            "description": "Payment required"
          }
        },
        "security": [
          {
            "x402": []
          }
        ]
      }
    },
    "/api/mind/crisis": {
      "get": {
        "summary": "Crisis resource routing \u2014 ALWAYS FREE",
        "description": "Crisis resource routing \u2014 always free, never x402-gated. Routes immediately to appropriate crisis resources: 988 Suicide & Crisis Lifeline (US), Crisis Text Line, Samaritans (UK/Ireland: 116 123), Lifeline Australia (13 11 14), Crisis Services Canada (1-833-456-4566). Includes immediate safety planning guidance.",
        "x-price-usd": 0.0,
        "x-free": true,
        "x-agent-use-case": "on-demand",
        "x-agent-chaining": "Always call this endpoint when any crisis language is detected \u2014 it is free. Routes to 988 Lifeline, Crisis Text Line, international crisis lines, and emergency protocols by country.",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "User's country for localized crisis resources"
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Response language"
          }
        ],
        "responses": {
          "200": {
            "description": "Crisis resources and immediate safety guidance \u2014 always free"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "x402": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "x402 micropayment signature. Send OPTIONS to get the 402 payment challenge, sign the payment with your wallet (USDC on Base mainnet), then retry with PAYMENT-SIGNATURE header."
      }
    }
  }
}