{"id":43001293,"url":"https://github.com/derrickobedgiu1/hostinger-php-sdk","last_synced_at":"2026-01-31T04:07:21.607Z","repository":{"id":285411267,"uuid":"956008290","full_name":"derrickobedgiu1/hostinger-php-sdk","owner":"derrickobedgiu1","description":"A complete PHP SDK for interacting with the Hostinger API.","archived":false,"fork":false,"pushed_at":"2025-06-24T10:30:48.000Z","size":161,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-27T14:52:51.970Z","etag":null,"topics":["api","client","hostinger","hostinger-api","hostinger-client","hostinger-php","hostinger-sdk","hostinger-vps","sdk"],"latest_commit_sha":null,"homepage":"https://developers.hostinger.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derrickobedgiu1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-27T14:51:19.000Z","updated_at":"2025-06-24T10:29:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"afecad96-eb54-4a45-ae7d-0f01c9274f8a","html_url":"https://github.com/derrickobedgiu1/hostinger-php-sdk","commit_stats":null,"previous_names":["derrickobedgiu1/hostinger-php-sdk"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/derrickobedgiu1/hostinger-php-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickobedgiu1%2Fhostinger-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickobedgiu1%2Fhostinger-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickobedgiu1%2Fhostinger-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickobedgiu1%2Fhostinger-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derrickobedgiu1","download_url":"https://codeload.github.com/derrickobedgiu1/hostinger-php-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickobedgiu1%2Fhostinger-php-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28928835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T04:05:25.756Z","status":"ssl_error","status_checked_at":"2026-01-31T04:02:35.005Z","response_time":128,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","client","hostinger","hostinger-api","hostinger-client","hostinger-php","hostinger-sdk","hostinger-vps","sdk"],"created_at":"2026-01-31T04:07:20.663Z","updated_at":"2026-01-31T04:07:21.597Z","avatar_url":"https://github.com/derrickobedgiu1.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Hostinger Datacenter Cover](https://www.hostinger.com/blog/wp-content/uploads/sites/4/2021/12/data-centers-expansions-engineering-copy.jpg)](https://hostinger.com?REFERRALCODE=derrick)\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/derrickob/hostinger-php-sdk.svg)](https://packagist.org/packages/derrickob/hostinger-php-sdk)\n[![Tests](https://github.com/derrickobedgiu1/hostinger-php-sdk/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/derrickobedgiu1/hostinger-php-sdk/actions/workflows/tests.yml)\n[![Code Style](https://img.shields.io/badge/code%20style-PSR--12-orange.svg)](https://www.php-fig.org/psr/psr-12/)\n[![Static Analysis](https://img.shields.io/badge/static%20analysis-PHPStan-brightgreen.svg)](https://phpstan.org/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)\n[![License](https://img.shields.io/github/license/derrickobedgiu1/hostinger-php-sdk)](https://github.com/derrickobedgiu1/hostinger-php-sdk?tab=MIT-1-ov-file)\n\nA complete PHP SDK for interacting with the Hostinger API, allowing you to programmatically manage your Hostinger resources including VPS, domains, billing, and more.\n\n\u003c!-- TOC --\u003e\n  * [Don't Have a Hostinger Account?](#dont-have-a-hostinger-account)\n  * [Installation](#installation)\n  * [API Token](#api-token)\n  * [Usage](#usage)\n    * [Initialize the Client](#initialize-the-client)\n    * [Handle Errors](#handle-errors)\n  * [Domains](#domains)\n    * [Availability](#availability)\n      * [Check Domain Availability](#check-domain-availability)\n    * [Forwarding](#forwarding)\n      * [Get Forwarding Data](#get-forwarding-data)\n      * [Delete Forwarding Data](#delete-forwarding-data)\n      * [Create Forwarding Data](#create-forwarding-data)\n    * [Portfolio](#portfolio)\n      * [Enable Domain Lock](#enable-domain-lock)\n      * [Disable Domain Lock](#disable-domain-lock)\n      * [Get Domain](#get-domain)\n      * [Get Domain List](#get-domain-list)\n      * [Purchase New Domain](#purchase-new-domain)\n      * [Enable Privacy Protection](#enable-privacy-protection)\n      * [Disable Privacy Protection](#disable-privacy-protection)\n      * [Update Nameservers](#update-nameservers)\n    * [WHOIS](#whois)\n      * [Get WHOIS Profile List](#get-whois-profile-list)\n      * [Create WHOIS Profile](#create-whois-profile)\n      * [Get WHOIS Profile](#get-whois-profile)\n      * [Delete WHOIS Profile](#delete-whois-profile)\n      * [Get WHOIS Profile Usage](#get-whois-profile-usage)\n  * [DNS](#dns)\n    * [Snapshot](#snapshot)\n      * [Get Snapshot](#get-snapshot)\n      * [Restore Snapshot](#restore-snapshot)\n      * [Get Snapshot List](#get-snapshot-list)\n    * [Zone](#zone)\n      * [Get Records](#get-records)\n      * [Update Zone Records](#update-zone-records)\n      * [Delete Zone Records](#delete-zone-records)\n      * [Validate Zone Records](#validate-zone-records)\n      * [Reset Zone Records](#reset-zone-records)\n  * [Billing](#billing)\n    * [Catalog](#catalog)\n      * [Get Catalog Item List](#get-catalog-item-list)\n    * [Orders](#orders)\n      * [Create New Service Order](#create-new-service-order)\n    * [Payment Methods](#payment-methods)\n      * [Set Default Payment Method](#set-default-payment-method)\n      * [Delete Payment Method](#delete-payment-method)\n      * [Get Payment Method List](#get-payment-method-list)\n    * [Subscriptions](#subscriptions)\n      * [Cancel Subscription](#cancel-subscription)\n      * [Get Subscription List](#get-subscription-list)\n  * [VPS](#vps)\n    * [Actions](#actions)\n      * [Get Action](#get-action)\n      * [Get Action List](#get-action-list)\n    * [Backups](#backups)\n      * [Delete Backup](#delete-backup)\n      * [Get Backup List](#get-backup-list)\n      * [Restore Backup](#restore-backup)\n    * [Data Centers](#data-centers)\n      * [Get Data Centers List](#get-data-centers-list)\n    * [PTR Records](#ptr-records)\n      * [Create PTR Record](#create-ptr-record)\n      * [Delete PTR Record](#delete-ptr-record)\n    * [Firewall](#firewall)\n      * [Activate Firewall](#activate-firewall)\n      * [Deactivate Firewall](#deactivate-firewall)\n      * [Get Firewall](#get-firewall)\n      * [Delete Firewall](#delete-firewall)\n      * [Get Firewall List](#get-firewall-list)\n      * [Create New Firewall](#create-new-firewall)\n      * [Update Firewall Rule](#update-firewall-rule)\n      * [Delete Firewall Rule](#delete-firewall-rule)\n      * [Create Firewall Rule](#create-firewall-rule)\n      * [Sync Firewall](#sync-firewall)\n    * [Malware Scanner](#malware-scanner)\n      * [Get Scan Metrics](#get-scan-metrics)\n      * [Install Monarx](#install-monarx)\n      * [Uninstall Monarx](#uninstall-monarx)\n    * [OS Templates](#os-templates)\n      * [Get Template](#get-template)\n      * [Get Template List](#get-template-list)\n    * [Post-Install Scripts](#post-install-scripts)\n      * [Get Post-Install Script](#get-post-install-script)\n      * [Update Post-Install Script](#update-post-install-script)\n      * [Delete a Post-Install Script](#delete-a-post-install-script)\n      * [Get Post-Install Script List](#get-post-install-script-list)\n      * [Create Post-Install Script](#create-post-install-script)\n    * [Public Keys](#public-keys)\n      * [Attach Public Key](#attach-public-key)\n      * [Delete a Public Key](#delete-a-public-key)\n      * [Get Public Key List](#get-public-key-list)\n      * [Create New Public Key](#create-new-public-key)\n    * [Recovery](#recovery)\n      * [Start Recovery Mode](#start-recovery-mode)\n      * [Stop Recovery Mode](#stop-recovery-mode)\n    * [Snapshots](#snapshots)\n      * [Get Snapshot](#get-snapshot-1)\n      * [Create Snapshot](#create-snapshot)\n      * [Delete Snapshot](#delete-snapshot)\n      * [Restore Snapshot](#restore-snapshot-1)\n    * [Virtual Machine](#virtual-machine)\n      * [Get Attached Public Keys](#get-attached-public-keys)\n      * [Set Hostname](#set-hostname)\n      * [Reset Hostname](#reset-hostname)\n      * [Get Virtual Machine](#get-virtual-machine)\n      * [Get Virtual Machine List](#get-virtual-machine-list)\n      * [Purchase New Virtual Machine](#purchase-new-virtual-machine)\n      * [Get Metrics](#get-metrics)\n      * [Set Nameservers](#set-nameservers)\n      * [Set Panel Password](#set-panel-password)\n      * [Recreate Virtual Machine](#recreate-virtual-machine)\n      * [Restart Virtual Machine](#restart-virtual-machine)\n      * [Set Root Password](#set-root-password)\n      * [Setup New Virtual Machine](#setup-new-virtual-machine)\n      * [Start Virtual Machine](#start-virtual-machine)\n      * [Stop Virtual Machine](#stop-virtual-machine)\n  * [Testing](#testing)\n  * [Contributing](#contributing)\n  * [Credits](#credits)\n  * [License](#license)\n\u003c!-- TOC --\u003e\n\n## Don't Have a Hostinger Account?\n[Hostinger](https://hostinger.com?REFERRALCODE=derrick) offers affordable web hosting and VPS solutions with excellent performance, uptime and has an amazing support team. If you don't have a Hostinger account yet, you can sign up using [this referral link](https://hostinger.com?REFERRALCODE=derrick) to get 20% additional discount on top of Hostinger's regular discounts.\n\n***Disclaimer**: If you use the referral link, I may earn a commission from Hostinger and you'll get 20% discount on your purchase.*\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require derrickob/hostinger-php-sdk\n```\n\n## API Token\n\nTo use this SDK, you'll need an API token from Hostinger. You can create one from the [Account page](https://hpanel.hostinger.com/profile/api) of the Hostinger Panel.\n\n## Usage\n\n### Initialize the Client\n\n```php\nuse DerrickOb\\HostingerApi\\Hostinger;\n\n// Initialize with just an API token\n$hostinger = new Hostinger('your-api-token');\n\n// Or with additional options\n$hostinger = new Hostinger('your-api-token', [\n    'timeout' =\u003e 30,                                 // Request timeout in seconds\n    'base_url' =\u003e 'https://developers.hostinger.com', // API base URL\n    'api_version' =\u003e 'v1',                           // API version\n]);\n```\n\n### Handle Errors\n\nAll API errors are converted to exceptions:\n\n```php\nuse DerrickOb\\HostingerApi\\Exceptions\\ApiException;\nuse DerrickOb\\HostingerApi\\Exceptions\\AuthenticationException;\nuse DerrickOb\\HostingerApi\\Exceptions\\ValidationException;\nuse DerrickOb\\HostingerApi\\Exceptions\\RateLimitException;\n\ntry {\n    $catalogs = $hostinger-\u003ebilling()-\u003ecatalog()-\u003elist();\n} catch (AuthenticationException $e) {\n    // Handle authentication errors (401)\n    $message = $e-\u003egetMessage();\n} catch (ValidationException $e) {\n    // Handle validation errors (422)\n    $message = $e-\u003egetMessage();\n    // Get detailed validation errors\n    $errors = $e-\u003egetErrors(); // ['field_1' =\u003e ['Error message 1', ...], ...]\n} catch (RateLimitException $e) {\n    // Handle rate limit errors (429)\n    $message = $e-\u003egetMessage();\n} catch (ApiException $e) {\n    // Handle any other API errors (4xx, 5xx)\n    $message = $e-\u003egetMessage();\n    $code = $e-\u003egetCode();\n\n    // Get correlation ID for support\n    $correlationId = $e-\u003egetCorrelationId();\n}\n```\n\n## Domains\n\nAccess domain-related features via `$hostinger-\u003edomains()`.\n\n### Availability\n\nAccess domain availability checks via `$hostinger-\u003edomains()-\u003eavailability()`.\n\n#### Check Domain Availability\n\nChecks the availability of a domain name across multiple TLDs. Can optionally return alternative suggestions.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-availability/POST/api/domains/v1/availability)\n\n```php\n$data = [\n    'domain' =\u003e 'mydomain',\n    'tlds' =\u003e ['com', 'net', 'org'],\n    'with_alternatives' =\u003e false, // Optional: Set to true for suggestions\n];\n\n$results = $hostinger-\u003edomains()-\u003eavailability()-\u003echeck($data);\n\nforeach ($results as $result) {\n    $result-\u003edomain; // mydomain.com\n    $result-\u003eis_available; // true\n    $result-\u003eis_alternative; // false\n    $result-\u003erestriction; // null\n\n    $result-\u003etoArray(); // ['domain' =\u003e 'mydomain.com', 'is_available' =\u003e true, ...]\n}\n```\n\n### Forwarding\n\nManage domain forwarding via `$hostinger-\u003edomains()-\u003eforwarding()`.\n\n#### Get Forwarding Data\n\nRetrieves domain forwarding data.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-forwarding/GET/api/domains/v1/forwarding/{domain})\n\n```php\n$domainName = \"mydomain.tld\";\n$forwarding = $hostinger-\u003edomains()-\u003eforwarding()-\u003eget($domainName);\n\n$forwarding-\u003edomain; // mydomain.tld\n$forwarding-\u003eredirect_type; // 301\n$forwarding-\u003eredirect_url; // https://forward.to.my.url\n$forwarding-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$forwarding-\u003eupdated_at?-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n\n$forwarding-\u003etoArray(); // ['domain' =\u003e 'mydomain.tld', 'redirect_type' =\u003e '301', ...]\n```\n\n#### Delete Forwarding Data\n\nDeletes domain forwarding data.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-forwarding/DELETE/api/domains/v1/forwarding/{domain})\n\n```php\n$domainName = \"mydomain.tld\";\n$response = $hostinger-\u003edomains()-\u003eforwarding()-\u003edelete($domainName);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Create Forwarding Data\n\nCreates domain forwarding data.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-forwarding/POST/api/domains/v1/forwarding)\n\n```php\n$data = [\n    'domain' =\u003e 'mydomain.tld',\n    'redirect_type' =\u003e '301', // '301' (Permanent) or '302' (Temporary)\n    'redirect_url' =\u003e 'https://forward.to.my.url',\n];\n\n$forwarding = $hostinger-\u003edomains()-\u003eforwarding()-\u003ecreate($data);\n\n$forwarding-\u003edomain; // mydomain.tld\n$forwarding-\u003eredirect_type; // 301\n$forwarding-\u003eredirect_url; // https://forward.to.my.url\n$forwarding-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$forwarding-\u003eupdated_at?-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n\n$forwarding-\u003etoArray(); // ['domain' =\u003e 'mydomain.tld', 'redirect_type' =\u003e '301', ...]\n```\n\n### Portfolio\n\nManage your domain portfolio via `$hostinger-\u003edomains()-\u003eportfolio()`.\n\n#### Enable Domain Lock\n\nEnables the transfer lock for a domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/PUT/api/domains/v1/portfolio/{domain}/domain-lock)\n\n```php\n$domainName = \"mydomain.tld\";\n$response = $hostinger-\u003edomains()-\u003eportfolio()-\u003eenableDomainLock($domainName);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Disable Domain Lock\n\nDisables the transfer lock for a domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/DELETE/api/domains/v1/portfolio/{domain}/domain-lock)\n\n```php\n$domainName = \"mydomain.tld\";\n$response = $hostinger-\u003edomains()-\u003eportfolio()-\u003edisableDomainLock($domainName);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Domain\n\nRetrieves extended details for a specific domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/GET/api/domains/v1/portfolio/{domain})\n\n```php\n$domainName = \"mydomain.tld\";\n$domainDetails = $hostinger-\u003edomains()-\u003eportfolio()-\u003eget($domainName);\n\n$domainDetails-\u003edomain; // mydomain.tld\n$domainDetails-\u003estatus-\u003evalue; // active\n$domainDetails-\u003emessage; // null\n$domainDetails-\u003eis_privacy_protection_allowed; // true\n$domainDetails-\u003eis_privacy_protected; // false\n$domainDetails-\u003eis_lockable; // true\n$domainDetails-\u003eis_locked; // true\n$domainDetails-\u003ename_servers; // ['ns1' =\u003e 'ns1.example.tld', 'ns2' =\u003e 'ns2.example.tld']\n$domainDetails-\u003echild_name_servers; // null or array\n$domainDetails-\u003edomain_contacts; // ['admin_id' =\u003e 114698, ...]\n$domainDetails-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$domainDetails-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n$domainDetails-\u003esixty_days_lock_expires_at?-\u003eformat('Y-m-d H:i:s'); // 2025-04-26 11:54:22\n$domainDetails-\u003eregistered_at?-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$domainDetails-\u003eexpires_at?-\u003eformat('Y-m-d H:i:s'); // 2026-02-27 11:54:22\n\n$domainDetails-\u003etoArray(); // ['domain' =\u003e 'mydomain.tld', 'status' =\u003e 'active', ...]\n```\n\n#### Get Domain List\n\nRetrieves a list of all domains associated with your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/GET/api/domains/v1/portfolio)\n\n```php\n$domains = $hostinger-\u003edomains()-\u003eportfolio()-\u003elist();\n\nforeach ($domains as $domain) {\n    $domain-\u003eid; // 13632\n    $domain-\u003edomain; // mydomain.tld or null\n    $domain-\u003etype-\u003evalue; // domain or free_domain\n    $domain-\u003estatus-\u003evalue; // active, pending_setup, expired, requested, pending_verification\n    $domain-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n    $domain-\u003eexpires_at?-\u003eformat('Y-m-d H:i:s'); // 2026-02-27 11:54:22\n\n    $domain-\u003etoArray(); // ['id' =\u003e 13632, 'domain' =\u003e 'mydomain.tld', ...]\n}\n```\n\n#### Purchase New Domain\n\nPurchases and registers a new domain name.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/POST/api/domains/v1/portfolio)\n\n```php\n$data = [\n    'domain' =\u003e 'mynewdomain.tld',\n    'item_id' =\u003e 'hostingercom-domain-tld-usd-1y', // Price Item ID from Catalog\n    'payment_method_id' =\u003e 1327362, // Optional: Uses default if omitted\n    'domain_contacts' =\u003e [ // Optional: Uses default TLD contacts if omitted\n        'owner_id' =\u003e 741288,\n        'admin_id' =\u003e 546123,\n        'billing_id' =\u003e 741288,\n        'tech_id' =\u003e 741288,\n    ],\n    'additional_details' =\u003e [], // optional\n    'coupons' =\u003e ['Coupon 3'], // optional: discount coupon codes\n];\n\n$order = $hostinger-\u003edomains()-\u003eportfolio()-\u003epurchase($data);\n\n$order-\u003eid; // 2957086\n$order-\u003estatus-\u003evalue; // completed\n$order-\u003ecurrency; // USD\n$order-\u003esubtotal; // 899 (cents)\n$order-\u003etotal; // 1088 (cents)\n\n$order-\u003ebilling_address-\u003efirst_name; // John\n$order-\u003ebilling_address-\u003elast_name; // Doe\n$order-\u003ebilling_address-\u003ecompany; // null\n$order-\u003ebilling_address-\u003eaddress_1; // null\n$order-\u003ebilling_address-\u003eaddress_2; // null\n$order-\u003ebilling_address-\u003ecity; // null\n$order-\u003ebilling_address-\u003estate; // null\n$order-\u003ebilling_address-\u003ezip; // null\n$order-\u003ebilling_address-\u003ecountry; // NL\n$order-\u003ebilling_address-\u003ephone; // null\n$order-\u003ebilling_address-\u003eemail; // john@doe.tld\n\n$order-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$order-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n\n$order-\u003etoArray(); // ['id' =\u003e 2957086, 'subscription_id' =\u003e '...', 'status' =\u003e 'completed', 'billing_address' =\u003e [...], ...]\n```\n\n#### Enable Privacy Protection\n\nEnables WHOIS privacy protection for a domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/PUT/api/domains/v1/portfolio/{domain}/privacy-protection)\n\n```php\n$domainName = \"mydomain.tld\";\n$response = $hostinger-\u003edomains()-\u003eportfolio()-\u003eenablePrivacyProtection($domainName);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Disable Privacy Protection\n\nDisables WHOIS privacy protection for a domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/DELETE/api/domains/v1/portfolio/{domain}/privacy-protection)\n\n```php\n$domainName = \"mydomain.tld\";\n$response = $hostinger-\u003edomains()-\u003eportfolio()-\u003edisablePrivacyProtection($domainName);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Update Nameservers\n\nUpdates the nameservers for a domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-portfolio/PUT/api/domains/v1/portfolio/{domain}/nameservers)\n\n```php\n$domainName = \"mydomain.tld\";\n$data = [\n    'ns1' =\u003e 'ns1.some-nameserver.tld',\n    'ns2' =\u003e 'ns2.some-nameserver.tld',\n    'ns3' =\u003e 'ns3.some-nameserver.tld', // optional\n    'ns4' =\u003e 'ns4.some-nameserver.tld', // optional\n];\n\n$response = $hostinger-\u003edomains()-\u003eportfolio()-\u003eupdateNameservers($domainName, $data);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n### WHOIS\n\nManage WHOIS contact profiles via `$hostinger-\u003edomains()-\u003ewhois()`.\n\n#### Get WHOIS Profile List\n\nRetrieves a list of WHOIS contact profiles. Can be filtered by TLD.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-whois/GET/api/domains/v1/whois)\n\n```php\n// Get all profiles\n$profiles = $hostinger-\u003edomains()-\u003ewhois()-\u003elist();\n\n// Get profiles for '.com' TLD\n$comProfiles = $hostinger-\u003edomains()-\u003ewhois()-\u003elist(['tld' =\u003e 'com']);\n\nforeach ($profiles as $profile) {\n    $profile-\u003eid; // 746263\n    $profile-\u003etld; // com\n    $profile-\u003ecountry; // NL\n    $profile-\u003eentity_type; // individual\n    $profile-\u003ewhois_details; // ['first_name' =\u003e 'John', ...]\n    $profile-\u003etld_details; // null or array\n    $profile-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n    $profile-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n\n    $profile-\u003etoArray(); // ['id' =\u003e 746263, 'tld' =\u003e 'com', ...]\n}\n```\n\n#### Create WHOIS Profile\n\nCreates a new WHOIS contact profile.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-whois/POST/api/domains/v1/whois)\n\n```php\n$data = [\n    'tld' =\u003e 'com',\n    'entity_type' =\u003e 'individual', // or 'organization'\n    'country' =\u003e 'US', // ISO 3166 2-letter code\n    'whois_details' =\u003e [\n        'first_name' =\u003e 'Jane',\n        'last_name' =\u003e 'Doe',\n        'email' =\u003e 'jane@doe.tld',\n        'phone' =\u003e '+1.1234567890',\n        'address1' =\u003e '123 Main St',\n        'city' =\u003e 'Anytown',\n        'state' =\u003e 'CA',\n        'zip' =\u003e '90210',\n        // ...\n    ],\n    'tld_details' =\u003e [], // optional\n];\n\n$newProfile = $hostinger-\u003edomains()-\u003ewhois()-\u003ecreate($data);\n\n$newProfile-\u003eid; // 746264\n$newProfile-\u003etld; // com\n$newProfile-\u003ecountry; // US\n$newProfile-\u003eentity_type; // individual\n$newProfile-\u003ewhois_details; // ['first_name' =\u003e 'Jane', ...]\n$newProfile-\u003etld_details; // []\n$newProfile-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-04-01 10:00:00\n$newProfile-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-04-01 10:00:00\n\n$newProfile-\u003etoArray();\n```\n\n#### Get WHOIS Profile\n\nRetrieves details for a specific WHOIS profile.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-whois/GET/api/domains/v1/whois/{whoisId})\n\n```php\n$whoisId = 746263;\n$profile = $hostinger-\u003edomains()-\u003ewhois()-\u003eget($whoisId);\n\n$profile-\u003eid; // 746263\n$profile-\u003etld; // com\n$profile-\u003ecountry; // NL\n$profile-\u003eentity_type; // individual\n$profile-\u003ewhois_details; // ['first_name' =\u003e 'John', ...]\n$profile-\u003etld_details; // null\n$profile-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$profile-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n\n$profile-\u003etoArray();\n```\n\n#### Delete WHOIS Profile\n\nDeletes a WHOIS contact profile.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-whois/DELETE/api/domains/v1/whois/{whoisId})\n\n```php\n$whoisId = 746263;\n$response = $hostinger-\u003edomains()-\u003ewhois()-\u003edelete($whoisId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get WHOIS Profile Usage\n\nRetrieves a list of domains currently using a specific WHOIS profile.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/domains-whois/GET/api/domains/v1/whois/{whoisId}/usage)\n\n```php\n$whoisId = 746263;\n$usage = $hostinger-\u003edomains()-\u003ewhois()-\u003egetUsage($whoisId);\n\n$usage-\u003edomains; // ['mydomain1.tld', 'mydomain2.tld']\n\n$usage-\u003etoArray(); // ['mydomain1.tld', 'mydomain2.tld']\n```\n\n## DNS\n\nAccess DNS features via `$hostinger-\u003edns()`.\n\n### Snapshot\n\nManage DNS snapshots via `$hostinger-\u003edns()-\u003esnapshots()`.\n\n#### Get Snapshot\n\nRetrieves a specific DNS snapshot with its content.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-snapshot/GET/api/dns/v1/snapshots/{domain}/{snapshotId})\n\n```php\n$domainName = \"mydomain.tld\";\n$snapshotId = 53513053;\n$snapshot = $hostinger-\u003edns()-\u003esnapshots()-\u003eget($domainName, $snapshotId);\n\n$snapshot-\u003eid; // 53513053\n$snapshot-\u003ereason; // Zone records update request\n$snapshot-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n\nforeach ($snapshot-\u003esnapshot as $recordGroup) {\n    $recordGroup-\u003ename; // www\n    $recordGroup-\u003etype; // A\n    $recordGroup-\u003ettl; // 14400\n    foreach ($recordGroup-\u003erecords as $recordValue) {\n         $recordValue-\u003econtent; // mydomain.tld.\n         $recordValue-\u003eis_disabled; // false\n    }\n}\n\n$snapshot-\u003etoArray(); // ['id' =\u003e 53513053, 'reason' =\u003e '...', 'snapshot' =\u003e [[...], ...], 'created_at' =\u003e ...]\n```\n\n#### Restore Snapshot\n\nRestores a domain's DNS zone to the state captured in a selected snapshot.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-snapshot/POST/api/dns/v1/snapshots/{domain}/{snapshotId}/restore)\n\n```php\n$domainName = \"mydomain.tld\";\n$snapshotId = 53513053;\n$response = $hostinger-\u003edns()-\u003esnapshots()-\u003erestore($domainName, $snapshotId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Snapshot List\n\nRetrieves a list of DNS snapshots for a specific domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-snapshot/GET/api/dns/v1/snapshots/{domain})\n\n```php\n$domainName = \"mydomain.tld\";\n$snapshots = $hostinger-\u003edns()-\u003esnapshots()-\u003elist($domainName);\n\nforeach ($snapshots as $snapshot) {\n    $snapshot-\u003eid; // 5341\n    $snapshot-\u003ereason; // Zone records update request\n    $snapshot-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n\n    $snapshot-\u003etoArray(); // ['id' =\u003e 5341, 'reason' =\u003e '...', 'created_at' =\u003e ...]\n}\n```\n\n### Zone\n\nManage DNS zones and records via `$hostinger-\u003edns()-\u003ezones()`.\n\n#### Get Records\n\nRetrieves all DNS records for a specific domain.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-zone/GET/api/dns/v1/zones/{domain})\n\n```php\n$domainName = \"mydomain.tld\";\n$recordGroups = $hostinger-\u003edns()-\u003ezones()-\u003egetRecords($domainName);\n\nforeach ($recordGroups as $group) {\n    $group-\u003ename; // www\n    $group-\u003etype; // A\n    $group-\u003ettl; // 14400\n\n    foreach ($group-\u003erecords as $recordValue) {\n        $recordValue-\u003econtent; // mydomain.tld.\n        $recordValue-\u003eis_disabled; // false\n        $recordValue-\u003etoArray(); // ['content' =\u003e '...', 'is_disabled' =\u003e false]\n    }\n\n    $group-\u003etoArray(); // ['name' =\u003e 'www', 'records' =\u003e [[...], ...], 'ttl' =\u003e 14400, 'type' =\u003e 'A']\n}\n```\n\n#### Update Zone Records\n\nUpdates DNS records for the selected domain. Using `overwrite = true` (default) replaces records; otherwise, appends or updates TTLs.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-zone/PUT/api/dns/v1/zones/{domain})\n\n```php\n$domainName = \"mydomain.tld\";\n$data = [\n    'overwrite' =\u003e true, // Optional, default: true\n    'zone' =\u003e [\n        [\n            'name' =\u003e 'www', // Use '@' for root domain\n            'records' =\u003e [['content' =\u003e '192.0.2.1']], // Array of record values\n            'ttl' =\u003e 3600, // Optional, default TTL applies if omitted\n            'type' =\u003e 'A', // A, AAAA, CNAME, ALIAS, MX, TXT, NS, SOA, SRV, CAA\n        ],\n        [\n            'name' =\u003e 'www',\n            'records' =\u003e [['content' =\u003e 'example.com.']],\n            'type' =\u003e 'CNAME',\n        ],\n    ],\n];\n\n$response = $hostinger-\u003edns()-\u003ezones()-\u003eupdate($domainName, $data);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Delete Zone Records\n\nDeletes specific DNS records based on name and type filters.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-zone/DELETE/api/dns/v1/zones/{domain})\n\n```php\n$domainName = \"mydomain.tld\";\n$data = [\n    'filters' =\u003e [\n        ['name' =\u003e '@', 'type' =\u003e 'A'], // Delete all A records for the root domain\n        ['name' =\u003e 'www', 'type' =\u003e 'CNAME'], // Delete www CNAME record\n    ],\n];\n\n$response = $hostinger-\u003edns()-\u003ezones()-\u003edelete($domainName, $data);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Validate Zone Records\n\nValidates DNS records before attempting an update. Throws a `ValidationException` if invalid.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-zone/POST/api/dns/v1/zones/{domain}/validate)\n\n```php\n$domainName = \"mydomain.tld\";\n$data = [\n    'zone' =\u003e [\n        [\n            'name' =\u003e 'valid',\n            'records' =\u003e [['content' =\u003e '192.0.2.10']],\n            'type' =\u003e 'A',\n        ]\n    ],\n];\n\ntry {\n    $response = $hostinger-\u003edns()-\u003ezones()-\u003evalidate($domainName, $data);\n    $response-\u003emessage;\n    $response-\u003etoArray(); // ['message' =\u003e '...']\n} catch (\\DerrickOb\\HostingerApi\\Exceptions\\ValidationException $e) {\n    // Handle validation failure\n    echo \"Validation failed: \" . $e-\u003egetMessage() . \"\\n\";\n    print_r($e-\u003egetErrors());\n}\n```\n\n#### Reset Zone Records\n\nResets the DNS zone for a domain to the default Hostinger records.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/dns-zone/POST/api/dns/v1/zones/{domain}/reset)\n\n```php\n$domainName = \"mydomain.tld\";\n\n// Reset with defaults (sync=true, reset_email_records=true)\n$response = $hostinger-\u003edns()-\u003ezones()-\u003ereset($domainName);\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n\n// Reset with options\n$data = [\n    'sync' =\u003e true, // Optional\n    'reset_email_records' =\u003e false, // Optional\n    'whitelisted_record_types' =\u003e ['MX', 'TXT'], // Optional. Specify record types not to reset.\n];\n$response = $hostinger-\u003edns()-\u003ezones()-\u003ereset($domainName, $data);\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n\n```\n\n## Billing\n\nAccess billing features via `$hostinger-\u003ebilling()`.\n\n### Catalog\n\nAccess the service catalog via `$hostinger-\u003ebilling()-\u003ecatalog()`.\n\n#### Get Catalog Item List\n\nRetrieves a list of catalog items available for order. Prices are in cents. Can be filtered.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/billing-catalog/GET/api/billing/v1/catalog)\n\n```php\n// Get all items\n$catalogs = $hostinger-\u003ebilling()-\u003ecatalog()-\u003elist();\n\n// Get only VPS items\n$vpsCatalogs = $hostinger-\u003ebilling()-\u003ecatalog()-\u003elist(['category' =\u003e 'VPS']);\n\n// Get only .COM domain items\n$comCatalogs = $hostinger-\u003ebilling()-\u003ecatalog()-\u003elist(['name' =\u003e '.COM*']);\n\nforeach ($catalogs as $catalog) {\n    $catalog-\u003eid; // hostingercom-vps-kvm2\n    $catalog-\u003ename; // KVM 2\n    $catalog-\u003ecategory; // VPS\n\n    foreach ($catalog-\u003eprices as $price) {\n        $price-\u003eid; // hostingercom-vps-kvm2-usd-1m\n        $price-\u003ename; // KVM 2 (billed every month)\n        $price-\u003ecurrency; // USD\n        $price-\u003eprice; // 1799 (cents)\n        $price-\u003efirst_period_price; // 899 (cents)\n        $price-\u003eperiod; // 1\n        $price-\u003eperiod_unit-\u003evalue; // month, year, day, week, none\n\n        $price-\u003etoArray(); // ['id' =\u003e '...', 'name' =\u003e '...', 'currency' =\u003e 'USD', ...]\n    }\n\n    $catalog-\u003etoArray(); // ['id' =\u003e '...', 'name' =\u003e 'KVM 2', 'category' =\u003e 'VPS', 'prices' =\u003e [[...], ...]]\n}\n```\n\n### Orders\n\nManage service orders via `$hostinger-\u003ebilling()-\u003eorders()`.\n\n#### Create New Service Order\n\nCreates a new service order. Requires a payment method ID and catalog item price IDs. Orders created via API are set for auto-renewal. Prices are in cents.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/billing-orders/POST/api/billing/v1/orders)\n\n```php\n$data = [\n    'payment_method_id' =\u003e 517244,\n    'items' =\u003e [\n        [\n            'item_id' =\u003e 'hostingercom-vps-kvm2-usd-1m', // Price ID from Catalog\n            'quantity' =\u003e 1,\n        ],\n    ],\n    'coupons' =\u003e ['Coupon 3'], // optional\n];\n\n$order = $hostinger-\u003ebilling()-\u003eorders()-\u003ecreate($data);\n\n$order-\u003eid; // 2957086\n$order-\u003esubscription_id; // Azz353Uhl1xC54pR0\n$order-\u003estatus-\u003evalue; // completed, pending, processing, failed, etc.\n$order-\u003ecurrency; // USD\n$order-\u003esubtotal; // 899 (cents)\n$order-\u003etotal; // 1088 (cents)\n\n$order-\u003ebilling_address-\u003efirst_name; // John\n$order-\u003ebilling_address-\u003elast_name; // Doe\n$order-\u003ebilling_address-\u003ecompany; // null\n$order-\u003ebilling_address-\u003eaddress_1; // null\n$order-\u003ebilling_address-\u003eaddress_2; // null\n$order-\u003ebilling_address-\u003ecity; // null\n$order-\u003ebilling_address-\u003estate; // null\n$order-\u003ebilling_address-\u003ezip; // null\n$order-\u003ebilling_address-\u003ecountry; // NL\n$order-\u003ebilling_address-\u003ephone; // null\n$order-\u003ebilling_address-\u003eemail; // john@doe.tld\n\n$order-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$order-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n\n$order-\u003etoArray(); // ['id' =\u003e 2957086, 'subscription_id' =\u003e '...', 'status' =\u003e 'completed', 'billing_address' =\u003e [...], ...]\n```\n\n### Payment Methods\n\nManage payment methods via `$hostinger-\u003ebilling()-\u003epaymentMethods()`.\n\n#### Set Default Payment Method\n\nSets a specific payment method as the default for your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/billing-payment-methods/POST/api/billing/v1/payment-methods/{paymentMethodId})\n\n```php\n$paymentMethodId = 9693613;\n$response = $hostinger-\u003ebilling()-\u003epaymentMethods()-\u003esetDefault($paymentMethodId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Delete Payment Method\n\nDeletes a payment method from your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/billing-payment-methods/DELETE/api/billing/v1/payment-methods/{paymentMethodId})\n\n```php\n$paymentMethodId = 9693613;\n$response = $hostinger-\u003ebilling()-\u003epaymentMethods()-\u003edelete($paymentMethodId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Payment Method List\n\nRetrieves available payment methods linked to your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/billing-payment-methods/GET/api/billing/v1/payment-methods)\n\n```php\n$paymentMethods = $hostinger-\u003ebilling()-\u003epaymentMethods()-\u003elist();\n\nforeach ($paymentMethods as $paymentMethod) {\n    $paymentMethod-\u003eid; // 6523\n    $paymentMethod-\u003ename; // Credit Card\n    $paymentMethod-\u003eidentifier; // 1234*****6464\n    $paymentMethod-\u003epayment_method-\u003evalue; // card, paypal, googlepay\n    $paymentMethod-\u003eis_default; // true\n    $paymentMethod-\u003eis_expired; // false\n    $paymentMethod-\u003eis_suspended; // false\n    $paymentMethod-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n    $paymentMethod-\u003eexpires_at?-\u003eformat('Y-m-d H:i:s'); // 2028-03-31 00:00:00\n\n    $paymentMethod-\u003etoArray(); // ['id' =\u003e 6523, 'name' =\u003e 'Credit Card', 'identifier' =\u003e '...', 'payment_method' =\u003e 'card', ...]\n}\n```\n\n### Subscriptions\n\nManage service subscriptions via `$hostinger-\u003ebilling()-\u003esubscriptions()`.\n\n#### Cancel Subscription\n\nCancels a subscription and stops further billing.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/billing-subscriptions/DELETE/api/billing/v1/subscriptions/{subscriptionId})\n\n```php\n$subscriptionId = \"Cxy353Uhl1xC54pG6\";\n\n// Cancel immediately with a reason\n$data = [\n    'reason_code' =\u003e 'other',\n    'cancel_option' =\u003e 'immediately',\n];\n$response = $hostinger-\u003ebilling()-\u003esubscriptions()-\u003ecancel($subscriptionId, $data);\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n\n\n// Cancel at the end of the term (default behavior if $data is empty or omitted)\n$response = $hostinger-\u003ebilling()-\u003esubscriptions()-\u003ecancel($subscriptionId);\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Subscription List\n\nRetrieves all subscriptions associated with your account. Prices are in cents.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/billing-subscriptions/GET/api/billing/v1/subscriptions)\n\n```php\n$subscriptions = $hostinger-\u003ebilling()-\u003esubscriptions()-\u003elist();\n\nforeach ($subscriptions as $subscription) {\n    $subscription-\u003eid; // Azz36nUfKX1S1MSF\n    $subscription-\u003ename; // KVM 1\n    $subscription-\u003estatus-\u003evalue; // active, paused, cancelled, not_renewing, transferred, in_trial, future\n    $subscription-\u003ebilling_period; // 1\n    $subscription-\u003ebilling_period_unit-\u003evalue; // day, week, month, year, none\n    $subscription-\u003ecurrency_code; // USD\n    $subscription-\u003etotal_price; // 1799 (cents)\n    $subscription-\u003erenewal_price; // 1799 (cents)\n    $subscription-\u003eis_auto_renewed; // true\n    $subscription-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n    $subscription-\u003eexpires_at?-\u003eformat('Y-m-d H:i:s'); // 2026-02-27 11:54:22\n    $subscription-\u003enext_billing_at?-\u003eformat('Y-m-d H:i:s'); // 2025-03-27 11:54:22\n\n    $subscription-\u003etoArray(); // ['id' =\u003e '...', 'name' =\u003e 'KVM 1', 'status' =\u003e 'active', 'is_auto_renewed' =\u003e true, ...]\n}\n```\n\n## VPS\n\nAccess Virtual Private Server features via `$hostinger-\u003evps()`.\n\n### Actions\n\nView VM action history via `$hostinger-\u003evps()-\u003eactions()`.\n\n#### Get Action\n\nRetrieves details for a specific action performed on a VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-actions/GET/api/vps/v1/virtual-machines/{virtualMachineId}/actions/{actionId})\n\n```php\n$virtualMachineId = 1268054;\n$actionId = 8123712;\n$action = $hostinger-\u003evps()-\u003eactions()-\u003eget($virtualMachineId, $actionId);\n\n$action-\u003eid; // 8123712\n$action-\u003ename; // action_name (e.g., start, stop, create_snapshot)\n$action-\u003estate-\u003evalue; // success, error, delayed, sent, created\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123712, 'name' =\u003e 'action_name', 'state' =\u003e 'success', ...]\n```\n\n#### Get Action List\n\nRetrieves a paginated list of actions performed on a specific VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-actions/GET/api/vps/v1/virtual-machines/{virtualMachineId}/actions)\n\n```php\n$virtualMachineId = 1268054;\n$actionsPage = $hostinger-\u003evps()-\u003eactions()-\u003elist($virtualMachineId, ['page' =\u003e 1]);\n\n// Access pagination metadata\n$actionsPage-\u003egetCurrentPage(); // 1\n$actionsPage-\u003egetPerPage(); // 15\n$actionsPage-\u003egetTotal(); // 100\n\nforeach ($actionsPage-\u003egetData() as $action) {\n    $action-\u003eid; // 8123712\n    $action-\u003ename; // action_name\n    $action-\u003estate-\u003evalue; // success\n    $action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n    $action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n    $action-\u003etoArray(); // ['id' =\u003e 8123712, 'name' =\u003e 'action_name', 'state' =\u003e 'success', ...]\n}\n\n$actionsPage-\u003etoArray(); // ['data' =\u003e [[...], ...], 'meta' =\u003e ['current_page' =\u003e 1, ...]]\n```\n\n### Backups\n\nManage VM backups via `$hostinger-\u003evps()-\u003ebackups()`.\n\n#### Delete Backup\n\nDeletes a specific backup.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-backups/DELETE/api/vps/v1/virtual-machines/{virtualMachineId}/backups/{backupId})\n\n```php\n$virtualMachineId = 1268054;\n$backupId = 8676502;\n$response = $hostinger-\u003evps()-\u003ebackups()-\u003edelete($virtualMachineId, $backupId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Backup List\n\nRetrieves a paginated list of backups for a specific virtual machine.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-backups/GET/api/vps/v1/virtual-machines/{virtualMachineId}/backups)\n\n```php\n$virtualMachineId = 1268054;\n$backupsPage = $hostinger-\u003evps()-\u003ebackups()-\u003elist($virtualMachineId, ['page' =\u003e 1]);\n\n// Access pagination metadata\n$backupsPage-\u003egetCurrentPage(); // 1\n$backupsPage-\u003egetPerPage(); // 15\n$backupsPage-\u003egetTotal(); // 100\n\nforeach ($backupsPage-\u003egetData() as $backup) {\n    $backup-\u003eid; // 325\n    $backup-\u003elocation; // nl-srv-openvzbackups\n    $backup-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n\n    $backup-\u003etoArray(); // ['id' =\u003e 325, 'location' =\u003e 'nl-srv-openvzbackups', 'created_at' =\u003e ...]\n}\n\n$backupsPage-\u003etoArray(); // ['data' =\u003e [[...], ...], 'meta' =\u003e ['current_page' =\u003e 1, ...]]\n```\n\n#### Restore Backup\n\nRestores a VM to the state of a specific backup. **Warning: Overwrites current VM data!**\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-backups/POST/api/vps/v1/virtual-machines/{virtualMachineId}/backups/{backupId}/restore)\n\n```php\n$virtualMachineId = 1268054;\n$backupId = 8676502;\n$action = $hostinger-\u003evps()-\u003ebackups()-\u003erestore($virtualMachineId, $backupId);\n\n$action-\u003eid; // 8123712\n$action-\u003ename; // restore_backup\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123712, 'name' =\u003e 'restore_backup', 'state' =\u003e 'success', ...]\n```\n\n### Data Centers\n\nAccess data center information via `$hostinger-\u003evps()-\u003edataCenters()`.\n\n#### Get Data Centers List\n\nRetrieves a list of all available Hostinger data centers where VPS can be deployed.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-data-centers/GET/api/vps/v1/data-centers)\n\n```php\n$dataCenters = $hostinger-\u003evps()-\u003edataCenters()-\u003elist();\n\nforeach ($dataCenters as $dataCenter) {\n    $dataCenter-\u003eid; // 29\n    $dataCenter-\u003ename; // phx\n    $dataCenter-\u003elocation; // us\n    $dataCenter-\u003ecity; // Phoenix\n    $dataCenter-\u003econtinent; // North America\n\n    $dataCenter-\u003etoArray(); // ['id' =\u003e 29, 'name' =\u003e 'phx', 'location' =\u003e 'us', 'city' =\u003e 'Phoenix', 'continent' =\u003e 'North America']\n}\n```\n\n### PTR Records\n\nManage reverse DNS (PTR) records via `$hostinger-\u003evps()-\u003eptrRecords()`.\n\n#### Create PTR Record\n\nCreates or updates the PTR (reverse DNS) record for a VM's primary IP, pointing to the VM's hostname.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-ptr-records/POST/api/vps/v1/virtual-machines/{virtualMachineId}/ptr)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003eptrRecords()-\u003ecreate($virtualMachineId);\n\n$action-\u003eid; // 8123728\n$action-\u003ename; // create_ptr_record\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123728, 'name' =\u003e 'create_ptr_record', 'state' =\u003e 'success', ...]\n```\n\n#### Delete PTR Record\n\nDeletes the PTR record for a VM's primary IP.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-ptr-records/DELETE/api/vps/v1/virtual-machines/{virtualMachineId}/ptr)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003eptrRecords()-\u003edelete($virtualMachineId);\n\n$action-\u003eid; // 8123729\n$action-\u003ename; // delete_ptr_record\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123729, 'name' =\u003e 'delete_ptr_record', 'state' =\u003e 'success', ...]\n```\n\n### Firewall\n\nManage network firewalls via `$hostinger-\u003evps()-\u003efirewalls()`. Access requires at least one VPS.\n\n#### Activate Firewall\n\nActivates a firewall for a specific VM. Only one firewall can be active per VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/POST/api/vps/v1/firewall/{firewallId}/activate/{virtualMachineId})\n\n```php\n$firewallId = 9449049;\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003efirewalls()-\u003eactivate($firewallId, $virtualMachineId);\n\n$action-\u003eid; // 8123715\n$action-\u003ename; // activate_firewall\n$action-\u003estate-\u003evalue; // sent\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123715, 'name' =\u003e 'activate_firewall', 'state' =\u003e 'sent', ...]\n```\n\n#### Deactivate Firewall\n\nDeactivates the currently active firewall for a specific VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/POST/api/vps/v1/firewall/{firewallId}/deactivate/{virtualMachineId})\n\n```php\n$firewallId = 9449049;\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003efirewalls()-\u003edeactivate($firewallId, $virtualMachineId);\n\n$action-\u003eid; // 8123716\n$action-\u003ename; // deactivate_firewall\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123716, 'name' =\u003e 'deactivate_firewall', 'state' =\u003e 'success', ...]\n```\n\n#### Get Firewall\n\nRetrieves details for a specific firewall, including its rules.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/GET/api/vps/v1/firewall/{firewallId})\n\n```php\n$firewallId = 9449049;\n$firewall = $hostinger-\u003evps()-\u003efirewalls()-\u003eget($firewallId);\n\n$firewall-\u003eid; // 65224\n$firewall-\u003ename; // HTTP and SSH only\n$firewall-\u003eis_synced; // false\n$firewall-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2021-09-01 12:00:00\n$firewall-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2021-09-01 12:00:00\n\nforeach ($firewall-\u003erules as $rule) {\n    $rule-\u003eid; // 24541\n    $rule-\u003eaction-\u003evalue; // accept, drop\n    $rule-\u003eprotocol-\u003evalue; // TCP, UDP, ICMP, ANY, SSH, HTTP, HTTPS, etc.\n    $rule-\u003eport; // e.g., \"443\", \"1024:2048\"\n    $rule-\u003esource-\u003evalue; // any, custom\n    $rule-\u003esource_detail; // e.g., \"any\", \"192.168.1.1\", \"10.0.0.0/8\"\n\n    $rule-\u003etoArray(); // ['id' =\u003e 24541, 'action' =\u003e 'accept', 'protocol' =\u003e 'TCP', ...]\n}\n\n$firewall-\u003etoArray(); // ['id' =\u003e 65224, 'name' =\u003e '...', 'is_synced' =\u003e false, 'rules' =\u003e [...], ...]\n```\n\n#### Delete Firewall\n\nDeletes a firewall. Any VMs using it will have the firewall deactivated.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/DELETE/api/vps/v1/firewall/{firewallId})\n\n```php\n$firewallId = 9449049;\n$response = $hostinger-\u003evps()-\u003efirewalls()-\u003edelete($firewallId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Firewall List\n\nRetrieves a paginated list of all firewalls available in your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/GET/api/vps/v1/firewall)\n\n```php\n$firewallsPage = $hostinger-\u003evps()-\u003efirewalls()-\u003elist(['page' =\u003e 1]);\n\n// Access pagination metadata\n$firewallsPage-\u003egetCurrentPage(); // 1\n$firewallsPage-\u003egetPerPage(); // 15\n$firewallsPage-\u003egetTotal(); // 100\n\nforeach ($firewallsPage-\u003egetData() as $firewall) {\n    $firewall-\u003eid; // 65224\n    $firewall-\u003ename; // HTTP and SSH only\n    $firewall-\u003eis_synced; // false\n    $firewall-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2021-09-01 12:00:00\n    $firewall-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2021-09-01 12:00:00\n\n    foreach ($firewall-\u003erules as $rule) {\n        $rule-\u003eid; // 24541\n        $rule-\u003eaction-\u003evalue; // accept\n        $rule-\u003eprotocol-\u003evalue; // TCP\n        $rule-\u003eport; // 1024:2048\n        $rule-\u003esource-\u003evalue; // any\n        $rule-\u003esource_detail; // any\n\n        $rule-\u003etoArray(); // ['id' =\u003e 24541, 'action' =\u003e 'accept', 'protocol' =\u003e 'TCP', ...]\n    }\n\n    $firewall-\u003etoArray(); // ['id' =\u003e 65224, 'name' =\u003e '...', 'is_synced' =\u003e false, 'rules' =\u003e [[...], ...], ...]\n}\n\n$firewallsPage-\u003etoArray(); // ['data' =\u003e [[...], ...], 'meta' =\u003e ['current_page' =\u003e 1, ...]]\n```\n\n#### Create New Firewall\n\nCreates a new, empty firewall group.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/POST/api/vps/v1/firewall)\n\n```php\n$data = [\n    'name' =\u003e 'My New Firewall',\n];\n\n$firewall = $hostinger-\u003evps()-\u003efirewalls()-\u003ecreate($data);\n\n$firewall-\u003eid; // 65225\n$firewall-\u003ename; // My New Firewall\n$firewall-\u003eis_synced; // true (initially synced as it's not attached)\n$firewall-\u003erules; // [] (empty array)\n$firewall-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2021-09-01 12:00:00\n$firewall-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2021-09-01 12:00:00\n\n$firewall-\u003etoArray(); // ['id' =\u003e 65225, 'name' =\u003e 'My New Firewall', 'is_synced' =\u003e true, 'rules' =\u003e [], ...]\n```\n\n#### Update Firewall Rule\n\nUpdates an existing rule within a firewall. The firewall becomes unsynced if attached to VMs.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/PUT/api/vps/v1/firewall/{firewallId}/rules/{ruleId})\n\n```php\n$firewallId = 9449049;\n$ruleId = 8941182;\n$data = [\n    'protocol' =\u003e 'UDP', // TCP, UDP, ICMP, ANY, SSH, HTTP, HTTPS, etc.\n    'port' =\u003e '53', // Port or range \"1024:2048\"\n    'source' =\u003e 'custom', // any, custom\n    'source_detail' =\u003e '1.1.1.1', // IP, CIDR, or 'any'\n    'action' =\u003e 'accept', // accept, drop\n];\n\n$rule = $hostinger-\u003evps()-\u003efirewalls()-\u003eupdateRule($firewallId, $ruleId, $data);\n\n$rule-\u003eid; // 8941182\n$rule-\u003eaction-\u003evalue; // accept\n$rule-\u003eprotocol-\u003evalue; // UDP\n$rule-\u003eport; // 53\n$rule-\u003esource-\u003evalue; // custom\n$rule-\u003esource_detail; // 1.1.1.1\n\n$rule-\u003etoArray(); // ['id' =\u003e 8941182, 'action' =\u003e 'accept', 'protocol' =\u003e 'UDP', ...]\n```\n\n#### Delete Firewall Rule\n\nDeletes a specific rule from a firewall. The firewall becomes unsynced if attached to VMs.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/DELETE/api/vps/v1/firewall/{firewallId}/rules/{ruleId})\n\n```php\n$firewallId = 9449049;\n$ruleId = 8941182;\n$response = $hostinger-\u003evps()-\u003efirewalls()-\u003edeleteRule($firewallId, $ruleId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Create Firewall Rule\n\nAdds a new rule to an existing firewall. The firewall becomes unsynced if attached to VMs.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/POST/api/vps/v1/firewall/{firewallId}/rules)\n\n```php\n$firewallId = 9449049;\n$data = [\n    'protocol' =\u003e 'TCP',\n    'port' =\u003e '443',\n    'source' =\u003e 'any', // 'any' or 'custom'\n    'source_detail' =\u003e 'any', // IP, CIDR, or 'any'\n    'action' =\u003e 'accept', // 'accept' or 'drop'\n];\n\n$rule = $hostinger-\u003evps()-\u003efirewalls()-\u003ecreateRule($firewallId, $data);\n\n$rule-\u003eid; // 8941183\n$rule-\u003eaction-\u003evalue; // accept\n$rule-\u003eprotocol-\u003evalue; // TCP\n$rule-\u003eport; // 443\n$rule-\u003esource-\u003evalue; // any\n$rule-\u003esource_detail; // any\n\n$rule-\u003etoArray(); // ['id' =\u003e 8941183, 'action' =\u003e 'accept', 'protocol' =\u003e 'TCP', ...]\n```\n\n#### Sync Firewall\n\nSyncs firewall rules to an attached VM if the firewall is marked as unsynced (e.g., after rule changes).\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-firewall/POST/api/vps/v1/firewall/{firewallId}/sync/{virtualMachineId})\n\n```php\n$firewallId = 9449049;\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003efirewalls()-\u003esync($firewallId, $virtualMachineId);\n\n$action-\u003eid; // 8123717\n$action-\u003ename; // sync_firewall\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123717, 'name' =\u003e 'sync_firewall', 'state' =\u003e 'success', ...]\n```\n\n### Malware Scanner\n\nManage the Monarx malware scanner via `$hostinger-\u003evps()-\u003emalwareScanner()`.\n\n#### Get Scan Metrics\n\nRetrieves the latest Monarx malware scan metrics for a VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-malware-scanner/GET/api/vps/v1/virtual-machines/{virtualMachineId}/monarx)\n\n```php\n$virtualMachineId = 1268054;\n$metrics = $hostinger-\u003evps()-\u003emalwareScanner()-\u003egetMetrics($virtualMachineId);\n\n$metrics-\u003erecords; // 1\n$metrics-\u003emalicious; // 2\n$metrics-\u003ecompromised; // 3\n$metrics-\u003escanned_files; // 193218\n$metrics-\u003escan_started_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$metrics-\u003escan_ended_at?-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 12:10:00\n\n$metrics-\u003etoArray(); // ['records' =\u003e 1, 'malicious' =\u003e 2, 'compromised' =\u003e 3, ...]\n```\n\n#### Install Monarx\n\nInstalls the Monarx malware scanner on a VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-malware-scanner/POST/api/vps/v1/virtual-machines/{virtualMachineId}/monarx)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003emalwareScanner()-\u003einstall($virtualMachineId);\n\n$action-\u003eid; // 8123718\n$action-\u003ename; // install_monarx\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123718, 'name' =\u003e 'install_monarx', 'state' =\u003e 'success', ...]\n```\n\n#### Uninstall Monarx\n\nUninstalls the Monarx malware scanner from a VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-malware-scanner/DELETE/api/vps/v1/virtual-machines/{virtualMachineId}/monarx)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003emalwareScanner()-\u003euninstall($virtualMachineId);\n\n$action-\u003eid; // 8123719\n$action-\u003ename; // uninstall_monarx\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123719, 'name' =\u003e 'uninstall_monarx', 'state' =\u003e 'success', ...]\n```\n\n### OS Templates\n\nAccess available OS templates via `$hostinger-\u003evps()-\u003etemplates()`.\n\n#### Get Template\n\nRetrieves details for a specific OS template.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-os-templates/GET/api/vps/v1/templates/{templateId})\n\n```php\n$templateId = 2868928;\n$template = $hostinger-\u003evps()-\u003etemplates()-\u003eget($templateId);\n\n$template-\u003eid; // 2868928\n$template-\u003ename; // Ubuntu 20.04 LTS\n$template-\u003edescription; // Ubuntu 20.04 LTS\n$template-\u003edocumentation; // https://docs.ubuntu.com or null\n\n$template-\u003etoArray(); // ['id' =\u003e 2868928, 'name' =\u003e '...', 'description' =\u003e '...', 'documentation' =\u003e null]\n```\n\n#### Get Template List\n\nRetrieves a list of available OS templates for installing on virtual machines.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-os-templates/GET/api/vps/v1/templates)\n\n```php\n$templates = $hostinger-\u003evps()-\u003etemplates()-\u003elist();\n\nforeach ($templates as $template) {\n    $template-\u003eid; // 6523\n    $template-\u003ename; // Ubuntu 20.04 LTS\n    $template-\u003edescription; // Ubuntu 20.04 LTS\n    $template-\u003edocumentation; // https://docs.ubuntu.com or null\n\n    $template-\u003etoArray(); // ['id' =\u003e 6523, 'name' =\u003e 'Ubuntu 20.04 LTS', 'description' =\u003e '...', 'documentation' =\u003e '...']\n}\n```\n\n### Post-Install Scripts\n\nManage scripts to run after OS installation via `$hostinger-\u003evps()-\u003epostInstallScripts()`.\n\n#### Get Post-Install Script\n\nRetrieves details of a specific post-install script.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-post-install-scripts/GET/api/vps/v1/post-install-scripts/{postInstallScriptId})\n\n```php\n$postInstallScriptId = 9568314;\n$script = $hostinger-\u003evps()-\u003epostInstallScripts()-\u003eget($postInstallScriptId);\n\n$script-\u003eid; // 325\n$script-\u003ename; // My Setup Script\n$script-\u003econtent; // #!/bin/bash\\napt-get update...\n$script-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$script-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n\n$script-\u003etoArray(); // ['id' =\u003e 325, 'name' =\u003e '...', 'content' =\u003e '...', 'created_at' =\u003e ..., 'updated_at' =\u003e ...]\n```\n\n#### Update Post-Install Script\n\nUpdates the name and/or content of an existing post-install script.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-post-install-scripts/PUT/api/vps/v1/post-install-scripts/{postInstallScriptId})\n\n```php\n$postInstallScriptId = 9568314;\n$data = [\n    'name' =\u003e 'Updated Setup Script',\n    'content' =\u003e \"#!/bin/bash\\napt-get update \u0026\u0026 apt-get upgrade -y\",\n];\n\n$script = $hostinger-\u003evps()-\u003epostInstallScripts()-\u003eupdate($postInstallScriptId, $data);\n\n$script-\u003eid; // 9568314\n$script-\u003ename; // Updated Setup Script\n$script-\u003econtent; // \"#!/bin/bash\\napt-get update \u0026\u0026 apt-get upgrade -y\"\n$script-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$script-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-04-01 10:30:00 (updated time)\n\n$script-\u003etoArray(); // ['id' =\u003e 9568314, 'name' =\u003e 'Updated Setup Script', ...]\n```\n\n#### Delete a Post-Install Script\n\nDeletes a post-install script from your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-post-install-scripts/DELETE/api/vps/v1/post-install-scripts/{postInstallScriptId})\n\n```php\n$postInstallScriptId = 9568314;\n$response = $hostinger-\u003evps()-\u003epostInstallScripts()-\u003edelete($postInstallScriptId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Post-Install Script List\n\nRetrieves a paginated list of post-install scripts associated with your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-post-install-scripts/GET/api/vps/v1/post-install-scripts)\n\n```php\n$scriptsPage = $hostinger-\u003evps()-\u003epostInstallScripts()-\u003elist(['page' =\u003e 1]);\n\n// Access pagination metadata\n$scriptsPage-\u003egetCurrentPage(); // 1\n$scriptsPage-\u003egetPerPage(); // 15\n$scriptsPage-\u003egetTotal(); // 100\n\nforeach ($scriptsPage-\u003egetData() as $script) {\n    $script-\u003eid; // 325\n    $script-\u003ename; // \"My Setup Script\"\n    $script-\u003econtent; // \"#!/bin/bash\\napt-get update\\napt-get install -y nginx\"\n    $script-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n    $script-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n\n    $script-\u003etoArray(); // ['id' =\u003e 325, 'name' =\u003e 'My Setup Script', 'content' =\u003e '...', ...]\n}\n\n$scriptsPage-\u003etoArray(); // ['data' =\u003e [[...], ...], 'meta' =\u003e ['current_page' =\u003e 1, ...]]\n```\n\n#### Create Post-Install Script\n\nCreates a new script that can be run after OS installation on a VM. Max size 48KB.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-post-install-scripts/POST/api/vps/v1/post-install-scripts)\n\n```php\n$data = [\n    'name' =\u003e 'Install Docker Script',\n    'content' =\u003e \"#!/bin/bash\\napt-get update\\napt-get install -y docker.io\",\n];\n$script = $hostinger-\u003evps()-\u003epostInstallScripts()-\u003ecreate($data);\n\n$script-\u003eid; // 326\n$script-\u003ename; // Install Docker Script\n$script-\u003econtent; // \"#!/bin/bash\\napt-get update\\napt-get install -y docker.io\"\n$script-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-04-01 10:00:00\n$script-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-04-01 10:00:00\n\n$script-\u003etoArray(); // ['id' =\u003e 326, 'name' =\u003e 'Install Docker Script', 'content' =\u003e '...', ...]\n```\n\n### Public Keys\n\nManage SSH public keys via `$hostinger-\u003evps()-\u003epublicKeys()`.\n\n#### Attach Public Key\n\nAttaches existing public keys from your account to a specific VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-public-keys/POST/api/vps/v1/public-keys/attach/{virtualMachineId})\n\n```php\n$virtualMachineId = 1268054;\n$data = [\n    'ids' =\u003e [18232, 10230230], // Array of Public Key IDs\n];\n\n$action = $hostinger-\u003evps()-\u003epublicKeys()-\u003eattach($virtualMachineId, $data);\n\n$action-\u003eid; // 8123720\n$action-\u003ename; // attach_public_key\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123720, 'name' =\u003e 'attach_public_key', 'state' =\u003e 'success', ...]\n```\n\n#### Delete a Public Key\n\nDeletes a public key from your account. This does *not* remove it from VMs it's already attached to.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-public-keys/DELETE/api/vps/v1/public-keys/{publicKeyId})\n\n```php\n$publicKeyId = 6672861;\n$response = $hostinger-\u003evps()-\u003epublicKeys()-\u003edelete($publicKeyId);\n\n$response-\u003emessage; // Request accepted\n$response-\u003etoArray(); // ['message' =\u003e 'Request accepted']\n```\n\n#### Get Public Key List\n\nRetrieves a paginated list of SSH public keys associated with your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-public-keys/GET/api/vps/v1/public-keys)\n\n```php\n$keysPage = $hostinger-\u003evps()-\u003epublicKeys()-\u003elist(['page' =\u003e 1]);\n\n// Access pagination metadata\n$keysPage-\u003egetCurrentPage(); // 1\n$keysPage-\u003egetPerPage(); // 15\n$keysPage-\u003egetTotal(); // 100\n\nforeach ($keysPage-\u003egetData() as $key) {\n    $key-\u003eid; // 325\n    $key-\u003ename; // My public key\n    $key-\u003ekey; // ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD...\n\n    $key-\u003etoArray(); // ['id' =\u003e 325, 'name' =\u003e 'My public key', 'key' =\u003e 'ssh-rsa...']\n}\n\n$keysPage-\u003etoArray(); // ['data' =\u003e [[...], ...], 'meta' =\u003e ['current_page' =\u003e 1, ...]]\n```\n\n#### Create New Public Key\n\nAdds a new SSH public key to your account, which can then be attached to VMs.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-public-keys/POST/api/vps/v1/public-keys)\n\n```php\n$data = [\n    'name' =\u003e 'My Laptop Key',\n    'key' =\u003e 'ssh-rsa AAAAB3NzaC1yc2EAAA...',\n];\n\n$publicKey = $hostinger-\u003evps()-\u003epublicKeys()-\u003ecreate($data);\n\n$publicKey-\u003eid; // 326\n$publicKey-\u003ename; // My Laptop Key\n$publicKey-\u003ekey; // ssh-rsa AAAAB3NzaC1yc2EAAA...\n\n$publicKey-\u003etoArray(); // ['id' =\u003e 326, 'name' =\u003e 'My Laptop Key', 'key' =\u003e 'ssh-rsa...']\n```\n\n### Recovery\n\nManage VM recovery mode via `$hostinger-\u003evps()-\u003erecovery()`.\n\n#### Start Recovery Mode\n\nBoots a VM into a temporary recovery environment with the specified root password. The original disk is mounted at `/mnt`.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-recovery/POST/api/vps/v1/virtual-machines/{virtualMachineId}/recovery)\n\n```php\n$virtualMachineId = 1268054;\n$data = [\n    'root_password' =\u003e 'TemporarySecurePassword123!',\n];\n\n$action = $hostinger-\u003evps()-\u003erecovery()-\u003estart($virtualMachineId, $data);\n\n$action-\u003eid; // 8123721\n$action-\u003ename; // start_recovery\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123721, 'name' =\u003e 'start_recovery', 'state' =\u003e 'success', ...]\n```\n\n#### Stop Recovery Mode\n\nBoots the VM back into its normal operating system from recovery mode.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-recovery/DELETE/api/vps/v1/virtual-machines/{virtualMachineId}/recovery)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003erecovery()-\u003estop($virtualMachineId);\n\n$action-\u003eid; // 8123722\n$action-\u003ename; // stop_recovery\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123722, 'name' =\u003e 'stop_recovery', 'state' =\u003e 'success', ...]\n```\n\n### Snapshots\n\nManage VM snapshots via `$hostinger-\u003evps()-\u003esnapshots()`. Note: Only one snapshot is kept per VM.\n\n#### Get Snapshot\n\nRetrieves information about the current snapshot for a VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-snapshots/GET/api/vps/v1/virtual-machines/{virtualMachineId}/snapshot)\n\n```php\n$virtualMachineId = 1268054;\n$snapshot = $hostinger-\u003evps()-\u003esnapshots()-\u003eget($virtualMachineId);\n\n$snapshot-\u003eid; // 325\n$snapshot-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$snapshot-\u003eexpires_at-\u003eformat('Y-m-d H:i:s'); // 2025-03-19 11:54:22\n\n$snapshot-\u003etoArray(); // ['id' =\u003e 325, 'created_at' =\u003e ..., 'expires_at' =\u003e ...]\n```\n\n#### Create Snapshot\n\nCreates a new snapshot of a VM. **Warning: Overwrites any existing snapshot for this VM!**\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-snapshots/POST/api/vps/v1/virtual-machines/{virtualMachineId}/snapshot)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003esnapshots()-\u003ecreate($virtualMachineId);\n\n$action-\u003eid; // 8123732\n$action-\u003ename; // create_snapshot\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123732, 'name' =\u003e 'create_snapshot', 'state' =\u003e 'success', ...]\n```\n\n#### Delete Snapshot\n\nDeletes the existing snapshot for a VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-snapshots/DELETE/api/vps/v1/virtual-machines/{virtualMachineId}/snapshot)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003esnapshots()-\u003edelete($virtualMachineId);\n\n$action-\u003eid; // 8123733\n$action-\u003ename; // delete_snapshot\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123733, 'name' =\u003e 'delete_snapshot', 'state' =\u003e 'success', ...]\n```\n\n#### Restore Snapshot\n\nRestores a VM to the state of its existing snapshot. **Warning: Overwrites current VM data!**\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-snapshots/POST/api/vps/v1/virtual-machines/{virtualMachineId}/snapshot/restore)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003esnapshots()-\u003erestore($virtualMachineId);\n\n$action-\u003eid; // 8123734\n$action-\u003ename; // restore_snapshot\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123734, 'name' =\u003e 'restore_snapshot', 'state' =\u003e 'success', ...]\n```\n\n### Virtual Machine\n\nManage core VM operations via `$hostinger-\u003evps()-\u003evirtualMachines()`.\n\n#### Get Attached Public Keys\n\nRetrieves a paginated list of SSH public keys attached to a specific virtual machine.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/GET/api/vps/v1/virtual-machines/{virtualMachineId}/public-keys)\n\n```php\n$virtualMachineId = 1268054;\n$keysPage = $hostinger-\u003evps()-\u003evirtualMachines()-\u003egetAttachedPublicKeys($virtualMachineId, ['page' =\u003e 1]);\n\n// Access pagination metadata\n$keysPage-\u003egetCurrentPage(); // 1\n$keysPage-\u003egetPerPage(); // 15\n$keysPage-\u003egetTotal(); // 100\n\nforeach ($keysPage-\u003egetData() as $key) {\n    $key-\u003eid; // 325\n    $key-\u003ename; // My public key\n    $key-\u003ekey; // ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD...\n\n    $key-\u003etoArray(); // ['id' =\u003e 325, 'name' =\u003e 'My public key', 'key' =\u003e 'ssh-rsa...']\n}\n\n$keysPage-\u003etoArray(); // ['data' =\u003e [[...], ...], 'meta' =\u003e ['current_page' =\u003e 1, ...]]\n```\n\n#### Set Hostname\n\nSets the hostname for a virtual machine. Does not automatically update PTR record.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/PUT/api/vps/v1/virtual-machines/{virtualMachineId}/hostname)\n\n```php\n$virtualMachineId = 1268054;\n$newHostname = 'my.new-server.tld';\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003esetHostName($virtualMachineId, $newHostname);\n\n$action-\u003eid; // 8123723\n$action-\u003ename; // set_hostname\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123723, 'name' =\u003e 'set_hostname', 'state' =\u003e 'success', ...]\n```\n\n#### Reset Hostname\n\nResets the hostname and PTR record to the default value (e.g., srvXXXXX.hstgr.cloud).\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/DELETE/api/vps/v1/virtual-machines/{virtualMachineId}/hostname)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003eresetHostName($virtualMachineId);\n\n$action-\u003eid; // 8123724\n$action-\u003ename; // reset_hostname\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123724, 'name' =\u003e 'reset_hostname', 'state' =\u003e 'success', ...]\n```\n\n#### Get Virtual Machine\n\nRetrieves detailed information for a specific virtual machine.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/GET/api/vps/v1/virtual-machines/{virtualMachineId})\n\n```php\n$virtualMachineId = 1268054;\n$vm = $hostinger-\u003evps()-\u003evirtualMachines()-\u003eget($virtualMachineId);\n\n$vm-\u003eid; // 17923\n$vm-\u003efirewall_group_id; // null or ID\n$vm-\u003esubscription_id; // Azz353Uhl1xC54pR0\n$vm-\u003eplan; // KVM 4\n$vm-\u003ehostname; // srv17923.hstgr.cloud\n$vm-\u003estate-\u003evalue; // running, stopped, creating, initial, error, etc.\n$vm-\u003eactions_lock-\u003evalue; // unlocked, locked\n$vm-\u003ecpus; // 4\n$vm-\u003ememory; // 8192 (MB)\n$vm-\u003edisk; // 51200 (MB)\n$vm-\u003ebandwidth; // 1073741824 (MB)\n$vm-\u003ens1; // 1.1.1.1 or null\n$vm-\u003ens2; // 8.8.8.8 or null\n$vm-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2024-09-05 07:25:36\n\nif ($vm-\u003eipv4) {\n    foreach ($vm-\u003eipv4 as $ip4) {\n        $ip4-\u003eid; // 52347\n        $ip4-\u003eaddress; // 213.331.273.15\n        $ip4-\u003eptr; // something.domain.tld\n        $ip4-\u003etoArray(); // ['id' =\u003e 52347, 'address' =\u003e '...', 'ptr' =\u003e '...']\n    }\n}\nif ($vm-\u003eipv6) {\n    foreach ($vm-\u003eipv6 as $ip6) {\n         $ip6-\u003eid; // 52347\n         $ip6-\u003eaddress; // 2a00:4000:f:eaee::1\n         $ip6-\u003eptr; // something.domain.tld\n         $ip6-\u003etoArray(); // ['id' =\u003e 52347, 'address' =\u003e '...', 'ptr' =\u003e '...']\n     }\n}\nif ($vm-\u003etemplate) {\n    $vm-\u003etemplate-\u003eid; // 6523\n    $vm-\u003etemplate-\u003ename; // Ubuntu 20.04 LTS\n    $vm-\u003etemplate-\u003edescription; // Ubuntu 20.04 LTS\n    $vm-\u003etemplate-\u003edocumentation; // https://docs.ubuntu.com\n    $vm-\u003etemplate-\u003etoArray(); // ['id' =\u003e 6523, 'name' =\u003e '...', ...]\n}\n\n$vm-\u003etoArray(); // ['id' =\u003e 17923, 'firewall_group_id' =\u003e null, 'hostname' =\u003e '...', 'state' =\u003e 'running', ...]\n```\n\n#### Get Virtual Machine List\n\nRetrieves a list of all virtual machines in your account.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/GET/api/vps/v1/virtual-machines)\n\n```php\n$vms = $hostinger-\u003evps()-\u003evirtualMachines()-\u003elist();\n\nforeach ($vms as $vm) {\n    $vm-\u003eid; // 17923\n    $vm-\u003efirewall_group_id; // null\n    $vm-\u003esubscription_id; // Azz353Uhl1xC54pR0\n    $vm-\u003eplan; // KVM 4\n    $vm-\u003ehostname; // srv17923.hstgr.cloud\n    $vm-\u003estate-\u003evalue; // running\n    $vm-\u003eactions_lock-\u003evalue; // unlocked\n    $vm-\u003ecpus; // 4\n    $vm-\u003ememory; // 8192\n    $vm-\u003edisk; // 51200\n    $vm-\u003ebandwidth; // 1073741824\n    $vm-\u003ens1; // 1.1.1.1\n    $vm-\u003ens2; // 8.8.8.8\n    $vm-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2024-09-05 07:25:36\n\n    if ($vm-\u003eipv4) {\n        foreach ($vm-\u003eipv4 as $ip4) {\n            $ip4-\u003eid; // 52347\n            $ip4-\u003eaddress; // 213.331.273.15\n            $ip4-\u003eptr; // something.domain.tld\n            $ip4-\u003etoArray(); // ['id' =\u003e 52347, 'address' =\u003e '...', 'ptr' =\u003e '...']\n        }\n    }\n    if ($vm-\u003eipv6) {\n         foreach ($vm-\u003eipv6 as $ip6) {\n             $ip6-\u003eid; // 52347\n             $ip6-\u003eaddress; // 2a00:4000:f:eaee::1\n             $ip6-\u003eptr; // something.domain.tld\n             $ip6-\u003etoArray(); // ['id' =\u003e 52347, 'address' =\u003e '...', 'ptr' =\u003e '...']\n         }\n    }\n    if ($vm-\u003etemplate) {\n        $vm-\u003etemplate-\u003eid; // 6523\n        $vm-\u003etemplate-\u003ename; // Ubuntu 20.04 LTS\n        $vm-\u003etemplate-\u003edescription; // Ubuntu 20.04 LTS\n        $vm-\u003etemplate-\u003edocumentation; // https://docs.ubuntu.com\n        $vm-\u003etemplate-\u003etoArray(); // ['id' =\u003e 6523, 'name' =\u003e '...', ...]\n    }\n\n    $vm-\u003etoArray(); // ['id' =\u003e 17923, 'firewall_group_id' =\u003e null, 'hostname' =\u003e '...', 'state' =\u003e 'running', ...]\n}\n```\n\n#### Purchase New Virtual Machine\n\nAllows you to buy (purchase) and setup a new virtual machine.\n\nIf virtual machine setup fails for any reason, login to hPanel and complete the setup manually.\n\nIf no payment method is provided, your default payment method will be used automatically.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/POST/api/vps/v1/virtual-machines)\n\n```php\n$data = [\n    'item_id' =\u003e 'hostingercom-vps-kvm2-usd-1m',\n    'payment_method_id' =\u003e 1327362,\n    'setup' =\u003e [\n        'template_id' =\u003e 1130,\n        'data_center_id' =\u003e 19,\n        'post_install_script_id' =\u003e 6324,\n        'password' =\u003e 'MyS3cureP@ssw0rd!',\n        'hostname' =\u003e 'my.server.tld',\n        'install_monarx' =\u003e false,\n        'enable_backups' =\u003e true,\n        'ns1' =\u003e '1.1.1.1',\n        'ns2' =\u003e '1.0.0.1',\n        'public_key' =\u003e [\n            'name' =\u003e 'my-key',\n            'key' =\u003e 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC2X...'\n        ]\n    ],\n    'coupons' =\u003e ['VPSPROMO'],\n];\n\n$response = $hostinger-\u003evps()-\u003evirtualMachines()-\u003epurchase($data);\n\n// Access order details\n$response-\u003eorder-\u003eid; // 2957087\n$response-\u003eorder-\u003esubscription_id; // Azz353Uhl1xC54pR0\n$response-\u003eorder-\u003estatus-\u003evalue; // completed\n$response-\u003eorder-\u003ecurrency; // USD\n$response-\u003eorder-\u003esubtotal; // 899\n$response-\u003eorder-\u003etotal; // 1080\n\n$response-\u003eorder-\u003ebilling_address-\u003efirst_name; // John\n$response-\u003eorder-\u003ebilling_address-\u003elast_name; // Doe\n$response-\u003eorder-\u003ebilling_address-\u003ecompany; // null\n$response-\u003eorder-\u003ebilling_address-\u003eaddress_1; // null\n$response-\u003eorder-\u003ebilling_address-\u003eaddress_2; // null\n$response-\u003eorder-\u003ebilling_address-\u003ecity; // null\n$response-\u003eorder-\u003ebilling_address-\u003estate; // null\n$response-\u003eorder-\u003ebilling_address-\u003ezip; // null\n$response-\u003eorder-\u003ebilling_address-\u003ecountry; // NL\n$response-\u003eorder-\u003ebilling_address-\u003ephone; // null\n$response-\u003eorder-\u003ebilling_address-\u003eemail; // john@doe.tld\n\n$response-\u003eorder-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n$response-\u003eorder-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:22\n\n// Access virtual machine details\n$response-\u003evirtual_machine-\u003eid; // 1268054\n$response-\u003evirtual_machine-\u003ehostname; // my.server.tld\n$response-\u003evirtual_machine-\u003estate-\u003evalue; // creating\n$response-\u003evirtual_machine-\u003eplan; // KVM 4\n$response-\u003evirtual_machine-\u003ecpus; // 4\n$response-\u003evirtual_machine-\u003ememory; // 8192\n$response-\u003evirtual_machine-\u003edisk; // 51200\n```\n\n#### Get Metrics\n\nRetrieves historical performance metrics (CPU, RAM, Disk, Network, Uptime) for a VM within a specified time range.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/GET/api/vps/v1/virtual-machines/{virtualMachineId}/metrics)\n\n```php\n$virtualMachineId = 1268054;\n$dateFrom = '2025-05-01T00:00:00Z'; // RFC 3339 format\n$dateTo = '2025-06-01T00:00:00Z'; // RFC 3339 format\n$metrics = $hostinger-\u003evps()-\u003evirtualMachines()-\u003egetMetrics($virtualMachineId, $dateFrom, $dateTo);\n\nif ($metrics-\u003ecpu_usage) {\n    $metrics-\u003ecpu_usage-\u003eunit; // %\n    $metrics-\u003ecpu_usage-\u003eusage; // {\"1742269632\": 1.45, ...} (Timestamp =\u003e Value)\n    $metrics-\u003ecpu_usage-\u003etoArray(); // ['unit' =\u003e '%', 'usage' =\u003e [...]]\n}\nif ($metrics-\u003eram_usage) {\n    $metrics-\u003eram_usage-\u003eunit; // bytes\n    $metrics-\u003eram_usage-\u003eusage; // {\"1742269632\": 554176512, ...}\n    $metrics-\u003eram_usage-\u003etoArray(); // ['unit' =\u003e 'bytes', 'usage' =\u003e [...]]\n}\nif ($metrics-\u003edisk_space) {\n    $metrics-\u003edisk_space-\u003eunit; // \"bytes\"\n    $metrics-\u003edisk_space-\u003eusage; // {\"1742269632\": 2620018688, ...}\n    $metrics-\u003edisk_space-\u003etoArray(); // ['unit' =\u003e 'bytes', 'usage' =\u003e [...]]\n}\nif ($metrics-\u003eoutgoing_traffic) {\n    $metrics-\u003eoutgoing_traffic-\u003eunit; // \"bytes\"\n    $metrics-\u003eoutgoing_traffic-\u003eusage; // {\"1742269632\": 784800, ...}\n    $metrics-\u003eoutgoing_traffic-\u003etoArray(); // ['unit' =\u003e 'bytes', 'usage' =\u003e [...]]\n}\nif ($metrics-\u003eincoming_traffic) {\n    $metrics-\u003eincoming_traffic-\u003eunit; // \"bytes\"\n    $metrics-\u003eincoming_traffic-\u003eusage; // {\"1742269632\": 8978400, ...}\n    $metrics-\u003eincoming_traffic-\u003etoArray(); // ['unit' =\u003e 'bytes', 'usage' =\u003e [...]]\n}\nif ($metrics-\u003euptime) {\n    $metrics-\u003euptime-\u003eunit; // \"milliseconds\"\n    $metrics-\u003euptime-\u003eusage; // {\"1742269632\": 455248, ...}\n    $metrics-\u003euptime-\u003etoArray(); // ['unit' =\u003e 'milliseconds', 'usage' =\u003e [...]]\n}\n\n$metrics-\u003etoArray(); // ['cpu_usage' =\u003e [...], 'ram_usage' =\u003e [...], ...]\n```\n\n#### Set Nameservers\n\nSets the DNS resolvers used by the virtual machine.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/PUT/api/vps/v1/virtual-machines/{virtualMachineId}/nameservers)\n\n```php\n$virtualMachineId = 1268054;\n$data = [\n    'ns1' =\u003e '1.1.1.1', // Primary nameserver IP\n    'ns2' =\u003e '1.0.0.1', // Optional secondary nameserver IP\n];\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003esetNameServers($virtualMachineId, $data);\n\n$action-\u003eid; // 8123725\n$action-\u003ename; // set_nameservers\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123725, 'name' =\u003e 'set_nameservers', 'state' =\u003e 'success', ...]\n```\n\n#### Set Panel Password\n\nSets the password for the control panel (if applicable to the OS template). Requires a strong password.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/PUT/api/vps/v1/virtual-machines/{virtualMachineId}/panel-password)\n\n```php\n$virtualMachineId = 1268054;\n$newPassword = 'VeryStr0ngP@ssw0rd!';\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003esetPanelPassword($virtualMachineId, $newPassword);\n\n$action-\u003eid; // 8123726\n$action-\u003ename; // set_panel_password\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123726, 'name' =\u003e 'set_panel_password', 'state' =\u003e 'success', ...]\n```\n\n#### Recreate Virtual Machine\n\nReinstalls the OS on a virtual machine. **Warning: All data will be lost! Snapshots will be deleted.** Requires a strong password if provided.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/POST/api/vps/v1/virtual-machines/{virtualMachineId}/recreate)\n\n```php\n$virtualMachineId = 1268054;\n$data = [\n    'template_id' =\u003e 1130, // ID of the OS template to install\n    'password' =\u003e 'AnotherStr0ngP@ss!', // Optional: If omitted, a random one is generated\n    'post_install_script_id' =\u003e 6324, // Optional: ID of a script to run after install\n];\n\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003erecreate($virtualMachineId, $data);\n\n$action-\u003eid; // 8123727\n$action-\u003ename; // recreate\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-04-01 10:00:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-04-01 10:05:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123727, 'name' =\u003e 'recreate', 'state' =\u003e 'success', ...]\n```\n\n#### Restart Virtual Machine\n\nRestarts a virtual machine (equivalent to stop then start). Starts a stopped VM.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/POST/api/vps/v1/virtual-machines/{virtualMachineId}/restart)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003erestart($virtualMachineId);\n\n$action-\u003eid; // 8123712\n$action-\u003ename; // restart\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123712, 'name' =\u003e 'restart', 'state' =\u003e 'success', ...]\n```\n\n#### Set Root Password\n\nSets the root password for the virtual machine. Requires a strong password.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/PUT/api/vps/v1/virtual-machines/{virtualMachineId}/root-password)\n\n```php\n$virtualMachineId = 1268054;\n$newPassword = 'EvenM0reSecur3P@ss!';\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003esetRootPassword($virtualMachineId, $newPassword);\n\n$action-\u003eid; // 8123728\n$action-\u003ename; // set_root_password\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123728, 'name' =\u003e 'set_root_password', 'state' =\u003e 'success', ...]\n```\n\n#### Setup New Virtual Machine\n\nSets up a newly purchased VPS (in `initial` state). Requires OS template and data center.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/POST/api/vps/v1/virtual-machines/{virtualMachineId}/setup)\n\n```php\n$virtualMachineId = 1268054;\n$data = [\n    'template_id' =\u003e 1130,\n    'data_center_id' =\u003e 19,\n    'password' =\u003e 'MyS3cureP@ssw0rd!', // Optional: Strong password, random if omitted\n    'hostname' =\u003e 'my.server.tld', // Optional: Override default hostname\n    'install_monarx' =\u003e false, // Optional: Install malware scanner (default: false)\n    'enable_backups' =\u003e true, // Optional: Enable weekly backups (default: true)\n    'ns1' =\u003e '1.1.1.1', // Optional: Primary DNS resolver\n    'ns2' =\u003e '1.0.0.1', // Optional: Secondary DNS resolver\n    'post_install_script_id' =\u003e 6324, // Optional: Script to run after setup\n    'public_key' =\u003e [ // Optional: Add and attach a new SSH key\n        'name' =\u003e 'my-setup-key',\n        'key' =\u003e 'ssh-rsa AAAAB3NzaC1yc2EAAA...',\n    ]\n];\n\n$vm = $hostinger-\u003evps()-\u003evirtualMachines()-\u003esetup($virtualMachineId, $data);\n\n$vm-\u003eid; // 1268054\n$vm-\u003efirewall_group_id; // null\n$vm-\u003esubscription_id; // Azz353Uhl1xC54pR0\n$vm-\u003eplan; // KVM 4\n$vm-\u003ehostname; // my.server.tld\n$vm-\u003estate-\u003evalue; // creating\n$vm-\u003eactions_lock-\u003evalue; // unlocked\n$vm-\u003ecpus; // 4\n$vm-\u003ememory; // 8192\n$vm-\u003edisk; // 51200\n$vm-\u003ebandwidth; // 1073741824\n$vm-\u003ens1; // 1.1.1.1\n$vm-\u003ens2; // 1.0.0.1\n$vm-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2024-09-05 07:25:36\n\nif ($vm-\u003eipv4) {\n    foreach ($vm-\u003eipv4 as $ipv4) {\n        $ipv4-\u003eid; // 52347\n        $ipv4-\u003eaddress; // 213.331.273.15\n        $ipv4-\u003eptr; // something.domain.tld\n        $ipv4-\u003etoArray(); // ['id' =\u003e 52347, 'address' =\u003e '...', 'ptr' =\u003e '...']\n    }\n}\nif ($vm-\u003eipv6) {\n     foreach ($vm-\u003eipv6 as $ipv6) {\n         $ipv6-\u003eid; // 52347\n         $ipv6-\u003eaddress; // 2a00:4000:f:eaee::1\n         $ipv6-\u003eptr; // something.domain.tld\n         $ipv6-\u003etoArray(); // ['id' =\u003e 52347, 'address' =\u003e '...', 'ptr' =\u003e '...']\n     }\n}\nif ($vm-\u003etemplate) {\n    $vm-\u003etemplate-\u003eid; // 6523\n    $vm-\u003etemplate-\u003ename; // Ubuntu 20.04 LTS\n    $vm-\u003etemplate-\u003edescription; // Ubuntu 20.04 LTS\n    $vm-\u003etemplate-\u003edocumentation; // https://docs.ubuntu.com\n    $vm-\u003etemplate-\u003etoArray(); // ['id' =\u003e 6523, 'name' =\u003e '...', ...]\n}\n\n$vm-\u003etoArray(); // ['id' =\u003e 1268054, 'firewall_group_id' =\u003e null, 'hostname' =\u003e 'my.server.tld', 'state' =\u003e 'creating', ...]\n```\n\n#### Start Virtual Machine\n\nStarts a stopped virtual machine.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/POST/api/vps/v1/virtual-machines/{virtualMachineId}/start)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003estart($virtualMachineId);\n\n$action-\u003eid; // 8123729\n$action-\u003ename; // start\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123729, 'name' =\u003e 'start', 'state' =\u003e 'success', ...]\n```\n\n#### Stop Virtual Machine\n\nStops a running virtual machine.\n\n*Doc:* [API Reference](https://developers.hostinger.com/#tag/vps-virtual-machine/POST/api/vps/v1/virtual-machines/{virtualMachineId}/stop)\n\n```php\n$virtualMachineId = 1268054;\n$action = $hostinger-\u003evps()-\u003evirtualMachines()-\u003estop($virtualMachineId);\n\n$action-\u003eid; // 8123730\n$action-\u003ename; // stop\n$action-\u003estate-\u003evalue; // success\n$action-\u003ecreated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:54:00\n$action-\u003eupdated_at-\u003eformat('Y-m-d H:i:s'); // 2025-02-27 11:58:00\n\n$action-\u003etoArray(); // ['id' =\u003e 8123730, 'name' =\u003e 'stop', 'state' =\u003e 'success', ...]\n```\n\n## Testing\n\nRun the test suite using Pest:\n\n```bash\ncomposer test\n```\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute, including coding standards, testing procedures, and guidelines for adding new features.\n\n## Credits\n\n- [Derrick Obedgiu](https://github.com/derrickobedgiu1)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see the [License File](LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderrickobedgiu1%2Fhostinger-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderrickobedgiu1%2Fhostinger-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderrickobedgiu1%2Fhostinger-php-sdk/lists"}