๐ User Registration Explorer
Test user registration flows with different versions and configurations. Create new accounts with various verification methods.
๐ Registration v2 (Recommended)โ
The latest registration endpoint with enhanced features and better error handling:
https://api.swapbits.co/auth/register/v2Register a new user account (v2)
Parรกmetros
User's email address
Password (8+ chars, include numbers/symbols)
User's full name
Country code (ISO 3166-1 alpha-2)
Preferred language (es/en)
Optional referral code
Comando cURL
curl -X POST 'https://api.swapbits.co/auth/register/v2' \
-H 'Content-Type: application/json'๐ Registration v1 (Legacy)โ
Original registration endpoint for compatibility:
https://api.swapbits.co/auth/register/v1Register a new user account (v1)
Parรกmetros
User's email address
Password (minimum 8 characters)
User's full name
Comando cURL
curl -X POST 'https://api.swapbits.co/auth/register/v1' \
-H 'Content-Type: application/json'๐ Phone Registrationโ
Register using phone number instead of email:
https://api.swapbits.co/auth/phone/registerRegister with phone number
Parรกmetros
Phone number with country code
Account password
User's full name
Country code
Comando cURL
curl -X POST 'https://api.swapbits.co/auth/phone/register' \
-H 'Content-Type: application/json'Response Scenariosโ
Registration v2 Successโ
โ Registration Successful (Code 1001)
Account created successfully - Email verification required.
{
"code": 1001,
"message": "User registered successfully",
"data": {
"user": {
"id": "user-uuid-v4",
"email": "newuser@example.com",
"name": "John Doe",
"verified": false,
"country": "US",
"language": "en",
"createdAt": "2024-01-15T10:30:00Z"
},
"verificationSent": true,
"verificationMethod": "email"
}
}
Next step: Check email for verification code and use Email Verification Explorer
Registration Errorsโ
โ Email Already Exists (Code 4009)
Account already exists - Email is already registered.
{
"code": 4009,
"message": "Email already in use",
"id": "error-trace-id"
}
Action: Use a different email or try Login Explorer if this is your account
โ Weak Password (Code 4003)
Password doesn't meet requirements - Password is too weak.
{
"code": 4003,
"message": "Password does not meet security requirements",
"data": {
"requirements": {
"minLength": 8,
"requireNumbers": true,
"requireSymbols": true,
"requireUppercase": true,
"requireLowercase": true
}
},
"id": "error-trace-id"
}
Password must include:
- Minimum 8 characters
- At least one number
- At least one symbol (!@#$%^&*)
- Upper and lowercase letters
โ Invalid Email Format (Code 4002)
Email format invalid - Email doesn't match expected format.
{
"code": 4002,
"message": "Invalid email format",
"id": "error-trace-id"
}
Action: Check email format (must contain @ and valid domain)
Phone Registration Successโ
๐ฑ Phone Registration Successful
Phone account created - SMS verification code sent.
{
"code": 1001,
"message": "User registered with phone",
"data": {
"user": {
"id": "user-uuid-v4",
"phone": "+1234567890",
"name": "Phone User",
"verified": false,
"country": "US",
"createdAt": "2024-01-15T10:30:00Z"
},
"verificationSent": true,
"verificationMethod": "sms"
}
}
Next step: Check SMS for verification code and use phone verification endpoint
๐ Complete Registration Flowโ
Step-by-step Registration Process
Email Registration Flow:
- Choose Version โ Use v2 for new integrations, v1 for legacy compatibility
- Prepare Data โ Email, password, name, and optional country/language
- Submit Registration โ POST to registration endpoint
- Check Email โ Look for verification code in inbox/spam
- Verify Account โ Use Email Verification Explorer
- Login โ Use Login Explorer after verification
Phone Registration Flow:
- Format Phone โ Include country code (+1, +34, etc.)
- Submit Registration โ POST to phone registration endpoint
- Check SMS โ Look for verification code via text message
- Verify Phone โ POST to phone verification endpoint
- Login โ Use phone number and password for login
Password Requirements:
- Minimum 8 characters
- At least one uppercase letter (A-Z)
- At least one lowercase letter (a-z)
- At least one number (0-9)
- At least one symbol (!@#$%^&*)
๐ป Integration Examplesโ
JavaScript/TypeScriptโ
interface RegistrationData {
email: string;
password: string;
name: string;
country?: string;
language?: string;
referralCode?: string;
}
interface PhoneRegistrationData {
phone: string;
password: string;
name: string;
country?: string;
}
class SwapBitsRegistration {
private baseUrl = 'https://api.swapbits.co';
async registerV2(data: RegistrationData) {
const response = await fetch(`${this.baseUrl}/auth/register/v2`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
const result = await response.json();
if (result.code === 1001) {
return {
success: true,
user: result.data.user,
verificationSent: result.data.verificationSent,
method: result.data.verificationMethod,
};
} else {
throw new Error(`Registration failed: ${result.message} (Code: ${result.code})`);
}
}
async registerV1(email: string, password: string, name: string) {
const response = await fetch(`${this.baseUrl}/auth/register/v1`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email, password, name }),
});
const result = await response.json();
if (result.code === 1001) {
return {
success: true,
user: result.data.user,
};
} else {
throw new Error(`Registration failed: ${result.message} (Code: ${result.code})`);
}
}
async registerWithPhone(data: PhoneRegistrationData) {
const response = await fetch(`${this.baseUrl}/auth/phone/register`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
const result = await response.json();
if (result.code === 1001) {
return {
success: true,
user: result.data.user,
verificationSent: result.data.verificationSent,
method: result.data.verificationMethod,
};
} else {
throw new Error(`Phone registration failed: ${result.message} (Code: ${result.code})`);
}
}
validatePassword(password: string): { valid: boolean; errors: string[] } {
const errors: string[] = [];
if (password.length < 8) {
errors.push('Password must be at least 8 characters long');
}
if (!/[A-Z]/.test(password)) {
errors.push('Password must contain at least one uppercase letter');
}
if (!/[a-z]/.test(password)) {
errors.push('Password must contain at least one lowercase letter');
}
if (!/[0-9]/.test(password)) {
errors.push('Password must contain at least one number');
}
if (!/[!@#$%^&*(),.?":{}|<>]/.test(password)) {
errors.push('Password must contain at least one symbol');
}
return {
valid: errors.length === 0,
errors,
};
}
}
// Usage examples
const registration = new SwapBitsRegistration();
// Register with email (v2)
try {
const validation = registration.validatePassword('MySecurePass123!');
if (!validation.valid) {
console.log('Password errors:', validation.errors);
return;
}
const result = await registration.registerV2({
email: 'newuser@example.com',
password: 'MySecurePass123!',
name: 'John Doe',
country: 'US',
language: 'en',
referralCode: 'FRIEND123',
});
console.log('Registration successful:', result);
console.log('Check your email for verification code');
} catch (error) {
console.error('Registration failed:', error.message);
}
// Register with phone
try {
const phoneResult = await registration.registerWithPhone({
phone: '+1234567890',
password: 'PhonePass123!',
name: 'Phone User',
country: 'US',
});
console.log('Phone registration successful:', phoneResult);
console.log('Check your SMS for verification code');
} catch (error) {
console.error('Phone registration failed:', error.message);
}
Pythonโ
import requests
import re
from typing import Dict, Any, Optional, List
class SwapBitsRegistration:
def __init__(self):
self.base_url = 'https://api.swapbits.co'
def register_v2(self, email: str, password: str, name: str,
country: str = None, language: str = 'en',
referral_code: str = None) -> Dict[str, Any]:
"""Register user with v2 endpoint (recommended)"""
# Validate password first
validation = self.validate_password(password)
if not validation['valid']:
raise ValueError(f"Password validation failed: {', '.join(validation['errors'])}")
data = {
'email': email,
'password': password,
'name': name,
}
if country:
data['country'] = country
if language:
data['language'] = language
if referral_code:
data['referralCode'] = referral_code
response = requests.post(
f'{self.base_url}/auth/register/v2',
json=data
)
result = response.json()
if result['code'] == 1001:
return {
'success': True,
'user': result['data']['user'],
'verification_sent': result['data']['verificationSent'],
'verification_method': result['data']['verificationMethod']
}
else:
raise Exception(f"Registration failed: {result['message']} (Code: {result['code']})")
def register_v1(self, email: str, password: str, name: str) -> Dict[str, Any]:
"""Register user with v1 endpoint (legacy)"""
response = requests.post(
f'{self.base_url}/auth/register/v1',
json={
'email': email,
'password': password,
'name': name
}
)
result = response.json()
if result['code'] == 1001:
return {
'success': True,
'user': result['data']['user']
}
else:
raise Exception(f"Registration failed: {result['message']} (Code: {result['code']})")
def register_with_phone(self, phone: str, password: str, name: str,
country: str = None) -> Dict[str, Any]:
"""Register user with phone number"""
data = {
'phone': phone,
'password': password,
'name': name
}
if country:
data['country'] = country
response = requests.post(
f'{self.base_url}/auth/phone/register',
json=data
)
result = response.json()
if result['code'] == 1001:
return {
'success': True,
'user': result['data']['user'],
'verification_sent': result['data']['verificationSent'],
'verification_method': result['data']['verificationMethod']
}
else:
raise Exception(f"Phone registration failed: {result['message']} (Code: {result['code']})")
def validate_password(self, password: str) -> Dict[str, Any]:
"""Validate password against requirements"""
errors = []
if len(password) < 8:
errors.append('Password must be at least 8 characters long')
if not re.search(r'[A-Z]', password):
errors.append('Password must contain at least one uppercase letter')
if not re.search(r'[a-z]', password):
errors.append('Password must contain at least one lowercase letter')
if not re.search(r'[0-9]', password):
errors.append('Password must contain at least one number')
if not re.search(r'[!@#$%^&*(),.?":{}|<>]', password):
errors.append('Password must contain at least one symbol')
return {
'valid': len(errors) == 0,
'errors': errors
}
def validate_email(self, email: str) -> bool:
"""Basic email validation"""
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
return re.match(pattern, email) is not None
# Usage examples
registration = SwapBitsRegistration()
# Email registration (v2)
try:
# Validate inputs first
email = 'newuser@example.com'
password = 'SecurePass123!'
if not registration.validate_email(email):
print("Invalid email format")
exit()
password_check = registration.validate_password(password)
if not password_check['valid']:
print("Password errors:", password_check['errors'])
exit()
# Register user
result = registration.register_v2(
email=email,
password=password,
name='John Doe',
country='US',
language='en',
referral_code='FRIEND123'
)
print("Registration successful!")
print(f"User ID: {result['user']['id']}")
print(f"Verification method: {result['verification_method']}")
print("Check your email for verification code")
except Exception as e:
print(f"Registration failed: {e}")
# Phone registration
try:
phone_result = registration.register_with_phone(
phone='+1234567890',
password='PhonePass123!',
name='Phone User',
country='US'
)
print("Phone registration successful!")
print(f"User ID: {phone_result['user']['id']}")
print("Check your SMS for verification code")
except Exception as e:
print(f"Phone registration failed: {e}")
๐ Related Explorersโ
- ๐ง Email Verification Explorer - Verify your new account
- ๐ Login Explorer - Access your account after verification
- ๐ฑ Phone Verification Explorer (Coming Soon) - Verify phone registration
- ๐ก๏ธ 2FA Explorer - Set up additional security
๐ Troubleshootingโ
๐ง Common Registration Issues & Solutions
Problem: "Email already in use" Solution: Use a different email or check if you already have an account
Problem: Password validation errors Solution: Ensure password has 8+ chars, includes uppercase, lowercase, numbers, and symbols
Problem: No verification email received Solution: Check spam folder, verify email spelling, try registering again
Problem: Phone registration fails Solution: Include country code (+1, +34, etc.), ensure valid phone format
Problem: "Invalid email format" Solution: Check for typos, ensure proper email structure (user@domain.com)
Problem: Country code not accepted Solution: Use ISO 3166-1 alpha-2 format (US, UK, ES, etc.)