Request a code
Sends the user a 6-digit code by email to sign in.
Emails a 6-digit code so the end user can sign in.
If the email has no Loybox account, the account is created when verifying the code, not here.
It always answers 200
It answers 200 even if the email does not exist. That is deliberate: if it
answered differently, anyone could use this endpoint to find out which emails are
registered.
In your UI this means that after requesting the code you always show the same message ("we sent a code to your email"), with no way to know whether the account existed.
Headers
X-Commerce-IdintegerheaderrequiredId of the commerce integrating the API. Every response is scoped to this commerce.
It carries no Authorization: this is the endpoint the session starts with.
Body
emailstringrequiredThe user's email. It has to be a valid email format.
Example
curl -X POST https://loybox-public-api-752998171300.southamerica-west1.run.app/v1/auth/otp/request \
-H "X-Commerce-Id: 87" \
-H "Content-Type: application/json" \
-d '{
"email": "ana@example.com"
}'// 200 OK
{
"message": "Código enviado"
}The message comes back from the API in Spanish. It is text for the developer,
not for showing to the user (see Errors).
Rules of the code
- It expires in 10 minutes.
- It allows 5 attempts.
- Requesting a new code invalidates the previous one.
Errors
| Code | When |
|---|---|
422 | The X-Commerce-Id header is missing, or the email is invalid. |