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"
    }
  }
}
Register a new player account with email and password credentials. This creates a permanent account that can be accessed across devices and sessions.

Query Parameters

include
string
Include related data in the response.Available includes: chests
fields
object
Limit response fields to only those specified.

Request Body

data
object
required
Player registration data
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"
    }
  }
}

Response Fields

data
object
required
The newly registered player resource
meta
object
required
Authentication tokens and welcome bonuses

Registration Requirements

Password must meet the following criteria:
  • Minimum 8 characters
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one number
  • At least one special character (!@#$%^&*)

Registration Flow

1

Validate input data

Ensure email format is valid and password meets security requirements.
Frontend validation should match backend requirements.
2

Submit registration

Send the registration request with all required fields.
Password and password_confirmation must match exactly.
3

Handle the response

Store authentication tokens and redirect the user to the game.
Show the welcome bonus to celebrate successful registration.
4

Claim welcome rewards

New players receive bonus currency and a starter chest automatically.
Welcome bonuses are immediately available in the player’s account.

Error Handling

Status: 400 Bad RequestThe email address is already registered to another account.Solution: Ask the user to sign in instead or use a different email address.

Form Validation Example

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;
};
Registered players receive additional benefits compared to guest players, including cross-device sync, password recovery, and exclusive registered-player bonuses.
Store the authentication tokens securely after registration. Loss of tokens will require the player to sign in again.