Skip to content
Outside Australia? Our international site shows prices in US dollars, with the location you choose.
Outside Australia? Our international site shows prices in US dollars, with the location you choose.

TerrariaSettings and admin

TShock REST API: tokens and setup

Turn on TShock's REST API on its own port, make an application or login token, check it with tokentest and keep the token safe on your Terraria server.

Updated 3 min read

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.

Running your Terraria server somewhere else?

Move it to Sydney and upload your world in the panel. From A$9.60 a month.

Add a port for the API

  1. In the left rail, open Manage and choose Settings.
  2. On the Network ports card, select Add port.
  3. 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

  1. Stop the server.
  2. Open the File manager, go into the tshock folder, select config.json and press Edit.
  3. Inside "Settings", set these two lines, with the port you just added in place of 25570:
"RestApiEnabled": true,
"RestApiPort": 25570,
  1. 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:

KindHow long it lastsWhere it comes from
Application tokenUntil you remove itYou write it into config.json
Login tokenUntil the server restartsThe 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

  1. Stop the server and open tshock/config.json again.
  2. Find "ApplicationRestTokens": {} and fill it in like this:
"ApplicationRestTokens": {
  "pick-a-long-random-secret": {
    "Username": "YourAccountName",
    "UserGroupName": "owner"
  }
},
  1. Replace pick-a-long-random-secret with a long, random string of your own: that string is the token. Use an account that exists and the group it is in.
  2. 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=YourPassword

The 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=:

AddressWhat it does
http://203.0.113.10:25570/tokentest?token=YOURTOKENChecks the token works.
http://203.0.113.10:25570/v2/server/status?token=YOURTOKENShows 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 ApplicationRestTokens and restart the server. /rest destroytokens ends every login token at once.
  • To turn the API off, set "RestApiEnabled": false, restart, and release the port on the Network ports card.

Ready to launch your Terraria server?

Aussie hardware, NVMe disks and DDoS protection on every plan.

See Terraria plans