Rest API examples

Discussion in 'ISPConfig 3 Priority Support' started by Jemt, Sep 1, 2018.

  1. Jemt

    Jemt Member HowtoForge Supporter

    I have been trying for several hours to figure out how to use the Remote API, but there is no proper documentation on the subject available.
    Can someone provide me with examples on how to:
    1. Create a website "" with Proxy Redirecting to "" ?
    2. Create a subdomain "" with Proxy Redirecting to "" ?
    3. Create an e-mail domain "" AND an e-mail account "[email protected]" with password "xyz" with SMTP+POP3 enabled but IMAP disabled?
    I'm currently working on a project where we have been planning on using ISPConfig's Remote API for a long time. But the lack of documentation makes me really worried that we have to find another solution, which basically puts us back 3 months :-S

    A command line interface is also an option if it is reliable and documented - anything that can help us automate things. I'd really love to avoid SOAP though if possible.

    * Fingers crossed *

    - Thanks
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The documentation for the remote API is in the remote_client folder of the ISPConfig tar.gz. The examples and documentation that you find there are for the SOAP flavor of the API, but the REST version is identical, just that it get's the data by POST request and returns the data in json format.

    The remote API is stable and used by most larger ISPConfig installations since many years, it is also used by the ISPConfig WHMCS plugin (see thread in this forum, e.g. in case you like to see more examples in that code) and it is also used by the ISPConfig Migration tool.

    Here a short example on how to use the REST version:

    1) Login to the API to obtain the session id token:

    curl --header "Content-Type: application/json" \
      --insecure --request POST \
      --data '{"username":"admin","password":"xxxxxxxxx"}' \
    2) Then you can e.g. get the data of a dns zone like this:

    curl --header "Content-Type: application/json" \
    --insecure --request POST \
    --data '{"session_id":"8a550bdbee45385dcbed3beadc78167f","primary_id":{"origin":"test.tld."}}' \
    Adding something is similar, just put all the data columns in the POST data section and set the function name as GET parameter. Here an example of the newly added config store function:

    curl --header "Content-Type: application/json" \
    --insecure --request POST \
    --data '{"session_id":"8a550bdbee45385dcbed3beadc78167f","group":"migration","name":"test","value":"1"}' \
    In regard to the command line script, there is one and it uses the REST API as well, you can find it in the remote_client/cli/ folder of the master branch. So one more example of software that uses the ISPConfig remote API.
    Jesse Norell likes this.
  3. Jemt

    Jemt Member HowtoForge Supporter

    Thanks God!
    Sorry I jumped to conclusions. We are getting used to great documentation on HowToForge, so it just wasn't aligned with the level of quality and accessibility we are used to. Also, it's really hard to google things in an archive. Perhaps consider making it available from the website.
    In any case, thank you very much for the snippets to get us started :)

  4. till

    till Super Moderator Staff Member ISPConfig Developer

    We keep the API docs in GIT so that developers can commit changes to them directly. They are accessible online as well when you have an ISPConfig git account (
    ironjohn likes this.
  5. ironjohn

    ironjohn New Member HowtoForge Supporter

    This post helped me check that my ISPConfig remote user could connect correctly while troubleshooting the whmcs connection.
    Thanks again @till!

    till likes this.
  6. ironjohn

    ironjohn New Member HowtoForge Supporter

    I should have added what I learned today for other API newbies benefit.

    I am having a problem getting limit template details on a remote whmcs install. After the login command above I plugged my session_id into the client_templates_get_all request below.

    curl --header 'Content-Type: application/json' --insecure --request POST --data '{"session_id":"LongStringOfLettersAndNumbers"}'

    In my case it worked perfectly and returned all details of my one and only limit template. So I know the problem is not with this specific ISPConfig install or firewall/networking on my end.

    Simple things I'm sure, but I use curl once or twice in a decade and never before for testing an API.

Share This Page