Build & Integrate
Connecting Apps
Let an external app request a connection and get API keys after one click of admin approval, with no manual setup.
The Handshake
- The app calls
POST /connect/requestwith itsappslug, a displaynameand thecollectionsit needs. No API key is required. The response is202with arequest_idand a single-usepolling_token. - WordPress shows a notice to administrators. Opening the Pottr dashboard shows the app and the collections it wants, and the admin clicks Approve or Reject.
- The app polls
GET /connect/status?request_id=...with the headerX-Pottr-Connect-Token. While waiting it receives{ "status": "pending" }. After approval it receivesapproved, the public key and the created collections.
Requests expire after 15 minutes and are limited to 5 per 10 minutes per IP address.
connect.js
const base = 'https://example.com/wp-json/pottr/v1';
const req = await fetch(`${base}/connect/request`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
app: 'task-manager',
name: 'Task Manager',
collections: [
{ slug: 'tasks', name: 'Tasks', fields: [{ key: 'title', type: 'text', required: true }] }
]
})
}).then(r => r.json());
// Poll until the admin approves
const status = await fetch(`${base}/connect/status?request_id=${req.request_id}`, {
headers: { 'X-Pottr-Connect-Token': req.polling_token }
}).then(r => r.json());
// { status: 'approved', public_key: 'pk_live_...', collections: {...} }From Another WordPress Plugin
Code running on the same site can skip HTTP. See PHP Helpers for pottr_connect_app().
Keyless First Writes
Pottr can also catch a first POST to a collection that does not exist yet. The admin sees the inferred fields and can create the collection with one click, which suits quick prototypes and webhook sources.