• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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