Adding new SIP devices and extensions programatically


I want to add new SIP devices and extensions from my webpage on to Asterisk through PHP. I have been looking for information on this but, have not been able to find any valuable answer - the database tables that need to be modified, file changes or CLI commands that can be used and so on.

Methods tried:

  1. Using core_device_add(). Is this supported?
  2. Through Asterisk CLI - dialplan add new extension - (Is there a CLI command to add new SIP device?)

Both the methods did not work. If anyone can provide an answer with a sample code or CLI commands to do this, that would be of great help.

Thank You.

Look at how FreePBX does it.

It would be done using AMI, not CLI. Alternatively, using “realtime”.

I suspect FreePBX uses the ability to rewrite the config files.

Thanks for your response. Any pointers on which files to look into in the implementation of FreePBX? Where can I find this?

You can also use MYSQL with realtime configuration then use PHP to add sip_buddies and when its done relaod the sip and your new peer will appear. Check this for the DB structure … alTime+Sip then use your own code with PHP to add and relaod.

Thanks! I feel there should be a less complex way to do this. Ideally, may be, by calling some Asterisk APIs?
Wondering as to why this is so complicated. I’ve seen quite a number of posts related to this. Shouldn’t Asterisk be opening up some API to add new SIP devices and extensions?