# Create a website when a client signs up (/docs/embed/create-website)

Every client gets **one website**. Create it in your sign-up code, right after you create the client's company in your own database, with your master key (`HL_MASTER_KEY`, sent as `?privateKey=`).

## 1. Create the website [#1-create-the-website]

`POST /admin/websites` with the client's name and domain. The domain may be empty: the install screen asks the client for it. The answer is the new website's id.

<ApiPlayground method="post" path="/admin/websites" tool="" args={`{ "name": "Acme Ltd", "domain": "acme.example" }`} />

## 2. Save the websiteId on your client [#2-save-the-websiteid-on-your-client]

<Callout type="warn" title="Do this before any other call">
Store the `websiteId` on your own customer record (for example `company.happierleadsWebsiteId`). It is the only link between your client and their website: credits, trial, paid, cancel and every screen you open later need it. Lose it and that client cannot open their screens.
</Callout>

```js
// after POST /admin/websites, before anything else
await db.companies.update(company.id, { happierleadsWebsiteId: websiteId });
```

## 3. Then give it credits [#3-then-give-it-credits]

In the same sign-up request, right after saving the id: [start a trial](./start-trial), or [switch it to paid](./switch-to-paid) if the client paid at sign-up.

## If our API is down at sign-up [#if-our-api-is-down-at-sign-up]

Let the sign-up succeed anyway: flag the company (for example `happierleadsPending`) and retry from a background job. Never create a second website for a company that already has a `websiteId`.

**Next:** [open a screen: the one-time link](/docs/embed/open-a-screen).
