Create site

Create a new site on your server.


POST/api/servers/{server}/sites

Create a site

This endpoint allows you to create a new site on your server.

Required parameters

  • Name
    root_domain
    Type
    string
    Description

    The domain name for the site. Maximum: 100 characters.

  • Name
    web_directory
    Type
    string
    Description

    The web directory path. Maximum: 50 characters. Must match /[a-zA-Z0-9\/]/.

Optional parameters

  • Name
    project_root
    Type
    string
    Description

    The project root path. Maximum: 50 characters.

  • Name
    project_type
    Type
    string
    Description

    The site's project type. Options: laravel, nodejs, statamic, craft-cms, symfony, wordpress, octobercms, cakephp.

  • Name
    system_user
    Type
    string
    Description

    Must match the name of a system user on your server.

  • Name
    webserver_template
    Type
    integer
    Description

    The ID of a webserver template saved in your account.

  • Name
    webhook_url
    Type
    url
    Description

    A URL to receive a notification when the site has been installed.

Request

POST
/api/servers/{server}/sites
curl -X POST "https://ploi.io/api/servers/{server}/sites" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "root_domain": "domain.com",
    "web_directory": "/public",
    "system_user": "ploi"
  }'

Response

{
  "data": {
    "id": 1,
    "server_id": 1,
    "domain": "domain.com",
    "deploy_script": false,
    "web_directory": "/public",
    "project_type": null,
    "project_root": "/",
    "last_deploy_at": null,
    "system_user": "ploi",
    "php_version": 7.2,
    "health_url": null,
    "notification_urls": {
      "slack": null,
      "discord": null,
      "webhook": null
    },
    "has_repository": true,
    "created_at": "2019-07-29 10:27:32"
  }
}

Webhook payload

If you provide a webhook_url, you'll receive this payload when the site is created:

Webhook Payload

{
  "message": "Site example.com has been created",
  "server": {
    "id": 1,
    "name": "royal-reef"
  },
  "site": {
    "id": 1,
    "domain": "example.com",
    "ip": "127.0.0.1",
    "paths": {
      "public": "/home/ploi/example.com/public",
      "server": "/home/ploi/example.com"
    }
  }
}