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
Hide input
Hide input
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.Known values:
"insight-narrative-v1", "phabc-data-insights-v1". Returns 400 if unrecognized.UUID of an app in your workspace. Returns
404 if it doesn’t belong to your workspace.External reference ID, tracked in billing. Max 256 chars.
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
Hide data
Hide data
Show outputSnapshot
Show outputSnapshot
Currently
1ISO 8601
Echoes request
scopeEchoes request
periodShow llm
Show llm
120–400 word summary
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