Quickstart
This guide walks you through creating an app, defining a schema, inserting data, and setting up authentication. You can do all of this through the MCP tools (if using an AI assistant), the CLI, or the REST API.
-
Create an app
Use the init_app tool with name: "my-app"Terminal window butterbase apps create my-appbutterbase apps use <app_id>Terminal window curl -X POST https://api.butterbase.ai/init \-H "Authorization: Bearer bb_sk_..." \-H "Content-Type: application/json" \-d '{"name": "my-app"}'You’ll receive an
app_idand API base URL. Save these — you’ll need them for all subsequent operations. -
Define your schema
Describe your tables in a declarative JSON format:
{"schema": {"tables": {"posts": {"columns": {"id": { "type": "uuid", "primary": true, "default": "gen_random_uuid()" },"title": { "type": "text", "nullable": false },"body": { "type": "text" },"user_id": { "type": "uuid", "nullable": false },"published": { "type": "boolean", "default": "false" },"created_at": { "type": "timestamptz", "default": "now()" }}}}},"name": "create posts table"}Preview the changes first with
dry_run: true, then apply. -
Enable row-level security
Restrict data so each user only sees their own posts:
Use create_user_isolation_policy with table_name: "posts", user_column: "user_id"Terminal window curl -X POST https://api.butterbase.ai/v1/{app_id}/rls \-H "Authorization: Bearer bb_sk_..." \-H "Content-Type: application/json" \-d '{"table_name": "posts", "user_column": "user_id"}' -
Insert and query data
import { createClient } from '@butterbase/sdk';const butterbase = createClient({appId: 'app_abc123',apiUrl: 'https://api.butterbase.ai',});// Insert a rowconst { data } = await butterbase.from('posts').insert({ title: 'Hello World', body: 'My first post' });// Query rowsconst { data: posts } = await butterbase.from('posts').select('*').eq('published', true).order('created_at', { ascending: false });Terminal window # Insertcurl -X POST https://api.butterbase.ai/v1/{app_id}/posts \-H "Authorization: Bearer {user_jwt}" \-H "Content-Type: application/json" \-d '{"title": "Hello World", "body": "My first post"}'# Querycurl "https://api.butterbase.ai/v1/{app_id}/posts?published=eq.true&order=created_at.desc" -
Deploy your frontend
Build your frontend, zip the output, and deploy:
Terminal window npm run build# Zip the dist/ folder (use archiver or Git Bash zip)Then use the
create_frontend_deploymentandstart_frontend_deploymentMCP tools, or the REST API.
Next steps
Section titled “Next steps”- Database & Schema — Learn the full schema DSL
- Authentication — Set up sign-in for your users
- TypeScript SDK — Use the SDK in your frontend