Phone-OTP authentication, token lifecycle, and the authenticated user's profile.
Paths are relative to the /api/v1 prefix.
See Common errors. The OTP endpoints are rate-limited in production.
| Method | URI | Auth | Description |
|---|---|---|---|
POST |
/auth/otp/request |
No | Send a one-time login code by SMS |
POST |
/auth/otp/verify |
No | Verify the code; logs in or signs up, returns a token |
GET |
/me |
Yes | Get the authenticated user's profile |
PATCH |
/me |
Yes | Complete/update name & email after onboarding |
POST |
/auth/refresh |
Yes | Rotate the current token |
POST |
/auth/logout |
Yes | Revoke the current token |
POST |
/me/deletion/otp |
Yes | Send the code that confirms closing the account |
DELETE |
/me |
Yes | Close the account (soft delete) |
GET |
/auth/dev-lookup |
No · dev-only | Look up a user id by phone |
POST |
/auth/dev-token |
No · dev-only | Mint a token for an existing user |
dev-lookup and dev-token return 404 in production.
Sends a numeric code to the phone. Outside production the response includes the
generated code to make testing easy.
Rate limit (production): 3 requests / 10 minutes per phone, with a ceiling of 30 / 10 minutes per address.
Phones the platform configures as test accounts are the exception: the response is
{ "sent": true, "mocked": false } and never carries code, in any environment.
Request body
| Field | Type | Required | Rules |
|---|---|---|---|
phone |
string | yes | E.164-ish, ^\+\d{10,15}$ (e.g. +584241000001) |
Response 200
{ "sent": true, "mocked": true, "code": "123456" }
codeis present only outside production. In production the field is omitted.
Errors
| Status | Body | When |
|---|---|---|
429 |
{ "error": "TooManyRequests", "message": "…", "retryAfterSeconds": 240 } |
Over the rate limit for the phone or the address. Carries a Retry-After header |
429 |
{ "error": "TooManyOtpRequests", "message": "…", "retryAfterSeconds": 240 } |
Over the resend quota for the phone. Carries a Retry-After header |
503 |
{ "error": "SmsSendError", "message": "No se pudo enviar el código SMS. Intentá de nuevo." } |
The SMS carrier refused the message or did not answer |
Verifies the code and authenticates. Creates the account if none exists for the phone.
A phone maps to a single role: verifying with an app that differs from the phone's
existing role is rejected.
Rate limit (production): 5 requests / 10 minutes per phone, with a ceiling of 50 / 10 minutes per address.
For a phone configured as a test account only the fixed code the platform sets for it
is accepted; any other code returns 401. That code neither expires nor is consumed,
so it can be verified repeatedly without calling /auth/otp/request again. It is
valid for login only: DELETE /me still requires a code from POST /me/deletion/otp.
Request body
| Field | Type | Required | Rules |
|---|---|---|---|
phone |
string | yes | ^\+\d{10,15}$ |
code |
string | yes | exactly 6 digits |
app |
string | no | client (default) or driver |
Response 200
{
"token": "12|abc...",
"isNew": false,
"needsUserData": false,
"user": {
"id": 1,
"name": "Ana MartĂnez",
"phone": "+584241000001",
"hasClientProfile": true,
"hasDriverProfile": false,
"isDriverPending": false
}
}
Field notes:
isNew — true when the user was just created.needsUserData — true when the profile still has a placeholder name and the
client must collect name/email before continuing. While true, user.name is
omitted (use user.phone for any provisional greeting).needsKyc — present only when app=driver; true until the driver starts KYC.Errors
| Status | Body | When |
|---|---|---|
401 |
{ "error": "InvalidOtp", "message": "CĂłdigo incorrecto o vencido." } |
Wrong or expired code |
409 |
{ "error": "RoleConflict", "message": "Este número ya está registrado con otro rol." } |
app=driver for a phone already registered as client, or app=client for a phone already registered as driver |
Returns the authenticated user with their profile aggregates.
Response 200
{
"user": {
"id": 1,
"name": "Ana MartĂnez",
"phone": "+584241000001",
"isActive": true,
"clientProfile": {
"totalOrders": 12,
"totalLitersOrdered": 36000,
"totalSolidaryUSD": 4.2
},
"driver": null
}
}
For a driver the driver block is populated and clientProfile is null:
{
"user": {
"id": 3,
"name": "Carlos RodrĂguez",
"phone": "+584241001001",
"isActive": true,
"clientProfile": null,
"driver": {
"id": 3,
"status": "ACTIVE",
"isOnline": true,
"availableLiters": 8000,
"remainingLiters": 6000,
"avgRating": 4.8,
"completedOrders": 27,
"isCertified": true
}
}
}
clientProfile and driver are null when the user lacks that profile. When
present, the driver block carries:
| Field | Type | Description |
|---|---|---|
id |
integer | Driver profile id |
status |
string | ACTIVE, PENDING_VERIFICATION, SUSPENDED, … |
isOnline |
boolean | Whether the driver is currently online |
availableLiters |
integer | Water physically in the tank right now |
remainingLiters |
integer | Liters still free to commit, after active orders and live surplus listings |
avgRating |
number | Rolling average rating (0–5) |
completedOrders |
integer | Lifetime delivered orders |
isCertified |
boolean | Whether the driver is certified |
availableLiters vs remainingLiters:
availableLiters — water physically in the tank right now.remainingLiters — free capacity still available to commit, once the liters of the
driver's active orders and published surplus listings are taken out.Completes or updates the user's name and email (typically right after OTP sign-up).
Request body
| Field | Type | Required | Rules |
|---|---|---|---|
name |
string | yes | 2–80 chars |
email |
string | no | valid email, ≤120 chars, unique among users |
Response 200 — the updated user (same shape as user in otp/verify).
Revokes the current token and issues a new one.
Response 200
{ "token": "13|def..." }
Revokes the current token.
Response 200
{ "ok": true }
Sends a 6-digit code by SMS to the authenticated account's own phone. The code is
valid for 5 minutes and is accepted only by DELETE /me; a code from
/auth/otp/request is not. Outside production the response includes the
generated code.
Rate limit (production): 3 requests / 10 minutes.
No request body.
Response 200
{ "sent": true, "mocked": true, "code": "123456" }
codeis present only outside production.
Errors
| Status | Body | When |
|---|---|---|
409 |
{ "error": "ActiveOrders", "message": "…" } |
The user is the client of an order in BROADCASTING, COUNTER_OFFERED, WAITING_FOR_PAYMENT, CONFIRMED, IN_PROGRESS or ARRIVED, or the assigned driver of one in WAITING_FOR_PAYMENT, CONFIRMED, IN_PROGRESS or ARRIVED |
409 |
{ "error": "OutstandingCashDebt", "message": "…", "outstanding_usd": 30 } |
The driver's wallet still owes cash |
409 |
{ "error": "PendingBalance", "message": "…", "pending_usd": 12.5 } |
The wallet holds a balance or an in-flight payout, or the client profile holds promotional credit |
429 |
{ "error": "TooManyRequests", "message": "…", "retryAfterSeconds": 240 } |
Over the rate limit. Carries a Retry-After header |
429 |
{ "error": "TooManyOtpRequests", "message": "…", "retryAfterSeconds": 240 } |
Over the resend quota for the phone. Carries a Retry-After header |
503 |
{ "error": "SmsSendError", "message": "No se pudo enviar el código SMS. Intentá de nuevo." } |
The SMS carrier refused the message or did not answer |
Closes the authenticated account. The user row is soft-deleted; phone, email
and name are anonymized, so the phone number can sign up again as a new
account. Every token and device token of the account is revoked.
Request body
| Field | Type | Required | Rules |
|---|---|---|---|
code |
string | yes | exactly 6 digits, from POST /me/deletion/otp |
reason |
string | no | nullable, ≤500 chars |
Response 200
{ "deleted": true }
Errors
| Status | Body | When |
|---|---|---|
401 |
{ "error": "InvalidOtp", "message": "CĂłdigo incorrecto o vencido." } |
Wrong, expired or already-used code, or a code issued by /auth/otp/request |
409 |
{ "error": "ActiveOrders", … } |
Same triggers as POST /me/deletion/otp |
409 |
{ "error": "OutstandingCashDebt", … } |
Same triggers as POST /me/deletion/otp |
409 |
{ "error": "PendingBalance", … } |
Same triggers as POST /me/deletion/otp |
Available outside production only (otherwise 404).
Query: phone (string, required).
Response 200
{ "userId": 7, "name": "Carlos RodrĂguez", "hasClientProfile": false, "hasDriverProfile": true }
| Status | Body | When |
|---|---|---|
400 |
{ "error": "MissingPhone" } |
phone not provided |
404 |
{ "error": "UserNotFound" } |
No user for that phone |
Request body
| Field | Type | Required | Rules |
|---|---|---|---|
userId |
integer | yes | existing user id |
app |
string | yes | client or driver |
Response 200
{ "token": "14|ghi...", "user": { "id": 7, "name": "Carlos RodrĂguez", "hasClientProfile": false, "hasDriverProfile": true, "isDriverPending": false } }
| Status | Body | When |
|---|---|---|
404 |
{ "error": "UserNotFound" } |
No user for userId |
400 |
{ "error": "NoClientProfile" } |
app=client but the user has no client profile |
400 |
{ "error": "NoDriverProfile" } |
app=driver but the user has no driver profile |
# 1) Request a code (dev returns it inline)
curl -X POST /api/v1/auth/otp/request \
-H "Content-Type: application/json" \
-d '{"phone": "+584241000001"}'
# 2) Verify + log in
curl -X POST /api/v1/auth/otp/verify \
-H "Content-Type: application/json" \
-d '{"phone": "+584241000001", "code": "123456", "app": "client"}'
# 3) Use the token
curl /api/v1/me -H "Authorization: Bearer 12|abc..."
# 4) Log out
curl -X POST /api/v1/auth/logout -H "Authorization: Bearer 12|abc..."
# 5) Close the account: ask for the code, then confirm
curl -X POST /api/v1/me/deletion/otp -H "Authorization: Bearer 12|abc..."
curl -X DELETE /api/v1/me \
-H "Authorization: Bearer 12|abc..." \
-H "Content-Type: application/json" \
-d '{"code": "654321", "reason": "Ya no la uso"}'