Customer Portal API
Integrate passwordless customer accounts, saved addresses, communication preferences, and self-serve order editing in headless storefronts.
Every devhelp shop store includes a store-scoped Customer Portal (/storefront/v1/account/*) that works identically on hosted *.devhelp.store storefronts, custom domains, and headless @devhelp/shop apps.
Isolation & authentication model
- Per-store isolation: Customer accounts are strictly isolated per store. The same email or phone at Store A and Store B has separate customer records and separate sessions.
- Passwordless 6-digit Email OTP: Shoppers sign in with a 6-digit one-time code sent by email (10-minute TTL, max 5 attempts, 60-second resend cooldown).
requestOtpnever reveals whether an account exists. - Guest checkout stays default: Shoppers never need an account to buy. Signed-in shoppers automatically get checkout prefill and saved-address selection.
Session transport for headless storefronts
Every authenticated Customer Portal endpoint requires:
- Your store's Publishable key (
x-api-key: dh_pk_live_…) - The customer's opaque session token in
x-dh-customer-token
For custom-domain Next.js storefronts, store the opaque token in a first-party, host-only HttpOnly; Secure; SameSite=Lax; Path=/ cookie (__Host-dh_c in production HTTPS; no Domain attribute) and forward it as x-dh-customer-token from Server Actions / Route Handlers. Never read customer cookies during edge-cached public SSR renders.
Typical sign-in flow
// 1. Request a 6-digit Email OTP
await fetch("https://api.devhelp.pk/storefront/v1/account/auth/otp/request", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_DEVHELP_PUBLISHABLE_KEY!,
},
body: JSON.stringify({ channel: "email", identifier: "buyer@example.com" }),
});
// 2. Verify the code and receive { token, expiresAt, customer }
const res = await fetch(
"https://api.devhelp.pk/storefront/v1/account/auth/otp/verify",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.NEXT_PUBLIC_DEVHELP_PUBLISHABLE_KEY!,
},
body: JSON.stringify({
channel: "email",
identifier: "buyer@example.com",
code: "123456",
}),
},
);
const { token, customer } = await res.json();Available capabilities
Check GET /storefront/v1/account/session to inspect which capabilities are enabled for the store's portal settings and plan:
- Profile & sessions: View/update name, verify a new email or phone via OTP (
verify_contact), list active devices, and sign out (logout/logout-all). - Saved addresses: Create, update, delete, and set default international/Pakistani addresses used to prefill checkout.
- Communication preferences: Manage opt-in/opt-out for
email,whatsapp, andsmsmarketing, plus review requests and back-in-stock alerts (always allowed even if the portal is later disabled). - Orders, bookings & self-serve editing: View historical and active orders, tracking, invoices, and bookings; confirm pending COD orders; reorder; and (when enabled by the store on Growth/Scale) edit delivery details, cancel before cutoff, swap same-price variants, or edit items on unconfirmed COD orders.
Explore all 32 endpoints under Storefront — Customer Portal in the API Reference.