Blueprints API
Blueprints are reusable workflow templates defined in YAML. Each blueprint declares typed variables, ordered steps with prompt templates, and an execution pattern (sequence, planner-executor, or checkpoint). The Blueprints API supports listing, creating, importing from GitHub, instantiating into live workflows, and deleting user-created blueprints.
Quick Start
Browse available blueprints, instantiate one with your variables, and check the resulting workflow:
// 1. List available blueprints to find one that fits your use case
const blueprints: Blueprint[] = await fetch('/api/blueprints').then(r => r.json());
const codeReview = blueprints.find(bp => bp.tags.includes('code-review'));
console.log(`${codeReview.name} (${codeReview.pattern})`);
console.log(`Variables: ${codeReview.variables.map(v => v.id).join(', ')}`);
// → "Code Review Pipeline (sequence)"
// → "Variables: repo_url, branch, focus_areas"
// 2. Instantiate the blueprint — supply values for its declared variables
const workflow: Workflow = await fetch(`/api/blueprints/${codeReview.id}/instantiate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
variables: {
repo_url: 'https://github.com/acme/payments-service',
branch: 'feature/stripe-v3',
focus_areas: 'security, error handling',
},
projectId: 'proj-8f3a-4b2c',
}),
}).then(r => r.json());
// → Live workflow with all steps created, prompts populated with your variables
// 3. Execute the instantiated workflow
await fetch(`/api/workflows/${workflow.id}/execute`, { method: 'POST' });
// 4. Check workflow status to track step progress
const status: WorkflowStatus = await fetch(`/api/workflows/${workflow.id}/status`)
.then(r => r.json());
for (const step of status.steps) {
console.log(` ${step.stepId}: ${step.status}`);
} Base URL
/api/blueprints
Endpoints
List Blueprints
/api/blueprints Retrieve all registered blueprints, including built-in and user-created entries.
Response 200 — Array of blueprint objects
Blueprint Object
| Field | Type | Req | Description |
|---|---|---|---|
| id | string | * | Blueprint identifier |
| name | string | * | Display name |
| description | string | * | What this blueprint does |
| version | string | * | Semver version (e.g. 1.0.0) |
| domain | enum | * | work or personal |
| tags | string[] | * | Categorization tags |
| pattern | enum | * | Execution pattern: sequence, planner-executor, or checkpoint |
| variables | Variable[] | * | Typed input variables for instantiation |
| steps | Step[] | * | Ordered workflow steps |
| author | string | — | Blueprint author |
| source | string (URL) | — | Source repository URL |
| estimatedDuration | string | — | Estimated execution time |
| difficulty | enum | — | beginner, intermediate, or advanced |
Fetch all blueprints to display a template gallery — filter by domain or tags for your use case:
// List all blueprints and group by domain
const blueprints: Blueprint[] = await fetch('/api/blueprints').then(r => r.json());
const work = blueprints.filter(bp => bp.domain === 'work');
const personal = blueprints.filter(bp => bp.domain === 'personal');
console.log(`${work.length} work blueprints, ${personal.length} personal`);
work.forEach(bp => console.log(` ${bp.name} [${bp.pattern}] — ${bp.tags.join(', ')}`)); Example response:
[
{
"id": "code-review-pipeline",
"name": "Code Review Pipeline",
"description": "Automated multi-step code review with security analysis and style checking",
"version": "1.2.0",
"domain": "work",
"tags": ["code-review", "security", "automation"],
"pattern": "sequence",
"variables": [
{ "id": "repo_url", "type": "text", "label": "Repository URL", "required": true },
{ "id": "branch", "type": "text", "label": "Branch", "required": true, "default": "main" },
{ "id": "focus_areas", "type": "textarea", "label": "Focus Areas", "required": false }
],
"steps": [
{ "name": "Security Scan", "profileId": "code-reviewer", "promptTemplate": "Review {{repo_url}} branch {{branch}} for security vulnerabilities", "requiresApproval": false },
{ "name": "Style Review", "profileId": "code-reviewer", "promptTemplate": "Check code style and patterns in {{repo_url}}", "requiresApproval": false },
{ "name": "Final Report", "profileId": "technical-writer", "promptTemplate": "Compile findings into a review report focusing on {{focus_areas}}", "requiresApproval": true }
],
"author": "Stagent Team",
"estimatedDuration": "10–15 minutes",
"difficulty": "beginner"
}
] Create Blueprint
/api/blueprints Register a new blueprint by providing its YAML definition. The YAML is validated against the blueprint schema.
Request Body
| Field | Type | Req | Description |
|---|---|---|---|
| yaml | string | * | Complete blueprint YAML content |
Response 201 Created — The registered blueprint object
Errors: 400 — YAML parse error or schema validation failure
Register a custom blueprint from YAML — the YAML is validated against the blueprint schema before saving:
// Register a blueprint from YAML content
const yaml: string = `
id: daily-standup-report
name: Daily Standup Report
description: Generate a daily standup summary from project tasks
version: 1.0.0
domain: work
tags: [standup, reporting]
pattern: sequence
variables:
- id: project_name
type: text
label: Project Name
required: true
steps:
- name: Gather Status
profileId: project-manager
promptTemplate: "List all tasks updated in the last 24 hours for {{project_name}}"
requiresApproval: false
- name: Write Summary
profileId: technical-writer
promptTemplate: "Write a standup summary from the task status data"
requiresApproval: false
`.trim();
const blueprint: Blueprint = await fetch('/api/blueprints', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ yaml }),
}).then(r => r.json());
console.log(`Registered: ${blueprint.id}`); Import Blueprint from GitHub
/api/blueprints/import Import a blueprint from a GitHub URL pointing to a YAML file. Supports both github.com blob/tree URLs and raw.githubusercontent.com URLs.
Request Body
| Field | Type | Req | Description |
|---|---|---|---|
| url | string (URL) | * | GitHub URL to a blueprint YAML file |
Response 201 Created
Response Body
| Field | Type | Req | Description |
|---|---|---|---|
| ok | boolean | * | Always true on success |
| id | string | * | Registered blueprint ID |
| name | string | * | Blueprint display name |
Errors:
400— URL missing, not a GitHub URL, fetch failed, or YAML validation error
Import a blueprint directly from a GitHub repository — Stagent fetches the YAML, validates it, and registers it:
// Import a blueprint from GitHub — validates and registers automatically
const { id, name }: { id: string; name: string } = await fetch('/api/blueprints/import', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
url: 'https://github.com/acme/stagent-blueprints/blob/main/blueprints/code-review.yaml',
}),
}).then(r => r.json());
console.log(`Imported "${name}" as ${id}`); Example response:
{
"ok": true,
"id": "code-review-pipeline",
"name": "Code Review Pipeline"
} Get Blueprint
/api/blueprints/{id} Retrieve a single blueprint by ID.
Response 200 — Blueprint object
Errors: 404 — Blueprint not found
Fetch a blueprint to inspect its variables before instantiation:
// Fetch a blueprint to build a dynamic form for its variables
const bp: Blueprint = await fetch('/api/blueprints/code-review-pipeline')
.then(r => r.json());
// Build a form from the variable schema
bp.variables.forEach(v => {
console.log(`${v.label} (${v.type})${v.required ? ' *' : ''}`);
if (v.default) console.log(` default: ${v.default}`);
}); Instantiate Blueprint
/api/blueprints/{id}/instantiate Create a live workflow from a blueprint by supplying values for its declared variables. Each variable is substituted into the step prompt templates.
Request Body
| Field | Type | Req | Description |
|---|---|---|---|
| variables | object | * | Key-value map of variable IDs to their values |
| projectId | string (UUID) | — | Project to associate the created workflow with |
Response 201 Created — The instantiated workflow object with all steps created
Errors: 400 — Variables object missing, blueprint not found, or variable validation failure
Instantiate a blueprint into a live workflow — variables are substituted into every step’s prompt template:
// Instantiate — variables are substituted into step prompts
const workflow: Workflow = await fetch('/api/blueprints/code-review-pipeline/instantiate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
variables: {
repo_url: 'https://github.com/acme/payments-service',
branch: 'feature/stripe-v3',
focus_areas: 'security, error handling, input validation',
},
projectId: 'proj-8f3a-4b2c',
}),
}).then(r => r.json());
console.log(`Created workflow: ${workflow.id}`);
console.log(`Status: ${workflow.status}`); // "draft" — execute to start Example response:
{
"id": "wf-9b3d-2e7c",
"name": "Code Review Pipeline",
"projectId": "proj-8f3a-4b2c",
"status": "draft",
"runNumber": 0,
"createdAt": "2026-04-03T10:30:00.000Z",
"updatedAt": "2026-04-03T10:30:00.000Z"
} Delete Blueprint
/api/blueprints/{id} Remove a user-created blueprint. Built-in blueprints cannot be deleted.
Response 200 — { "ok": true }
Errors:
403— Cannot delete a built-in blueprint400— Delete failed
// Delete a user-created blueprint — built-ins are protected
const res: Response = await fetch('/api/blueprints/daily-standup-report', {
method: 'DELETE',
});
if (res.status === 403) {
console.log('Cannot delete built-in blueprints');
} Variable Schema
Each blueprint declares typed variables that must be supplied at instantiation time.
Variable Object
| Field | Type | Req | Description |
|---|---|---|---|
| id | string | * | Variable identifier used in prompt templates |
| type | enum | * | Input type: text, textarea, select, number, boolean, or file |
| label | string | * | Human-readable label |
| description | string | — | Help text for the variable |
| required | boolean | * | Whether a value must be provided |
| default | any | — | Default value if not supplied |
| placeholder | string | — | Placeholder text for input fields |
| options | Option[] | — | Choices for select type: [{ value, label }] |
| min | number | — | Minimum value (number type only) |
| max | number | — | Maximum value (number type only) |
Step Schema
Each step defines an agent task to execute within the workflow.
Step Object
| Field | Type | Req | Description |
|---|---|---|---|
| name | string | * | Step display name |
| profileId | string | * | Agent profile to use for execution |
| promptTemplate | string | * | Prompt with {{variable}} placeholders |
| requiresApproval | boolean | * | Whether the step needs manual approval before running |
| expectedOutput | string | — | Description of expected output |
| condition | string | — | Conditional expression to skip this step |
Execution Patterns
| Pattern | Description |
|---|---|
| sequence | Steps execute in order, one after the other |
| planner-executor | A planner step generates sub-tasks, then executor steps process them |
| checkpoint | Steps execute with approval gates between stages |
Error Format
All errors follow a consistent JSON format:
{
"error": "Descriptive error message"
}