• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Plesk REST API for PHP

Riculum

New Pleskian
Hello everyone

I am trying to automate the ordering process. I want to use the REST API and PHP. The official documentation is not very helpful, hardly anything is described. The swagger version is not very informative either. Does anyone know good documentation that describes how to create a new subscription?

Greetings
 
Thank you for the quick feedback. What do you mean by use 'subscription' CLI utility use. I see the command /cli/commands in the swagger documentation. This gives me a list. But how do I use it?
 
Hello, most recent documentation incl. swagger scheme and playground can be found under Tools & Settings > Server Management > Remote API (REST) page.
 
Example of creating a domain using REST API

Code:
POST https://{{api_host}}:{{api_port}}/api/v2/domains
Accept: application/json
X-API-Key: {{api_token}}

{
  "name": "test.dev",
  "hosting_type": "virtual",
  "hosting_settings": {
    "ftp_login": "test_login",
    "ftp_password": "test_password"
  },
  "plan": {
    "name": "Unlimited"
  }
}
 
I'm sorry, but I don't get it. I successfully created a user and a domain with CURL and PHP. However, I don't see in the documentation how to set this up for a subscription. Sorry, but there is nothing in the KB about how I use the CLI in PHP. I found this:

plesk bin subscription --create example.com -owner admin -service-plan "Default Domain" -ip 192.168.1.100 -login jdoe -passwd "userpass"

LINK: subscription: Subscriptions

How can I use this in PHP?
 
I don't see in the documentation how to set this up for a subscription.
When you use /domains endpoint in REST it creates a subscription when no 'base_domain' nor 'parent_domain' provided.

You can use all CLI commands using /cli endpoint like this
Code:
POST https://{{api_host}}:{{api_port}}/api/v2/cli/subscription/call
Accept: application/json
X-API-Key: {{api_token}}
{"params": ["--create", "example.com", "-owner", "admin", "-service-plan", "Default Domain", "-login", "jdoe", "-passwd", "userpass", "-ip", "10.58.108.108"]}
 
So if I understand correctly it automatically creates a subscription when I create a domain. Under "base_domain" you need an "id" and a "guid". The domain doesn't exist yet (will be created first). Where should I get these values from?
 
Back
Top