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.

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

var yorlet = new Yorlet("YOUR_PUBLISHABLE_KEY");

Create an enquiry

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

yorlet.enquiries.create(
  {
    email: "[email protected]",
    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.

yorlet.enquiries.create(
  {
    email: "[email protected]",
    name: "Jane Doe",
  },
  {
    idempotencyKey: "Lp89oaErl0aZxofpq",
  },
  function (result) {
    // Handle result.error
  }
);