Schema templates
A template is a ready-to-use schema you can launch a database from. Instead
of starting empty and writing CREATE TABLE by hand, pick a template and
PerSQL provisions the database with its tables, indexes, and foreign keys
already in place.
Templates carry schema only — no rows, the same as a fresh branch or a schema-only fork. You get empty tables to start writing into immediately.
Available templates
Section titled “Available templates”| Slug | What it covers |
|---|---|
agent-memory | Threads, messages, tool calls, and durable facts for an AI agent’s per-run memory. |
saas-starter | Multi-tenant users, organizations, memberships, and API keys. |
blog | Authors, posts, comments, and tags for a content site or headless CMS. |
ecommerce | Customers, products, variants, orders, and line items. |
project-tracker | Projects, tasks, and labels for an issue tracker or to-do backend. |
analytics-events | Sessions and a flexible JSON event stream for product analytics. |
url-shortener | Short links with per-click tracking. |
feature-flags | Flags plus per-context overrides. |
Console
Section titled “Console”In Databases → New database, pick a Starting schema. The picker shows each template’s description and the tables it creates. Leave it on Empty database for a blank database.
persql db templates # list available schemaspersql db create my-app --template blog # create pre-loaded with the blog schemaimport { PerSQL } from "@persql/sdk";
const persql = new PerSQL({ token: process.env.PERSQL_TOKEN });
await persql.databases.templates(); // [{ slug, title, description, tables }]
await persql.databases.create({ name: "Agent sandbox", slug: "agent-sandbox", template: "agent-memory",});Pass template to the create endpoint — over a bearer token:
curl -X POST https://api.persql.com/v1/databases \ -H "Authorization: Bearer $PERSQL_TOKEN" \ -H "Content-Type: application/json" \ -d '{"name":"Agent sandbox","slug":"agent-sandbox","template":"agent-memory"}'GET /v1/templates returns the same list the picker uses. An unknown
template slug is rejected with 400.
Agents can discover and use templates with the list_templates tool and the
template argument on create_database — handy for spinning up a fresh
agent-memory database per run.