> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voicemark.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Enrol a voice and verify it in under 5 minutes.

## Install the SDK

```bash theme={null}
npm install @defchat-ltd/voicemark-sdk
```

> [!NOTE]
>
> The SDK is published to GitHub Packages. Add this to your `.npmrc` before installing:
>
> ```
> @defchat-ltd:registry=https://npm.pkg.github.com
> //npm.pkg.github.com/:_authToken=${GH_TOKEN}
> ```
>
> `GH_TOKEN` must have `read:packages` scope. See [SDK installation](https://docs.voicemark.dev/sdk/installation) for details.

## Enrol a voice

```typescript theme={null}
import { VoiceMark } from "@defchat-ltd/voicemark-sdk";

const vm = new VoiceMark({ apiKey: process.env.VOICEMARK_API_KEY });

// Record audio (browser)
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
const recorder = new MediaRecorder(stream);
const chunks: BlobPart[] = [];
recorder.ondataavailable = e => chunks.push(e.data);
recorder.onstop = async () => {
  const blob = new Blob(chunks, { type: "audio/webm" });
  const enroll = await vm.enroll(blob, userId);

  console.log(enroll.voiceprint_id);  // store this
  console.log(enroll.quality_score);  // 0–1; re-record if below 0.4
  // enroll.glyph_params → render Glyph VoiceMark immediately
};
recorder.start();
setTimeout(() => recorder.stop(), 5000);
```

## Verify (challenge + record + verify)

```typescript theme={null}
// 1. Get a challenge phrase
const { phrase, challenge_id } = await vm.challenge();
showToUser(phrase); // "Wild roses grew beside the wooden fence."

// 2. Record the user speaking the phrase (same approach as above)
// ...

// 3. Verify
const verify = await vm.verify(blob, {
  voiceprintId: storedVoiceprintId,
  challengeId: challenge_id,
});

if (!verify.authorized) {
  throw new Error("Voice not recognised");
}

// 4. Use the token on your backend
await fetch("/api/secure-action", {
  headers: { "X-VoiceMark-Token": verify.token },
});
```

## Validate on your backend

```typescript theme={null}
// Your Express/Fastify/Next.js route handler
const check = await vm.token(tokenId, tokenJwt);
if (!check.valid) return res.status(401).json({ error: "Token expired" });
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.