# How it works

This page walks through an integration from start to finish. Each step says what happens, why it is needed, and who does
it, and links to the guide with the details.

## 1. Connect your salon app

You book a technical call with Beauty Router. Beauty Router then creates your salon
app and gives you access to the salon app admin area. There you generate your app tokens, and you can limit the
lifetime of each one, so you can rotate them. You also set up your origins, your
webhook URL, and your app's details for the emails to your users. Users can log in once the required settings are in
place.

Your server uses the app token to act for your salon app, so treat it as your most sensitive secret. Anyone who has it
can log in as any user of your salon app and place orders for any company in your client base that has already added
a payment card. Keep it only on your server. Never put it in browser or mobile code, and never let it leave your
security perimeter. If it leaks, revoke it right away.

See [Access and support](/support/) and [Authentication](/authentication/).

## 2. Log in your user

Whenever a user needs Beauty Router, your server makes one call, `POST /v1/login`, and gets back a user token. It
sends your app token, your own salon location ID and user ID, and the user's name and email.

That one call replaces every registration step. You do not register a company, register a user, confirm an email, or
set a password, and there is no separate flow for the first time. Beauty Router creates whatever it has not seen yet:

- The first user from a new salon location creates the company and the user.
- The next user from that location creates only the user.
- A returning user creates nothing. Their name and email are updated if they changed.

In every case your server gets a user token, so your code has one path: a user opens a screen that needs Beauty Router,
your server gets a token, and the screen works.

Unlike the app token, the user token can go to your frontend. It acts for one user only and lasts 24 hours. Your page
uses it to call the Beauty Router API and to start the JavaScript library. When it expires, your server makes the same
call again.

See [Authentication](/authentication/).

## 3. Keep products in sync

Salon software usually has no unified list of products. Each salon types in its own names, so the same shampoo has a
different name in every salon, and nothing connects it to a brand, a photo, or an order. Beauty Router gives you a ready
unified list to use in your salon app, with one ID for each product and the same catalog for every salon. It has brands,
categories, sizes, barcodes, images, and descriptions.

You first download the full product list in Beauty Router's format and load it into your salon app. After that, you
download the daily delta, which has the changes from the last 24 hours. Your list stays current with no work on your
side. You can also search the catalog over the API, so you do not need a search index of your own.

See [Catalog](/catalog/).

## 4. Match your products

Your salon app already holds products that your users typed in by hand. Product matching connects each of those
products to the unified list, so your inventory, your reorders, and the marketplace all refer to the same product.

You send your existing products to Beauty Router, and it returns a match for each one. A product with a known barcode
can match right away, and Beauty Router reviews the rest. When a product is not in the catalog yet, Beauty Router adds it
for you. When it needs more information, it sends a question for you to show your user. A webhook tells your server each
time a match changes, and a finished match has the Beauty Router product ID.

See [Product matching](/product-matching/).

## 5. Verify the company

Brands sell professional products only to licensed businesses, so Beauty Router reviews each salon before it can order.
The review covers the business type, legal company name, EIN, display name, default delivery address, business or
professional licenses, and exemption certificates.

You choose how to collect those details. The easiest way is to show Beauty Router's verification page inside your salon
app. Or you build your own screens and send the details through the API. Either way, the payment card is entered only on
Beauty Router's page.

The company can look around in the meantime, and prices and checkout open once the review lets it order. Each login
returns the company's verification status, so you know what to show the user, and a webhook tells your server when the
status changes.

See [Companies and verification](/companies/).

## 6. Show the marketplace

Your users shop in Beauty Router's interface, inside your salon app. You add the JavaScript library to your page and
give it a function that gets the user token from your server. It has functions that show the main page, the cart, the checkout, favorites, order
history, one order, order tracking, and product details. Each one takes the HTML element to render into, so you decide
where it appears and can open it from your own screens.

You write no catalog, cart, or checkout code, because Beauty Router runs all of it. In a mobile app, show the same page
in a web view.

If your salon app already has a New order page, such as a reorder screen, you can keep it and create the orders through
the API instead.

See [Embedded marketplace](/embedded-marketplace/) and [Create orders](/create-orders/).

## 7. Receive orders

When a user places an order, you hear about it in two places. A callback runs in the page, so your salon app can react
at once. Your server also receives a webhook, so it gets the order even if the user closes the page.

One checkout can create several orders, one for each brand or distributor in the cart. Beauty Router charges the card,
routes each order, and tracks the delivery. After that, webhooks send order updates, such as status and tracking, to
your server, so you can show them in your salon app. You need a webhook endpoint to receive them.

See [Orders](/orders/) and [Webhooks](/webhooks/).