Spark Suggestions
Spark produces one focused AI suggestion per request. It resolves context from your Projects, Tasks, personalization memory, and active sessions, then generates a concise suggestion without starting a full conversation session.
Use Spark for lightweight in-app moments: "what should I work on next?", "turn this comment into an action", "suggest a Task for this Project".
Endpoint
| Method | Path | Description | Auth |
|---|---|---|---|
| POST | /ai/spark/suggestions | Create a context-aware suggestion | JWT + Spark entitlement |
POST /ai/spark/suggestions
Authentication: JWT Bearer token required.
Entitlement: Active Spark entitlement required. Available on Plus and above (not included in the Free plan).
Rate limit: 30 requests per minute.
Idempotency: Pass an idempotency-key header to deduplicate retries — identical keys return the stored result without re-invoking the LLM. See Idempotency for retry, conflict and key-format behavior.
Request
Request Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <token> |
Content-Type | Yes | application/json |
idempotency-key | No | Unique key to deduplicate the request (8–128 characters from A–Z a–z 0–9 : _ - .) |
Request Body
All fields are optional. If no fields are provided the server uses the auto_suggest mode.
| Field | Type | Constraints | Description |
|---|---|---|---|
mode | string | auto_suggest, prompt_suggest, next_bit, comment_result | Explicit mode. Omit to let the server resolve automatically. |
prompt | string | max 4000 chars | Primary instruction or question. |
comment | string | max 4000 chars | Raw comment to transform into a suggestion. |
chainyIds | string[] | max 10, each a valid UUID | Ground the suggestion in specific Projects. |
bitIds | string[] | max 25, each a valid UUID | Ground the suggestion in specific Tasks. |
contextOptions.useMemory | boolean | — | Set false to suppress memory context for this request. |
contextOptions.useLatestSessions | boolean | — | Set false to suppress recent-sessions context for this request. |
Mode auto-resolution (when mode is omitted):
commentprovided →comment_resultpromptprovided →prompt_suggestchainyIdsprovided →next_bit- Nothing →
auto_suggest
Response
Response Example
{
"data": {
"suggestionId": "cm9spark01",
"mode": "next_bit",
"title": "Add a pronunciation practice session",
"content": "Your Spanish Chainy has strong vocabulary coverage but no pronunciation Bits. Adding a 10-minute daily audio session would round out the practice cycle.",
"structuredResult": {
"type": "next_bit",
"payload": {
"suggestedTitle": "Pronunciation: 10-min daily audio",
"suggestedPriority": "high"
}
},
"contextUsed": ["chainies", "bits", "memory"],
"blockedContext": [
{
"category": "sessions",
"reason": "sessions_disabled_by_preference"
}
],
"chainyIdsUsed": ["a1b2c3d4-e5f6-7890-abcd-ef1234567890"],
"bitIdsUsed": [
"b2c3d4e5-f6a7-8901-bcde-f12345678901",
"c3d4e5f6-a7b8-9012-cdef-123456789012"
],
"personaUsed": "coach",
"provider": "google",
"model": "gemini-2.5-flash",
"createdAt": "2026-05-22T09:30:00.000Z"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
suggestionId | string | Persisted suggestion ID |
mode | string | Resolved mode used: auto_suggest, prompt_suggest, next_bit, comment_result |
title | string | Short suggestion headline (max 200 chars) |
content | string | Full suggestion text (max 2000 chars) |
structuredResult | object | null | Optional structured output (see below) |
contextUsed | string[] | Context categories that fed the suggestion |
blockedContext | object[] | Context categories that were suppressed and why |
chainyIdsUsed | string[] | Project IDs that grounded the suggestion |
bitIdsUsed | string[] | Task IDs that grounded the suggestion |
personaUsed | string | null | AI persona key if a persona was applied |
provider | string | AI provider used (e.g. google, anthropic) |
model | string | Model identifier |
createdAt | string | ISO 8601 timestamp |
structuredResult object
Present when the LLM returns structured data in addition to the narrative text.
| Field | Type | Description |
|---|---|---|
type | string | next_bit, idea, transformation, or generic |
payload | object | Type-specific fields (e.g. suggestedTitle, suggestedPriority) |
contextUsed values
| Value | Meaning |
|---|---|
prompt | User's prompt field was used |
comment | User's comment field was used |
chainies | Project data was retrieved |
bits | Task data was retrieved |
memory | Personalization memory was used |
sessions | Recent AI sessions were used |
preferences | AI persona or language preference was applied |
blockedContext object
| Field | Type | Description |
|---|---|---|
category | string | The contextUsed category that was blocked |
reason | string | Why it was blocked (see table below) |
| Reason | Cause |
|---|---|
memory_disabled_by_preference | Memory disabled in your AI preferences |
memory_disabled_by_client | Request sent contextOptions.useMemory: false |
sessions_disabled_by_preference | Session context disabled in your AI preferences |
sessions_disabled_by_client | Request sent contextOptions.useLatestSessions: false |
empty_input | No prompt, comment, or Project IDs were provided |
no_bits_available | The requested Projects exist but contain no Tasks |
Error Responses
| Status | Code | When |
|---|---|---|
| 400 | VALIDATION_FAILED | Mode/input mismatch (e.g. next_bit without chainyIds) |
| 403 | forbidden | chainyIds or bitIds do not belong to your account |
| 429 | RATE_LIMITED | More than 30 requests per minute |
| 502 | BAD_GATEWAY | AI provider returned an empty or failed response |
| 503 | SERVICE_UNAVAILABLE | No AI provider available |
Code Examples
Use the id of one of your Projects as $CHAINY_ID in the "next task" examples below.
curl -X POST "https://api.chainabit.com/api/v1/ai/spark/suggestions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{}'curl -X POST "https://api.chainabit.com/api/v1/ai/spark/suggestions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "idempotency-key: req_abc123" \
-d '{
"mode": "prompt_suggest",
"prompt": "What is the highest priority thing I should tackle today?"
}'curl -X POST "https://api.chainabit.com/api/v1/ai/spark/suggestions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"mode": "next_bit",
"chainyIds": ["'"$CHAINY_ID"'"]
}'curl -X POST "https://api.chainabit.com/api/v1/ai/spark/suggestions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"mode": "comment_result",
"comment": "I keep losing focus after lunch and end up skipping my language practice."
}'Plan availability
| Plan | Spark access | Monthly suggestion limit |
|---|---|---|
| Free | No | — |
| Plus | Yes | 150 |
| Pro | Yes | 500 |
| Pro (higher capacity) | Yes | Unlimited |
Calling this endpoint on a plan without Spark access returns 403 (entitlement_required or auth_insufficient_permissions).
Modes
auto_suggest
No inputs required. Spark reads your recent Tasks, Projects, memory, and sessions and generates an unprompted suggestion — useful for "surprise me" or "what's next?" moments.
prompt_suggest
Requires prompt. Generates a suggestion grounded in your explicit question or instruction combined with your available context.
next_bit
Requires at least one chainyId. Spark analyses the Project's existing Tasks and suggests a concrete next Task to create or action to take.
comment_result
Requires comment. Transforms a raw user comment (a note, thought, or observation) into an actionable suggestion.
Context controls
Grounding with specific IDs
Provide chainyIds and/or bitIds to pin the suggestion to specific content. Without IDs Spark pulls from your most recent Projects and Tasks automatically.
Suppressing context per request
Use contextOptions to override your account-level preferences for a single request:
{
"contextOptions": {
"useMemory": false,
"useLatestSessions": false
}
}Account-level preferences
Memory and session context follow your AI preferences (ai_memory_enabled, use_latest_sessions). Manage these via the Preferences API.
Idempotency
Pass an idempotency-key header to make retries safe. If a suggestion was already created with the same key, the persisted result is returned immediately without calling the LLM again.
curl -X POST "https://api.chainabit.com/api/v1/ai/spark/suggestions" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "idempotency-key: client-generated-unique-id" \
-d '{ "prompt": "What should I focus on today?" }'Keys are scoped to your account and the workspace the request runs in. Use a UUID or a hash of the request inputs as the key (8–128 characters from A–Z a–z 0–9 : _ - .).
The X-Idempotency-Status response header tells you what happened to the key:
X-Idempotency-Status | Meaning |
|---|---|
created | First request with this key; the suggestion was generated and stored. |
replayed | The key was already used with the same request and the same credential; the stored response is returned with its original status and no new suggestion is generated. A refreshed access token counts as the same credential. |
in_progress | A request with this key is still running. Status 409 with code idempotency_in_progress and a Retry-After header (seconds); retry the same request after that delay. |
conflict | The key was already used with a different request body or a different credential (for example after signing in again). Status 409 with code idempotency_key_reused_with_different_payload; send a new key for a different request. |
A key that does not match the allowed format is rejected with status 400 and code invalid_idempotency_key. Requests without a key are processed normally and are not deduplicated.