Skip to main content
POST
/
game
/
new
Create Game
curl --request POST \
  --url https://api.example.com/game/new \
  --header 'Content-Type: application/json' \
  --data '
{
  "playerName": "<string>"
}
'
{
  "201": {},
  "400": {},
  "gameId": "<string>",
  "playerId": "<string>",
  "status": "<string>"
}

Request

Creates a new Blackjack game for a player. The game starts immediately with cards dealt to both the player and dealer.

Body Parameters

playerName
string
required
The name of the player. Must not be blank and cannot exceed 30 characters.

Request Example

{
  "playerName": "John Doe"
}

cURL Example

curl -X POST http://localhost:8080/game/new \
  -H "Content-Type: application/json" \
  -d '{
    "playerName": "John Doe"
  }'

Response

Returns details of the newly created game.
gameId
string
Unique identifier for the game
playerId
string
Unique identifier for the player
status
string
Current status of the game (typically IN_PROGRESS for a new game)

Response Example

{
  "gameId": "550e8400-e29b-41d4-a716-446655440000",
  "playerId": "660e8400-e29b-41d4-a716-446655440001",
  "status": "IN_PROGRESS"
}

Status Codes

201
Created
Game successfully created
400
Bad Request
Validation error - player name is blank or exceeds 30 characters

Example Scenarios

Success

Request:
{
  "playerName": "Alice"
}
Response (201):
{
  "gameId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "playerId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
  "status": "IN_PROGRESS"
}

Validation Error

Request:
{
  "playerName": ""
}
Response (400):
{
  "message": "Player name must not be blank"
}

Build docs developers (and LLMs) love