fattain-naime/cwp-superpowers/cwp-api

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

This skill should be used when the user asks to "use CWP API", "create API key", "manage accounts via API", "automate CWP tasks", "list API endpoints", "integrate with CWP", "use cwp_api script", "configure API access", "create account via API", "manage databases via API", "set up billing integration", "configure WHMCS", or needs to interact with the CWP API or automate CWP operations.

Install

npx vskill@latest install fattain-naime/cwp-superpowers/cwp-api

SKILL.md

CWP API Integration

Interact with the CWP REST API and shell-based API for automation, account management, and third-party integrations. Handle API endpoints, authentication, and common automation workflows.

If the user provides specific details via "$ARGUMENTS", focus the response on that API task. For example: /cwp-pro-centos:cwp-api create account for example.com will focus on the account creation API endpoint.

API Overview

Use two API interfaces for CWP automation:

InterfacePortProtocol
REST API2304HTTPS
Shell APIN/ACLI via /scripts/cwp_api

API Configuration

Setup
  1. Navigate to CWP Settings -> API Manager
  2. Generate an API key
  3. Whitelist allowed IP addresses
  4. Note the API base URL
Base URL
https://SERVER_IP:2304/v1/{function}
Authentication

All API requests require the key parameter with your API key.

Request Format
  • Method: POST for all endpoints
  • Response: JSON or XML

REST API Endpoints

Account Management
EndpointOperations
/v1/accountadd, update, delete, list, suspend, unsuspend
/v1/accountdetaillist
/v1/accountquotalist
/v1/account_metadatalist
/v1/changepackupdate
/v1/changepassupdate
Database Management
EndpointOperations
/v1/databasemysqladd, delete, list
/v1/usermysqladd, delete, list
SSL Management
EndpointOperations
/v1/autossladd, list, delete, renew
Domain Management
EndpointOperations
/v1/admindomainsadd, delete, list
Email Management
EndpointOperations
/v1/emailadminlist
Cron Jobs
EndpointOperations
/v1/cronjobsusersadd, delete, list
Packages
EndpointOperations
/v1/packagesadd, update, delete, list
Server Information
EndpointOperations
/v1/typeserverlist
/v1/quotalimitlist

API Usage Examples

Create Account
bash
# Replace ${CWP_API_KEY} with your actual API key or set it as an environment variable
curl -X POST "https://SERVER_IP:2304/v1/account" \
-d "key=${CWP_API_KEY}" \
-d "action=add" \
-d "domain=example.com" \
-d "username=examuser" \
-d "password=CHANGE_ME" \
-d "email=admin@example.com" \
-d "server_ips=1.2.3.4" \
-d "package=default"
List Accounts
bash
curl -X POST "https://SERVER_IP:2304/v1/account" \
-d "key=${CWP_API_KEY}" \
-d "action=list"
Suspend Account
bash
curl -X POST "https://SERVER_IP:2304/v1/account" \
-d "key=${CWP_API_KEY}" \
-d "action=suspend" \
-d "username=examuser"
Create Database
bash
curl -X POST "https://SERVER_IP:2304/v1/databasemysql" \
-d "key=${CWP_API_KEY}" \
-d "action=add" \
-d "username=examuser" \
-d "dbname=mydb"

Shell API (/scripts/cwp_api)

The shell API provides command-line access to CWP functions.

Account Operations
bash
# Account management
/scripts/cwp_api account add USERNAME DOMAIN PASSWORD EMAIL IP PACKAGE
/scripts/cwp_api account remove_user USERNAME
/scripts/cwp_api account suspend_user USERNAME
/scripts/cwp_api account unsuspend_user USERNAME
/scripts/cwp_api account fix_perms USERNAME
/scripts/cwp_api account list_domains USERNAME
# Bulk operations
/scripts/cwp_api account update_diskquota_all
/scripts/cwp_api account update_limits_all
/scripts/cwp_api account mail_fix_permissions
/scripts/cwp_api account update_policyd_all
/scripts/cwp_api account rebuild_etc_named_conf
/scripts/cwp_api account rebuild_var_named_all
Web Server Operations
bash
/scripts/cwp_api webservers rebuild_all
/scripts/cwp_api webservers rebuild_user USERNAME
/scripts/cwp_api webservers restart
/scripts/cwp_api webservers reload
Application Operations
bash
/scripts/cwp_api apps install_softaculous
Database Operations
bash
/scripts/cwp_api databasemysql add USERNAME DBNAME
/scripts/cwp_api databasemysql delete USERNAME DBNAME
/scripts/cwp_api databasemysql list USERNAME

PHP API Client

Installation
bash
composer require puerari/cwp_api
Usage
php
require_once 'vendor/autoload.php';
// Use environment variable for API key: getenv('CWP_API_KEY')
$cwpApi = new Cwpapi('https://yourcwpdomain.com', getenv('CWP_API_KEY'));
// Create account - use a secure password, not a hardcoded string
$status = $cwpApi->createAccount(
'domain.com',
'username',
'CHANGE_ME', // Generate a secure password
'email@domain.com',
'1.2.3.4'
);
// Create database
$status = $cwpApi->createMysqlDatabase('username', 'dbname');
// List accounts
$accounts = $cwpApi->listAccounts();

Action Hooks

Hooks allow executing custom code on CWP events.

DNS Hooks

Location: /usr/local/cwpsrv/htdocs/resources/admin/hooks/dns/

HookTrigger
dns_serial_updateZone additions, subdomain changes
dns_new_zone_addNew DNS zone created
dns_new_subdomain_addNew subdomain created
dns_zone_removeDomain deleted
dns_subdomain_removeSubdomain deleted
Account Hooks

Location: /usr/local/cwpsrv/htdocs/resources/admin/hooks/account/

HookTrigger
account_newAccount created
account_removeAccount deleted
account_suspendAccount suspended
account_unsuspendAccount reactivated
account_new_domainDomain added
account_remove_domainDomain removed
account_new_subdomainSubdomain added
account_remove_subdomainSubdomain removed
Hook Example
php
<?php
function account_new($array){
// $array contains: username, domain, status
// Reseller accounts also include 'reseller' key
$log = date('Y-m-d H:i:s') . " - New account: {$array['username']} ({$array['domain']})\n";
file_put_contents('/var/log/cwp_hooks.log', $log, FILE_APPEND);
}
?>

Billing Integration

WHMCS Integration
bash
# Download WHMCS module
wget http://dl1.centos-webpanel.com/files/3rdparty/whmcs/cwp7.zip
# Extract to WHMCS
unzip cwp7.zip -d /path/to/whmcs/modules/servers/cwp7/

WHMCS Configuration:

  1. Setup -> Products/Services -> Servers
  2. Type: Cwp7
  3. Enter CWP server IP and API key
Other Supported Systems
  • WiseCP
  • HostBill
  • Blesta
  • Clientexec

Automation Workflows

New Server Provisioning
bash
#!/bin/bash
# Automate new account setup
# Set CWP_API_KEY environment variable before running: export CWP_API_KEY="your-key"
API_URL="https://SERVER_IP:2304/v1"
API_KEY="${CWP_API_KEY}"
# Create account
curl -s -X POST "$API_URL/account" \
-d "key=$API_KEY" \
-d "action=add" \
-d "domain=$1" \
-d "username=$2" \
-d "password=$3" \
-d "email=$4"
# Create database
curl -s -X POST "$API_URL/databasemysql" \
-d "key=$API_KEY" \
-d "action=add" \
-d "username=$2" \
-d "dbname=${2}_db"
# Enable AutoSSL
curl -s -X POST "$API_URL/autossl" \
-d "key=$API_KEY" \
-d "action=add" \
-d "domain=$1"
Backup Script
bash
#!/bin/bash
# Backup all users via API
# Script name varies by CWP version
for user in $(/scripts/list_users); do
if [ -f /scripts/user_backup ]; then
sh /scripts/user_backup "$user"
elif [ -f /scripts/backup_user ]; then
sh /scripts/backup_user "$user"
fi
done

API Security

  1. Whitelist only necessary IP addresses
  2. Use strong API keys
  3. Rotate API keys periodically
  4. Monitor API access logs
  5. Use HTTPS only (port 2304)
  6. Never expose API key in client-side code

Troubleshooting

IssueSolution
API connection refusedVerify port 2304 is open in CSF
Authentication failedVerify API key and IP whitelist
Timeout errorsCheck server load, increase timeout
JSON parse errorCheck response format, verify endpoint
Hook not executingCheck file permissions, verify PHP syntax
Diagnostic Commands
bash
# Test API connectivity - set CWP_API_KEY environment variable first
curl -k -s "https://SERVER_IP:2304/v1/typeserver" -d "key=${CWP_API_KEY}"
# Check API port
ss -tlnp | grep 2304
# Check CWP API service
/scripts/check_api
# View CWP logs
tail -f /usr/local/cwpsrv/logs/error_log

Additional Resources

  • references/api-endpoints.md -- Complete API endpoint reference
  • references/api-examples.md -- API request/response examples
  • references/hooks-reference.md -- All available action hooks

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/fattain-naime/cwp-superpowers/cwp-api/badge)](https://verified-skill.com/skills/fattain-naime/cwp-superpowers/cwp-api)

Something wrong with this skill or its page? Tell us.