Add a client
When a client signs up on your site: create their website, then invite them to sign in on your domain.
When a client signs up on your marketing site, your server creates their website, saves its id, starts their trial and invites them.
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
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.
/admin/websitescurl -X POST "https://rest-admin.happierleads.com/admin/websites?privateKey=YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Acme Ltd", "domain": "acme.example"}'2. Save the websiteId on your client
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.
// after POST /admin/websites, before anything else
await db.companies.update(company.id, { happierleadsWebsiteId: websiteId });3. Then give it credits
In the same sign-up request, right after saving the id: start a trial, or switch it to paid if the client paid 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.
Invite the client
Last, invite them with the Client role on their own website. They get an invite email from your sender address and sign in at reveal.youragency.example.
POST /admin/invite with preset: "client" and their website.
/admin/invitecurl -X POST "https://rest-admin.happierleads.com/admin/invite?privateKey=YOUR_KEY" \ -H "Content-Type: application/json" \ -d '{ "invites": [ { "email": "jo@client.example", "firstName": "Jo", "preset": "client", "websites": [ "64b7f0a1c2d3e4f5a6b7c8d9" ] } ]}'The Client role sees their own website only: no buying, no team, no account or billing pages. Need a different role for someone (for example your own account managers)? See Team.
await hl('POST', '/admin/invite', {
invites: [{ email: user.email, firstName: user.firstName, preset: 'client', websites: [websiteId] }],
});Next: start their trial.