> ## 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.

# JavaScript agent

> Reference for the ShieldLabs browser agent, its methods and result types.

The JavaScript SDK loads the ShieldLabs browser agent and returns an Identification ID for each identification. Use that ID to read the result through the [Server API](https://docs.shieldlabs.ai/api/server-api.md) or match a [webhook](https://docs.shieldlabs.ai/api/webhooks.md).

```ts theme={null}
import { load } from '@shieldlabs-ai/js';

const agent = await load({ publicKey: 'PUBLIC_API_KEY' });
const { requestId: identificationId } = await agent.identify();
```

## Methods

| Method | Returns | Purpose |
| - | - | - |
| [`load(options)`](https://docs.shieldlabs.ai/api/js-load) | `Promise<ShieldLabsAgent>` | Load the agent and set defaults |
| [`agent.identify(options?)`](https://docs.shieldlabs.ai/api/js-identify) | `Promise<IdentifyResult>` | Start a fresh identification for a protected action |
| [`agent.check(options?)`](https://docs.shieldlabs.ai/api/js-check) | `Promise<IdentifyResult \| null>` | Run a background check subject to the visit cooldown |
| [`agent.identifyOnInteraction(target, options?)`](https://docs.shieldlabs.ai/api/js-interaction) | `InteractionIdentifier` | Start early and obtain the result when a form is submitted |

The [direct CDN snippet](https://docs.shieldlabs.ai/api/js-snippet.md) exposes callback-based methods. Framework SDKs wrap the same agent; see [SDKs](https://docs.shieldlabs.ai/api/sdks.md#browser-packages).

Examples use `@shieldlabs-ai/js` version 1.0.1.

## Installation and support

Start with [JavaScript Quickstart](https://docs.shieldlabs.ai/sdks/javascript.md) for account creation, installation and your first result. For deployment requirements, see [browser support](https://docs.shieldlabs.ai/browser-support.md) and [Content Security Policy](https://docs.shieldlabs.ai/setup/csp.md).

The package exports TypeScript definitions for `LoadOptions`, `IdentifyOptions`, `IdentifyResult`, `ShieldLabsAgent`, `InteractionIdentifier` and `ShieldLabsErrorCode`. Handle failures with [`ShieldLabsError`](https://docs.shieldlabs.ai/api/js-errors).


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