Mysql insert to add bulk sip,users,devices issues

I have written a small Windows app to import new extensions by placing the proper information into sip,users and devices and everything looks fine. When I look at the data that was made by freepbx and the import I did, it looks the same. Freepbx can see that data that I import but when I do the “red bar” reload or any reboot the data is not making it into the Asterisk Database. Only after I go into each extension, click submit, then a red bar reload does it actually go into the asterisk database, ‘database show’.

‘sip show peers’ shows the new data I imported with my program without having to go into each extension and clicking submit. I must be missing something crucial so that freePBX can add them to the astersisk database with a single update.

I did notice that when I add records to the sip table my records end up all over the place and when FreePBX adds records it seems to add them in a clustered format(all of extension keywords grouped). Could this be my problem?


Yes I was trying to add them directly to the tables then thinking that once I did the update in freePBX the newly added data would get placed in the asterisk database. I’ll look for the functions and see what it does.

you will want to use the function vs. trying to copy what it does. Things will change in the coming future, using the function will keep your app working. Also - once you get your app up and working, why don’t you ping me to take a look at it, I’m sure it would be useful.

I’ll let you know once I get it working.

This was really a twister…cause all the *.conf files were updated fine but the database show was not giving me any new information about the extensions that were added.

point of referance, I am running the beta version.

there is more involved then just adding the info to the db tables. How does your porgram work, is it just accessing the db over the network?

You really need to access the core_add_users() and core_add_devices() calls to properly get everything added correctly.

Hi swolfe !

I’m writing a script to create extensios from the Linux Cli and I’m having the same problem you have.

Did you solve it ? and how did u do it ?

p_lindheimer, i was trying to use the functions core_users_add() and core_devices_add().
I called them in my script but i get some errors. Is there any secret in how to use it ? or some include ?



I’ve created a php file that allow adding extensions using core_users_add and core_devices_add. Please be advised that it’s not been tested on a production environment. File location:

Comments and Tweaks are welcome.


samyantoun - thanks for the php script/page - I’m using it with a bash script to bulkload users from a csv file to a backup server.

Is there a way to batch edit existing user extensions? I may want to restore from an old backup and may need to add/edit/remove some of them in an automated manner.

i don’t seem to know how to automate the calling of the url’s with the data i have

Well this is what we need to do also. I had hoped to just populate the databases and then issue an update or something.

We use a coldfusion dev enviornment, so I’m not sure we can access the functions directly.

Also, we need to set the followme modules settings.

Any ideas?


Thanks Samy. Works great.

However it only seems to work if I have your php file in the /var/www/html directory. I put it in another directory the include for the header.php fails.


I want to trigger the creation of a new extension from another transactional system. I’m aware of the bulk extensions tool, and I’ve used it successfully, but I want to do something more transactional.

So, I was excited when I read this thread. Then, I read this thread… where p_lindheimer called the API’s “an ugly mess” and suggested we stay away from them.

So, Samyantoun - are you still around? Do you still use this script? p_lindheimer - if the API’s are amess, do you have another suggestion for transactionally creating extensions?


Hi to all,

am new bie to Free PBX as well as asterisk.

As i have a task to add ‘n’ number of extensions using PHP and MySQL. So i was cross checked in the internet and got the idea by reading the samyantoun link.
I was followed the instructions what samyantoun has given in the link. When am tryed the same code into my page and getting blank page after executing the code. Please can you people guided me to out of these issue.

My file path :-
and am passing the values :- addext.php?tech=sip&extension=".$ext."&name=".$name."&devinfo_secret=".$secret."

in addext.php, i kept the samyantoun code as he mentioned in link. When am debugging the code, the functions and header.php is not working.

how and where can i change in the code. Please help me out from this issue.

Please use the Bulk Extensions module. No support will be given here for an outdated script.

Try to replace these includes:

// Add Extension

with folowing line:


The main problem of yours might be that there is no ‘admin/header.php’ file in FreePBX 2.9

And make sure ‘pinless’ variable is set to enabled/disabled before passing array to core_users_add function, otherwise you’ll get a warning.

I need to make a PHP script to create Trixbox extension and apply conf in configuration files from php script itself.

PHP.txt : provided by samyantoun (tadpole) is not working for me and inclusive files are not with me.
Can you please advise revised php script or steps and cli - -> php code to complete this On urgent basis?

Am using elastix server for voice call functionality in mobile application, in this I can able to store value(extension data) in asterisk database and also able to view data’s in elastix page through the PHP code. When am calling via extension number am receiving “service not available”.

How can I solve this issue or else can you tell me how to store the extension data in elastix server using API?

Checking, nope this isn’t Elastix support. They decided to fork our project. Suggest you try

I have a problem with script when i open in browser say Missing Type, Extension or Description can you help me?