Modern PHP API package for Asterisk, Issabel PBX and FreePBX — supports AMI, ARI, PJSIP and legacy SIP channels.
Migration note: Elastix (the original target of this package) reached end-of-life and is no longer maintained. This package now targets the three actively maintained PBX platforms listed above.
- PHP 7.4+
- ext-pdo, ext-json, ext-curl
- Asterisk 13+ (AMI port 5038)
- Composer (for the modern driver-based install)
composer require 101t/asterisk-pbx-apiOr clone and install dependencies:
git clone https://github.com/101t/elastix-api.git
cd elastix-api
composer installCopy and configure the environment file:
cp .env.example .env
nano .env # set API_SECRET_KEY and PBX_DRIVER at minimumThe web root entry point is api.php. Place the repository (or a symlink) inside your web server's document root.
For use on existing servers without Composer, api.php automatically falls back to the legacy PHP4-compatible include-based loader. No extra steps are needed beyond setting the secret key.
All settings are controlled via environment variables. Copy .env.example to .env and fill in the values.
| Variable | Default | Description |
|---|---|---|
API_SECRET_KEY |
(placeholder) | 50-char random secret sent in every Authorization header |
PBX_DRIVER |
asterisk |
Active driver: asterisk | issabel | freepbx |
AMI_HOST |
127.0.0.1 |
Asterisk Manager Interface host |
AMI_PORT |
5038 |
AMI port |
AMI_USERNAME |
(auto-detect) | AMI username; leave empty to auto-read from manager.conf |
AMI_SECRET |
(auto-detect) | AMI secret; leave empty to auto-read from manager.conf |
ARI_ENABLED |
false |
Enable Asterisk REST Interface (Asterisk 12+) |
ARI_HOST |
127.0.0.1 |
ARI host |
ARI_PORT |
8088 |
ARI HTTP port |
CHAN_DRIVER |
pjsip |
Channel driver: pjsip (Asterisk 13+) or sip (legacy) |
DB_HOST |
localhost |
MySQL host |
DB_PASSWORD |
(empty) | MySQL password |
ISSABEL_CONF_PATH |
/etc/issabel.conf |
Path to Issabel config (auto-reads DB password) |
FREEPBX_CONF_PATH |
/etc/freepbx.conf |
Path to FreePBX config (auto-reads DB credentials) |
RECORDINGS_PATH |
/var/spool/asterisk/monitor |
Directory for call recordings |
LOG_LEVEL |
error |
Logging verbosity |
CORS_ALLOWED_ORIGINS |
* |
CORS origin header value |
See .env.example for the complete list.
Full Asterisk driver with:
- AMI (port 5038) for peer/channel/call management
- ARI (port 8088, optional) for channel operations and origination
- PJSIP endpoint management (
chan_pjsip, Asterisk 13+) - Legacy chan_sip peer management
- FreePBX-style MySQL schema (asterisk / asteriskcdrdb databases)
Extends the Asterisk driver with:
- Bootstrap from
/etc/issabel.conf - Issabel-specific disk-usage paths (
/opt/issabel) getIssabelVersion()— reads/etc/issabel-releasegetFirewallStatus()— Fail2Ban jail status
Extends the Asterisk driver with:
- Bootstrap from
/etc/freepbx.conf(auto-parses$amp_conf[]values) - PJSIP endpoint table support (
pjsiptable, FreePBX 14+) - Queue management (
getQueues,queueAddMember,queueRemoveMember) fwconsoleReload()— modern config applygetAdvancedSetting($key)— reads from theadmintable
All requests require the Authorization header to match API_SECRET_KEY.
Authorization: <your-secret-key>
| Method | URL | Description |
|---|---|---|
| POST | ?cmd=auth |
Returns base64-encoded AMI credentials |
| Method | URL | Description |
|---|---|---|
| POST | ?cmd=sippeers |
List all SIP/PJSIP peers with status |
| POST | ?cmd=sipextensions |
List extension profiles from config file |
| Method | URL | Description |
|---|---|---|
| POST | ?cmd=activecall |
Live channel list (core show channels verbose) |
| POST | ?cmd=channelstatus[&channel=SIP/200] |
AMI channel status |
| POST | ?cmd=parkedcalls |
Parked call list |
| Method | URL | Body params | Description |
|---|---|---|---|
| POST | ?cmd=originatecall |
channel, extension, context, callerid, timeout |
Originate outbound call via AMI |
| Method | URL | Description |
|---|---|---|
| POST | ?cmd=arichannels |
List active channels via Asterisk REST Interface |
| Method | URL | Description |
|---|---|---|
| POST | ?cmd=systemresources |
Uptime, users, load average |
| POST | ?cmd=getharddrivers |
Disk usage for common PBX directories |
| POST | ?cmd=getiptablesstatus |
iptables service status |
| Method | URL | Body params | Description |
|---|---|---|---|
| POST | ?cmd=cdrreport |
start_date, end_date, field_name, field_pattern, status, limit |
Query CDR database |
| Method | URL | Description |
|---|---|---|
| GET | ?cmd=getwavfile&name=/2024/01/01/file.wav |
Download recording file |
| Method | URL | Description |
|---|---|---|
| POST | ?cmd=addextension |
Create SIP/PJSIP extension |
| POST | ?cmd=updateextension |
Update extension |
| POST | ?cmd=deleteextension |
Delete extension (body: account) |
| Method | URL | Description |
|---|---|---|
| POST | ?cmd=addfollowmeextension |
Add Follow-Me rule |
| POST | ?cmd=updatefollowmeextension |
Update Follow-Me rule |
| POST | ?cmd=deletefollowmeextension |
Delete Follow-Me rule (body: grpnum) |
| POST | ?cmd=getfollowmeextension |
Get Follow-Me for one extension (body: grpnum) |
| POST | ?cmd=getallfollowmeextensions |
Get Follow-Me for all extensions |
| Method | URL | Body params | Description |
|---|---|---|---|
| POST | ?cmd=getqueues |
— | List all FreePBX queues |
| POST | ?cmd=queueaddmember |
queue, device, penalty |
Add agent to queue |
| POST | ?cmd=queueremovemember |
queue, device |
Remove agent from queue |
composer testTests cover: Config loading, AsteriskDriver SQL builders and security guards, IssabelDriver bootstrap, FreePBXDriver config parsing.
Full API reference with request/response examples: docs/README.md
Thank you to the amazing communities around FreePBX, Issabel and Asterisk for all the useful information.
