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

# Yorlet.js SDK

> Set up the Yorlet.js client-side SDK in your web application.

Yorlet’s browser-side JavaScript library can be used for creating enquiries.

## Including Yorlet.js

Include the Yorlet.js script on each page of your site. It should always be loaded directly from `https://js.yorlet.com`, rather than included in a bundle or hosted yourself.

```html theme={"theme":"dracula"}
<script src="https://js.yorlet.com/v2/yorlet.js"></script>
```

## Initialising Yorlet.js

Use `new Yorlet()` to create an instance of the Yorlet.js SDK. Your Yorlet publishable API key is required when initialising.

```js theme={"theme":"dracula"}
var yorlet = new Yorlet("YOUR_PUBLISHABLE_KEY");
```

## Create an enquiry

To create an enquiry via the API, create an Enquiry object.

```js theme={"theme":"dracula"}
yorlet.enquiries.create(
  {
    email: "jane@example.com",
    name: "Jane Doe",
  },
  function (result) {
    // Handle result.error
  }
);
```

### Ensure only one enquiry is created

We recommend including a idempotency key to ensure only one enquiry record is created.

```js theme={"theme":"dracula"}
yorlet.enquiries.create(
  {
    email: "jane@example.com",
    name: "Jane Doe",
  },
  {
    idempotencyKey: "Lp89oaErl0aZxofpq",
  },
  function (result) {
    // Handle result.error
  }
);
```
