# Quickstart Guide

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

- **Category:** Getting Started
- **Canonical Guide:** https://pottr.tangble.com/docs/quickstart

---

>
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:

**File: `.env.local`**

```text
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):

**File: `wp-config.php`**

```php
define( 'POTTR_ALLOWED_ORIGIN', 'http://localhost:3000' );
```

See [Configuration](/pottr/docs/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:

**File: `bootstrap.js`**

```javascript
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:

**File: `Response`**

```json
{
  "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](/pottr/docs/blueprints).

## 5. Create and Query Entries

Create a task entry via `POST /collections/tasks`:

**File: `create-entry.js`**

```javascript
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:

**File: `fetch-entries.js`**

```javascript
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 }
```
