business_token, and your KYB search runs on exactly that business, with no typos and no wrong-business matches.
Try it in the live demo with your own API key. For how the product works, see Auto.Complete.
The SDK’s own site is shown below, with the full guide, styling options and API reference. If the frame is too small, open the SDK site in its own tab.
What’s in the package
The SDK finds a business three ways: by its name, by a person who holds a role at it, or by an address it is filed at. Whichever way, the pick is a business.
Install
The SDK is pre-release (version 0.x). Until 1.0, a breaking change bumps the minor version, so pin the minor version you test with.
How it fits together
- When the field is used, the SDK asks your backend for a session.
- Your backend creates (mints) the session with your API key (
POST /autocomplete/sessions), forwards the page’sOrigin, and returns Baselayer’s answer unchanged. - Each keystroke goes straight from the browser to Baselayer with that session. No cookies, no API key.
- Picking a row hands your form its
business_token. - Your backend sends the token with
POST /searches, so the search runs on exactly the business that was picked.
1. Add the session endpoint to your backend
Next.js (App Router), inapp/api/ac-session/route.ts:
mintForOrigin({ apiKey, origin }) from the same import, and pass its status, headers and body straight through.
Put this endpoint behind your own login, like the rest of your API. Every session it mints counts against your organization’s session pool.
2. Add the component
For styling, headless hooks and every option, see the SDK site.
3. Send the pick with your search
From your backend, send the token on its own as the body ofPOST /searches:
name or address with it. The token stands in for both.
A token lasts 15 minutes from when the row was shown, and only works for your organization. If the search refuses it (expired, or the business is gone), drop the token and search by the name and address as typed. The SDK’s refusedThePin(status, code) tells you when to do that.
Links
- Live demo: try the components with your own API key
- SDK overview and API reference
- Source on GitHub
- Auto.Complete: how the product works
- Business Search: Basics: the KYB search you run on the pick