Submits a player's solution and scores for a specific level.
{
"level_id": "string", // Unique identifier for the level
"level_version": 1, // Version number of the level
"game_version": "string", // Version of the game client
"api_key": "string", // User's API/secret key for authentication
"solution": "string", // Base64 encoded solution bytes
"solution_hash": "string", // SHA256 hash of (solution + salt)
"scores": { // Map of score type to score value
"time": 12500, // Time in milliseconds (lower is better)
"striping": 85, // Striping score (higher is better)
"fuel": 750, // Fuel consumed (lower is better)
"stars": 3 // Stars earned (higher is better)
}
}The endpoint uses API key authentication. The api_key field in the request body is hashed using SHA256 and compared against stored user credentials.
The solution_hash must be the SHA256 hash of the concatenated string: solution + SOLUTION_SALT where SOLUTION_SALT is a server-side secret configured via environment variable.
# Example using the hash utility
go run utils/hash-util.go <base64_solution> <salt>
# Example
go run utils/hash-util.go SGVsbG8gV29ybGQ= your_secret_salt_change_in_productionCurrently supported score types:
time- Completion time in milliseconds (lower is better)striping- Striping optimization score (higher is better)fuel- Fuel consumption (lower is better)stars- Stars earned (higher is better)
{
"success": true,
"solution_id": "0195b031-cf3f-7bf7-8f72-c6f8ef9db41c",
"message": "Score submitted successfully"
}{
"success": false,
"message": "Error description"
}- 400 Bad Request: Missing required fields, invalid JSON, invalid base64 solution, solution hash verification failed, invalid score types
- 401 Unauthorized: Invalid API key
- 500 Internal Server Error: Database errors, transaction failures
SOLUTION_SALT- Secret salt used for solution hash verification (required)
The endpoint inserts data into:
solutiontable - Stores the user's solution attemptscoretable - Stores individual score values by type
- API Key Authentication - Users must provide valid API keys
- Solution Hash Verification - Prevents tampering with solution data
- Transaction Safety - All database operations are atomic
- Input Validation - Validates all input fields and data types
- Score Type Validation - Only allows submission of registered score types