🌿 Green VPS Reseller API
v1 · Base URL https://api.greenvds.ir/v1 · JSON over HTTPS
این API مخصوص نمایندگان Green VPS است. کلید API را از ربات، بخش «🤝 نمایندگی ← 🔑 API و اتصال» بسازید. هر کاری که در ربات انجام میدهید (خرید سرور، روشن/خاموش، نصب مجدد، حذف، تیکت) از اینجا هم ممکن است و تخفیف نمایندگی شما خودکار اعمال میشود.
Authentication
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
{"data": …}. Error: {"error": {"code": "…", "message": "…"}} with an HTTP status.
| Status | Codes |
|---|---|
| 400 | missing_fields, invalid_billing, invalid_action, idempotency_key_required, invalid_json |
| 401 / 403 | unauthorized, 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) |
| 402 | insufficient_balance (top up the wallet in the bot) |
| 404 | datacenter_not_found, location_not_found, plan_not_found, image_not_found, server_not_found |
| 409 | plan_unavailable, order_in_progress, server_suspended, traffic_exhausted, reinstall_unavailable |
| 422 | idempotency_conflict |
| 429 | rate_limited, creation_limit, too_many_attempts (see Retry-After) |
| 502 / 503 | provider_failed (nothing charged), rate_unavailable, api_disabled |
Account
/v1/meWallet balance (toman and USD), reseller tier, discount and 30-day sales.
/v1/transactions?limit=50Latest wallet transactions (max 200).
Catalog
/v1/datacentersDatacenters you can order from, with the billing periods they offer.
/v1/datacenters/{datacenter}/locationsLocations in stock.
/v1/datacenters/{datacenter}/plans?location=…&billing=monthlyPlans with your price after your reseller discount (USD and toman) for one period. billing: hourly, weekly or monthly.
/v1/datacenters/{datacenter}/images?location=…Operating system images.
/v1/quotePrice of one order without buying.
{"datacenter":"hetzner","location":"hel1","plan":"cpx12","billing":"monthly"}Servers
/v1/serversOrder 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"}'/v1/serversYour servers (active, pending, suspended…). Filter with ?status=.
/v1/servers/{id}?live=1One server with IP, IPv6, root password and renewal price. live=1 also asks the datacenter for power state and traffic.
/v1/servers/{id}/powerStart, stop or reboot.
{"action":"reboot"}/v1/servers/{id}/reinstallReinstall with another image (erases the disk). Returns the new password when it changes.
{"image":"debian-13"}/v1/servers/{id}Delete the server now. Some datacenters charge a small deletion fee (returned as feeToman).
Support
/v1/ticketsYour tickets.
/v1/ticketsOpen a ticket.
{"subject":"Network issue","message":"…"}/v1/tickets/{id}A ticket with its messages.
/v1/tickets/{id}/messagesReply to a ticket.
{"message":"…"}Webhooks
https:// URL (bot: 🔑 API → 🔔 وبهوک, or the endpoints below) and your system receives a POST for every event, signed with your webhook secret.
| Event | When |
|---|---|
| server.created | An order was placed (bot or API). Includes the root password. |
| server.ready | The server is running with its IP. Includes IPv4, IPv6 and root password. |
| server.suspended / server.resumed | Suspended for an unpaid renewal / renewed and running again. |
| server.deleted | reason: customer, api or expired. |
| server.traffic_low / _exhausted / _restored | Traffic quota warnings; exhausted servers are turned off, never deleted. |
| balance.low | Wallet will run out within 48 h (balanceToman, hoursLeft). |
| ticket.replied | Support answered one of your tickets. |
| ping | Test event. |
{"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
/v1/webhookYour webhook URL, event list and the last 20 deliveries.
/v1/webhookSet the URL. The secret is returned the first time only.
{"url":"https://shop.example.com/hooks/greenvps"}/v1/webhook/testSend a ping now and get the result.
/v1/webhook/rotateNew signing secret (the old one stops working).
/v1/webhookRemove the webhook.
Datacenters available through the API
Questions? Open a ticket in the bot or via POST /v1/tickets.