🔌 REST API & Developer Reference
AiPBX exposes structured REST endpoints and WebSocket protocols for bidirectional integration with CRMs, ERPs, call center wallboards, and mobile softphones.
1. Codebase & Architectural Standards
AiPBX web core runs on a clean, dependency-free PHP 8 MVC pattern:
- Whitelist Front Router: Only routes defined in
index.php's$ROUTESare reachable; unknown paths trigger an instant 404. - src/controllers/: Authentication checks, input sanitization, and response orchestration only.
- src/services/: Business logic, database mutations, and triggering Asterisk synchronization.
- src/sync/: Generates modular Asterisk configuration with automatic
.bakrollback safety.
2. REST API Endpoints
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/auth/login |
Extension credentials authentication | Public |
| GET | /api/mobile/contacts.php |
Corporate directory with real-time presence | User |
| GET | /api/mobile/history.php |
Call detail history and talk durations (CDR) | User |
| POST | /api/cc_actions/agent.php |
Agent pause/unpause (*22/*23) and queue state | Agent |
3. Automated Test Suite (PHPUnit CI/CD)
bash — Unit Tests
# Prepare test database
bash bin/setup-test-db.sh
# Execute PHPUnit suite (142 tests, 350 assertions)
./vendor/bin/phpunit