TShock has a REST API: a small web service that lets a Discord bot, a website or your own script read your Terraria server's status and send it commands, with a token as the key. It is off until you turn it on. This guide turns it on, makes a token and makes a first call.
Checked against TShock 5's source code and documentation, November 2026.
What you need
- A server running TShock, which is the default. A tModLoader server has no REST API.
- A claimed server, so you have an owner account. TShock admin commands and permissions shows how.
- A free extra port. The REST API listens on a port of its own, separate from the one players join on.
Add a port for the API
- In the left rail, open Manage and choose Settings.
- On the Network ports card, select Add port.
- Note the new port's number. You can't pick it: ports come from a shared range.
Add an extra port to your server explains the card.
Turn the REST API on
- Stop the server.
- Open the File manager, go into the
tshockfolder, selectconfig.jsonand press Edit. - Inside
"Settings", set these two lines, with the port you just added in place of25570:
"RestApiEnabled": true,
"RestApiPort": 25570,- Press Save, then Start the server.
TShock's own default port is 7878, but that port isn't open on your server, so always use the one you added.
Make a token
TShock has two kinds of token:
| Kind | How long it lasts | Where it comes from |
|---|---|---|
| Application token | Until you remove it | You write it into config.json |
| Login token | Until the server restarts | The API gives it to an account that logs in |
A bot or website that runs all the time needs an application token.
An application token
- Stop the server and open
tshock/config.jsonagain. - Find
"ApplicationRestTokens": {}and fill it in like this:
"ApplicationRestTokens": {
"pick-a-long-random-secret": {
"Username": "YourAccountName",
"UserGroupName": "owner"
}
},- Replace
pick-a-long-random-secretwith a long, random string of your own: that string is the token. Use an account that exists and the group it is in. - Save and Start the server.
The token can do what its group can do. For a tool someone else made, name a group with fewer powers than owner.
A login token
Open this address in a browser, with your server's address, the API port and an account's name and password:
http://203.0.113.10:25570/v2/token/create?username=YourAccountName&password=YourPasswordThe reply holds a token. The account's group needs the tshock.rest.useapi permission. To give it to the owner group, type /group addperm owner tshock.rest.useapi in game while logged in. Without it, the API answers Username or password may be incorrect or this account may not have sufficient privileges.
Make your first call
Add the token to the end of an address as ?token=:
| Address | What it does |
|---|---|
http://203.0.113.10:25570/tokentest?token=YOURTOKEN | Checks the token works. |
http://203.0.113.10:25570/v2/server/status?token=YOURTOKEN | Shows the server's name, its players and more. |
TShock's REST documentation lists the other calls, such as running a server command, which needs the tshock.rest.command permission.
Keep the token safe
- The address is plain
http://and the token is in the address, so never post a full address with a token in it. - If a token leaks, remove it from
ApplicationRestTokensand restart the server./rest destroytokensends every login token at once. - To turn the API off, set
"RestApiEnabled": false, restart, and release the port on the Network ports card.
Related guides
TerrariaTerraria TShock admin commands and groups
Claim your TShock Terraria server, make admins, kick and ban, let in only the players you add, and change group permissions with TShock commands.
Updated 14 Oct 20265 min read
TerrariaChange invasion settings on Terraria TShock
Set invasion size and endless invasions in the Server Settings tab, then start or end goblin, pirate and moon events from the console.
Updated 21 Nov 20263 min read
TerrariaMake a hardcore-only Terraria server
Turn away softcore and mediumcore characters with TShock's Hardcore only switch, and choose what a hardcore death costs a player.
Updated 21 Nov 20263 min read