Create customer accounts
Create each customer's account from your own sign-up form through the API, or load your existing customers, so they can sign in to your apps.
Available, with limitsAPI
Until customers can sign themselves up on the realm’s pages, your app does it for them. Your sign-up form collects what you need, your app’s back end creates the account in your customer realm, and the customer signs in from then on through the realm. Customers you already have elsewhere are loaded the same way, passwords included.
Before you begin
Section titled “Before you begin”- Privilege:
RealmOwnerin the customer realm, held by the group of the account your back end signs in as. To give it less, make a privilege of your own; see Delegated administration. - Where: the API, from your app’s back end. Keep that account’s session on your server: never send it to a browser.
- The attributes your form collects, added to the realm’s user type first; see Attributes and validation.
How it works
Section titled “How it works”A customer is a user in your customer realm, created through the same API as any other user: a sign-in name in
uid, a profile, and a first password in passwordHash. Send the password the customer chose, in plain text over
HTTPS: the realm stores only its bcrypt hash. A value that is already a bcrypt hash ($2a$, $2b$ or $2y$) is
stored as it is, which is how customers loaded from another system keep their passwords. Every write is checked
against the realm’s rules, so a duplicate sign-in name, or a value that breaks a rule you added, is refused with every
reason at once.
Set it up
Section titled “Set it up”From your app’s back end, with its session in $CVYUH_SESSION (see Call the API), for each
customer who signs up:
curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/user?id=maya" \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \ -H "Content-Type: application/json" \ -d '{ "uid": "maya", "displayName": "Maya Chen", "email": "maya@example.com", "locale": "en-US", "passwordHash": "<the password she chose>" }'The realm answers 201, and Maya can sign in.
To bring in customers from another system, see Bring users in: bcrypt hashes carry over, so they keep their passwords.
What the customer sees
Section titled “What the customer sees”Nothing from the realm at sign-up: your form is theirs. At their first sign-in, on the realm’s pages, they sign in
with that password. While the realm requires a second step (twoFactorMandatory, on in a new realm), they’re then
walked through setting up an authenticator app, and shown their recovery codes once. Tell them so on your sign-up
form, or turn the second step off for customers who haven’t added a passkey; see
Passkey sign-in for customers.
When it fails
Section titled “When it fails”| Answer | Why | What to do |
|---|---|---|
201 | The account was made | Nothing |
409 | The id is taken | Ask the customer for another, or sign them in to their existing account |
400 | One or more rules failed, each listed | Show the customer each reason, such as a password the Password rules refuse |
401 | Your back end’s session has ended | Sign the back end in again |
403 | The back end’s account can’t create users | Grant its group the privilege it needs |
Limits and defaults
Section titled “Limits and defaults”| What | Default |
|---|---|
| Sign-in names | Matched without regard to case: maya and Maya are one customer |
| Password rules | The realm’s Password rules |
| Second step at first sign-in | Required in a new realm (twoFactorMandatory) |
A new account’s status | active; send "inactive" to prepare an account ahead |
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| A customer can’t sign in with the password they chose | It was sent already hashed by something other than bcrypt, or changed in transit | Send the plain password, or a bcrypt hash |
| A new customer is asked to set up an authenticator app | The realm requires a second step | Expected; or turn twoFactorMandatory off |
400 on an attribute your form collects | The attribute isn’t on the realm’s user type | Add it first |
| Fake accounts | Your sign-up form has no bot check | Add one to your form; see Protect customer sign-in |
Audit records
Section titled “Audit records”Each account made is a CREATED record in Change history, with the
account’s values (never the password) and the account that made it.
Good to know
Section titled “Good to know”- Confirm the email address yourself. The realm doesn’t yet verify an address before it counts. Confirm it in your own app before you write it; see What’s next for registration.
- Prepare accounts ahead. Create them with
"status": "inactive", and set themactivewhen the customer may sign in.
Related
Section titled “Related”- Add and change users: every attribute an account has.
- Passkey sign-in for customers: what customers sign in with.
- What’s next for registration: self sign-up and email verification.