/api/v1/auth/register
- Scope
- accounts
- Customer token
- none
- Limit
- 5 a minute
A login for the shop's customer, logged in at once: answers 201 with the customer and a token. When the shop already has a customer without a login whose phone and email both match (the phone in any spelling, such as 0712..., +254712... or 712..., and the email in any case), the login joins that record, keeping its name, points and orders; the name sent is then not used. Otherwise it is a new customer from the website, refused while the phone or the email belongs to someone else. A referral code that does not work is ignored and never stops the account.
Parameters
-
namestring · body · required - Up to 255 characters; HTML tags are removed.
-
emailstring · body · required - Up to 255 characters, kept in lower case.
-
phonestring · body · required - Up to 20 characters, kept as typed. It must read as a phone number, or registering answers 422 with "Enter a phone number, such as 0712 345 678."
-
passwordstring · body · required - At least 8 characters.
-
password_confirmationstring · body · required - The same password again.
-
referral_codestring · body - Another customer's referral code, up to 12 characters, in any case.
-
marketing_consentboolean · body - true records consent to marketing from sign-up; false records a refusal. Leave it out to record neither.
-
device_namestring · body - Names the token, such as Chrome on Windows; cut to 100 characters. Defaults to website.
Each refusal answers 422 with the field in errors. An email that already has a login: "An account with this email already exists. Log in, or reset your password." (email). A phone the shop holds for a customer whose email is different: "Bike Yard already has this phone number with other details. Register with the email Bike Yard has for you, or ask Bike Yard to update your record." (phone). An email the shop holds with a different phone: "Bike Yard already has this email with another phone number. Register with the phone Bike Yard has for you, or ask Bike Yard to update your record." (email). The shop's own name takes the place of Bike Yard. Show these messages as they are: they tell the person what to do.
{
"data": {
"user": {
"id": "01a16731-b30f-7197-9f60-6bdb5f10511d",
"name": "Wanjiru Kamau",
"email": "wanjiru@example.com",
"phone": "0711 000 001"
},
"token": "12|dpc_x8QmT4vLr2NpK7aZc9WbE3hJ5sGd1YfUo6RkMn0qbfa40aba"
}
}