Skip to content

Tic-Tac-Toe Play ​

The /tic-tac-toe/play endpoint plays a move in an existing game using a REST method.

Changed in 6.0.0

This endpoint moved from PATCH to POST, and its identifier left the URL: game is now sent in the JSON body. PATCH and DELETE no longer exist anywhere in the API.

Parameters ​

ParameterRequiredDescription
gameYesThe game identifier
usernameYesThe username making the move
moveYesThe move played (e.g., 1-1, 2-2, 3-3)
sessionYesThe user's session identifier

Good to know

All parameters are sent as a JSON body with Content-Type: application/json.

Response Fields ​

FieldTypeDescription
messagestringStatus message about the move
winnerstring|nullUsername of the winner (if game is over)
loserstring|nullUsername of the loser (if game is over)
tiebooleanWhether the game ended in a tie

Code Examples ​

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "game": "VWXYZ",
    "username": "alice",
    "move": "1-1",
    "session": "abc123"
  }' \
  "https://api.sylvain.sh/v6/tic-tac-toe/play"

Try It ​

Error Handling ​

If parameters are missing or invalid, the API will return an error:

Error MessageDescription
Invalid move. Please provide a valid move (e.g., 1-1, 2-2, 3-3).Invalid move format
Game is full, you can only watch.Game already has two players
Please wait for the other player to make a move.Not your turn
Move already made. Please choose a different move.Cell already occupied
Session ID mismatchSession doesn't match the player