Skip to content
instantscan.io docs

Quickstart

Go from nothing to a scanned PDF arriving in your form, and then to a verified webhook on your server. About ten minutes, on the 250 signup credits.

This walks the whole loop: a session, a scan, and the result in two places. Everything here uses a test key, which costs the same one credit as a live session. Signup grants 250 credits, so you can finish this before buying a pack.

1. Create a key

Create an account in the console. You start with 250 credits and a three-step guide on the Overview screen, which follows along as you work through this page. Its first step creates your key:

  • Publishable — pk_test_…. Safe in your HTML. Can only open sessions. This is the one you need for the embed.
  • Secret — sk_test_…. Server only, for opening sessions from your backend. Shown once at creation, stored as a hash afterwards. You do not need one for this guide.

Signup creates no keys of its own: a key is shown in full only when it is created, so it is created when you ask for it.

If you are running the stack locally, apps/api seeds a demo tenant with fixed keys so every sample below works without you copying anything:

# Seeded on first boot of apps/api (SEED_DEMO=1, the default).
# Console login:  demo@usecollect.com / scanner-demo
PUBLISHABLE_KEY=pk_test_demo
SECRET_KEY=sk_test_demo

2. Nothing to configure yet

While your list of allowed domains is empty, a test key works from any website: localhost, a preview deploy, staging. So you can embed first and lock things down later.

A live key never works from an empty list. Before you go live you allow your production domain under Domains, and that first entry locks test keys to the list too. The console suggests the origins your keys were actually used from, so locking is one click. See Going live.

3. Turn a file input into a scanner

The fastest possible integration: one script tag, one attribute. No application code.

<form method="post" action="/applications">
  <label for="proof">Proof of address</label>
  <input id="proof" type="file" name="proof_of_address" data-scanner />
  <button type="submit">Submit</button>
</form>

<script src="https://instantscan.io/v1/scanner.js" data-key="pk_test_demo"></script>

The launcher hides the real input, renders a “Scan a document” box in its place, and when the scan finishes it writes the PDF into that input as a real File and fires a change event. Your form submits exactly as it did before — the server receives a multipart file upload and cannot tell the difference.

Open the page on a phone (or a laptop with a webcam), tap the box, and scan something.

When the session opens, the guide in the console ticks the step off by itself.

Nothing happened when I tapped the box. Check the browser console. The common causes are a live key on a page whose origin is not allowed (403 origin_not_allowed), a test key on a page outside a list you have already started, and, on a local stack, a data-api pointing at an API that is not running. All surface as a Session create failed error from the SDK.

4. Or call it yourself

If your input is controlled by a framework, or the scan is not attached to a form at all, use the programmatic API. open() resolves with a File.

import { Scanner } from "@scanner-cloud/embed-sdk";

const scanner = Scanner.init({
  publicKey: "pk_test_demo",
  apiBase: "https://api.instantscan.io",
});

document.querySelector("#scan").addEventListener("click", async () => {
  try {
    const { file, pageCount, url } = await scanner.open({
      metadata: { application_id: "app_1042" },
    });
    console.log(`${pageCount} page(s), ${file.size} bytes`);
    // `url` is a signed, short-lived download URL for the same PDF.
  } catch (err) {
    if (err.code !== "cancelled") throw err;
  }
});

metadata is opaque to us. Whatever you put there comes back verbatim in the session, the webhook and your analytics — it is how you tie a scan back to a row in your own database.

5. Optional: receive the result on your server

With a file input you can stop here: the PDF travels with your form. A webhook is for when your server should hear about every scan on its own: sessions you open from your backend, a QR flow with no browser on your side, or documents you process in the background.

In the console, open Webhooks and save your endpoint. The signing secret is created on that first save and shown once, so copy it then. Verify every delivery:

import { createHmac, timingSafeEqual } from "node:crypto";

const SECRET = process.env.SCANNER_WEBHOOK_SECRET!; // whsec_…

app.post("/webhooks/scanner", express.raw({ type: "*/*" }), (req, res) => {
  // Verify against the raw bytes. A re-serialised body will not match.
  if (!verify(req.body.toString("utf8"), req.get("X-Scanner-Signature") ?? "", SECRET)) {
    return res.sendStatus(400);
  }

  const event = JSON.parse(req.body.toString("utf8"));
  if (event.type === "scan.completed") {
    // event.result.url is signed and short-lived — fetch it now, store the bytes.
    void download(event.result.url, event.metadata.application_id);
  }

  // Answer 2xx quickly; we retry anything else with backoff.
  res.sendStatus(204);
});

The verify helper is eight lines and is written out in full in Webhooks.

Use Send test event in the console to get a test.ping delivery without scanning anything, then read the delivery log to see the exact request we sent and the response you returned.

6. Check it in the console

Once your first session arrives, the Overview screen swaps the guide’s first steps for your numbers: sessions, completion rate, pages and credits over the last 30 days, with a status breakdown that tells you whether users are finishing or abandoning. The guide stays on top, shrunk to the one step left: going live.

Your scan appears in analytics immediately, tagged test, and as a -1 row in the credit ledger.

Where to go next

  • Embed SDK — every option on the launcher.
  • Customization — language, colours, watermark, success screen, capture limits.
  • QR hand-off — desktop users with no camera.
  • Going live — the checklist before you switch to live keys.