### Provision Custom Server using PHP Source: https://api.spinupwp.com/index This PHP snippet shows how to provision a custom server using the SpinupWP SDK. It initializes the SpinupWP client with an API token and then calls the `createCustom` method with all the necessary server configuration details, mirroring the parameters used in the cURL example. ```php $spinupwp = new SpinupWp\SpinupWp('API_TOKEN'); $server = $spinupwp->servers->createCustom([ 'provider_name' => 'OVH', 'ip_address' => '10.0.0.1', 'ssh_port' => 22, 'ubuntu_version' => 24.04, 'username' => 'root', 'password' => '9X1PU0cnJp8FyjMW', 'auth_method' => 'password', 'hostname' => 'turnipjuice-media', 'timezone' => 'America/Toronto', 'database_root_password' => 'V9ByakWHYgFN', 'post_provision_script' => 'apt-get install -q -y nodejs; apt-get install -q -y npm;', ]); ``` -------------------------------- ### POST /sites Source: https://api.spinupwp.com/index Creates a new website on the SpinupWP platform. This endpoint allows for the configuration of various site settings, including domain, user, installation method, caching, HTTPS, database, and WordPress-specific details. The response includes an `event_id` to track the site creation progress. ```APIDOC ## POST /sites ### Description Creates a new site. Returns the `event_id` of the create site event along with the created Site object. You can check the events endpoint for the `event_id` every few minutes to find out when the site is ready. ### Method POST ### Endpoint https://api.spinupwp.app/v1/sites ### Parameters #### Request Body - **server_id** (integer) - Required - The ID of the server where the site will be created. - **domain** (string) - Required - The primary domain for the site. - **additional_domains[n][domain]** (string) - Optional - An additional domain for the site. - **additional_domains[n][redirect]** (boolean) - Optional - Whether to redirect additional domains to the primary domain. - **site_user** (string) - Required - The username for the site on the server. - **installation_method** (string) - Required - The installation method (e.g., 'wp'). - **page_cache[enabled]** (boolean) - Optional - Whether to enable page caching. - **https[enabled]** (boolean) - Optional - Whether to enable HTTPS (SSL). - **database[name]** (string) - Required - The name for the site's database. - **database[username]** (string) - Required - The username for the site's database. - **wordpress[title]** (string) - Optional - The title of the WordPress site. - **wordpress[admin_user]** (string) - Optional - The username for the WordPress admin. - **wordpress[admin_email]** (string) - Optional - The email address for the WordPress admin. - **wordpress[admin_password]** (string) - Optional - The password for the WordPress admin. ### Request Example ```curl curl -X POST https://api.spinupwp.app/v1/sites \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' \ -d 'server_id'=1 \ -d 'domain'=turnipjuice.media \ -d 'additional_domains[1][domain]'=www.turnipjuice.media \ -d 'additional_domains[1][redirect]'=true \ -d 'site_user'=turnipjuicemedia \ -d 'installation_method'=wp \ -d 'page_cache[enabled]'=true \ -d 'https[enabled]'=true \ -d 'database[name]'=turnipjuicemedia \ -d 'database[username]'=turnipjuicemedia \ -d 'wordpress[title]'="Turnip Juice Media" \ -d 'wordpress[admin_user]'=admin \ -d 'wordpress[admin_email]'=abraham@turnipjuice.media \ -d 'wordpress[admin_password]'=DK6Jrfj8gyWzL ``` ### Response #### Success Response (200) - **event_id** (integer) - The ID of the site creation event. - **data** (object) - Contains the details of the newly created site. - **id** (integer) - The unique identifier for the site. - **server_id** (integer) - The ID of the server hosting the site. - **domain** (string) - The primary domain of the site. - **additional_domains** (array) - An array of additional domains configured for the site. - **site_user** (string) - The username for the site on the server. - **php_version** (string) - The PHP version used by the site. - **public_folder** (string) - The public directory for the site. - **is_wordpress** (boolean) - Indicates if the site is a WordPress installation. - **page_cache** (object) - Page caching configuration. - **https** (object) - HTTPS (SSL) configuration. - **nginx** (object) - Nginx configuration details. - **database** (object) - Database configuration. - **backups** (object) - Backup configuration. - **wp_core_update** (boolean) - Whether WordPress core updates are enabled. - **wp_theme_updates** (integer) - Number of available WordPress theme updates. - **wp_plugin_updates** (integer) - Number of available WordPress plugin updates. - **git** (object) - Git integration details. - **basic_auth** (object) - Basic authentication configuration. - **created_at** (string) - The timestamp when the site was created. - **status** (string) - The current status of the site. #### Response Example ```json { "event_id": 1, "data": { "id": 0, "server_id": 1, "domain": "turnipjuice.media", "additional_domains": [ { "domain": "www.turnipjuice.media", "redirect": { "enabled": true }, "created_at": "2024-07-01T12:00:00.000000Z" } ], "site_user": "turnipjuicemedia", "php_version": "8.3", "public_folder": "/", "is_wordpress": true, "page_cache": { "enabled": true }, "https": { "enabled": true }, "nginx": { "uploads_directory_protected": true, "xmlrpc_protected": true, "subdirectory_rewrite_in_place": false }, "database": { "id": 1, "user_id": 1, "table_prefix": "wp_" }, "backups": { "files": true, "database": true, "paths_to_exclude": "node_modules\n/files/vendor", "retention_period": 30, "next_run_time": "2024-07-01T12:00:00.000000Z", "storage_provider": { "id": 1, "region": "nyc3", "bucket": "turnipjuice-media" } }, "wp_core_update": true, "wp_theme_updates": 0, "wp_plugin_updates": 3, "git": { "repo": "git@github.com:spinupwp/spinupwp-composer-site.git", "branch": "main", "deploy_script": "composer install --optimize-autoload --no-dev", "push_enabled": true, "deployment_url": "https://api.spinupwp.app/git/jeJLdKrl63/deploy" }, "basic_auth": { "enabled": true, "username": "turnipjuice" }, "created_at": "2024-07-01T12:00:00.000000Z", "status": "deployed" } } ``` ``` -------------------------------- ### Paginate Server List (cURL) Source: https://api.spinupwp.com/index Example of making a paginated request to list servers, specifying a page number. ```bash curl -X GET https://api.spinupwp.app/v1/servers?page=2 \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` -------------------------------- ### Create Site with cURL Source: https://api.spinupwp.com/index This snippet demonstrates how to create a new site using a cURL request to the SpinupWP API. It includes parameters for server ID, domain, additional domains, WordPress installation, page caching, HTTPS, database configuration, and WordPress admin credentials. Ensure you replace `{access-token}` with your actual API token. ```curl curl -X POST https://api.spinupwp.app/v1/sites \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' \ -d 'server_id'=1 \ -d 'domain'=turnipjuice.media \ -d 'additional_domains[1][domain]'=www.turnipjuice.media \ -d 'additional_domains[1][redirect]'=true \ -d 'site_user'=turnipjuicemedia \ -d 'installation_method'=wp \ -d 'page_cache[enabled]'=true \ -d 'https[enabled]'=true \ -d 'database[name]'=turnipjuicemedia \ -d 'database[username]'=turnipjuicemedia \ -d 'wordpress[title]'="Turnip Juice Media" \ -d 'wordpress[admin_user]'=admin \ -d 'wordpress[admin_email]'=abraham@turnipjuice.media \ -d 'wordpress[admin_password]'=DK6Jrfj8gyWzL ``` -------------------------------- ### GET /servers/{id} Source: https://api.spinupwp.com/index Retrieves the details of a single server. Returns a Server object. ```APIDOC ## Retrieve a server ### Description Retrieves the details of a single server. ### Method GET ### Endpoint /servers/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the server to retrieve. ### Request Example ```curl curl -X GET https://api.spinupwp.app/v1/servers/{id} \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ### Response #### Success Response (200) - **data** (object) - Contains the server details. - **id** (integer) - The server ID. - **name** (string) - The server name. - **provider_name** (string) - The cloud provider name (e.g., DigitalOcean). - **ubuntu_version** (string) - The Ubuntu version installed on the server. - **ip_address** (string) - The server's IP address. - **ssh_port** (integer) - The SSH port for the server. - **timezone** (string) - The server's timezone. - **region** (string) - The server's region. - **size** (string) - The server size (e.g., '1 GB / 1 vCPU'). - **disk_space** (object) - Information about disk space usage. - **total** (integer) - Total disk space in bytes. - **available** (integer) - Available disk space in bytes. - **used** (integer) - Used disk space in bytes. - **updated_at** (string) - Timestamp of the last disk space update. - **database** (object) - Database server details. - **server** (string) - The database server type and version (e.g., 'mysql-8.0'). - **host** (string) - The database host. - **port** (integer) - The database port. - **ssh_publickey** (string) - The SSH public key for the server. - **git_publickey** (string) - The Git public key for the server. - **connection_status** (string) - The connection status of the server. - **reboot_required** (boolean) - Indicates if a reboot is required. - **upgrade_required** (boolean) - Indicates if an upgrade is required. - **install_notes** (string|null) - Any notes related to the server installation. - **created_at** (string) - Timestamp of when the server was created. - **status** (string) - The current status of the server (e.g., 'provisioned'). #### Response Example ```json { "data": { "id": 1, "name": "turnipjuice-media", "provider_name": "DigitalOcean", "ubuntu_version": "24.04", "ip_address": "10.0.0.1", "ssh_port": 22, "timezone": "UTC", "region": "TOR1", "size": "1 GB / 1 vCPU", "disk_space": { "total": 25210576000, "available": 20966548000, "used": 4244028000, "updated_at": "2024-07-01T12:00:00.000000Z" }, "database": { "server": "mysql-8.0", "host": "localhost", "port": 3306 }, "ssh_publickey": "ssh-rsa AAAA....", "git_publickey": "ssh-rsa AAAA....", "connection_status": "connected", "reboot_required": true, "upgrade_required": false, "install_notes": null, "created_at": "2024-07-01T12:00:00.000000Z", "status": "provisioned" } } ``` ``` -------------------------------- ### Provision Custom Server using cURL Source: https://api.spinupwp.com/index This snippet demonstrates how to provision a new custom server using the SpinupWP API via a cURL request. It includes essential parameters like server provider, Ubuntu version, IP address, SSH details, and authentication method. The request also specifies a hostname, timezone, database root password, and a post-provision script for installing Node.js and npm. ```curl curl -X POST https://api.spinupwp.app/v1/servers/custom \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' \ -d 'provider_name=OVH' \ -d 'ubuntu_version=24.04' \ -d 'ip_address=10.0.0.1' \ -d 'ssh_port=22' \ -d 'auth_method=password' \ -d 'username=root' \ --data-urlencode 'password=9X1PU0cnJp8FyjMW' \ -d 'hostname=turnipjuice-media' \ -d 'timezone=America/Toronto' \ --data-urlencode 'database_root_password=V9ByakWHYgFN' \ --data-urlencode 'post_provision_script=apt-get install -q -y nodejs; apt-get install -q -y npm;' ``` -------------------------------- ### GET /sites/{id} Source: https://api.spinupwp.com/index Retrieves the details of a single site. Returns a Site object. ```APIDOC ## GET /sites/{id} ### Description Retrieves the details of a single site. Returns a Site object. ### Method GET ### Endpoint `/sites/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the site to retrieve. ### Request Example ```curl curl -X GET https://api.spinupwp.app/v1/sites/{id} \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ```php sites->get($siteId); ?> ``` ### Response #### Success Response (200) - **data** (object) - Contains the site details. - **id** (integer) - The unique identifier for the site. - **server_id** (integer) - The ID of the server where the site is hosted. - **domain** (string) - The primary domain of the site. - **additional_domains** (array) - A list of additional domains associated with the site. - **site_user** (string) - The username for the site's user. - **php_version** (string) - The PHP version used by the site. - **public_folder** (string) - The public directory for the site's files. - **is_wordpress** (boolean) - Indicates if the site is a WordPress installation. - **page_cache** (object) - Configuration for page caching. - **https** (object) - Configuration for HTTPS. - **nginx** (object) - Nginx configuration details. - **database** (object) - Database configuration details. - **backups** (object) - Backup configuration details. - **wp_core_update** (boolean) - Indicates if WordPress core updates are enabled. - **wp_theme_updates** (integer) - The number of available WordPress theme updates. - **wp_plugin_updates** (integer) - The number of available WordPress plugin updates. - **git** (object) - Git integration configuration details. - **basic_auth** (object) - Basic authentication configuration details. - **created_at** (string) - The timestamp when the site was created. - **status** (string) - The current status of the site (e.g., 'deployed'). #### Response Example ```json { "data": { "id": 0, "server_id": 1, "domain": "turnipjuice.media", "additional_domains": [ { "domain": "www.turnipjuice.media", "redirect": { "enabled": true }, "created_at": "2024-07-01T12:00:00.000000Z" } ], "site_user": "turnipjuicemedia", "php_version": "8.3", "public_folder": "/", "is_wordpress": true, "page_cache": { "enabled": true }, "https": { "enabled": true }, "nginx": { "uploads_directory_protected": true, "xmlrpc_protected": true, "subdirectory_rewrite_in_place": false }, "database": { "id": 1, "user_id": 1, "table_prefix": "wp_" }, "backups": { "files": true, "database": true, "paths_to_exclude": "node_modules\\n/files/vendor", "retention_period": 30, "next_run_time": "2024-07-01T12:00:00.000000Z", "storage_provider": { "id": 1, "region": "nyc3", "bucket": "turnipjuice-media" } }, "wp_core_update": true, "wp_theme_updates": 0, "wp_plugin_updates": 3, "git": { "repo": "git@github.com:spinupwp/spinupwp-composer-site.git", "branch": "main", "deploy_script": "composer install --optimize-autoload --no-dev", "push_enabled": true, "deployment_url": "https://api.spinupwp.app/git/jeJLdKrl63/deploy" }, "basic_auth": { "enabled": true, "username": "turnipjuice" }, "created_at": "2024-07-01T12:00:00.000000Z", "status": "deployed" } } ``` ``` -------------------------------- ### List Sites with cURL Source: https://api.spinupwp.com/index This snippet demonstrates how to list all sites using a GET request to the SpinupWP API with cURL. It includes necessary headers for authentication and data format. ```shell curl -X GET https://api.spinupwp.app/v1/sites \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' \ -d server_id=1 \ -G ``` -------------------------------- ### Retrieve Site Details (PHP) Source: https://api.spinupwp.com/index Retrieves the details of a single site using the SpinupWP PHP client library. It shows how to instantiate the client and call the `get` method with a site ID. ```php $spinupwp = new SpinupWp\SpinupWp('API_TOKEN'); $site = $spinupwp->sites->get($siteId); ``` -------------------------------- ### GET /events Source: https://api.spinupwp.com/index Retrieves a paginated list of all events associated with your SpinupWP account, providing insights into site actions and operations. ```APIDOC ## GET /events ### Description Retrieves a list of events. Returns a paginated list of Event objects. ### Method GET ### Endpoint /events ### Parameters #### Query Parameters - **page** (integer) - Optional - The page number for pagination. - **per_page** (integer) - Optional - The number of items to return per page. ### Request Example ```bash curl -X GET https://api.spinupwp.app/v1/events \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ### Response #### Success Response (200) - **data** (array) - A list of Event objects. - **id** (integer) - The unique identifier for the event. - **initiated_by** (string) - The user or process that initiated the event. - **server_id** (integer) - The ID of the server where the event occurred. - **name** (string) - A description of the event. - **status** (string) - The current status of the event (e.g., "deployed", "failed"). - **output** (string|null) - Any output or error messages associated with the event. - **created_at** (string) - The timestamp when the event was created. - **started_at** (string) - The timestamp when the event started. - **finished_at** (string) - The timestamp when the event finished. - **pagination** (object) - Pagination details for the response. - **previous** (string|null) - URL for the previous page of results. - **next** (string|null) - URL for the next page of results. - **per_page** (integer) - The number of items per page. - **count** (integer) - The total number of items. #### Response Example ```json { "data": [ { "id": 0, "initiated_by": "Abraham", "server_id": 1, "name": "Creating site turnipjuice.media", "status": "deployed", "output": null, "created_at": "2024-07-01T12:00:00.000000Z", "started_at": "2024-07-01T12:00:00.000000Z", "finished_at": "2024-07-01T12:00:00.000000Z" } ], "pagination": { "previous": null, "next": "https://api.spinupwp.app/v1/events?page=2", "per_page": 10, "count": 15 } } ``` ``` -------------------------------- ### POST /servers/{id}/services/php/restart Source: https://api.spinupwp.com/index Restart all versions of the PHP-FPM service installed on a server. Returns the `event_id` of the restart PHP-FPM event. ```APIDOC ## Restart PHP-FPM service ### Description Restarts all installed versions of the PHP-FPM service on a server. ### Method POST ### Endpoint /servers/{id}/services/php/restart ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the server whose PHP-FPM service should be restarted. ### Request Example ```curl curl -X POST https://api.spinupwp.app/v1/servers/{id}/services/php/restart \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ### Response #### Success Response (200) - **event_id** (integer) - The ID of the restart PHP-FPM event. #### Response Example ```json { "event_id": 1 } ``` ``` -------------------------------- ### Retrieve Site Details (cURL) Source: https://api.spinupwp.com/index Fetches the details of a specific site using its ID. This cURL command demonstrates how to make a GET request to the SpinupWP API, including authentication headers. ```curl curl -X GET https://api.spinupwp.app/v1/sites/{id} \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` -------------------------------- ### Provision Server via PHP SDK Source: https://api.spinupwp.com/index Illustrates provisioning a new server using the SpinupWP PHP SDK. This code snippet shows how to instantiate the SDK with an API token and create a server object with detailed configuration parameters. ```php $spinupwp = new SpinupWp\SpinupWp('API_TOKEN'); $server = $spinupwp->servers->create([ 'server_provider' => [ 'id' => 1, 'region' => 'tor1', 'size' => 's-1vcpu-1gb', 'enable_backups' => true, ], 'hostname' => 'turnipjuice-media', 'timezone' => 'America/Toronto', 'database' => [ 'root_password' => 'V9ByakWHYgFN', ], 'post_provision_script' => "apt-get install -q -y nodejs; apt-get install -q -y npm;", ]); ``` -------------------------------- ### Instantiate SpinupWP SDK (PHP) Source: https://api.spinupwp.com/index Shows how to initialize the SpinupWP PHP SDK with an API token. ```php $spinupwp = new SpinupWp\SpinupWp('API_TOKEN'); ``` -------------------------------- ### Provision a server Source: https://api.spinupwp.com/index Provisions a new server with default settings. ```APIDOC ## Provision a server ### Description Provisions a new server using the default configuration settings. ### Method POST ### Endpoint `/v1/servers` ### Parameters #### Headers - **Accept** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer {access-token}` #### Request Body - **provider** (string) - Required - The server provider to use (e.g., 'digitalocean', 'aws'). - **region** (string) - Required - The region where the server will be provisioned. - **size** (string) - Required - The size or plan for the server. ### Request Example ```json { "provider": "digitalocean", "region": "nyc3", "size": "s-1vcpu-1gb" } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the newly provisioned server. - **status** (string) - The current status of the server (e.g., 'provisioning'). ``` -------------------------------- ### Run a Git deployment Source: https://api.spinupwp.com/index Initiates a Git deployment for a specific website. ```APIDOC ## Run a Git deployment ### Description Triggers a Git deployment for a website, updating it with the latest code from its repository. ### Method POST ### Endpoint `/v1/sites/{site_id}/deploy-git` ### Parameters #### Path Parameters - **site_id** (integer) - Required - The ID of the site to deploy. #### Headers - **Accept** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer {access-token}` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the Git deployment has been initiated. ``` -------------------------------- ### GET /events/{id} Source: https://api.spinupwp.com/index Retrieves detailed information about a specific event using its unique ID. This is useful for monitoring the status and output of past operations. ```APIDOC ## GET /events/{id} ### Description Retrieves the details of a single event. Returns an Event object. For operations that return an `event_id` you can use this endpoint to check the status of the event. A `status` of “deployed” means that the event was successfully completed. If the event fails, the `output` field will contain any error messages. ### Method GET ### Endpoint /events/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the event to retrieve. ### Request Example ```bash curl -X GET https://api.spinupwp.app/v1/events/{id} \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ### Response #### Success Response (200) - **data** (object) - An Event object containing details about the event. - **id** (integer) - The unique identifier for the event. - **initiated_by** (string) - The user or process that initiated the event. - **server_id** (integer) - The ID of the server where the event occurred. - **name** (string) - A description of the event. - **status** (string) - The current status of the event (e.g., "deployed", "failed"). - **output** (string|null) - Any output or error messages associated with the event. - **created_at** (string) - The timestamp when the event was created. - **started_at** (string) - The timestamp when the event started. - **finished_at** (string) - The timestamp when the event finished. #### Response Example ```json { "data": { "id": 0, "initiated_by": "Abraham", "server_id": 1, "name": "Creating site turnipjuice.media", "status": "deployed", "output": null, "created_at": "2024-07-01T12:00:00.000000Z", "started_at": "2024-07-01T12:00:00.000000Z", "finished_at": "2024-07-01T12:00:00.000000Z" } } ``` ``` -------------------------------- ### Create Site with PHP SDK Source: https://api.spinupwp.com/index This PHP code snippet utilizes the SpinupWP SDK to create a new site. It initializes the SDK with an API token and then calls the `create` method on the `sites` object, passing server ID and an array of site configuration options. This method abstracts the API request details. ```php $spinupwp = new SpinupWp\SpinupWp('API_TOKEN'); $site = $spinupwp->sites->create($serverId, [ 'domain' => 'turnipjuice.media', 'site_user' => 'turnipjuicemedia', 'installation_method' => 'wp', 'page_cache' => [ 'enabled' => true, ], 'https' => [ 'enabled' => true, ], 'database' => [ 'name' => 'turnipjuicemedia', 'username' => 'turnipjuicemedia', ], 'wordpress' => [ 'title' => 'Turnip Juice Media', 'admin_user' => 'admin', 'admin_email' => 'abraham@turnipjuice.media', 'admin_password' => 'DK6Jrfj8gyWzL', ] ]); ``` -------------------------------- ### Create a site Source: https://api.spinupwp.com/index Creates a new website on a specified server. ```APIDOC ## Create a site ### Description Creates a new website on a specified SpinupWP server. You need to provide the server ID and domain name. ### Method POST ### Endpoint `/v1/sites` ### Parameters #### Headers - **Accept** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer {access-token}` #### Request Body - **server_id** (integer) - Required - The ID of the server where the site will be created. - **domain** (string) - Required - The domain name for the new website. - **php_version** (string) - Optional - The PHP version to use for the site. ### Request Example ```json { "server_id": 456, "domain": "example.com", "php_version": "8.1" } ``` ### Response #### Success Response (201) - **id** (integer) - The unique identifier for the newly created site. - **domain** (string) - The domain name of the site. - **status** (string) - The status of the site creation. ``` -------------------------------- ### Provision Server via cURL Source: https://api.spinupwp.com/index Demonstrates provisioning a new server using a cURL request. It specifies server provider details, hostname, timezone, database credentials, and a post-provision script. This method is useful for command-line operations. ```curl curl -X POST https://api.spinupwp.app/v1/servers \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' \ -d 'server_provider[id]'=1 \ -d 'server_provider[region]'="tor1" \ -d 'server_provider[size]'="s-1vcpu-1gb" \ -d 'server_provider[enable_backups]'=true \ -d 'hostname'="turnipjuice-media" \ -d 'timezone'="America/Toronto" \ -d 'database[root_password]'="V9ByakWHYgFN" \ -d 'post_provision_script'="apt-get install -q -y nodejs; apt-get install -q -y npm;" ``` -------------------------------- ### Restart PHP-FPM Service Source: https://api.spinupwp.com/index Restarts all installed versions of the PHP-FPM service on the server. This action is crucial for applying PHP configuration updates or resolving performance issues. Returns the event ID for the service restart. ```curl curl -X POST https://api.spinupwp.app/v1/servers/{id}/services/php/restart \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ```php $spinupwp = new SpinupWp\SpinupWp('API_TOKEN'); $eventId = $spinupwp->servers->restartPhp($serverId); ``` -------------------------------- ### Paginate Server List with SDK (PHP) Source: https://api.spinupwp.com/index Demonstrates fetching a list of servers using the SpinupWP PHP SDK, with automatic pagination handling. ```php $spinupwp = new SpinupWp\SpinupWp('API_TOKEN'); $servers = $spinupwp->servers->list(); // Auto-pagination handles fetching lists of resources without having // to paginate results and perform subsequent requests manually foreach ($servers as $server) { // Do something with $server } ``` -------------------------------- ### SpinupWP Event Structure Source: https://api.spinupwp.com/index Details the structure of an event object within SpinupWP, including its unique identifier, the initiator, server association, event name, status, output logs, and timestamps for creation, start, and completion. ```json { "id": 0, "initiated_by": "Abraham", "server_id": 1, "name": "Creating site turnipjuice.media", "status": "deployed", "output": null, "created_at": "2024-07-01T12:00:00.000000Z", "started_at": "2024-07-01T12:00:00.000000Z", "finished_at": "2024-07-01T12:00:00.000000Z" } ``` -------------------------------- ### Provision a custom server Source: https://api.spinupwp.com/index Provisions a new server with custom configuration details. ```APIDOC ## Provision a custom server ### Description Provisions a new server with custom configuration, allowing for more specific setup parameters. ### Method POST ### Endpoint `/v1/servers` ### Parameters #### Headers - **Accept** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer {access-token}` #### Request Body - **provider** (string) - Required - The server provider. - **region** (string) - Required - The server region. - **size** (string) - Required - The server size. - **ssh_key_id** (integer) - Optional - The ID of the SSH key to use. - **ip_address** (string) - Optional - A static IP address for the server. - **additional_volumes** (array) - Optional - Array of additional volumes to attach. ### Request Example ```json { "provider": "digitalocean", "region": "nyc3", "size": "s-1vcpu-1gb", "ssh_key_id": 123, "ip_address": "192.168.1.100" } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the newly provisioned server. - **status** (string) - The current status of the server. ``` -------------------------------- ### POST /servers/custom Source: https://api.spinupwp.com/index Provisions a new custom server with specified configurations. This endpoint returns an event ID for tracking the provisioning process, which typically takes around 10 minutes. Users will be notified via email upon successful provisioning. ```APIDOC ## POST /servers/custom ### Description Provisions a new custom server with the specified configurations. The response includes an `event_id` to track the provisioning status. Provisioning can take up to 10 minutes, and an email notification will be sent upon completion. ### Method POST ### Endpoint /servers/custom ### Parameters #### Request Body - **provider_name** (string) - Required - The name of the server provider (e.g., OVH). - **ubuntu_version** (string) - Required - The Ubuntu version for the server (e.g., "24.04"). Must be one of the latest two LTS versions. - **ip_address** (string) - Required - The public IP address of the server. - **ssh_port** (integer) - Optional - The SSH port. Defaults to 22. - **username** (string) - Required - The username for SSH connection. - **auth_method** (string) - Optional - The authentication method. Either `password` or `publickey`. Defaults to `publickey`. - **password** (string) - Optional - The SSH password. Required if `auth_method` is `password`. - **hostname** (string) - Required - The hostname for the server. Allowed characters are alphanumeric, dashes, and periods. - **timezone** (string) - Optional - The server's timezone. Defaults to UTC. - **post_provision_script** (string) - Optional - A script to run as root after provisioning. - **database_root_password** (string) - Optional - The root password for the database. If omitted, one will be auto-generated. - **database_provider_id** (integer) - Optional - The ID of an external database to use. ### Request Example ```json { "provider_name": "OVH", "ubuntu_version": "24.04", "ip_address": "10.0.0.1", "ssh_port": 22, "username": "root", "password": "9X1PU0cnJp8FyjMW", "auth_method": "password", "hostname": "turnipjuice-media", "timezone": "America/Toronto", "database_root_password": "V9ByakWHYgFN", "post_provision_script": "apt-get install -q -y nodejs; apt-get install -q -y npm;" } ``` ### Response #### Success Response (200) - **event_id** (integer) - The ID of the provisioning event. - **data** (object) - Contains the Server object. - **id** (integer) - The unique identifier for the server. - **name** (string) - The hostname of the server. - **provider_name** (string) - The name of the server provider. - **ubuntu_version** (string) - The Ubuntu version installed. - **ip_address** (string) - The server's public IP address. - **ssh_port** (integer) - The SSH port. - **timezone** (string) - The server's configured timezone. - **region** (string) - The server's region. - **size** (string) - The server's size or plan. - **disk_space** (object) - Information about disk space usage. - **database** (object) - Database configuration details. - **ssh_publickey** (string) - The SSH public key for the server. - **git_publickey** (string) - The Git SSH public key for the server. - **connection_status** (string) - The current connection status. - **reboot_required** (boolean) - Indicates if a reboot is required. - **upgrade_required** (boolean) - Indicates if an upgrade is required. - **install_notes** (string | null) - Notes related to the server installation. - **created_at** (string) - The timestamp when the server was created. - **status** (string) - The current status of the server (e.g., "provisioned"). #### Response Example ```json { "event_id": 1, "data": { "id": 1, "name": "turnipjuice-media", "provider_name": "OVH", "ubuntu_version": "24.04", "ip_address": "10.0.0.1", "ssh_port": 22, "timezone": "UTC", "region": "", "size": "", "disk_space": { "total": 25210576000, "available": 20966548000, "used": 4244028000, "updated_at": "2024-07-01T12:00:00.000000Z" }, "database": { "server": "mysql-8.0", "host": "localhost", "port": 3306 }, "ssh_publickey": "ssh-rsa AAAA....", "git_publickey": "ssh-rsa AAAA....", "connection_status": "connected", "reboot_required": true, "upgrade_required": false, "install_notes": null, "created_at": "2024-07-01T12:00:00.000000Z", "status": "provisioned" } } ``` ``` -------------------------------- ### POST /sites/{id}/git/deploy Source: https://api.spinupwp.com/index Initiates a Git deployment for a site, pulling the latest changes from the repository and executing any configured deployment scripts. ```APIDOC ## POST /sites/{id}/git/deploy ### Description Run a Git deployment which will pull the latest changes from your Git repository to the site on your server, and run your deployment script afterward (if you have one configured). Returns the `event_id` of the git deployment event. ### Method POST ### Endpoint /sites/{id}/git/deploy ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the site for which to run the Git deployment. ### Request Example ```bash curl -X POST https://api.spinupwp.app/v1/sites/{id}/git/deploy \ -H 'Accept: application/json' \ -H 'Authorization: Bearer {access-token}' ``` ### Response #### Success Response (200) - **event_id** (integer) - The ID of the event triggered by the Git deployment request. #### Response Example ```json { "event_id": 1 } ``` ```