🌿 Green VPS Reseller API

v1 · Base URL https://api.greenvds.ir/v1 · JSON over HTTPS

این API مخصوص نمایندگان Green VPS است. کلید API را از ربات، بخش «🤝 نمایندگی ← 🔑 API و اتصال» بسازید. هر کاری که در ربات انجام می‌دهید (خرید سرور، روشن/خاموش، نصب مجدد، حذف، تیکت) از اینجا هم ممکن است و تخفیف نمایندگی شما خودکار اعمال می‌شود.

Authentication

Send your key in every request: Authorization: Bearer gvk_… (or X-API-Key). Keys are shown once when created, stored only as a hash, and can be limited to IP addresses and to read-only access. Revoke a leaked key instantly in the bot.
curl https://api.greenvds.ir/v1/me -H "Authorization: Bearer gvk_XXXXXXXXXX_..."

Responses & errors

Success: {"data": …}. Error: {"error": {"code": "…", "message": "…"}} with an HTTP status.
StatusCodes
400missing_fields, invalid_billing, invalid_action, idempotency_key_required, invalid_json
401 / 403unauthorized, not_a_reseller, api_not_enabled, ip_not_allowed, read_only_key, server_cap (your account has as many servers on this datacenter as it may; ask support to raise it)
402insufficient_balance (top up the wallet in the bot)
404datacenter_not_found, location_not_found, plan_not_found, image_not_found, server_not_found
409plan_unavailable, order_in_progress, server_suspended, traffic_exhausted, reinstall_unavailable
422idempotency_conflict
429rate_limited, creation_limit, too_many_attempts (see Retry-After)
502 / 503provider_failed (nothing charged), rate_unavailable, api_disabled
Limits: 60 requests/minute per key (bursts of 20), 6 orders/minute.

Account

GET/v1/me

Wallet balance (toman and USD), reseller tier, discount and 30-day sales.

GET/v1/transactions?limit=50

Latest wallet transactions (max 200).

Catalog

GET/v1/datacenters

Datacenters you can order from, with the billing periods they offer.

GET/v1/datacenters/{datacenter}/locations

Locations in stock.

GET/v1/datacenters/{datacenter}/plans?location=…&billing=monthly

Plans with your price after your reseller discount (USD and toman) for one period. billing: hourly, weekly or monthly.

GET/v1/datacenters/{datacenter}/images?location=…

Operating system images.

POST/v1/quote

Price of one order without buying.

{"datacenter":"hetzner","location":"hel1","plan":"cpx12","billing":"monthly"}

Servers

POST/v1/servers

Order a server. Charges your wallet at your discount. Requires an Idempotency-Key header: retrying with the same key never orders twice. Returns 201 with the server (IP and password when the datacenter delivers instantly; otherwise poll GET /v1/servers/{id}).

curl -X POST https://api.greenvds.ir/v1/servers \
  -H "Authorization: Bearer gvk_…" -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-2026-0001" \
  -d '{"datacenter":"hetzner","location":"hel1","plan":"cpx12","image":"ubuntu-24.04","billing":"monthly"}'
GET/v1/servers

Your servers (active, pending, suspended…). Filter with ?status=.

GET/v1/servers/{id}?live=1

One server with IP, IPv6, root password and renewal price. live=1 also asks the datacenter for power state and traffic.

POST/v1/servers/{id}/power

Start, stop or reboot.

{"action":"reboot"}
POST/v1/servers/{id}/reinstall

Reinstall with another image (erases the disk). Returns the new password when it changes.

{"image":"debian-13"}
DELETE/v1/servers/{id}

Delete the server now. Some datacenters charge a small deletion fee (returned as feeToman).

Servers renew automatically from your wallet at your reseller discount; with too little balance they are suspended, then deleted after the grace period, exactly like in the bot.

Support

GET/v1/tickets

Your tickets.

POST/v1/tickets

Open a ticket.

{"subject":"Network issue","message":"…"}
GET/v1/tickets/{id}

A ticket with its messages.

POST/v1/tickets/{id}/messages

Reply to a ticket.

{"message":"…"}

Webhooks

Set an https:// URL (bot: 🔑 API → 🔔 وب‌هوک, or the endpoints below) and your system receives a POST for every event, signed with your webhook secret.
EventWhen
server.createdAn order was placed (bot or API). Includes the root password.
server.readyThe server is running with its IP. Includes IPv4, IPv6 and root password.
server.suspended / server.resumedSuspended for an unpaid renewal / renewed and running again.
server.deletedreason: customer, api or expired.
server.traffic_low / _exhausted / _restoredTraffic quota warnings; exhausted servers are turned off, never deleted.
balance.lowWallet will run out within 48 h (balanceToman, hoursLeft).
ticket.repliedSupport answered one of your tickets.
pingTest event.
Body: {"id":"…","event":"server.ready","createdAt":"…","data":{"server":{…}}}. Headers: X-GV-Event, X-GV-Delivery, X-GV-Timestamp, X-GV-Signature: sha256=…. Reply with any 2xx within 10 s. Otherwise we retry after 1 m, 5 m, 30 m, 2 h and 6 h. Deliveries can repeat: use id to ignore duplicates. Only public HTTPS addresses on ports 443/8443 are allowed.

Verify every request: compute HMAC-SHA256 of "<X-GV-Timestamp>.<raw body>" with your secret, compare with the signature, and reject timestamps older than 5 minutes.

// Node.js (Express, raw body)
const crypto = require('crypto');
function verify(req, secret) {
  const ts = req.get('X-GV-Timestamp');
  const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(ts + '.' + req.rawBody).digest('hex');
  const ok = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(req.get('X-GV-Signature') || ''));
  return ok && Math.abs(Date.now() / 1000 - Number(ts)) < 300;
}
// PHP
$ts = $_SERVER['HTTP_X_GV_TIMESTAMP'];
$body = file_get_contents('php://input');
$expected = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, $secret);
$ok = hash_equals($expected, $_SERVER['HTTP_X_GV_SIGNATURE'] ?? '') && abs(time() - (int)$ts) < 300;
# Python
import hmac, hashlib, time
expected = 'sha256=' + hmac.new(secret.encode(), f"{ts}.".encode() + raw_body, hashlib.sha256).hexdigest()
ok = hmac.compare_digest(expected, signature) and abs(time.time() - int(ts)) < 300
GET/v1/webhook

Your webhook URL, event list and the last 20 deliveries.

PUT/v1/webhook

Set the URL. The secret is returned the first time only.

{"url":"https://shop.example.com/hooks/greenvps"}
POST/v1/webhook/test

Send a ping now and get the result.

POST/v1/webhook/rotate

New signing secret (the old one stops working).

DELETE/v1/webhook

Remove the webhook.

Datacenters available through the API

Hetzner, Linode, LightNode, GreenNode, NordNode, CGI and Dataforest. Iran and 3HCloud are ordered in the bot.

Questions? Open a ticket in the bot or via POST /v1/tickets.