Battlesnake is played by responding to a simple Webhook API, meaning developers build a web server that receives and responds to HTTP requests from the game engine. How your server responds to these requests controls how your Battlesnake behaves.
There are four webhooks that every Battlesnake needs to respond to:
Game Engine Requests
Requests sent to your Battlesnake will contain JSON-encoded request bodies. Your server is resonsible for receiving and deserializing this data correctly (although most modern web frameworks come with easy ways to handle this type of request).
All responses to webhook requests must be JSON-encoded strings sent as `application/json`. If the game engine receives an invalid response from your Battlesnake it will consider it an error and act accordingly.
All Battlesnakes responses must return a valid HTTP `200 OK`. If any other status code is returned, the game engine will consider it an error and act accordingly.
Your Battlesnake server must respond to requests made by the game engine within the given timeout value. Most of the time will be 500 ms, however, this value can technically vary from game to game. Use the game information provided in the request to determine how long your Battlesnake should spend computing its next move.
Note that these values include round-trip latency, so communication between the game engine and your Battlesnake server should be taken into consideration.
If your response does not reach the game engine within the specified timeout, the game engine will consider it an error and act accordingly.
In all error cases the game engine will determine your Battlesnake's next move for you by repeating the move taken on the previous turn. For example, if your Battlesnake successfully moves
right on turn N, a timeout on turn N+1 will result in your Battlesnake moving
On the first move of a game, errors will cause the game engine to move your Battlesnake
up until a successful response is received or your Battlesnake is eliminated.