Skip to content

API v2 · SDK 3

Quickstart

By the end you'll have HEIP watching one page in observe mode, and your server reading its first decision.

Set up your site

01Sign in to the dashboard.

Your HEIP account comes with dashboard access. No account yet? Book a demo.

02Create a site.

Name it and add your domains, for example shop.example.com or *.example.com. Turn on Allow localhost for local testing. You get a site key (pk_live_…).

03Create a secret key.

Copy it now: it is shown once. Put it in your server's environment as HEIP_SECRET_KEY.

04Set the site to observe mode.

In Site, then Settings. Nothing will be blocked while you test.

Integrate

05Add the browser SDK.

With a script tag, or from npm.

Script tag. This goes in your web page.
<script src="https://<sdk-host>/sdk.js" data-site-key="pk_live_…" async></script>
npm. Or initialise it from your bundle.
import { init, prepareAction } from "heip-sdk";

init({ siteKey: "pk_live_…" });

You should see a GET /v2/ping request succeed in the network tab. If it's refused, the X-HEIP-Reason response header says why, for example domain_not_allowed or invalid_site_key.

06Protect one action.

Call prepareAction when the form is submitted, and send sessionId and actionNonce with the request.

Your page. Runs when the visitor presses the button.
form.addEventListener("submit", async (e) => {
  e.preventDefault();
  const { sessionId, actionNonce } = await HEIP.prepareAction("checkout");

  await fetch("/api/checkout", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ sessionId, actionNonce, ...formData }),
  });
});

07Verify on your server.

Node.js. Runs on your server.
import { HeipServer, allow } from "heip-sdk/server";

const heip = new HeipServer({ secretKey: process.env.HEIP_SECRET_KEY });

const result = await heip.verify({ sessionId, actionNonce, action: "checkout" });
console.log(result.decision, result.mode, result.traceId);

if (!allow(result)) return res.status(403).end();
Any language. The same call over HTTPS.
curl -X POST https://<api-host>/v2/verify \
  -H "X-HEIP-SECRET-KEY: $HEIP_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sessionId":"…","actionNonce":"…","action":"checkout"}'

You should see a response with a decision and "mode": "observe".

08Read the decision in the dashboard.

Open Site, then Activity, to see the decision and its reasons. Look up a single decision by traceId within the hour.

09Choose a policy for the action.

Pass a built-in policy with policyId. Critical (strict_withdrawal) suits withdrawals and payout changes; Fast (fast_trading) suits order confirmations; Standard (marketplace_standard) suits sign-up and posting; Observe (passive_consumption_observe) never denies.

Node.js. A stricter policy for one action.
const result = await heip.verify({
  sessionId,
  actionNonce,
  action: "withdraw",
  policyId: "strict_withdrawal",
});

Observe, then enforce

10Run observe-only on real traffic.

For about a week. Review decisions and reasons in Activity.

11Switch to enforce, one action at a time.

Decide what your app does on STEP_UP: a passkey, a one-time code, a password, or a manual review.

Go-live checklist

  • Allowed domains are correct, and Allow localhost is off.
  • The secret key is only in your server's environment.
  • You've chosen what happens if HEIP can't be reached (onError; the default refuses).
  • Reasons and trace ids are logged next to your own ids.
  • You have a plan for rotating the secret key.

Was this page clear? Tell us what was missing.