The Hostinger API: managing a VPS with code

After this session you will be able to:

1. The basics in 5 minutes

What is an API?

Think of a restaurant again. hPanel is the dining room: a person looks at the menu and asks the waiter. The API is the order window for programs: a script, an app or an AI agent sends an order in a fixed format and gets a fixed-format answer back.

Why customers use it: to automate (restart a VPS every night, take a snapshot before every update), to connect Hostinger to other tools (dashboards, n8n workflows, Terraform), or to let an AI agent manage their services.

Key facts about the Hostinger API

ItemWhat to know
AddressAll requests go to https://developers.hostinger.com, with paths like /api/vps/v1/…, /api/hosting/v1/…, /api/dns/v1/…
ProductsVPS, web hosting, Agency hosting, domains, DNS, email, billing, ecommerce and more. The VPS part alone has about 65 operations.
Documentationdevelopers.hostinger.com lists every operation, with examples
StatusThe API is officially in beta
FormatJSON in, JSON out
Rate limit90 requests per minute per user. Above that: error 429 with a Retry-After header saying how long to wait

The API token: a password for programs

Treat a token like a password. Never ask a customer to send their token in the chat, and never paste one anywhere yourself. If a token leaks (sent in a chat, pushed to GitHub, shared with a freelancer), the customer should delete it in hPanel and create a new one.

Tools built on the API

Many customers never write API code themselves. They use a tool that calls the API for them, so "the API" can be behind any of these:

ToolWhat it is
Hostinger CLI (hostinger)Commands in a terminal, for example hostinger vps vm start <id>
SDKsReady-made libraries for PHP, Python and TypeScript/Node
MCP server / Hostinger connectorLets AI agents (Claude, ChatGPT, Cursor…) manage the account in plain language
Terraform, AnsibleInfrastructure tools: "keep my servers like this file says"
n8n, WHMCSAutomation workflows; reselling/billing systems
Postman collectionTry requests by clicking, no code

When an AI agent connects through Hostinger's MCP service, an entry such as hostinger-remote-mcp or GuzzleHttp, marked "Direct API", can show up in the customer's account. That's expected, not a hack.

2. Anatomy of a request

Every API call has the same parts. Here's "show me the details of VPS 2196542":

GET https://developers.hostinger.com/api/vps/v1/virtual-machines/2196542
Authorization: Bearer YOUR_API_TOKEN
Accept: application/json
PartIn the exampleMeaning
MethodGETWhat kind of order (table below)
Address (endpoint)/api/vps/v1/virtual-machines/2196542Which product (vps), which version (v1), which thing (virtual-machines), which one (2196542, the VPS ID)
HeaderAuthorization: Bearer …Who is asking (the token)
Body(none here)Extra data, as JSON, for calls that create or change something

Methods

MethodMeansExample
GETRead. Changes nothing.VPS details, metrics, list of backups
POSTDo something / createRestart, create snapshot, restore backup
PUTChange a settingSet hostname, set root password
DELETERemoveDelete snapshot, remove SSH key

The answer: status code + JSON

The response starts with a number that says how it went, then a JSON body. Part of the answer above:

HTTP 200
{
  "id": 2196542,
  "plan": "KVM 1",
  "hostname": "srv2196542.hstgr.cloud",
  "state": "running",
  "cpus": 1,
  "memory": 4096,
  "disk": 51200,
  "template": { "name": "CloudLinux 9" }
}
CodeMeaning in plain wordsUsual cause
200OK, here you go-
202Accepted, will finish in the backgroundNormal for slow jobs. Check later; don't send it again
401"Who are you?"Token missing, mistyped, expired or deleted; or the word Bearer is missing
403"You can't do that"The account isn't allowed this action
404"Not found"Wrong ID, or it belongs to another account
422"Something in your order is wrong"Missing or invalid field; the body says which one
429"Too many orders, slow down"More than 90 requests per minute
500Problem on Hostinger's sideRetry later; escalate if it persists

Errors come with a short explanation and a correlation ID, the reference of that exact request:

HTTP 404
{
  "message": "[VPS:2008] VirtualMachine with ID`s [1] was not found",
  "correlation_id": "a34e6873-bb52-4774-bdf3-ff7cfb9047ef"
}

3. What the API can do with a VPS

Almost everything a customer can do with their VPS in hPanel. Red = destructive or can't be undone.

AreaOperations
InformationList VPSs, details (plan, state, IPs, OS), metrics (CPU, RAM, disk, traffic, uptime history), action history
PowerStart, restart, stop (the VPS goes offline)
SnapshotsGet, create (replaces the existing one: only one snapshot at a time), restore, delete
BackupsList, restore (overwrites everything on the VPS). Backups are kept outside the VPS and can't be downloaded
RebuildRecreate with a new OS (erases all data), recovery mode, purchase and set up a new VPS
AccessRoot password, panel password, SSH keys, post-install scripts
NetworkFirewall rules, hostname, nameservers, PTR (reverse DNS)
AppsDocker Compose projects (Docker Manager), Monarx malware scanner
Metrics through the API are not real time either. In our test, the data points came about every 30 minutes, like the hPanel graphs. For live numbers, the customer still needs to check inside the VPS (top, free -h, df -h).

4. Real-world cases

Case 1: "I get 401 Unauthenticated"

"My script worked last month. Now every request returns 401."

What's going on: the API doesn't accept the token.

Usual causes: the token expired (they set an expiration date), was deleted, was copied with a missing character or an extra space, or the header is wrong (it must be Authorization: Bearer <token>, with the word Bearer).

What to tell them: check the token's expiration in hPanel → API. If in doubt, create a new token and update the script.

Try it in the playground: "Call without a token" and "Call with a wrong token".

Case 2: "429 Too Many Requests"

"My monitoring script keeps getting 429 errors."

What's going on: the account makes more than 90 requests per minute. The limit is per user, so all scripts and tools using that account share it.

What to tell them: ask less often (metrics only change about every 30 minutes, so checking every few seconds is wasted), wait the time in the Retry-After header before retrying, and check whether several tools use the same account.

Case 3: "My VPS restarted (or stopped) by itself"

"Nobody touched it, but my VPS restarted at 3:00 AM."

How to check: the VPS action history (the API's "actions" call, the "Action history" button in the playground) lists recent actions such as restart, stop or snapshot, with time and result.

What's going on, often: an automation the customer set up: a nightly script, an n8n workflow, Terraform, a reseller panel, or an AI agent with access to the account.

What to tell them: review their automations and tools, and in hPanel → API delete any token they don't recognise or no longer use. If they suspect someone else has a token, treat it as a security issue.

Not every restart is an API action: a crash inside the VPS, or the OOM killer, doesn't appear as an action. That's the previous session (check inside the VPS).

Case 4: "I created a snapshot and my old one disappeared"

"My script takes a snapshot every day. I wanted last week's, but there's only today's."

What's going on: a VPS has one snapshot. Creating a new one replaces the old one. That's how it works, from hPanel or the API.

What to tell them: for history over several days, use the backups (Hostinger keeps them outside the VPS) or their own backup tool that stores copies outside the VPS.

Case 5: "The API said OK but nothing happened"

"I sent the restart and got a success response, but the VPS was still running the old way."

What's going on: many actions are asynchronous: the API answers "accepted" right away and does the job in the background (restore, recreate, snapshot can take minutes).

What to tell them: check the action history or the VPS state after a while. Don't send the same request again: it can start the job twice.

Case 6: "I restored a backup with my script and lost my data"

"I ran restore through the API and now everything from this week is gone!"

What's going on: a backup restore replaces everything on the VPS with the backup's content, from hPanel or the API. There's no "are you sure?" in an API call.

What to tell them: data created after the backup can't be brought back by Hostinger backups. Before destructive calls (restore, recreate, snapshot restore), scripts should be tested carefully, and important data kept in their own backups outside the VPS.

Case 7: "Can you fix my script?"

"Here's my Python code, can you tell me why it doesn't work?"

Our scope: we don't debug or write customer code. What we can do:

Never ask for the token to "test it ourselves".

5. Practice: which case is it?

1. "I copied my token from an old note and now every call says Unauthenticated."

Answer

Case 1. The token is probably expired, deleted or copied wrong. Create a new one in hPanel → API.

2. "My Grafana dashboard checks the API every second and keeps breaking."

Answer

Case 2. 60+ requests per minute from one tool, plus anything else on the account, hits the 90/minute limit. Metrics only change every ~30 minutes, so checking every few minutes is plenty.

3. "Every night at 2:00 my VPS goes offline for a minute."

Answer

Case 3. Check the action history for a nightly restart; most likely an automation the customer (or their developer) set up.

4. "I pasted my API token in a public GitHub repository by mistake."

Answer

Delete that token in hPanel → API right away and create a new one. Then check the action history for anything they didn't do.

5. "The recreate call returned 'accepted', but my VPS still shows the old OS."

Answer

Case 5. Recreate runs in the background. Wait and check the action history; don't send it again.

6. Lab: the API playground

The API playground sends real requests to the Hostinger API for the lab VPS srv2196542 only, and shows the full request and the raw JSON answer.

  1. VPS details: find the plan, state, CPUs, RAM and OS in the JSON.
  2. Metrics: look at the timestamps. How far apart are the data points? (Compare with what you know about hPanel graphs.)
  3. Action history: what has happened to this VPS so far?
  4. Restart the VPS (tick the box). Then open the action history again: the restart is there. In the resources lab terminal, uptime now shows a few minutes.
  5. Errors on purpose: call without a token, with a wrong token, and for another VPS. Match each status code with the table in section 2.
  6. Look at the x-ratelimit-remaining header on any call: that's how many requests are left this minute.

The token is stored on the server, outside the website folder, and never reaches your browser: you only see its last 4 characters. Only the instructor should use "Restart" and "Create snapshot", one person at a time.


Based on the Hostinger API documentation (developers.hostinger.com, API reference overview) and the help article What is Hostinger API. Examples captured from a real Hostinger VPS.