Public API v1 • SDK

SDK Templates

Copy/paste blueprints for real integrations — plus a mini generator to get you started fast.

Overview

These templates follow one rule: API keys never touch browsers. Your UI calls your server, then your server calls Confera.

If you want step-by-step recipes, also see Use Cases.

Snippet generator

Pick a template and paste it into your project.

Tip: set CONFERA_BASE_URL and CONFERA_API_KEY on the server.

Next.js Route Handler: /api/kiosk/checkin
ts
import { NextResponse } from "next/server";
import { createConferaPublicClient, isConferaApiError } from "@confera/sdk";

const confera = createConferaPublicClient({
  baseUrl: process.env.CONFERA_BASE_URL!,
  apiKey: process.env.CONFERA_API_KEY!,
  timeoutMs: 8000,
  userAgent: "kiosk/1.0",
});

export async function POST(req: Request) {
  const body = (await req.json()) as { qr?: string; location?: string };
  if (!body.qr || !body.location) {
    return NextResponse.json({ ok: false, error: "Missing qr or location" }, { status: 400 });
  }

  try {
    const res = await confera.badges.checkin({ qr: body.qr, location: body.location });
    return NextResponse.json({ ok: true, data: res.data });
  } catch (e) {
    // Idempotent UX: duplicate scans should still show “checked in”.
    if (isConferaApiError(e) && e.status === 409) return NextResponse.json({ ok: true, duplicate: true });
    if (isConferaApiError(e)) {
      return NextResponse.json({ ok: false, status: e.status, code: e.code, message: e.message }, { status: 502 });
    }
    return NextResponse.json({ ok: false, message: "Unexpected error" }, { status: 500 });
  }
}

Next.js templates

Best for modern web stacks. Use Route Handlers as your “proxy” layer.

Express templates

Best for kiosks, internal tools, and simple deployments.

Install
bash
pnpm add @confera/sdk express
pnpm add -D @types/express

Kiosk (badge check-in)

Full walkthrough: Check-in Kiosk use case.

Gate (attendance)

Full walkthrough: Attendance Gate use case.

Registration form

Full walkthrough: External Registration Form use case.

Production

Ship safely: Production hardening.