curl -X POST https://suite.sundaypyjamas.com/api/v1/artifacts/generate \
-H "Authorization: Bearer spj_ai_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"templateId": "insight-narrative-v1",
"scope": { "level": "organization", "label": "Acme Inc." },
"period": { "start": "2026-04-01", "end": "2026-06-30" },
"input": {
"aggregates": {
"recordCount": 4210,
"metrics": { "activeUsers": 1893, "churnRate": 0.042 },
"breakdowns": [
{ "dimension": "plan", "rows": [ { "key": "pro", "count": 1200 }, { "key": "free", "count": 3010 } ] }
]
},
"samples": [
{ "id": "u_1", "fields": { "plan": "pro", "lastActive": "2026-06-28" } }
],
"context": { "instructions": "Focus on churn drivers.", "locale": "en-US" }
}
}'
{
"data": {
"templateId": "insight-narrative-v1",
"outputSnapshot": {
"version": 1,
"generatedAt": "2026-07-08T10:00:00Z",
"templateId": "insight-narrative-v1",
"scope": { "level": "organization", "label": "Acme Inc." },
"period": { "start": "2026-04-01", "end": "2026-06-30" },
"source": { "type": "customer_payload", "recordCount": 4210, "sampleCount": 1 },
"llm": {
"executiveSummary": "Acme's active user base grew steadily through Q2...",
"insights": [
{
"title": "Free-to-pro conversion is slowing",
"body": "Only 8% of new free users converted to pro this quarter, down from 12%.",
"category": "implementation_pressure",
"evidence": ["1200 pro / 4210 total"]
}
],
"followUpConsiderations": [
{
"title": "Investigate onboarding drop-off",
"body": "Session data suggests most churn happens in the first 7 days.",
"attentionLevel": "elevated"
}
],
"confidenceNotes": "Based on a 4210-record sample with moderate breakdown coverage."
}
},
"usage": {
"model": "google/gemini-2.5-flash",
"inputTokens": 812,
"outputTokens": 340,
"costUsd": 0.0021,
"providerSlug": "google"
}
},
"meta": { "requestId": "9f2a...", "persisted": false }
}
Artifacts
POST /artifacts/generate
Generate a structured insight report from aggregated data
POST
/
api
/
v1
/
artifacts
/
generate
curl -X POST https://suite.sundaypyjamas.com/api/v1/artifacts/generate \
-H "Authorization: Bearer spj_ai_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"templateId": "insight-narrative-v1",
"scope": { "level": "organization", "label": "Acme Inc." },
"period": { "start": "2026-04-01", "end": "2026-06-30" },
"input": {
"aggregates": {
"recordCount": 4210,
"metrics": { "activeUsers": 1893, "churnRate": 0.042 },
"breakdowns": [
{ "dimension": "plan", "rows": [ { "key": "pro", "count": 1200 }, { "key": "free", "count": 3010 } ] }
]
},
"samples": [
{ "id": "u_1", "fields": { "plan": "pro", "lastActive": "2026-06-28" } }
],
"context": { "instructions": "Focus on churn drivers.", "locale": "en-US" }
}
}'
{
"data": {
"templateId": "insight-narrative-v1",
"outputSnapshot": {
"version": 1,
"generatedAt": "2026-07-08T10:00:00Z",
"templateId": "insight-narrative-v1",
"scope": { "level": "organization", "label": "Acme Inc." },
"period": { "start": "2026-04-01", "end": "2026-06-30" },
"source": { "type": "customer_payload", "recordCount": 4210, "sampleCount": 1 },
"llm": {
"executiveSummary": "Acme's active user base grew steadily through Q2...",
"insights": [
{
"title": "Free-to-pro conversion is slowing",
"body": "Only 8% of new free users converted to pro this quarter, down from 12%.",
"category": "implementation_pressure",
"evidence": ["1200 pro / 4210 total"]
}
],
"followUpConsiderations": [
{
"title": "Investigate onboarding drop-off",
"body": "Session data suggests most churn happens in the first 7 days.",
"attentionLevel": "elevated"
}
],
"confidenceNotes": "Based on a 4210-record sample with moderate breakdown coverage."
}
},
"usage": {
"model": "google/gemini-2.5-flash",
"inputTokens": 812,
"outputTokens": 340,
"costUsd": 0.0021,
"providerSlug": "google"
}
},
"meta": { "requestId": "9f2a...", "persisted": false }
}
Request Body
object
required
object
required
Hide input
Hide input
object
required
object[]
Up to 60 sample records. Each item:
{ id?: string, fields: object } — fields supports up to 20 keys, each value truncated server-side to ~800 characters.string
default:"insight-narrative-v1"
Known values:
"insight-narrative-v1", "phabc-data-insights-v1". Returns 400 if unrecognized.string
UUID of an app in your workspace. Returns
404 if it doesn’t belong to your workspace.object
string
External reference ID, tracked in billing. Max 256 chars.
string
Override model, e.g.
"google/gemini-2.5-flash". Max 200 chars.The full request body, serialized as JSON, must not exceed 512,000 bytes.
Response
object
Hide data
Hide data
string
object
Show outputSnapshot
Show outputSnapshot
number
Currently
1string
ISO 8601
object
Echoes request
scopeobject
Echoes request
periodobject
object
Optional human-readable label overrides for categories/sections/attention levels
curl -X POST https://suite.sundaypyjamas.com/api/v1/artifacts/generate \
-H "Authorization: Bearer spj_ai_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"templateId": "insight-narrative-v1",
"scope": { "level": "organization", "label": "Acme Inc." },
"period": { "start": "2026-04-01", "end": "2026-06-30" },
"input": {
"aggregates": {
"recordCount": 4210,
"metrics": { "activeUsers": 1893, "churnRate": 0.042 },
"breakdowns": [
{ "dimension": "plan", "rows": [ { "key": "pro", "count": 1200 }, { "key": "free", "count": 3010 } ] }
]
},
"samples": [
{ "id": "u_1", "fields": { "plan": "pro", "lastActive": "2026-06-28" } }
],
"context": { "instructions": "Focus on churn drivers.", "locale": "en-US" }
}
}'
{
"data": {
"templateId": "insight-narrative-v1",
"outputSnapshot": {
"version": 1,
"generatedAt": "2026-07-08T10:00:00Z",
"templateId": "insight-narrative-v1",
"scope": { "level": "organization", "label": "Acme Inc." },
"period": { "start": "2026-04-01", "end": "2026-06-30" },
"source": { "type": "customer_payload", "recordCount": 4210, "sampleCount": 1 },
"llm": {
"executiveSummary": "Acme's active user base grew steadily through Q2...",
"insights": [
{
"title": "Free-to-pro conversion is slowing",
"body": "Only 8% of new free users converted to pro this quarter, down from 12%.",
"category": "implementation_pressure",
"evidence": ["1200 pro / 4210 total"]
}
],
"followUpConsiderations": [
{
"title": "Investigate onboarding drop-off",
"body": "Session data suggests most churn happens in the first 7 days.",
"attentionLevel": "elevated"
}
],
"confidenceNotes": "Based on a 4210-record sample with moderate breakdown coverage."
}
},
"usage": {
"model": "google/gemini-2.5-flash",
"inputTokens": 812,
"outputTokens": 340,
"costUsd": 0.0021,
"providerSlug": "google"
}
},
"meta": { "requestId": "9f2a...", "persisted": false }
}
Errors
| Status | Code | Message |
|---|---|---|
| 400 | INVALID_INPUT | Schema validation failure (bad scope.level, unknown templateId, oversized payload) |
| 401 | — | Invalid API key |
| 402 | INSUFFICIENT_CREDITS | Insufficient credits. Please purchase additional credits to continue. |
| 404 | APP_NOT_FOUND | App not found in this workspace |
| 500 | — | The AI model could not produce a valid structured report. Please try again or use a different model. |
| 503 | — | No AI model configured |
⌘I