Back to Settings

X-API-KEY Guide

The X-API-KEY is a private security key used to connect applications, scripts, servers, or agents with MonitorHub securely. Think of it like a password for your MonitorHub API access.

What Is It Used For?

You can use the API key to:

Do I Need the MonitorHub Agent?

No.

The API key works even without the MonitorHub Agent.

Without Agent

You can still:

  • use APIs
  • automate tasks
  • create monitors
  • fetch data
  • build integrations

With Agent

You additionally get:

  • live CPU usage
  • RAM usage
  • disk monitoring
  • server heartbeat
  • automatic server metrics

How To Use The API Key

Add your API key inside request headers. MonitorHub checks the key before allowing access.

x-api-key: YOUR_API_KEY

Example cURL Request

curl -X GET https://api.monitorhubs.com/api/v1/monitors \
-H "x-api-key: YOUR_API_KEY"

Example JavaScript Request

fetch("https://api.monitorhubs.com/api/v1/monitors", {
  method: "GET",
  headers: {
    "x-api-key": "YOUR_API_KEY"
  }
})
.then(res => res.json())
.then(data => console.log(data));

Example Python Request

import requests

response = requests.get(
    "https://api.monitorhubs.com/api/v1/monitors",
    headers={
        "x-api-key": "YOUR_API_KEY"
    }
)

print(response.json())

MonitorHub Agent Example

monitorhub-agent --api-key YOUR_API_KEY

or in config.json:

{
  "apiKey": "YOUR_API_KEY"
}

Security Tips

Keep your API key private.

Do NOT:

Anyone with your API key may be able to access your MonitorHub resources.

Generate a New Key

You can generate a new API key anytime from:

Dashboard → Settings → Developer

Generating a new key may disable the old one for security reasons.