Overview
You build the form yourself and add ready-made elements only where you need them, such as times, forms and card payment. The booking is collected step by step on a Booking Intent, then booked with intent.confirm({ customer, metadata }). Your own fields (for example a car plate or a referral code) travel as metadata and show on the appointment in the Pikit dashboard.
Everything the widget does works here too: availability, staff, locations, forms, deposits and prepayment, card on file, Affirm, gift cards, family members, client addresses, rooms and reference photos.
1. Get a publishable key
In the Pikit dashboard, go to Business Settings → Online Booking → Custom booking forms, create a publishable key (pk_live_…) and list the websites allowed to use it. The key is public by design: it sits in your page, and the API answers only to the websites on that list.
2. Quick start
Load the script from https://book.pikit.io/install/pikit.js, create an intent for a location, mount the elements you want, and confirm on submit.
<form id="booking">
<div id="location"></div>
<div id="services"></div>
<div id="staff"></div>
<div id="time"></div>
<input name="first_name" required />
<input name="last_name" required />
<input name="email" type="email" required />
<input name="car_plate" /> <!-- your own field, sent as metadata -->
<div id="terms"></div>
<div id="forms"></div>
<div id="payment"></div>
<button>Book</button>
</form>
<script src="https://book.pikit.io/install/pikit.js"></script>
<script type="module">
const pikit = Pikit("pk_live_…", { locale: "en" }); // or "fr-CA"
const business = await pikit.business();
const intent = await pikit.bookingIntents.create({
branch_id: business.branches[0].id,
});
const elements = pikit.elements({ intent });
elements.create("location").mount("#location");
elements.create("service").mount("#services");
elements.create("staff").mount("#staff");
elements.create("datetime").mount("#time");
elements.create("terms").mount("#terms");
elements.create("forms").mount("#forms");
elements.create("payment").mount("#payment");
document.querySelector("#booking").addEventListener("submit", async (event) => {
event.preventDefault();
const form = new FormData(event.target);
try {
await intent.confirm({
customer: {
first_name: form.get("first_name"),
last_name: form.get("last_name"),
email: form.get("email"),
},
metadata: { car_plate: form.get("car_plate") },
});
if (intent.status === "succeeded") showThanks(intent.booking);
} catch (error) {
showError(error.message); // error.code, e.g. a time that was just taken
}
});
</script>3. What confirm() does
confirm() takes care of whatever the booking still needs:
- Forms: when the business requires forms, they appear in the
formselement. Confirm continues once they are signed; optional forms can be skipped. - Card payment: a deposit or full prepayment is charged with the card typed in the
paymentelement. - Card on file: when the business requires a card, the card is saved and nothing is charged now.
- Affirm: when Affirm is offered, it opens in a new tab and confirm waits for the answer.
If no element handles a step, confirm() resolves with intent.status set to requires_action (forms) or requires_payment. Handle that step yourself with the calls in section 7.
Confirm is safe to repeat: a booked intent answers its booking again. If the time was just taken, the intent stays open so the client can pick another time and confirm again.
4. Elements
Each element is the same step as in the Pikit booking widget.
| Type | What it does |
|---|---|
location | Pick a location |
service | Pick one or more services, with price options ({ multiple: false } for one) |
staff | Pick a staff member, or anyone available |
datetime | Date and free times for each service |
address | Client address with suggestions, checked against the service area |
resources | Room or station, when the service lets the client choose |
family | “Who is this for?” for each service (signed-in client, when the business offers it) |
photos | Reference photos (up to 3) |
gratuity | The business’s tip buttons (a preference, paid at the visit) |
gift_card | Pay with a gift card (signed-in client) |
terms | The business’s privacy policy and terms, with the “I accept” box |
forms | Forms to sign before booking |
payment | Card, pay at the visit when allowed, saved cards, “save this card”, Affirm |
Each element has mount(selector | node), unmount() and destroy(). Elements save their choices on the intent automatically. on("change", fn) receives { elementType, value, complete, error }.
const datetime = elements.create("datetime");
datetime.mount("#time");
datetime.on("change", ({ value, complete, error }) => {
submitButton.disabled = !complete;
});5. Match your brand
Pass appearance with any of colorPrimary, colorOnPrimary, colorText, colorBackground, colorBorder, colorDanger, fontFamily and borderRadius. Every node also has a pikit-* class you can style. Set locale to en or fr-CA.
const elements = pikit.elements({
intent,
appearance: {
colorPrimary: "#e11d48",
fontFamily: "Inter, sans-serif",
borderRadius: "10px",
},
});6. Client account (optional)
intent.signIn(email, password) books as that client, verified. Their packs and stored value then apply, and they can use saved cards, gift cards and family members. A family member is added with intent.addDependent({ first_name, … }), when the business allows it.
await intent.signIn(email, password);
const cards = await intent.paymentMethods();
const members = await intent.family();
intent.signOut();7. Without elements
Build every step yourself with these calls:
| Call | What it does |
|---|---|
pikit.business() | Business details, locations, services, staff and policies |
pikit.availability.next / day / calendar(query) | Free times |
pikit.address.suggest / details | Address suggestions |
pikit.checkServiceArea(body) | Check whether an address is in the service area |
pikit.resourceChoices(query) | Rooms or stations the client may choose |
pikit.joinWaitlist(body) | Join the waitlist |
intent.update(fields) | Change any field of the booking |
intent.retrieve() | Read the booking again |
intent.cancel() | Cancel the booking |
intent.submitForm(answer) | Sign one form |
intent.addFile(file) | Add a reference photo |
intent.paymentMethods() | The signed-in client’s saved cards |
intent.giftCards() | The signed-in client’s gift cards |
intent.family() | The signed-in client’s family members |
intent.startAffirm() | Start paying with Affirm |
To reopen a booking after a page reload:
// Keep intent.id and intent.client_secret, then after a reload:
const intent = await pikit.bookingIntents.retrieve(id, clientSecret);8. Events and errors
The intent emits change, status, requires_action, requires_payment, succeeded, canceled and error.
intent.on("status", (status) => console.log(status));
intent.on("requires_action", () => showFormsStep());
intent.on("succeeded", () => showThanks(intent.booking));Every failure is a Pikit.Error with code, message, status and details, exactly as the API answers it.
try {
await intent.confirm({ customer });
} catch (error) {
// error instanceof Pikit.Error
console.log(error.code, error.status, error.details);
}9. API address
By default the script talks to the API of the site it is served from. To use another API, for example while testing, pass apiBase or set window.PIKIT_API_BASE_URL before the script loads.
const pikit = Pikit("pk_live_…", { apiBase: "http://localhost:4000/v1" });
// or, before the script loads:
window.PIKIT_API_BASE_URL = "http://localhost:4000/v1";REST API reference
pikit.js is a thin layer over this API; you can also call it directly. Base path: https://api.pikit.io/v1/public/booking. Every call needs the X-Pikit-Key header. Every call about one intent also needs its client_secret (answered once, on create): in the query for GET, in the body for POST. Answers are wrapped in { data }.
curl -X POST https://api.pikit.io/v1/public/booking/intents \
-H "X-Pikit-Key: pk_live_…" \
-H "Content-Type: application/json" \
-d '{
"branch_id": "…",
"services": [
{ "action_id": "…", "date": "2026-12-10", "day": "thursday", "start_time": 600 }
],
"metadata": { "car_plate": "ABC 123" }
}'{
"data": {
"id": "…",
"object": "booking_intent",
"client_secret": "bisec_…",
"status": "requires_details",
"missing_fields": ["customer"],
"next_action": null,
"payment_options": { "mode": "deposit", "amount_due_online": 20, "currency": "CAD" },
"metadata": { "car_plate": "ABC 123" },
"expires_at": "2026-12-03T15:00:00Z"
}
}Booking Intents
| Method | Path | What it does |
|---|---|---|
POST | /intents | Create. branch_id, services[], customer, notes, accepted_policies, metadata, payment_method, gratuity, location, resource_ids |
GET | /intents/:id | Read (?client_secret=) |
POST | /intents/:id | Update any field above |
POST | /intents/:id/confirm | Book. After a payment step, send payment_intent_id or payment_method_id |
POST | /intents/:id/cancel | Cancel |
POST | /intents/:id/forms | Sign one form from next_action.sign_forms |
POST | /intents/:id/files | Add a reference photo (multipart, max 3) |
POST | /intents/:id/sign-in | Book as a verified client (email, password) |
POST | /intents/:id/sign-out | Sign the client out |
GET | /intents/:id/payment-methods | Signed-in client’s saved cards |
GET | /intents/:id/gift-cards | Signed-in client’s gift cards |
GET | /intents/:id/family | Signed-in client’s family members |
POST | /intents/:id/family/dependents | Add a family member, when the business allows it |
POST | /intents/:id/affirm | Pay the open payment step with Affirm |
Business and availability
| Method | Path | What it does |
|---|---|---|
GET | /business | Business, locations, services, staff and policies |
GET | /availability/next | day | calendar | Free times |
GET | /resources/choices | Rooms or stations the client may choose |
POST | /service-area/check | Check an address against the service area |
GET | /address/suggest | Address suggestions |
GET | /address/details/:id | Structured address of a suggestion |
POST | /waitlist | Join the waitlist |
Metadata limits
Up to 50 keys; each key uses A–Z a–z 0–9 _ - and is at most 40 characters. Values are text up to 500 characters (numbers and true/false are stored as text). An empty value or null removes a key.
Intent statuses
| Status | Meaning |
|---|---|
requires_details | Something is still missing; see missing_fields |
requires_confirmation | Ready to book; call confirm |
requires_action | Forms to sign; see next_action.sign_forms |
requires_payment | Payment or card needed; see next_action |
processing | Booking is being made |
succeeded | Booked; booking holds the result |
canceled | Canceled by your page |
expired | Not booked within 24 hours of creation |
Error codes
Errors answer with the HTTP status and this body:
{
"code": "BOOKING_INTENT_INCOMPLETE",
"message": "…",
"details": { "missing": ["customer"] }
}| HTTP | Code | When |
|---|---|---|
401 | PUBLIC_KEY_INVALID | Missing, unknown or revoked key |
403 | PUBLIC_ORIGIN_NOT_ALLOWED | Your website is not on the key’s list |
404 | BOOKING_INTENT_NOT_FOUND | Unknown intent or wrong client_secret |
400 | BOOKING_INTENT_EXPIRED | More than 24 hours old |
409 | BOOKING_INTENT_NOT_OPEN | Already booked or canceled |
400 | BOOKING_INTENT_INCOMPLETE | Fields missing; see details.missing |
400 | BOOKING_INTENT_METADATA_INVALID | Metadata breaks the limits below |
409 | BOOKING_INTENT_IN_PROGRESS | Another confirm is running |
400 | BOOKING_INTENT_PAYMENT_FAILED | The card was declined; the card form stays open |
400 | BOOKING_INTENT_GRATUITY_INVALID | Tip is not one of the business’s buttons |
400 | VALIDATION_FAILED | A field has the wrong shape |
Booking rules from the widget (time taken, forms required, policies not accepted, address required, booking limits) answer with the same codes as the widget.