Skip to content

Chao Context

Reference for the Chao Context API. Chao is Chainabit's Chainy-native behavioral advisor; this endpoint assembles the resolved context that powers personalized coaching sessions.

See also

Endpoints

MethodPathDescriptionAuthRate Limit
GET/ai/chao/contextGet resolved Chao contextJWT + Entitlement30/min

GET /ai/chao/context

Description

Retrieve the resolved Chao context. Behavior depends on whether chainyId is provided:

  • With chainyId — returns Chainy-scoped memories and chain productivity data for that specific goal system.
  • Without chainyId — returns general mode context: account-wide memories, near-term bits (tasks), and active chainies (goal systems with their vision).

Authentication: JWT Bearer token + active AI entitlement required. Rate limit: 30/min

Request

Query Parameters
ParameterTypeRequiredDescription
chainyIdstring (UUID)NoThe Chainy to resolve context for. Must belong to the authenticated account. If omitted, general mode is returned.

Response

Response — Chainy Mode

Returned when chainyId is provided.

json
{
  "data": {
    "mode": "chainy",
    "chainyId": "550e8400-e29b-41d4-a716-446655440000",
    "memories": [
      {
        "content": "User prefers morning workouts before 8 AM.",
        "type": "preference",
        "scope": "chainy",
        "importance": 85,
        "origin": "inferred",
        "confidence": "high"
      }
    ],
    "productivitySnapshot": {
      "chains": [
        {
          "title": "Morning Run",
          "currentStreak": 12,
          "longestStreak": 30,
          "totalCompletions": 156,
          "status": "active"
        }
      ],
      "recentCompletions": [
        {
          "chainTitle": "Morning Run",
          "completedAt": "2026-03-20T07:30:00.000Z"
        }
      ]
    }
  }
}
Response — General Mode

Returned when chainyId is omitted. Chao surfaces near-term tasks and active goal systems across the full account.

json
{
  "data": {
    "mode": "general",
    "memories": [
      {
        "content": "User prefers concise, action-oriented advice.",
        "type": "preference",
        "scope": "account",
        "importance": 70,
        "origin": "inferred",
        "confidence": "high"
      }
    ],
    "bits": [
      {
        "id": "a1b2c3d4-...",
        "title": "Write unit tests",
        "description": "Cover edge cases for the auth module.",
        "priority": "p2",
        "scheduledFor": "2026-03-31",
        "score": 47
      }
    ],
    "chainies": [
      {
        "id": "550e8400-...",
        "title": "Morning Athlete",
        "description": "Build a consistent morning exercise routine to feel energized daily.",
        "status": "active"
      }
    ]
  }
}
Response Fields — Chainy Mode
FieldTypeDescription
modestringAlways "chainy"
chainyIdstringThe Chainy UUID this context was resolved for
memoriesobject[]Chainy-scoped memory entries
memories[].contentstringHuman-readable memory content
memories[].typestringMemory type: preference, behavioral_pattern, goal, observation
memories[].scopestringMemory scope: chainy, account, workspace
memories[].importancenumberImportance score (0–100)
memories[].originstringHow the memory was created: inferred, explicit, system
memories[].confidencestringConfidence level: high, medium, low
productivitySnapshot.chains[].titlestringChain title
productivitySnapshot.chains[].currentStreaknumberCurrent active streak
productivitySnapshot.chains[].longestStreaknumberAll-time longest streak
productivitySnapshot.chains[].totalCompletionsnumberTotal completions
productivitySnapshot.chains[].statusstringChain status: active, paused, archived
productivitySnapshot.recentCompletions[].chainTitlestringTitle of the completed chain
productivitySnapshot.recentCompletions[].completedAtstringISO 8601 completion timestamp
Response Fields — General Mode
FieldTypeDescription
modestringAlways "general"
memoriesobject[]Account-wide memory entries (same shape as chainy mode)
bitsobject[]Near-term tasks scored by date proximity and priority (max 10)
bits[].idstringBit UUID
bits[].titlestringTask title
bits[].descriptionstring | nullShort task description
bits[].prioritystringPriority: p1, p2, p3, p4
bits[].scheduledForstring | nullISO date the bit is scheduled for
bits[].scorenumberComputed relevance score (higher = more urgent)
chainiesobject[]Active goal systems (max 5)
chainies[].idstringChainy UUID
chainies[].titlestringGoal system title
chainies[].descriptionstring | nullGoal system vision or description
chainies[].statusstringAlways "active" in this response
Error Responses
StatusCodeDescription
400BAD_REQUESTchainyId was provided but is not a valid UUID
401UNAUTHORIZEDMissing or invalid JWT token
403FORBIDDENNo active AI entitlement
404NOT_FOUNDChainy not found or does not belong to the authenticated account

Code Examples

In Chainy mode, chainyId must be the id of an existing Chainy — e.g. from Create Chainy, shown below as $CHAINY_ID.

bash
curl "https://api.chainabit.com/api/v1/ai/chao/context?chainyId=$CHAINY_ID" \
  -H "Authorization: Bearer $TOKEN"
bash
curl "https://api.chainabit.com/api/v1/ai/chao/context" \
  -H "Authorization: Bearer $TOKEN"
javascript
const chainyId = process.env.CHAINY_ID; // id of the Chainy to resolve context for

// Chainy-scoped mode
const chainyRes = await fetch(
  `${BASE_URL}/ai/chao/context?chainyId=${chainyId}`,
  { headers: { Authorization: `Bearer ${TOKEN}` } },
);

// General mode
const generalRes = await fetch(
  `${BASE_URL}/ai/chao/context`,
  { headers: { Authorization: `Bearer ${TOKEN}` } },
);
python
import os
import requests

chainy_id = os.environ["CHAINY_ID"]  # id of the Chainy to resolve context for

# Chainy-scoped mode
chainy_res = requests.get(
    f"{BASE_URL}/ai/chao/context",
    params={"chainyId": chainy_id},
    headers={"Authorization": f"Bearer {TOKEN}"},
)

# General mode
general_res = requests.get(
    f"{BASE_URL}/ai/chao/context",
    headers={"Authorization": f"Bearer {TOKEN}"},
)

Built with purpose.