API Reference

Authentication

All requests require the X-Nefesh-Key header.

X-Nefesh-Key: YOUR_KEY

Endpoints

MethodEndpointDescription
POST/v1/ingestSend signals, get state
GET/v1/state?session_id=XRead current state
GET/v1/history?session_id=X&minutes=5State history (1-60 min)
GET/v1/triggers?subject_id=XTrigger Memory profile

Trigger Memory

Send user_message + ai_response together with biometric signals to /v1/ingest. Nefesh auto-extracts psychological trigger topics and tracks how a user's stress changes around specific topics over time.

Important: subject_id must be set — it's the persistent user identifier across sessions. session_id only identifies the current session.

Example: Ingest with Conversation

curl -X POST https://api.nefesh.ai/v1/ingest \
  -H "X-Nefesh-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "session-42",
    "subject_id": "user-abc-123",
    "heart_rate": 95,
    "tone": "anxious",
    "sentiment": -0.6,
    "user_message": "My manager just scheduled another performance review",
    "ai_response": "That sounds stressful. What specifically concerns you?",
    "timestamp": "2026-03-29T16:30:00Z"
  }'

Query Trigger Profile

curl "https://api.nefesh.ai/v1/triggers?subject_id=user-abc-123" \
  -H "X-Nefesh-Key: YOUR_KEY"
{
  "subject_id": "user-abc-123",
  "triggers": {
    "work_performance": {
      "status": "active",
      "avg_stress": 78,
      "peak_stress": 89,
      "sessions": 3,
      "last_seen": "2026-03-29T16:30:00Z"
    }
  },
  "active": ["work_performance"],
  "resolved": []
}

Rate Limits

LimitValue
Per session120 req/min
New sessions per key50/min
Solo tier total50,000 calls/month
Body size4 KB max

Common Errors

ErrorCauseFix
422: sentiment — Input should be a valid numbersentiment is a float, not a stringUse -1.0 to 1.0, NOT "negative"
422: expression — Input should be 'relaxed', ...Invalid literal valueOnly use allowed values (7 total)
422: Extra inputs are not permittedUnknown field (e.g. hrv_sdnn)Field is sdnn (no hrv_ prefix)
401: Invalid API keyWrong or expired keyCheck your API key
429: Rate limit exceededMore than 120 req/minThrottle requests
413: Body too largePayload exceeds 4 KBReduce signal fields per request

Error Codes

CodeMeaning
400Invalid payload, timestamp too old, missing signals
401Missing or invalid X-Nefesh-Key
413Body exceeds 4 KB limit
422Validation error (wrong type or value)
429Rate limit exceeded