Rest API to configure Caddy

Is there a plugin (and if no, how could I write one) that provides a Rest API to configure caddy?

We are serving several web app clouds with caddy and when a customer registers a new domain, I’d like to just let the app request this to caddy and caddy sets up the new host.

1 Like

Great idea! It would be a nice one!

It’s on our TODO list. A standard plugin probably won’t cut it, so it’s in our plans before “feature complete”.

1 Like

Still not ready, but, I have something much of what was mentioned in this post.

I put an online server with a demo of an REST API that does more or less what @kellertobias asked.

Before showing the use of the API I would like to say what is the Daspanel project:

  • Developed from scratch using Docker. You can run a dev environment on your local computer and it will work the same way on a production server.
  • A replacement for Cpanel, Plesk and others.
  • Fully manageable via REST API.
  • Like Caddy, every site on HTTPS
  • Using Caddy as your HTTPS server

Now let’s demonstrate the use of the API (these are working examples, you can run these tests in your computer):

Create new site

curl -X POST --header ‘Content-Type: application/json’ --header ‘Accept: application/json’ --header ‘Authorization: cj68e9ec90000325l9e3c2uy1’ -d ‘{“runtime”: “php71”, “runtime”: “php71”, “sitedescription”: “ site”, “sitetype”: “grav” }’ ‘

Take note of these 2 json response fields:

_cuid (the first one) I refer to it after as _CUID_RESPONSE
active_version I refer to it after as ACTIVE_VERSION_RESPONSE


  1. Runtime options: php56, php70, php71 and static
  2. Sitetype options for PHP runtime’s: grav, wordpress, generic, cakephp2x and nextcloud12x
  3. Sitetype options for STATIC runtime: generic

Now the site is online without any content on

Install site content (optional) - in this example I’m installing Grav

curl -X POST --header ‘Content-Type: application/json’ --header ‘Accept: application/json’ --header ‘Authorization: cj68e9ec90000325l9e3c2uy1’ -d ‘{ “auth_type”: “NONE”, “directory”: “/”, “password”: “mypassword”, “url”: “”, “user”: “username”, “version”: “ACTIVE_VERSION_RESPONSE” }’ ‘


  1. auth_type, directory, password and user fields are ignored by now. In the future you can use it to install content from protected sources
  2. url is where Daspanel can download the content to be put on the site

Now the site is online with some content on

Map (redirect) to the new created site

curl -X POST --header ‘Content-Type: application/json’ --header ‘Accept: application/json’ --header ‘Authorization: cj68e9ec90000325l9e3c2uy1’ -d ‘{ “domain”: “”, “hosturl”: “www”, “ssl”: “auto”, “version”: “ACTIVE_VERSION_RESPONSE” }’ ‘

Now the site is online on


  1. When hosturl == www the root domain also is mapped to the site
  2. You cann’t create an redirect if hosturl + domain it’s used by another site. If you got an error on this step Get list off all sites to see wich redirects are in use

Delete the site and all domains redirects to it

curl -X DELETE --header ‘Accept: application/json’ --header ‘Authorization: cj68e9ec90000325l9e3c2uy1’ ‘

Get list of all sites

curl -X GET --header ‘Accept: application/json’ --header ‘Authorization: cj68e9ec90000325l9e3c2uy1’ ‘

Instead of using curl command line you can test the API online (and see his docs) going to this address:

Before any test click on the authorize button in top lef and inform api_key = cj68e9ec90000325l9e3c2uy1

About versions:

  1. A site can have many versions like: production, test, etc. With this feature you can have an production site and clone it to test with an new version of PHP without any risk to disturb the working site.
  2. Every site have an active version and per default it is displayed in the URL
  3. The API docs for working with site versions is in this URL

Using your domain in this test:

  1. Add in your domain dns server 2 entries:

After this DNS changes are published in the internet you can make API test’s using instead of

Daspanel can be tested on a local computer by clicking the Install link on this page:

When testing Daspanel in your local computer change every reference of to The domain always resolve to

Although a lot is missing/wrong, there is a draft documentation on this link:

This test server,, will be reset every day.

1 Like