A comprehensive REST API for managing multi-tenant Asterisk PBX systems with advanced call routing, IVR, queues, and real-time call control.
- Multi-Tenant Architecture - Complete isolation between organizations
- RESTful API - Clean, documented API endpoints
- Authentication & Authorization - JWT-based with admin and organization-level access
- Real-Time Call Control - Manage active calls via Asterisk AMI
- Global Settings Management - Configure Asterisk system-wide settings via API
- SIP Trunk Management - Configure inbound/outbound SIP trunks
- DID Number Routing - Flexible routing to extensions, queues, IVRs, or AI agents
- User Provisioning - Automatic SIP endpoint configuration
- Queue Management - Call queues with member management
- IVR (Interactive Voice Response) - Multi-level menu systems
- Outbound Routing - Pattern-based call routing
- Call Recording - Enable/disable per call or organization
- Webhook Notifications - Real-time event notifications
- AI Agent Integration - Route calls to AI voice agents
- Click-to-Call - Initiate calls between any two numbers
- Live Call Statistics - Real-time call monitoring
- Configuration Deployment - One-click deployment to Asterisk
- AMI-Based Reloads - Zero-downtime configuration updates
- Node.js 18+
- MariaDB/MySQL 10.5+
- Asterisk 18+ with PJSIP
- Git
# Clone repository
git clone https://github.com/saynth-ai/asterisk-api.git
cd asterisk-api
# Install dependencies
npm install
# Configure environment
cp .env.example .env
nano .env
# Setup database
npx sequelize-cli db:migrate
# Start server
npm start- API Server: http://localhost:3003
- API Documentation: http://localhost:3003/api
- Health Check: http://localhost:3003/health
- Installation Guide - Complete installation and setup instructions
- API Documentation - Interactive Swagger UI
- Architecture - System architecture and design
Admin Login
curl -X POST http://localhost:3003/api/v1/admin/auth \
-H "Content-Type: application/json" \
-d '{"admin_username":"pbx_admin","admin_password":"your_password"}'Organization Auth
curl -X POST http://localhost:3003/api/v1/auth \
-H "X-API-Key: your_key" \
-H "X-API-Secret: your_secret"| Endpoint | Method | Description |
|---|---|---|
/api/v1/organizations |
POST | Create organization (Admin) |
/api/v1/trunks |
POST | Create SIP trunk |
/api/v1/dids |
POST | Configure DID routing |
/api/v1/users |
POST | Create user/extension |
/api/v1/queues |
POST | Create call queue |
/api/v1/deploy/{orgId} |
POST | Deploy configuration |
/api/v1/calls/live |
GET | Get live calls |
/api/v1/admin/settings |
PUT | Update global settings |
/api/v1/admin/settings/deploy |
POST | Deploy global config |
┌─────────────┐
│ REST API │
│ (Express) │
└──────┬──────┘
│
├──────────────────────────────┐
│ │
┌──────▼──────┐ ┌────────▼────────┐
│ MariaDB │ │ Asterisk │
│ (Storage) │ │ (PJSIP/AMI) │
└─────────────┘ └─────────────────┘
Multi-Tenant Isolation:
- Database level (org_id)
- Asterisk context level (context_prefix)
- Authentication level (API keys)
# Install PM2
npm install -g pm2
# Start application
pm2 start src/server.js --name pbx-api
# Setup auto-start
pm2 startup
pm2 save# Create service file
sudo nano /etc/systemd/system/pbx-api.service
# Enable and start
sudo systemctl enable pbx-api
sudo systemctl start pbx-apiSee INSTALLATION.md for detailed deployment instructions.
asterisk-api/
├── src/
│ ├── server.js # Main application
│ ├── models/ # Sequelize models
│ └── services/ # Business logic
│ ├── asterisk/ # Asterisk integration
│ └── deployment/ # Config deployment
├── docs/
│ ├── API_SPECIFICATION.yaml # OpenAPI spec
│ └── ARCHITECTURE.md # Architecture docs
├── .env # Environment config
├── package.json
├── INSTALLATION.md
└── README.md
npm install
npm startVisit http://localhost:3003/api for API documentation.
Database Connection Failed
systemctl status mariadb
mysql -u pbx_api_user -p pbx_api_dbAMI Connection Failed
systemctl status asterisk
telnet localhost 5038Port Already in Use
lsof -i :3003
kill -9 <PID>See INSTALLATION.md for more troubleshooting tips.
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
MIT License - see LICENSE file for details.
- Installation Help: INSTALLATION.md
- API Docs: http://localhost:3003/api
- Issues: GitHub Issues
v1.0 (Current)
- ✅ Multi-tenant management
- ✅ SIP trunk & DID routing
- ✅ User provisioning
- ✅ Queue & IVR management
- ✅ Live call monitoring
- ✅ Global settings API
v2.0 (Planned)
- ⬜ WebRTC support
- ⬜ Advanced analytics
- ⬜ Recording management UI
- ⬜ CDR API
- ⬜ Billing integration
Made with ❤️ by Astra AI