Verify Email
curl --request POST \
--url https://api.example.com/auth/check_user.php \
--header 'Accept: <accept>' \
--header 'Content-Type: <content-type>' \
--data '
{
"email": "<string>"
}
'import requests
url = "https://api.example.com/auth/check_user.php"
payload = { "email": "<string>" }
headers = {
"Content-Type": "<content-type>",
"Accept": "<accept>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Accept: '<accept>'},
body: JSON.stringify({email: '<string>'})
};
fetch('https://api.example.com/auth/check_user.php', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/auth/check_user.php",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Accept: <accept>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/auth/check_user.php"
payload := strings.NewReader("{\n \"email\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Accept", "<accept>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/auth/check_user.php")
.header("Content-Type", "<content-type>")
.header("Accept", "<accept>")
.body("{\n \"email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/auth/check_user.php")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Accept"] = '<accept>'
request.body = "{\n \"email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"exists": true
}User Endpoints
Verify Email
Check if a user account exists for an email address
POST
/
auth
/
check_user.php
Verify Email
curl --request POST \
--url https://api.example.com/auth/check_user.php \
--header 'Accept: <accept>' \
--header 'Content-Type: <content-type>' \
--data '
{
"email": "<string>"
}
'import requests
url = "https://api.example.com/auth/check_user.php"
payload = { "email": "<string>" }
headers = {
"Content-Type": "<content-type>",
"Accept": "<accept>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Accept: '<accept>'},
body: JSON.stringify({email: '<string>'})
};
fetch('https://api.example.com/auth/check_user.php', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/auth/check_user.php",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'email' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Accept: <accept>",
"Content-Type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/auth/check_user.php"
payload := strings.NewReader("{\n \"email\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Accept", "<accept>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/auth/check_user.php")
.header("Content-Type", "<content-type>")
.header("Accept", "<accept>")
.body("{\n \"email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/auth/check_user.php")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Accept"] = '<accept>'
request.body = "{\n \"email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"exists": true
}Endpoint
POST /auth/check_user.php
Headers
string
required
Must be
application/jsonstring
required
Must be
application/jsonRequest Body
string
required
Email address to check
Response
boolean
required
true if a user with this email exists, false otherwiseRequest Example
curl -X POST https://76.13.114.194/auth/check_user.php \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"email": "carlos.rodriguez@example.com"
}'
import 'package:http/http.dart' as http;
import 'dart:convert';
Future<bool> checkEmailExists(String email) async {
try {
final response = await http.post(
Uri.parse('https://76.13.114.194/auth/check_user.php'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: jsonEncode({'email': email}),
).timeout(Duration(seconds: 10));
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
return data['exists'] == true;
}
return false;
} catch (e) {
return false; // Assume doesn't exist on error
}
}
async function checkEmailExists(email) {
try {
const response = await fetch('https://76.13.114.194/auth/check_user.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({ email }),
});
const data = await response.json();
return data.exists === true;
} catch (error) {
return false;
}
}
Response Example
{
"exists": true
}
{
"exists": false
}
Use Cases
Pre-Registration Validation
Check if an email is available before showing the registration form:Future<void> validateEmail(String email) async {
final exists = await checkEmailExists(email);
if (exists) {
showError('Este email ya está registrado. ¿Desea iniciar sesión?');
// Show login option
} else {
// Proceed with registration
navigateToRegistrationForm(email);
}
}
Forgot Password Flow
Verify the email exists before sending a password reset:async function initiatePasswordReset(email) {
const exists = await checkEmailExists(email);
if (!exists) {
alert('No hay cuenta asociada con este email');
return;
}
// Send password reset email
await sendPasswordResetEmail(email);
}
Smart Login/Register
Determine whether to show login or registration:Future<void> handleEmailSubmit(String email) async {
final exists = await checkEmailExists(email);
if (exists) {
// Show password field for login
setState(() {
showPasswordField = true;
isLoginMode = true;
});
} else {
// Navigate to registration
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => RegisterScreen(email: email),
),
);
}
}
Error Handling
This endpoint returns
{"exists": false} on any error or if the request times out. This prevents exposing information about whether emails exist in the database during error conditions.Future<Map<String, dynamic>> checkUserExists(String email) async {
try {
final response = await client.post(
Uri.parse('$_baseUrl/check_user.php'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: jsonEncode({'email': email}),
).timeout(AppConfig.connectionTimeout);
if (response.statusCode == 200) {
return jsonDecode(response.body) as Map<String, dynamic>;
}
return {'exists': false};
} catch (e) {
return {'exists': false};
}
}
Security Considerations
This endpoint can be used to enumerate registered email addresses. In a production environment, consider:
- Rate limiting to prevent abuse
- CAPTCHA for repeated checks
- Logging suspicious activity
- Generic error messages that don’t reveal user existence
See Also
- Register - Create a new user account
- Login - Authenticate an existing user
- User Profile - Get user information
⌘I