Skip to content

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.

SlugWhat it covers
agent-memoryThreads, messages, tool calls, and durable facts for an AI agent’s per-run memory.
saas-starterMulti-tenant users, organizations, memberships, and API keys.
blogAuthors, posts, comments, and tags for a content site or headless CMS.
ecommerceCustomers, products, variants, orders, and line items.
project-trackerProjects, tasks, and labels for an issue tracker or to-do backend.
analytics-eventsSessions and a flexible JSON event stream for product analytics.
url-shortenerShort links with per-click tracking.
feature-flagsFlags plus per-context overrides.

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.

Terminal window
persql db templates # list available schemas
persql db create my-app --template blog # create pre-loaded with the blog schema
import { 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:

Terminal window
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.