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

# CDN snippet methods

> Reference for the four callback-based methods exported by the ShieldLabs snippet.

The CDN snippet exposes four methods for sites that do not use the npm SDK. Each returns `void` and accepts an optional initialization callback.

```js theme={null}
const agent = await import(
  'https://cdn.shieldlabs.ai/snippet.js?publicKey=PUBLIC_API_KEY'
);

agent.forceCheckAnonymous({
  onInitialized(result) {
    if (result.status === 'initialized') {
      const { requestID: identificationId } = result;
      console.log(identificationId);
    }
  },
});
```

For installation and the JavaScript-disabled beacon, see [Install the JS Snippet](https://docs.shieldlabs.ai/setup/snippet.md).

## Methods

| Signature | User context | Cooldown |
| - | - | - |
| `checkAnonymous(options?)` | Anonymous | Five-minute same-user visit window |
| `checkAuthenticatedUser(userHID, options?)` | Supplied account | Five-minute same-user visit window |
| `forceCheckAnonymous(options?)` | Anonymous | Starts immediately |
| `forceCheckAuthenticatedUser(userHID, options?)` | Supplied account | Starts immediately |

Use a force method when your application requires a fresh Identification ID for a protected action. A regular call inside the cooldown posts no identification.

## Arguments

**userHID** `string`

Required for authenticated methods. A stable hashed or pseudonymous account identifier computed on your server. See [User HID](https://docs.shieldlabs.ai/privacy.md#user-hid-you-supply-it-and-it-must-be-pseudonymous).

**options.onInitialized** `function`

Called once with initialization status. Pass it inside an options object; a bare callback function is not supported.

## Callback result

```ts theme={null}
type InitializationResult =
  | { status: 'initialized'; requestID: string }
  | { status: 'not_initialized' };
```

The initialized branch supplies the Identification ID for server-side correlation. The other branch has no Identification ID and includes skipped checks. Module import failures must be handled separately with `try`/`catch`.

## SDK method mapping

| npm SDK | CDN snippet |
| - | - |
| `identify()` without `userId` | `forceCheckAnonymous()` |
| `identify({ userId })` | `forceCheckAuthenticatedUser(userId)` |
| `check()` without `userId` | `checkAnonymous()` |
| `check({ userId })` | `checkAuthenticatedUser(userId)` |

The SDK wraps initialization in a promise, adds timeouts and validation, and exposes the Identification ID as `requestId`.


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