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

GET /api/blueprints

Retrieve all registered blueprints, including built-in and user-created entries.

Response 200 — Array of blueprint objects

Blueprint Object

FieldTypeReqDescription
idstring*Blueprint identifier
namestring*Display name
descriptionstring*What this blueprint does
versionstring*Semver version (e.g. 1.0.0)
domainenum*work or personal
tagsstring[]*Categorization tags
patternenum*Execution pattern: sequence, planner-executor, or checkpoint
variablesVariable[]*Typed input variables for instantiation
stepsStep[]*Ordered workflow steps
authorstringBlueprint author
sourcestring (URL)Source repository URL
estimatedDurationstringEstimated execution time
difficultyenumbeginner, 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

POST /api/blueprints

Register a new blueprint by providing its YAML definition. The YAML is validated against the blueprint schema.

Request Body

FieldTypeReqDescription
yamlstring*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

POST /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

FieldTypeReqDescription
urlstring (URL)*GitHub URL to a blueprint YAML file

Response 201 Created

Response Body

FieldTypeReqDescription
okboolean*Always true on success
idstring*Registered blueprint ID
namestring*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

GET /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

POST /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

FieldTypeReqDescription
variablesobject*Key-value map of variable IDs to their values
projectIdstring (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

DELETE /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 blueprint
  • 400 — 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

FieldTypeReqDescription
idstring*Variable identifier used in prompt templates
typeenum*Input type: text, textarea, select, number, boolean, or file
labelstring*Human-readable label
descriptionstringHelp text for the variable
requiredboolean*Whether a value must be provided
defaultanyDefault value if not supplied
placeholderstringPlaceholder text for input fields
optionsOption[]Choices for select type: [{ value, label }]
minnumberMinimum value (number type only)
maxnumberMaximum value (number type only)

Step Schema

Each step defines an agent task to execute within the workflow.

Step Object

FieldTypeReqDescription
namestring*Step display name
profileIdstring*Agent profile to use for execution
promptTemplatestring*Prompt with {{variable}} placeholders
requiresApprovalboolean*Whether the step needs manual approval before running
expectedOutputstringDescription of expected output
conditionstringConditional expression to skip this step

Execution Patterns

PatternDescription
sequenceSteps execute in order, one after the other
planner-executorA planner step generates sub-tasks, then executor steps process them
checkpointSteps execute with approval gates between stages

Error Format

All errors follow a consistent JSON format:

{
  "error": "Descriptive error message"
}