Build your own app on a Palpable project.

Any project can have its own live API. Tell Claude Code, Lovable, Cursor or any AI coding tool the page or app you want, and it builds it on top of your hardware.

1

Get a key.

In the Palpable app, open the project, then its settings menu, then Manage API, and tap New key. Copy it right away: it starts with pk_ and is shown once. Rename it after the app that will use it.

  • A new key can only read. That is all an app that only shows things needs.
  • Switch on Can control on the key’s row if the app should change something, like a Water now button. Only give that key to apps you trust.
  • A key opens only the project it was made in. Your app also needs the Project ID, shown under the keys: press Copy ID.
2

Put the key in .env, then tell your AI tool what to build.

Never paste a key into a prompt or a chat. Put it in a file called .env next to your app’s code, and add .env to .gitignore so it never reaches git. Your AI tool’s code reads it from there.

.env
# .env — next to your app's code. Your AI tool's code reads it; you never paste it anywhere.
PALPABLE_PROJECT_ID=3f9c…e21
PALPABLE_KEY=pk_…
.gitignore
# .gitignore — so the key never reaches git
.env

Then say what you want in one sentence, and name the variables, not the key:

“Build me a page that shows my basil’s soil moisture live, with a Water now button that sets waterNow. My Palpable project id is in PALPABLE_PROJECT_ID and the key is in PALPABLE_KEY in .env. Never print or commit it.”

A page that only shows things needs a read-only key. Water now needs a key that can control, and it belongs on your app’s server, never in the page.

An app can only change what the project’s script listens for. If you want a button, ask PAL first, in the project’s chat: “Share the soil moisture as a variable called moisture, and water once whenever waterNow is set.” Then your app sets waterNow, and the script does the watering.

3

What an app can read and change.

The project’s live connection has four channels. Your app subscribes to the ones it needs and gets a snapshot straight away: the latest readings, the variables, whether the board is online and which parts are plugged in.

  • sensors: every new reading, as a module id and its value.
  • variables: the values the project’s script shares, each time they change.
  • status: the board coming online or going offline, and what is plugged in.
  • events: camera events. For a script’s own events, use webhooks (part 6).

With a key that can control, an app can also set a variable, run a part’s command (turn a relay on, light the pixels) and take a camera snapshot or watch its video. What a variable does is up to the project’s script.

A key cannot change scripts or code, change the project’s settings, or talk to PAL. Those stay in the app.

4

A minimal app.

This is all an app needs: find the connection, open it with the key, listen, and set a variable. Your AI tool writes the rest.

Connect, subscribe, set a variable
// app.mjs — run it with Node 22 or later: node --env-file=.env app.mjs
// The key stays on the server: read from .env, never sent to a browser.
const KEY = process.env.PALPABLE_KEY; // pk_…
const PROJECT = process.env.PALPABLE_PROJECT_ID; // the project's id

// 1. Ask where the project's live connection is.
const res = await fetch(`https://palpable.technology/api/projects/${PROJECT}/connect`, {
  headers: { Authorization: `Bearer ${KEY}` },
});
const found = await res.json();
if (!res.ok) throw new Error(`connect answered ${res.status}: ${found.error}`);
const { wsUrl, permissions } = found; // permissions: ['read'] or ['read', 'write']

// 2. Open it with the same key, and say what you want to hear about.
const ws = new WebSocket(`${wsUrl}?token=${encodeURIComponent(KEY)}`);
ws.onopen = () => {
  ws.send(JSON.stringify({ type: 'subscribe', channels: ['sensors', 'variables', 'status'] }));
};

// 3. A snapshot first, then every change as it happens.
ws.onmessage = (e) => {
  const msg = JSON.parse(e.data);
  if (msg.type === 'snapshot') console.log('now:', msg.sensors, msg.variables, msg.status.connected);
  if (msg.type === 'sensor_data') console.log(msg.moduleId, msg.value);
  if (msg.type === 'variable_state') console.log('variables:', msg.variables);
  if (msg.type === 'device_status') console.log('board online:', msg.connected);
  if (msg.type === 'error') console.error(msg.code, msg.message);
};

// 4. Water now: sets a variable the project's script listens for. Needs a key that can control.
export function waterNow() {
  if (!permissions.includes('write')) throw new Error('This key can only read.');
  ws.send(JSON.stringify({ type: 'set_variable', name: 'waterNow', value: true }));
}
  • Messages you send: subscribe and unsubscribe with a list of channels, set_variable with a name and a value, and ping.
  • Messages you get: snapshot, sensor_data, variable_state, device_status, and error with a code, for example FORBIDDEN when a read-only key tries to set a variable, or NO_BOARD when no board of the project is online. Nothing confirms a variable that arrived.
  • A refused key closes the connection with code 4401: no key, a wrong key, a revoked one, or one whose maker lost the project. Don’t reconnect with it.
  • Any website can ask for the connection and for saved data straight from the browser: Lovable, Vercel, a Claude artifact, a local file. Give a page a read-only key only.
5

Keep the key safe.

  • The key never goes into a prompt or a chat. It is a password to your boards’ live data. Keep it in .env or an environment variable, where your app’s code reads it.
  • A page that only shows things can hold a read-only key. Anyone who opens the page can read it, and it can only read.
  • A key with Can control on stays on your app’s server: anyone who has it can work the project’s parts and watch its camera. The page asks the server, and the server asks Palpable.
  • Make one key per app, so you can turn one off without touching the others.
  • To turn a key off, tap Revoke next to it in Manage API. Apps using it are disconnected right away.
6

Webhooks, for your own server.

To have Palpable call your server instead, add a webhook in Settings, Developer, Webhooks. Pick the events: sensor data, variable changes, script events, and devices connecting or disconnecting. Webhooks cover every project in your account.

Each one is a POST with a JSON body: the event, a timestamp and its data. Palpable makes a signing secret for it; every request then carries X-Palpable-Signature, the hex HMAC-SHA256 of the body. Check it before you trust the request.

Check a webhook’s signature
import { createHmac, timingSafeEqual } from 'node:crypto';

// rawBody: the request body exactly as it arrived, before JSON.parse.
function isFromPalpable(rawBody, signature, secret) {
  const expected = Buffer.from(createHmac('sha256', secret).update(rawBody).digest('hex'));
  const given = Buffer.from(signature ?? '');
  return given.length === expected.length && timingSafeEqual(given, expected);
}
// isFromPalpable(rawBody, req.headers['x-palpable-signature'], process.env.PALPABLE_WEBHOOK_SECRET)
7

Saved data.

The live connection shows now. A project also saves its readings, and a key can fetch them: a chart of last week, a spreadsheet, a report. The saving settings in the project decide how often a reading is kept, and for how long.

Fetch saved readings as a CSV file
# Saved readings from the last 7 days, as a CSV file. The key comes from the environment.
curl -sS -H "Authorization: Bearer $PALPABLE_KEY" \
  "https://palpable.technology/api/projects/$PALPABLE_PROJECT_ID/readings?format=csv&capability=temperature" \
  -o readings.csv
  • GET /api/projects/{projectId}/readings with the key as a bearer token, the same key the live connection takes. A key from another project is refused.
  • from and to: times like 2026-11-15T00:00:00Z. The range starts at from and ends before to. Without them you get the last 7 days.
  • capability: only these readings, for example temperature,humidity. Up to 20.
  • format: json (the default) or csv. The rows come oldest first.
  • The CSV columns are time_utc, module_id, capability, value and unit. The JSON rows carry the same five fields.
  • One answer holds at most 100,000 readings. Ask for more and you get a 413 that says so. Ask for a shorter range or fewer capabilities. Every error says what was wrong.