curl -X POST "https://gachabe-staging.fly.dev/api/v1/players/register" \ -H "Content-Type: application/vnd.api+json" \ -d '{ "data": { "type": "player", "attributes": { "email": "player@example.com", "password": "SecurePassword123!", "password_confirmation": "SecurePassword123!" }, "relationships": {} } }'
{ "data": { "type": "player", "id": "550e8400-e29b-41d4-a716-446655440000", "attributes": { "email": "player@example.com", "is_anonymous": false }, "relationships": { "chests": { "data": [] } } }, "included": [], "meta": { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "refresh_token": "refresh_token_string_here", "token_type": "Bearer", "expires_in": 3600, "created_at": "2024-01-15T15:30:00Z", "player_type": "registered", "initial_currency": { "coins": 1000, "gems": 50 }, "welcome_bonus": { "coins": 500, "gems": 25, "starter_chest": "welcome-chest-001" } } }
chests
Show Field Selection
id,email,is_anonymous
Show Registration Data
Show Required Attributes
Show Player Object
Show Player Attributes
Show Metadata
Show Welcome Bonus
Validate input data
Submit registration
Handle the response
Claim welcome rewards
const validateRegistrationForm = (formData) => { const errors = {}; // Email validation const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(formData.email)) { errors.email = 'Please enter a valid email address'; } // Password validation const password = formData.password; if (password.length < 8) { errors.password = 'Password must be at least 8 characters'; } else if (!/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*])/.test(password)) { errors.password = 'Password must include uppercase, lowercase, number, and special character'; } // Password confirmation if (formData.password !== formData.password_confirmation) { errors.password_confirmation = 'Passwords do not match'; } return errors; };