Skip to content

Code examples

Working requests in Shell, JavaScript and Python: list with a filter, create, update with an ETag, run a function, and page through results.

Last updated September 17, 2026

On this page

Replace <your app address> with the address on your API tab and pxa_sk_... with a secret key. Keep secret keys on a server.

List open orders

Shell
curl -G https://<your app address>/api/entities/Order \
  -H "X-Api-Key: pxa_sk_..." \
  --data-urlencode 'q={"status":"open"}' --data-urlencode 'sort_by=-created_date'

Create a record, safely retried

Shell
curl -X POST https://<your app address>/api/entities/Lead \
  -H "X-Api-Key: pxa_sk_..." -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6d1c0c2e-3b6a-4f7e-9a2b-0c1d2e3f4a5b" \
  -d '{"name": "Dana Patel", "email": "[email protected]", "source": "website"}'

Update only if unchanged

JavaScript
const one = await fetch(`${base}/entities/Order/${id}`, { headers });
const etag = one.headers.get("ETag");

const upd = await fetch(`${base}/entities/Order/${id}`, {
  method: "PATCH",
  headers: { ...headers, "Content-Type": "application/json", "If-Match": etag },
  body: JSON.stringify({ status: "shipped" }),
});
if (upd.status === 412) { /* someone changed it first: read again and decide */ }

Page through everything

Python
cursor = None
while True:
    params = {"limit": 500}
    if cursor:
        params["cursor"] = cursor
    r = requests.get(f"{BASE}/entities/Booking", params=params, headers=HEADERS)
    r.raise_for_status()
    for row in r.json():
        handle(row)
    cursor = r.headers.get("X-Next-Cursor")
    if not cursor:
        break

Run a function

JavaScript
const run = await fetch(`${base}/functions/send_reminders`, {
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify({ before: "2026-06-13" }),
});
const { ok, result, run_id } = await run.json();

Handle rate limits

Python
import time

def call(method, url, **kw):
    for attempt in range(5):
        r = requests.request(method, url, headers=HEADERS, **kw)
        if r.status_code != 429:
            return r
        time.sleep(int(r.headers.get("Retry-After", "2")))
    return r
Was this page helpful?