Management API Guide
Comprehensive guide to UncleBTech's Management API including service creation, billing operations, and common integration patterns.
Management API Guide
The UncleBTech Management API allows you to programmatically manage hosting services, domains, billing, and support tickets. This guide covers the most commonly used endpoints with practical examples and integration patterns.
Service Management
Creating New Services
Create WordPress Hosting Service:
POST /api/v1/services Content-Type: application/json Authorization: Bearer your-api-key { "type": "wordpress_hosting", "plan": "advanced", "domain": "example.com", "billing_cycle": "monthly", "options": { "auto_install_wordpress": true, "enable_ssl": true, "backup_frequency": "daily" } }
Response:
{ "success": true, "data": { "id": "svc_wp_123456", "type": "wordpress_hosting", "plan": "advanced", "status": "provisioning", "domain": "example.com", "server_ip": "192.168.1.100", "control_panel_url": "https://cp.uncleb.tech/login/auto/abc123", "created_at": "2025-01-21T10:00:00Z", "expires_at": "2025-02-21T10:00:00Z" } }
Create Cloud Hosting Service:
POST /api/v1/services { "type": "cloud_hosting", "plan": "starter_cloud", "billing_cycle": "annual", "options": { "wordpress_installs": 10, "enable_white_label": false, "backup_retention": "90_days" } }
Create LaunchStack Service:
POST /api/v1/services { "type": "launchstack_hosting", "plan": "advanced_launchstack", "billing_cycle": "monthly", "options": { "git_provider": "github", "repository": "username/repo-name", "auto_deploy": true, "environment": "production" } }
Service Operations
List All Services:
GET /api/v1/services?status=active&type=wordpress_hosting # Response { "success": true, "data": [ { "id": "svc_wp_123456", "type": "wordpress_hosting", "name": "My WordPress Site", "status": "active", "plan": "advanced", "domain": "example.com", "resource_usage": { "storage_used": "2.5 GB", "bandwidth_used": "45 GB", "storage_limit": "10 GB", "bandwidth_limit": "100 GB" }, "expires_at": "2025-02-21T10:00:00Z" } ], "meta": { "total": 1, "page": 1, "per_page": 20 } }
Get Service Details:
GET /api/v1/services/svc_wp_123456 # Response includes detailed configuration { "success": true, "data": { "id": "svc_wp_123456", "type": "wordpress_hosting", "status": "active", "configuration": { "php_version": "8.3", "mysql_version": "10.11", "ssl_enabled": true, "backup_schedule": "daily_3am", "cache_enabled": true }, "resource_limits": { "storage": "10 GB", "bandwidth": "100 GB", "php_memory": "512 MB", "databases": 1 }, "access_details": { "control_panel": "https://cp.uncleb.tech/...", "ftp_hostname": "ftp.example.com", "database_hostname": "db.example.com" } } }
Service Modifications
Upgrade/Downgrade Service:
PUT /api/v1/services/svc_wp_123456 { "plan": "premium", "billing_cycle": "annual", "upgrade_immediately": true } # Response { "success": true, "data": { "id": "svc_wp_123456", "plan": "premium", "status": "upgrading", "estimated_completion": "2025-01-21T11:00:00Z", "prorated_charge": "£15.00" } }
Suspend/Unsuspend Service:
# Suspend service POST /api/v1/services/svc_wp_123456/suspend { "reason": "maintenance", "notify_customer": true } # Unsuspend service POST /api/v1/services/svc_wp_123456/unsuspend { "reason": "maintenance_complete" }
Domain Management API
Domain Registration
Register New Domain:
POST /api/v1/domains { "domain": "newdomain.com", "period": 1, "contacts": { "registrant": { "name": "John Smith", "email": "john@example.com", "phone": "+44.1234567890", "address": { "street": "123 Main St", "city": "London", "postal_code": "SW1A 1AA", "country": "GB" } } }, "nameservers": [ "ns1.uncleb.tech", "ns2.uncleb.tech" ], "auto_renew": true, "privacy_protection": true }
Domain Registration Response:
{ "success": true, "data": { "domain": "newdomain.com", "status": "pending_registration", "registration_id": "reg_123456", "expires_at": "2026-01-21T10:00:00Z", "nameservers": ["ns1.uncleb.tech", "ns2.uncleb.tech"], "privacy_enabled": true, "auto_renew": true } }
DNS Record Management
List DNS Records:
GET /api/v1/domains/example.com/dns # Response { "success": true, "data": [ { "id": "dns_123456", "type": "A", "name": "@", "value": "192.168.1.100", "ttl": 3600, "created_at": "2025-01-21T10:00:00Z" }, { "id": "dns_123457", "type": "CNAME", "name": "www", "value": "example.com", "ttl": 3600, "created_at": "2025-01-21T10:00:00Z" } ] }
Create DNS Record:
POST /api/v1/domains/example.com/dns { "type": "A", "name": "subdomain", "value": "192.168.1.101", "ttl": 3600 } # Response { "success": true, "data": { "id": "dns_123458", "type": "A", "name": "subdomain", "value": "192.168.1.101", "ttl": 3600, "status": "active" } }
Update DNS Record:
PUT /api/v1/domains/example.com/dns/dns_123458 { "value": "192.168.1.102", "ttl": 1800 }
Delete DNS Record:
DELETE /api/v1/domains/example.com/dns/dns_123458 # Response { "success": true, "message": "DNS record deleted successfully" }
Billing and Invoice Management
Invoice Operations
List Invoices:
GET /api/v1/invoices?status=unpaid&limit=10 # Response { "success": true, "data": [ { "id": "inv_123456", "number": "UBT-2025-001234", "status": "unpaid", "amount": "14.99", "currency": "GBP", "due_date": "2025-01-28T23:59:59Z", "services": [ { "service_id": "svc_wp_123456", "description": "WordPress Advanced Hosting", "amount": "14.99" } ], "created_at": "2025-01-21T10:00:00Z" } ] }
Get Invoice Details:
GET /api/v1/invoices/inv_123456 # Detailed invoice response { "success": true, "data": { "id": "inv_123456", "number": "UBT-2025-001234", "status": "unpaid", "subtotal": "14.99", "tax_amount": "3.00", "total_amount": "17.99", "currency": "GBP", "line_items": [ { "description": "WordPress Advanced Hosting", "quantity": 1, "unit_price": "14.99", "total": "14.99", "service_id": "svc_wp_123456" } ], "payment_terms": "net_7", "due_date": "2025-01-28T23:59:59Z" } }
Payment Processing
Process Payment:
POST /api/v1/invoices/inv_123456/pay { "payment_method": "pm_card_123456", "amount": "17.99" } # Response { "success": true, "data": { "payment_id": "pay_123456", "status": "succeeded", "amount": "17.99", "currency": "GBP", "payment_method": { "type": "card", "last4": "4242", "brand": "visa" }, "processed_at": "2025-01-21T10:30:00Z" } }
List Payment Methods:
GET /api/v1/account/payment-methods # Response { "success": true, "data": [ { "id": "pm_card_123456", "type": "card", "brand": "visa", "last4": "4242", "exp_month": 12, "exp_year": 2025, "is_default": true, "created_at": "2025-01-01T00:00:00Z" } ] }
Support Ticket Management
Creating Support Tickets
Submit New Ticket:
POST /api/v1/tickets { "subject": "WordPress site loading slowly", "department": "technical", "priority": "normal", "message": "My WordPress site at example.com has been loading very slowly since yesterday. Page load times are over 10 seconds.", "service_id": "svc_wp_123456", "attachments": [ { "filename": "screenshot.png", "content": "base64-encoded-content", "content_type": "image/png" } ] } # Response { "success": true, "data": { "id": "tkt_123456", "number": "UBT-2025-001234", "subject": "WordPress site loading slowly", "status": "open", "priority": "normal", "department": "technical", "created_at": "2025-01-21T10:00:00Z", "estimated_response": "2025-01-21T14:00:00Z" } }
Ticket Management
List Support Tickets:
GET /api/v1/tickets?status=open&department=technical # Response { "success": true, "data": [ { "id": "tkt_123456", "number": "UBT-2025-001234", "subject": "WordPress site loading slowly", "status": "open", "priority": "normal", "last_reply": "2025-01-21T12:00:00Z", "assigned_to": "Technical Support Team" } ] }
Reply to Ticket:
POST /api/v1/tickets/tkt_123456/reply { "message": "I've tried clearing the cache as suggested, but the site is still loading slowly. The issue seems to be worse during peak hours.", "attachments": [ { "filename": "performance-test.pdf", "content": "base64-encoded-content", "content_type": "application/pdf" } ] }
Close Ticket:
POST /api/v1/tickets/tkt_123456/close { "reason": "issue_resolved", "feedback": "Great support, issue resolved quickly!" }
Resource Monitoring
Service Resource Usage
Get Resource Usage:
GET /api/v1/services/svc_wp_123456/usage # Response { "success": true, "data": { "current_period": { "start_date": "2025-01-01T00:00:00Z", "end_date": "2025-01-31T23:59:59Z", "storage": { "used": "2.5 GB", "limit": "10 GB", "percentage": 25 }, "bandwidth": { "used": "45 GB", "limit": "100 GB", "percentage": 45 }, "cpu_usage": { "average": "15%", "peak": "45%" } }, "daily_usage": [ { "date": "2025-01-20", "bandwidth": "2.1 GB", "cpu_avg": "12%", "requests": 1250 } ] } }
Performance Metrics
Get Performance Data:
GET /api/v1/services/svc_wp_123456/performance?period=7d # Response { "success": true, "data": { "uptime": "99.95%", "average_response_time": "245ms", "page_load_times": { "p50": "1.2s", "p95": "2.8s", "p99": "4.1s" }, "core_web_vitals": { "lcp": "1.8s", "fid": "45ms", "cls": "0.05" }, "error_rate": "0.02%" } }
Backup and Recovery API
Backup Management
List Available Backups:
GET /api/v1/services/svc_wp_123456/backups # Response { "success": true, "data": [ { "id": "bkp_123456", "type": "full", "status": "completed", "size": "1.2 GB", "created_at": "2025-01-21T03:00:00Z", "expires_at": "2025-04-21T03:00:00Z", "download_url": "https://backups.uncleb.tech/download/..." } ] }
Create Manual Backup:
POST /api/v1/services/svc_wp_123456/backups { "type": "full", "description": "Pre-update backup", "retention_days": 30 } # Response { "success": true, "data": { "id": "bkp_123457", "status": "in_progress", "estimated_completion": "2025-01-21T10:15:00Z" } }
Restore from Backup:
POST /api/v1/services/svc_wp_123456/restore { "backup_id": "bkp_123456", "restore_type": "full", "confirm_data_loss": true } # Response { "success": true, "data": { "restore_id": "rst_123456", "status": "in_progress", "estimated_completion": "2025-01-21T10:30:00Z" } }
Billing Automation
Payment Method Management
Add Payment Method:
POST /api/v1/account/payment-methods { "type": "card", "card": { "number": "4242424242424242", "exp_month": 12, "exp_year": 2025, "cvc": "123" }, "billing_details": { "name": "John Smith", "email": "john@example.com", "address": { "line1": "123 Main St", "city": "London", "postal_code": "SW1A 1AA", "country": "GB" } }, "set_as_default": true }
Auto-Pay Configuration:
PUT /api/v1/services/svc_wp_123456/auto-pay { "enabled": true, "payment_method": "pm_card_123456", "days_before_due": 7 } # Response { "success": true, "data": { "auto_pay_enabled": true, "payment_method": "pm_card_123456", "next_payment_date": "2025-02-14T10:00:00Z" } }
Invoice Automation
Generate Invoice:
POST /api/v1/invoices { "service_id": "svc_wp_123456", "billing_period": { "start": "2025-02-01T00:00:00Z", "end": "2025-02-28T23:59:59Z" }, "auto_pay": true }
Bulk Invoice Operations:
# Get invoices for multiple services POST /api/v1/invoices/bulk { "service_ids": ["svc_wp_123456", "svc_cl_789012"], "status": "unpaid", "due_before": "2025-01-31T23:59:59Z" }
Monitoring and Alerts API
Setting Up Monitoring
Configure Monitoring:
POST /api/v1/services/svc_wp_123456/monitoring { "uptime_monitoring": { "enabled": true, "check_interval": "5m", "timeout": "30s", "locations": ["london", "new-york", "singapore"] }, "performance_monitoring": { "enabled": true, "thresholds": { "response_time": "2s", "error_rate": "1%" } }, "alerts": { "email": ["admin@example.com"], "webhook": "https://your-app.com/alerts", "sms": ["+44123456789"] } }
Get Monitoring Status:
GET /api/v1/services/svc_wp_123456/monitoring/status # Response { "success": true, "data": { "uptime": { "status": "up", "last_check": "2025-01-21T10:00:00Z", "response_time": "245ms", "uptime_percentage": "99.95%" }, "alerts": { "active_alerts": 0, "recent_alerts": [ { "type": "performance", "message": "Response time exceeded threshold", "triggered_at": "2025-01-20T15:30:00Z", "resolved_at": "2025-01-20T15:45:00Z" } ] } } }
Bulk Operations and Automation
Batch API Requests
Batch Multiple Operations:
POST /api/v1/batch { "requests": [ { "method": "GET", "url": "/services/svc_wp_123456/usage" }, { "method": "GET", "url": "/services/svc_cl_789012/usage" }, { "method": "POST", "url": "/services/svc_wp_123456/backups", "body": {"type": "full"} } ] } # Batch response { "success": true, "data": [ { "status": 200, "body": { /* usage data */ } }, { "status": 200, "body": { /* usage data */ } }, { "status": 201, "body": { /* backup creation response */ } } ] }
Automation Examples
Service Provisioning Automation:
import requests import json class UncleBTechAPI: def __init__(self, api_key): self.api_key = api_key self.base_url = "https://api.uncleb.tech/v1" self.headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } def create_wordpress_service(self, domain, plan="advanced"): payload = { "type": "wordpress_hosting", "plan": plan, "domain": domain, "billing_cycle": "monthly", "options": { "auto_install_wordpress": True, "enable_ssl": True } } response = requests.post( f"{self.base_url}/services", headers=self.headers, data=json.dumps(payload) ) return response.json() def setup_dns_records(self, domain, server_ip): dns_records = [ {"type": "A", "name": "@", "value": server_ip}, {"type": "A", "name": "www", "value": server_ip}, {"type": "MX", "name": "@", "value": f"mail.{domain}", "priority": 10} ] for record in dns_records: response = requests.post( f"{self.base_url}/domains/{domain}/dns", headers=self.headers, data=json.dumps(record) ) return True # Usage example api = UncleBTechAPI("your-api-key") service = api.create_wordpress_service("newclient.com") api.setup_dns_records("newclient.com", service["data"]["server_ip"])
Error Handling and Debugging
Common API Errors
Validation Errors:
{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "The request contains invalid parameters", "details": { "field_errors": { "domain": ["Domain name is required"], "plan": ["Plan 'invalid_plan' is not available"] } } } }
Resource Errors:
{ "success": false, "error": { "code": "RESOURCE_LIMIT_EXCEEDED", "message": "Account has reached maximum number of services", "details": { "current_count": 10, "limit": 10, "upgrade_options": ["premium_account"] } } }
Debugging API Requests
Request Debugging:
# Include debug headers curl -H "Authorization: Bearer your-api-key" \ -H "X-Debug: true" \ -H "X-Request-ID: custom-request-id" \ https://api.uncleb.tech/v1/services # Debug response headers X-Request-ID: custom-request-id X-Response-Time: 245ms X-Rate-Limit-Remaining: 999
Logging API Requests:
// Example request logging function logAPIRequest(method, url, data, response) { console.log({ timestamp: new Date().toISOString(), method: method, url: url, request_data: data, response_status: response.status, response_data: response.data, request_id: response.headers['x-request-id'] }); }
API Development Tip: Always include proper error handling in your API integrations. Use the X-Request-ID header to track requests when contacting support about API issues.
Integration Patterns
Common Integration Scenarios
Customer Onboarding Automation:
- Create hosting service via API
- Configure DNS records automatically
- Set up monitoring and alerts
- Send welcome email with access details
- Create initial support ticket for follow-up
Billing Integration:
- Sync invoices with accounting system
- Automate payment processing
- Handle failed payments and notifications
- Generate custom billing reports
- Manage subscription lifecycle
Monitoring Integration:
- Pull service metrics into monitoring dashboard
- Set up custom alerting rules
- Integrate with incident management systems
- Automate response to common issues
- Generate performance reports
Webhook Integration
Processing Webhooks:
<?php // Webhook endpoint example function handleUncleBTechWebhook($payload, $signature) { // Verify webhook signature $expectedSignature = hash_hmac('sha256', $payload, $webhookSecret); if (!hash_equals($signature, $expectedSignature)) { http_response_code(401); exit('Invalid signature'); } $event = json_decode($payload, true); switch ($event['type']) { case 'service.created': handleServiceCreated($event['data']); break; case 'payment.failed': handlePaymentFailed($event['data']); break; case 'service.suspended': handleServiceSuspended($event['data']); break; } http_response_code(200); echo 'OK'; }
API Testing and Development
Testing Environment
Sandbox API:
# Sandbox API base URL https://api-sandbox.uncleb.tech/v1 # Sandbox features - Test API functionality without affecting live services - Simulated responses for testing error conditions - Rate limiting testing - Webhook testing with configurable delays
Test Data:
# Test service creation POST /api/v1/services { "type": "wordpress_hosting", "plan": "test_plan", "domain": "test-domain.example", "test_mode": true }
API Client Libraries
Example API Client (Node.js):
class UncleBTechAPI { constructor(apiKey, baseUrl = 'https://api.uncleb.tech/v1') { this.apiKey = apiKey; this.baseUrl = baseUrl; } async request(method, endpoint, data = null) { const url = `${this.baseUrl}${endpoint}`; const options = { method, headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' } }; if (data) { options.body = JSON.stringify(data); } const response = await fetch(url, options); const result = await response.json(); if (!response.ok) { throw new Error(`API Error: ${result.error.message}`); } return result; } // Service methods async listServices() { return this.request('GET', '/services'); } async createService(serviceData) { return this.request('POST', '/services', serviceData); } async getService(serviceId) { return this.request('GET', `/services/${serviceId}`); } } // Usage const api = new UncleBTechAPI('your-api-key'); const services = await api.listServices();
API Limits and Quotas
Request Limits
Rate Limiting Details:
# Rate limit information in response headers X-RateLimit-Limit: 1000 # Requests per hour X-RateLimit-Remaining: 999 # Remaining requests X-RateLimit-Reset: 1640995200 # Reset timestamp X-RateLimit-Retry-After: 3600 # Seconds until reset
Quota Management:
# Check API quota usage GET /api/v1/account/api-quota # Response { "success": true, "data": { "current_usage": 1250, "limit": 5000, "reset_at": "2025-01-21T15:00:00Z", "quota_type": "premium" } }
Resource Limits
Service Creation Limits:
- Standard Account: 10 services maximum
- Premium Account: 50 services maximum
- Enterprise Account: Custom limits
- API Requests: Separate limits for API usage
Bulk Operation Limits:
- Batch Requests: Maximum 10 requests per batch
- Bulk DNS: Maximum 100 DNS records per request
- Bulk Backups: Maximum 5 simultaneous backup operations
Performance Tip: Use batch operations and proper pagination to minimize API requests and stay within rate limits. Implement exponential backoff for handling rate limit errors gracefully.
Getting API Support
API Support Resources
Documentation and Help:
- Interactive Docs: https://api.uncleb.tech/docs
- API Status: https://status.uncleb.tech/api
- Developer Forum: Community support and discussions
- GitHub Examples: Code examples and sample integrations
Support Channels:
- Email: api@uncleb.tech for API-specific questions
- Developer Support: Dedicated support for API integration issues
- Emergency Support: 24/7 support for critical API issues
- Community: Developer community forum for peer support
Information for API Support
When Contacting API Support:
- Request ID: Include X-Request-ID from failed requests
- API Key ID: Provide API key ID (not the actual key)
- Endpoint: Specific API endpoint experiencing issues
- Request/Response: Complete request and response details
- Expected vs Actual: What you expected vs what happened
- Integration Context: How you're using the API in your application
Ready to integrate with the UncleBTech API? Start by generating your API key in the client portal and explore our interactive documentation at https://api.uncleb.tech/docs for hands-on testing and examples.