Phone Number Verification Code API #
Gateway Path: /User/phone-number/send-code
Service: Authentication & Authorization
Method: POST
Auth: Bearer token in Authorization
header
1) Overview & Purpose #
This endpoint sends a one-time verification code via SMS to a user’s phone number. The code is used to confirm ownership of the number and is required before enabling features that depend on verified phone contact (e.g., higher risk transactions, secure login, or two-factor flows).
When the request succeeds, the user receives an SMS message such as:
Your security code is: 189143
If the phone number is already registered to another user, the request fails with a 400 error.
2) Endpoint Definition #
HTTP: POST /User/phone-number/send-code
Headers
Authorization: Bearer <token>
— valid access token.Content-Type: application/json
Request Body Example
{
"id": 2077,
"phoneNumber": "+3522223333444"
}
Fields #
- id (integer, required) — User identifier. Range: 1..2147483647 (signed 32-bit).
- phoneNumber (string, required) — Phone number in international format (E.164). Must not be empty.
3) Responses #
3.1 Success — 204 No Content
#
- Request accepted, SMS with verification code was sent.
3.2 Duplicate Phone — 400 Bad Request
#
{
"errors": {
"Error": [
"Phone already registered"
]
},
"type": "https://tools.ietf.org/html/rfc7231#section-6.5.1",
"title": "Bad Request",
"status": 400,
"traceId": "00-886f5434dbb8ee5aec5156d3b24d9f16-6d7d7cbb1e0935d5-00"
}
3.3 Not Found — 404
#
{
"type": null,
"title": null,
"status": null,
"detail": null,
"instance": null,
"ANY_ADDITIONAL_PROPERTY": "anything"
}
3.4 Server Error — 500 Internal Server Error
#
- Empty body, indicates an unexpected failure.
4) Validation Rules #
- id: required, integer between 1 and 2147483647.
- phoneNumber: required, must be a valid phone number in international format.
5) Examples #
5.1 cURL #
curl -X POST "https://api-test.10npay.com/User/phone-number/send-code" \
-H "Authorization: Bearer <YOUR_SECRET_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"id": 2077,
"phoneNumber": "+3522223333444"
}' -i
5.2 C# (.NET) #
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("https://api-test.10npay.com/User/phone-number/send-code"),
Headers = { { "Authorization", "Bearer <YOUR_SECRET_TOKEN>" } },
Content = new StringContent(
"{\"id\": 2077, \"phoneNumber\": \"+3522223333444\"}"
) { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }
};
using var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode(); // Expect 204
5.3 JavaScript (fetch) #
await fetch("https://api-test.10npay.com/User/phone-number/send-code", {
method: "POST",
headers: {
"Authorization": "Bearer <YOUR_SECRET_TOKEN>",
"Content-Type": "application/json"
},
body: JSON.stringify({ id: 2077, phoneNumber: "+3522223333444" })
}); // Expect 204 No Content
6) Sequence #
Client → API Gateway: POST /User/phone-number/send-code (Bearer, body)
API Gateway → Auth Service: Validate token
Auth Service → API Gateway: OK
API Gateway → SMS Service: Send code
SMS Service → API Gateway: Accepted
API Gateway → Client: 204 No Content