Pottr/Docs
Topic:Quickstart Guide
Getting Started
.md

Quickstart Guide

Connect a frontend application to Pottr, declare your schema, and make your first verified API request in 5 minutes.

1. Retrieve Your API Keys

In the WordPress Admin, navigate to Pottr › API Keys. Copy your Public Key (starts with pk_live_).

2. Configure Environment Variables

In your frontend project (e.g. Next.js, Vite, React, Vue), configure your environment variables:

.env.local
NEXT_PUBLIC_POTTR_API_URL="https://example.com/wp-json/pottr/v1"
NEXT_PUBLIC_POTTR_PUBLIC_KEY="pk_live_your_public_key_here"

3. Allow Your Frontend Origin

Browsers only let your app call Pottr from origins you allow. Add this to wp-config.php (use POTTR_ALLOWED_ORIGINS for a comma-separated list):

wp-config.php
define( 'POTTR_ALLOWED_ORIGIN', 'http://localhost:3000' );

See Configuration for all options.

4. Declare Schema via Bootstrap (Optional)

You can create collections in the WordPress Admin, or send a declarative bootstrap request using your Public Key when your app boots:

bootstrap.js
const response = await fetch('https://example.com/wp-json/pottr/v1/auth/bootstrap', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.NEXT_PUBLIC_POTTR_PUBLIC_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    app: 'task-manager',
    version: '1.0.0',
    collections: [
      {
        slug: 'tasks',
        name: 'Tasks',
        fields: [
          { key: 'title', type: 'text', required: true },
          { key: 'priority', type: 'text' },
          { key: 'completed', type: 'boolean' }
        ]
      }
    ]
  })
});

const result = await response.json();
console.log(result);

Bootstrap is additive and safe to call on every app boot. The response reports what happened to each collection:

Response
{
  "app": "task-manager",
  "version": "1.0.0",
  "version_status": "new",
  "auth": null,
  "results": [
    { "slug": "tasks", "status": "created" }
  ]
}

Each result is created, existing or failed (for example when your plan’s collection limit is reached). See Blueprints.

5. Create and Query Entries

Create a task entry via POST /collections/tasks:

create-entry.js
const createRes = await fetch('https://example.com/wp-json/pottr/v1/collections/tasks', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.NEXT_PUBLIC_POTTR_PUBLIC_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    title: 'Ship documentation',
    priority: 'high',
    completed: false
  })
});

const newEntry = await createRes.json();
console.log(newEntry); // HTTP 201, the stored entry (id, collection, data, created_at, updated_at)

Fetch the list of tasks with pagination:

fetch-entries.js
const res = await fetch('https://example.com/wp-json/pottr/v1/collections/tasks?limit=10&order_by=created_at&order=DESC', {
  headers: {
    'Authorization': `Bearer ${process.env.NEXT_PUBLIC_POTTR_PUBLIC_KEY}`
  }
});

const { data, meta } = await res.json();
console.log(data); // Array of entries; each has a string id, created_at and your fields
console.log(meta); // { total: 1, limit: 10, offset: 0, has_more: false }