### Get OAuth Token Example Source: https://developers.cloudways.com/docs/index Demonstrates how to fetch an OAuth access token for authenticating with the Cloudways API. This is a prerequisite for making most API calls. ```Python import requests # Replace with your actual API key and secret api_key = 'YOUR_API_KEY' api_secret = 'YOUR_API_SECRET' url = 'https://api.cloudways.com/api/v1/oauth/access_token' data = { 'email': api_key, 'password': api_secret } response = requests.post(url, data=data) if response.status_code == 200: access_token = response.json().get('access_token') print(f'Access Token: {access_token}') else: print(f'Failed to get access token. Status Code: {response.status_code}, Response: {response.text}') ``` -------------------------------- ### Create Server Example Source: https://developers.cloudways.com/docs/index Provides a code example for creating a new server using the Cloudways API. This typically involves specifying server details like size, region, and OS. ```Python import requests # Assume you have obtained an access token access_token = 'YOUR_ACCESS_TOKEN' url = 'https://api.cloudways.com/api/v1/server' data = { 'label': 'My New Server', 'cloudProvider': 'digital_ocean', 'region': 'lon1', 'size': '1GB', 'os': 'ubuntu', 'database': 'mysql', 'php': '7.4' } headers = { 'Authorization': f'Bearer {access_token}', 'Content-Type': 'application/json' } response = requests.post(url, json=data, headers=headers) if response.status_code == 200: print(f'Server Creation Response: {response.json()}') else: print(f'Failed to create server. Status Code: {response.status_code}, Response: {response.text}') ``` -------------------------------- ### Create Server Example Source: https://developers.cloudways.com/docs/index Provides a code example for creating a new server using the Cloudways API. This typically involves specifying server details like size, region, and OS. ```PHP 'My New Server', 'cloudProvider' => 'digital_ocean', 'region' => 'lon1', 'size' => '1GB', 'os' => 'ubuntu', 'database' => 'mysql', 'php' => '7.4' ]; $headers = [ 'Authorization: Bearer ' . $accessToken, 'Content-Type: application/json' ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo 'Server Creation Response: ' . $response; } curl_close($ch); ?> ``` -------------------------------- ### Get OAuth Token Example Source: https://developers.cloudways.com/docs/index Demonstrates how to fetch an OAuth access token for authenticating with the Cloudways API. This is a prerequisite for making most API calls. ```PHP $apiKey, 'password' => $apiSecret ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { $responseData = json_decode($response, true); if (isset($responseData['access_token'])) { echo 'Access Token: ' . $responseData['access_token']; } else { echo 'Failed to get access token. Response: ' . $response; } } curl_close($ch); ?> ``` -------------------------------- ### Get List of Add-ons Source: https://developers.cloudways.com/docs/index Retrieves a list of all available add-ons that can be managed or activated. Useful for discovering available features. ```bash # Example: Get add-ons List # GET /addons ``` -------------------------------- ### Manage Servers Source: https://developers.cloudways.com/docs/index Provides comprehensive control over servers, including creation, deletion, scaling, starting, stopping, and updating server configurations. ```bash # Example: Attach Block Storage # POST /servers/{server_id}/storage/attach # Body: {"size_gb": 50} # Example: Clone Server # POST /servers/{server_id}/clone # Body: {"new_server_name": "Cloned Server"} # Example: Create Server # POST /servers # Body: {"server_type": "cloud", "size": "1GB", "region": "us-east-1"} # Example: Delete Server # DELETE /servers/{server_id} # Example: Get Disk Usage # GET /servers/{server_id}/disk-usage # Example: Get Servers List # GET /servers # Example: Restart Server # POST /servers/{server_id}/restart # Example: Scale Block Storage # PUT /servers/{server_id}/storage/scale # Body: {"storage_id": "...", "new_size_gb": 100} # Example: Scale Volume Size # PUT /servers/{server_id}/volume/scale # Body: {"new_size_gb": 200} # Example: Start Server # POST /servers/{server_id}/start # Example: Stop Server # POST /servers/{server_id}/stop # Example: Update Server Label # PUT /servers/{server_id}/label # Body: {"new_label": "My Server"} # Example: Upgrade Server # POST /servers/{server_id}/upgrade # Body: {"new_plan": "premium"} ``` -------------------------------- ### Manage Application Cron Jobs Source: https://developers.cloudways.com/docs/index Provides functionalities to get and update the list of cron jobs configured for an application. ```bash # Example: Get Cron List # GET /applications/{app_id}/cron # Example: Update Cron List # PUT /applications/{app_id}/cron # Body: {"cron_jobs": [...]} ``` -------------------------------- ### Get Application Access State Source: https://developers.cloudways.com/docs/index Retrieves the current access state of an application, indicating if it is active, suspended, or otherwise. ```bash # Example: Get Application access state # GET /applications/{app_id}/access ``` -------------------------------- ### Get Application Backup Status Source: https://developers.cloudways.com/docs/index Retrieves the status of the latest backup for a specific application. Useful for monitoring backup operations. ```bash # Example: Get Application Backup status # GET /applications/{app_id}/backup/status ``` -------------------------------- ### Get Operation Status Source: https://developers.cloudways.com/docs/index Retrieves the status of ongoing or recently completed operations. Useful for tracking asynchronous tasks. ```bash # Example: Get Operation Status # GET /operations/{operation_id}/status ``` -------------------------------- ### Get Application SSH Access Status Source: https://developers.cloudways.com/docs/index Retrieves the status of SSH access for an application. Indicates whether SSH access is enabled or disabled. ```bash # Example: Get Application SSH Access status # GET /applications/{app_id}/ssh/status ``` -------------------------------- ### Manage Projects Source: https://developers.cloudways.com/docs/index Handles the creation, deletion, listing, and updating of projects within the Cloudways environment. ```bash # Example: Create Project # POST /projects # Body: {"project_name": "New Project"} # Example: Delete Project # DELETE /projects/{project_id} # Example: Get Project List # GET /projects # Example: Update Project # PUT /projects/{project_id} # Body: {"project_name": "Updated Project Name"} ``` -------------------------------- ### Manage Server Settings and Backups Source: https://developers.cloudways.com/docs/index Handles server backup operations, deletion of local backups, monitoring graph retrieval, and updating server settings like maintenance windows. ```bash # Example: Backup Server # POST /servers/{server_id}/backup # Example: Delete Local Server Backups # DELETE /servers/{server_id}/backups/local # Example: Get Monitoring Graph # GET /servers/{server_id}/monitoring/graph?metric=cpu # Example: Get Server Settings # GET /servers/{server_id}/settings # Example: Get Maintenance Window # GET /servers/{server_id}/maintenance-window # Example: Update Maintenance Window # PUT /servers/{server_id}/maintenance-window # Body: {"start_time": "2023-10-27T02:00:00Z", "duration_hours": 2} # Example: Update Backup Settings # PUT /servers/{server_id}/backup/settings # Body: {"frequency": "daily"} # Example: Update Master Password # PUT /servers/{server_id}/master-password # Body: {"new_password": "new_master_password"} # Example: Update Master Username # PUT /servers/{server_id}/master ``` -------------------------------- ### Manage Application Varnish Settings Source: https://developers.cloudways.com/docs/index Enables the retrieval and modification of Varnish cache settings for an application, impacting content delivery speed. ```bash # Example: Get Varnish Settings. # GET /applications/{app_id}/varnish # Example: Update Varnish Settings # PUT /applications/{app_id}/varnish # Body: {"vcl_snippet": "..."} ``` -------------------------------- ### Retrieve Lists of Resources Source: https://developers.cloudways.com/docs/index Fetches various lists of resources, including applications, backup frequencies, countries, monitoring settings, and server configurations. ```bash # Example: Get App List # GET /applications # Example: Get Backup Frequencies # GET /backups/frequencies # Example: get Countries list # GET /countries # Example: Get Monitor Durations # GET /monitoring/durations # Example: Get Monitor Targets # GET /monitoring/targets # Example: Get Package List # GET /packages # Example: Get Provider List # GET /providers # Example: Get Region List # GET /regions # Example: Get Server Sizes list # GET /servers/sizes # Example: Get Settings List # GET /settings ``` -------------------------------- ### Backup Application Source: https://developers.cloudways.com/docs/index Initiates a backup operation for a specific application. This creates a snapshot of the application's data and files. ```bash # Example: Backup # POST /applications/{app_id}/backup ``` -------------------------------- ### Manage Security Settings Source: https://developers.cloudways.com/docs/index Covers various security-related operations, including IP whitelisting, SSL management, and DNS verification. ```bash # Example: Allow Adminer # POST /security/adminer/allow # Example: Allow SIAB # POST /security/siab/allow # Example: Change Auto Renewal policy # PUT /security/ssl/auto-renewal # Body: {"policy": "enabled"} # Example: Check If IP Blacklisted # GET /security/ip-blacklist/check?ip=1.2.3.4 # Example: Get Whitelisted IPs for MySQL conections # GET /security/whitelist/mysql # Example: Get Whitelisted IPs for SSH/SFTP # GET /security/whitelist/ssh-sftp # Example: Create your DNS # POST /security/dns # Body: {"domain": "example.com", "record_type": "A", "value": "1.2.3.4"} # Example: Verifying your DNS # POST /security/dns/verify # Body: {"domain": "example.com"} # Example: Install Lets Encrypt # POST /security/ssl/lets-encrypt/install?domain=example.com # Example: Renew Lets Encrypt Manually # POST /security/ssl/lets-encrypt/renew?domain=example.com # Example: Revoke LetsEncrypt # POST /security/ssl/lets-encrypt/revoke?domain=example.com # Example: Own SSL # POST /security/ssl/own # Body: {"certificate": "...", "private_key": "..."} # Example: Remove Own SSL # DELETE /security/ssl/own?domain=example.com ``` -------------------------------- ### Manage Application FPM Settings Source: https://developers.cloudways.com/docs/index Allows retrieval and updating of FastCGI Process Manager (FPM) settings for an application. Crucial for PHP performance. ```bash # Example: Get FPM Settings # GET /applications/{app_id}/fpm # Example: Update FPM Settings # PUT /applications/{app_id}/fpm # Body: {"pm": "dynamic", "max_children": 50} ``` -------------------------------- ### Request Add-on for Application Source: https://developers.cloudways.com/docs/index Submits a request to add a specific add-on to an application. This may involve provisioning or configuration steps. ```bash # Example: Addon request for an application # POST /applications/{app_id}/addons # Body: {"addon_name": "addon_to_request"} ``` -------------------------------- ### Manage CloudwaysBot Alerts Source: https://developers.cloudways.com/docs/index Handles the creation, retrieval, and marking of alerts within the CloudwaysBot system. Includes channel management. ```bash # Example: Create an Alert Channel # POST /cloudwaysbot/channels # Body: {"channel_name": "email", "destination": "alerts@example.com"} # Example: Get All Alerts # GET /cloudwaysbot/alerts # Example: Mark All Alerts as Read # POST /cloudwaysbot/alerts/mark-all-read ``` -------------------------------- ### Manage DNS Made Easy Domains and Records Source: https://developers.cloudways.com/docs/index Provides comprehensive management for DNS Made Easy domains, including adding, deleting, listing domains, and managing their DNS records. ```bash # Example: List DNS Made Easy domains # GET /dns-made-easy/domains # Example: Add DNS Made Easy domains # POST /dns-made-easy/domains # Body: {"domain_name": "example.com"} # Example: Delete DNS Made Easy domains # DELETE /dns-made-easy/domains/{domain_id} # Example: Get DNS Made Easy domain's records # GET /dns-made-easy/domains/{domain_id}/records # Example: Add records to DNS Made Easy domain # POST /dns-made-easy/domains/{domain_id}/records # Body: {"record_type": "A", "name": "@", "value": "1.2.3.4"} # Example: Delete records from DNS Made Easy domain # DELETE /dns-made-easy/domains/{domain_id}/records/{record_id} # Example: Update record of a DNS Made Easy domain # PUT /dns-made-easy/domains/{domain_id}/records/{record_id} # Body: {"value": "5.6.7.8"} ``` -------------------------------- ### Manage Application Credentials Source: https://developers.cloudways.com/docs/index Handles the creation, retrieval, and deletion of application-specific credentials, such as API keys or tokens. ```bash # Example: Create App Credentials # POST /applications/{app_id}/credentials # Example: Get App Credentials # GET /applications/{app_id}/credentials # Example: Delete App Credential # DELETE /applications/{app_id}/credentials/{credential_id} ``` -------------------------------- ### Manage Cloudflare Enterprise Settings Source: https://developers.cloudways.com/docs/index Provides functionalities to manage Cloudflare Enterprise settings for an application, including DNS, caching, and security. ```bash # Example: Get Cloudflare details # GET /applications/{app_id}/cloudflare # Example: Set up Cloudflare for your Application # POST /applications/{app_id}/cloudflare/setup # Example: Fetch TXT Records # GET /applications/{app_id}/cloudflare/dns/txt # Example: Purge Domain Cache # POST /applications/{app_id}/cloudflare/purge # Example: Get Smart Cache Purge status # GET /applications/{app_id}/cloudflare/smart-cache-purge/status # Example: Configure Smart Cache Purge # POST /applications/{app_id}/cloudflare/smart-cache-purge/configure # Example: Get Settings # GET /applications/{app_id}/cloudflare/settings # Example: Update Settings # PUT /applications/{app_id}/cloudflare/settings # Body: {"setting_name": "value"} # Example: Get Cloudflare Cache Analytics # GET /applications/{app_id}/cloudflare/analytics/cache # Example: Get Cloudflare Security Analytics # GET /applications/{app_id}/cloudflare/analytics/security ``` -------------------------------- ### Activate Add-on on Server Source: https://developers.cloudways.com/docs/index Activates a specific add-on on a given server. This operation requires server identification and the add-on to be activated. ```bash # Example: Activate add-on on your server # POST /addons/{server_id} # Body: {"addon_name": "addon_to_activate"} ``` -------------------------------- ### Manage Application Vulnerabilities Source: https://developers.cloudways.com/docs/index Allows listing and refreshing the vulnerability status for applications. Helps in identifying and mitigating security risks. ```bash # Example: List Application Vulnerabilities # GET /applications/{app_id}/vulnerabilities # Example: Refresh Listing # POST /applications/{app_id}/vulnerabilities/refresh ``` -------------------------------- ### Manage Cloudways Bot Protection Source: https://developers.cloudways.com/docs/index Configures and manages Cloudways Bot Protection features, including activation, traffic monitoring, and IP/bot whitelisting. ```bash # Example: Bot Protection Activation # POST /applications/{app_id}/bot-protection/activate # Example: Bot Protection Deactivation # POST /applications/{app_id}/bot-protection/deactivate # Example: Bot Protection IP Whitelisting # POST /applications/{app_id}/bot-protection/whitelist/ip # Body: {"ip_address": "192.168.1.1"} # Example: Bot Protection Bad-Bots Whitelisting # POST /applications/{app_id}/bot-protection/whitelist/bad-bot # Body: {"bot_name": "BadBotX"} ``` -------------------------------- ### Manage Git Operations Source: https://developers.cloudways.com/docs/index Facilitates Git operations such as generating SSH keys, cloning repositories, and retrieving deployment history. ```bash # Example: Generate Git SSH # POST /git/ssh/generate # Example: Get Branch Names # GET /git/branches/{repository_url} # Example: Get Git Deployment History # GET /git/deployments/{repository_url} # Example: Get Git SSH # GET /git/ssh # Example: Start Git Clone # POST /git/clone # Body: {"repository_url": "...", "destination_path": "..."} # Example: Start Git Pull # POST /git/pull # Body: {"repository_path": "..."} ``` -------------------------------- ### Activate Add-on at Account Level Source: https://developers.cloudways.com/docs/index Activates an add-on across the entire account, affecting all applicable servers or services. Requires account-level permissions. ```bash # Example: Activate an addon on account level # POST /addons/account # Body: {"addon_name": "addon_to_activate"} ``` -------------------------------- ### Manage Application Backups Source: https://developers.cloudways.com/docs/index Handles the deletion of local backups and the restoration or rollback of application data from backups. ```bash # Example: Delete Local Backup # DELETE /applications/{app_id}/backup/{backup_id} # Example: Restore App # POST /applications/{app_id}/restore # Body: {"backup_id": "backup_to_restore"} # Example: Rollback Restore # POST /applications/{app_id}/rollback # Body: {"restore_id": "restore_to_rollback"} ``` -------------------------------- ### Upgrade Add-on Package Source: https://developers.cloudways.com/docs/index Upgrades the package or tier of an existing add-on. This may involve changes in features or pricing. ```bash # Example: Upgrade an addon package # PUT /addons/{server_id}/{addon_name}/upgrade # Body: {"new_package": "desired_package"} ``` -------------------------------- ### Manage SSH Keys Source: https://developers.cloudways.com/docs/index Provides functionalities for creating, deleting, and updating SSH keys used for secure access to servers. ```bash # Example: Create SSH key # POST /ssh-keys # Body: {"key_name": "my_key", "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAA..."} # Example: Delete SSH key # DELETE /ssh-keys/{key_id} # Example: Update SSH key # PUT /ssh-keys/{key_id} # Body: {"key_name": "updated_key_name"} ``` -------------------------------- ### Manage SafeUpdates Source: https://developers.cloudways.com/docs/index Controls SafeUpdates features, including retrieving status, updating settings, and accessing historical data. ```bash # Example: Get Safeupdates # GET /safeupdates # Example: Update Safeupdates # PUT /safeupdates # Body: {"setting": "value"} # Example: Get Safeupdates List # GET /safeupdates/list # Example: Get Safeupdates Settings # GET /safeupdates/settings # Example: Get Safeupdates Schedule # GET /safeupdates/schedule # Example: Get Safeupdates History # GET /safeupdates/history ``` -------------------------------- ### Manage Elastic Email Domains Source: https://developers.cloudways.com/docs/index Provides functionalities to manage Elastic Email domains, including listing, verifying, and deleting them. ```bash # Example: List Elastic Email Domains # GET /elasticemail/domains # Example: Verify Elastic Email Domain # POST /elasticemail/domains/{domain_id}/verify # Example: Delete Elastic Email Domain # DELETE /elasticemail/domains/{domain_id} ``` -------------------------------- ### Update Application Webroot Source: https://developers.cloudways.com/docs/index Changes the webroot directory for an application. The webroot is the public-facing directory of the application. ```bash # Example: Update Webroot # PUT /applications/{app_id}/webroot # Body: {"new_webroot": "/public_html"} ``` -------------------------------- ### Manage Application CNAME Records Source: https://developers.cloudways.com/docs/index Allows for the deletion and updating of CNAME records associated with an application. Essential for domain configuration. ```bash # Example: Delete Cname # DELETE /applications/{app_id}/cname # Example: Update App Cname # PUT /applications/{app_id}/cname # Body: {"new_cname": "your.domain.com"} ``` -------------------------------- ### Authenticate with OAuth Access Token Source: https://developers.cloudways.com/docs/index Obtain an OAuth access token to authenticate API requests. This is a fundamental step for accessing protected resources. ```bash # Example: Obtaining an OAuth Access Token # POST /oauth/access_token # Headers: {"Authorization": "Basic YOUR_BASE64_ENCODED_CLIENT_CREDENTIALS"} # Body: {"grant_type": "client_credentials"} ``` -------------------------------- ### Update Application Device Detection Status Source: https://developers.cloudways.com/docs/index Controls the status of device detection features for an application. Useful for responsive design or device-specific content. ```bash # Example: Update Device Detection Status # PUT /applications/{app_id}/device-detection # Body: {"enabled": true} ``` -------------------------------- ### Reset Application File Permissions Source: https://developers.cloudways.com/docs/index Resets the file permissions for an application to their default or recommended state. Important for security and functionality. ```bash # Example: Reset File Permissions # POST /applications/{app_id}/permissions/reset ``` -------------------------------- ### Update Application XMLRPC Status Source: https://developers.cloudways.com/docs/index Enables or disables the XML-RPC interface for an application. XML-RPC can be a security risk if not managed properly. ```bash # Example: Update Application XMLRPC # PUT /applications/{app_id}/xmlrpc # Body: {"status": "disabled"} ``` -------------------------------- ### Update Application Symlink Source: https://developers.cloudways.com/docs/index Modifies the symlink configuration for an application. Symlinks are used to link directories or files. ```bash # Example: Update Symlink # PUT /applications/{app_id}/symlink # Body: {"target": "/path/to/target", "link_name": "my_symlink"} ``` -------------------------------- ### Update Application Direct PHP Execution Status Source: https://developers.cloudways.com/docs/index Controls whether direct PHP execution is allowed for an application. This setting impacts security and performance. ```bash # Example: Update Direct PHP Execution Status # PUT /applications/{app_id}/direct-php # Body: {"enabled": false} ``` -------------------------------- ### Update Application Aliases Source: https://developers.cloudways.com/docs/index Modifies the aliases associated with an application. Aliases are alternative domain names that point to the application. ```bash # Example: Update App Aliases # PUT /applications/{app_id}/aliases # Body: {"aliases": ["alias1.com", "alias2.com"]} ``` -------------------------------- ### Enforce HTTPS for Application Source: https://developers.cloudways.com/docs/index Enforces the use of HTTPS for an application, redirecting all HTTP traffic to HTTPS. Enhances security. ```bash # Example: Enforce HTTPS # POST /applications/{app_id}/enforce-https ``` -------------------------------- ### Update Application GEO IP Settings Source: https://developers.cloudways.com/docs/index Configures GeoIP settings for an application, potentially used for content localization or access control based on location. ```bash # Example: Update Application GEO IP # PUT /applications/{app_id}/geoip # Body: {"enabled": true, "country_code": "US"} ``` -------------------------------- ### Update Application Ignore Query String Status Source: https://developers.cloudways.com/docs/index Manages the setting for ignoring query strings in URLs for caching or other purposes within an application. ```bash # Example: Update Ignore Query String Status # PUT /applications/{app_id}/ignore-query-string # Body: {"enabled": true} ``` -------------------------------- ### Clear Application Cache Source: https://developers.cloudways.com/docs/index Clears the cache for a specific application. This is often done after making changes to ensure fresh content is served. ```bash # Example: Clear App Cache # POST /applications/{app_id}/cache/clear ``` -------------------------------- ### Change Application Access State Source: https://developers.cloudways.com/docs/index Modifies the access state of an application, such as enabling or disabling it. Requires application identification. ```bash # Example: Change Application access state # PUT /applications/{app_id}/access # Body: {"state": "enabled"} ``` -------------------------------- ### Update Application Cron Optimizer Status Source: https://developers.cloudways.com/docs/index Manages the status of the cron optimizer for an application, which can affect the scheduling and execution of cron jobs. ```bash # Example: Update Cron Optimizer Status # PUT /applications/{app_id}/cron-optimizer # Body: {"enabled": true} ``` -------------------------------- ### Update Application CORS Headers Source: https://developers.cloudways.com/docs/index Configures Cross-Origin Resource Sharing (CORS) headers for an application, allowing or restricting cross-domain requests. ```bash # Example: Update CORS Headers # PUT /applications/{app_id}/cors # Body: {"allowed_origins": ["https://example.com"]} ``` -------------------------------- ### Deactivate Add-on on Server Source: https://developers.cloudways.com/docs/index Deactivates a previously activated add-on on a specific server. This operation may revert configuration changes. ```bash # Example: Deactivate add-on on your server # DELETE /addons/{server_id}/{addon_name} ``` -------------------------------- ### Update Application Database Password Source: https://developers.cloudways.com/docs/index Changes the password for the application's database. Requires careful handling to maintain data integrity. ```bash # Example: Update DB Password # PUT /applications/{app_id}/database/password # Body: {"new_password": "secure_new_password"} ``` -------------------------------- ### Update Application Admin Password Source: https://developers.cloudways.com/docs/index Changes the administrative password for an application. This is crucial for securing access to application settings. ```bash # Example: Update Application Admin Password # PUT /applications/{app_id}/admin-password # Body: {"new_password": "strong_admin_password"} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.