Skip to content
Customer IdentityMarkdown

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.

  • Privilege: RealmOwner in 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.

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.

From your app’s back end, with its session in $CVYUH_SESSION (see Call the API), for each customer who signs up:

Terminal window
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.

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.

AnswerWhyWhat to do
201The account was madeNothing
409The id is takenAsk the customer for another, or sign them in to their existing account
400One or more rules failed, each listedShow the customer each reason, such as a password the Password rules refuse
401Your back end’s session has endedSign the back end in again
403The back end’s account can’t create usersGrant its group the privilege it needs
WhatDefault
Sign-in namesMatched without regard to case: maya and Maya are one customer
Password rulesThe realm’s Password rules
Second step at first sign-inRequired in a new realm (twoFactorMandatory)
A new account’s statusactive; send "inactive" to prepare an account ahead
SymptomCauseFix
A customer can’t sign in with the password they choseIt was sent already hashed by something other than bcrypt, or changed in transitSend the plain password, or a bcrypt hash
A new customer is asked to set up an authenticator appThe realm requires a second stepExpected; or turn twoFactorMandatory off
400 on an attribute your form collectsThe attribute isn’t on the realm’s user typeAdd it first
Fake accountsYour sign-up form has no bot checkAdd one to your form; see Protect customer sign-in

Each account made is a CREATED record in Change history, with the account’s values (never the password) and the account that made it.

  • 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 them active when the customer may sign in.