Developer API reference

Reference the main SDK methods, HTML attributes, FlowHandle events, and protected API authentication model.

This page summarizes the public developer surface. Use the task guides for full examples.

Endpoint reference

These are the API calls most implementation work starts with. Each endpoint keeps its request and response example attached to the right rail, so the code beside the page changes with the call you are reading.

Endpoint

Check identity

Returns the authenticated user and current organization for protected API work.

GET /api/users/me
Base URL
https://api.plandalf.com
Authentication
Bearer token
Operation ID
getCurrentUser
Request URL
https://api.plandalf.com/api/users/me

Headers

headerAuthorizationstringrequired

Send Bearer <token> from your server or trusted integration runtime.

headerAcceptstringdefault: application/json

Ask the route to return JSON.

Identity request

Request
curl "https://api.plandalf.com/api/users/me" \
  -H "Authorization: Bearer $PLANDALF_API_KEY" \
  -H "Accept: application/json"
const response = await fetch("https://api.plandalf.com/api/users/me", {
  headers: {
    Authorization: `Bearer ${process.env.PLANDALF_API_KEY}`,
    Accept: "application/json"
  }
});

const identity = await response.json();

Identity response

Response
{
  "id": "usr_123",
  "email": "founder@example.com",
  "current_organization": {
    "id": "org_123",
    "name": "Example Studio",
    "timezone": "Australia/Sydney"
  }
}

Endpoint

Load checkout

Initializes checkout data for a published offer. Use it when a custom surface needs the offer, theme, pages, and first page before creating a session.

GET /api/checkout
Base URL
https://api.plandalf.com
Authentication
Public offer route
Operation ID
initializeCheckout
Request URL
https://api.plandalf.com/api/checkout

Query parameters

queryofferstringrequired

Published offer slug, Sqid route key, or UUID. The route also accepts offer_id for compatibility.

Load offer checkout

Request
curl "https://api.plandalf.com/api/checkout?offer=pro-plan" \
  -H "Accept: application/json"
const response = await fetch(
  "https://api.plandalf.com/api/checkout?offer=pro-plan",
  { headers: { Accept: "application/json" } }
);

const checkout = await response.json();

Checkout initialization response

Response
{
  "offer": {
    "id": "off_123",
    "slug": "pro-plan",
    "name": "Pro plan"
  },
  "theme": {
    "primary_color": "#007d96"
  },
  "pages": [],
  "firstPage": null
}

Endpoint

Create checkout session

Creates a checkout session for a published offer. The SDK path defers invoice creation until the buyer starts a real checkout interaction.

POST /api/checkout/sessions
Base URL
https://api.plandalf.com
Authentication
Public offer route
Operation ID
createCheckoutSession
Request URL
https://api.plandalf.com/api/checkout/sessions

Request body

bodyofferstringrequired

Published offer slug, Sqid route key, or UUID. The route also accepts offer_id.

bodycustomerobject

Optional customer fields or signed identity passed by your integration.

bodymetadataobject

Optional implementation metadata, such as source page, campaign, or account ID.

Create a session

Request
curl -X POST "https://api.plandalf.com/api/checkout/sessions" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "offer": "pro-plan",
    "metadata": {
      "source": "pricing-page"
    }
  }'
const response = await fetch("https://api.plandalf.com/api/checkout/sessions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Accept: "application/json"
  },
  body: JSON.stringify({
    offer: "pro-plan",
    metadata: { source: "pricing-page" }
  })
});

const checkout = await response.json();

Session response

Response
{
  "session": {
    "id": "cs_123",
    "status": "open",
    "currency": "USD",
    "total": 2900
  },
  "offer": {
    "id": "off_123",
    "slug": "pro-plan",
    "name": "Pro plan"
  }
}

SDK surface

Most-used SDK calls

These are the calls most implementations use on a public website or logged-in app.

Browser SDK methods

MethodSignaturePurpose
presentplandalf.present(offer, opts?)Open an offer in a frame and return a FlowHandle.
mountplandalf.mount(target, offer, opts?)Render an offer inline and return a FlowHandle.
identifyplandalf.identify(jwtOrEmail)Set customer identity globally.
resetplandalf.reset()Clear customer identity while preserving anonymous device ID.
readyplandalf.ready(callback)Run code after the SDK loads.
fromplandalf.from(element)Get the current handle for a declarative element.
promoplandalf.promo(slug)Open an awaitable promo handle for state, tier changes, and countdown widgets.
addGateplandalf.addGate(name, offer, check)Register a local access gate.
gateplandalf.gate(name)Evaluate a registered gate.

HTML attributes

AttributePurpose
data-plandalf-presentOpen an offer when the element is clicked.
data-plandalf-mountMount an offer inline.
data-plandalf-promoRender a promo or countdown widget.
data-plandalf-apply-promoApply promo context to an offer trigger or mount.
data-plandalf-frameChoose frame modality.
data-plandalf-sizeChoose checkout frame size.
data-plandalf-modeChoose test, live, or preview.

FlowHandle

// Every checkout opener returns a promise-like handle.
interface FlowHandle<T> extends Promise<T> {
  // Stream lifecycle events while the checkout frame is open.
  events: AsyncIterable<FlowHandleEvent>;
  // Close the modal, slideout, bottom sheet, or embedded frame.
  close(): void;
}

Events:

  • start
  • purchase
  • complete
  • cancel

Choosing the right call

Protected API authentication

Protected API routes accept a bearer token. Use an API key for server-to-server automation or an OAuth bearer token for app integrations.

Authorization: Bearer <token>

Call the checkout API from the browser

HTML

The public browser SDK supports declarative markup, direct JavaScript, and framework components without changing the published offer.

Use attributes when a page builder or static template owns the markup.

<button data-plandalf-present="pro-plan" data-plandalf-frame="modal">
Buy Pro
</button>

Feature detail