Skip to content
moxon home

Tic-Tac-Toe Play

The /tic-tac-toe/play endpoint plays a move in a game. If the game identifier does not exist, the game is created.

posthttps://api.moxon.dev/v6/tic-tac-toe/play

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.

Try itpost/v6/tic-tac-toe/play

Parameters

  • gamestringrequired

    The game identifier. If the game does not exist, it is created

  • usernamestringrequired

    The username making the move

  • movestringrequired

    The move played in row-column format (e.g., 1-1, 2-2, 3-3), see Move Format

  • sessionstringrequired

    The user's session identifier

Good to know

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

Response Fields

  • messagestring

    Status message about the move

  • winnerstring|null

    Username of the winner (if game is over)

  • loserstring|null

    Username of the loser (if game is over)

  • tieboolean

    Whether the game ended in a tie

While the game goes on, the response only contains message (Move sent successfully). The winner, loser and tie fields are only present when the move ends the game.

Code Examples

Error Handling

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

  • 400Please provide a username (?username={username})The username parameter is missing
  • 400Please provide a valid move (&move={move})The move parameter is missing
  • 400Please provide a valid session ID (&session={ID})The session parameter is missing
  • 400Please provide a game ID (&game={ID})The game parameter is missing
  • 400Rate limit exceeded. Try again in X seconds.Per-user short-window limit
  • 400Invalid move. Please provide a valid move (e.g., 1-1, 2-2, 3-3).Invalid move format
  • 400Game is full, you can only watch.Game already has two players
  • 400Please wait for the other player to make a move.Not your turn
  • 400Move already made. Please choose a different move.Cell already occupied
  • 400Session ID mismatchSession doesn't match the player