Asterisk 13.6.0: Is There A Way To Create PJSIP Users And Dialplans Programmatically Using API
Home » Asterisk Users » Asterisk 13.6.0: Is There A Way To Create PJSIP Users And Dialplans Programmatically Using API
Hi,
I am using Asterisk 13.6.0 and was wondering if I can programmatically add users (to pjsip.conf) and dialplan (to extensions.conf) to the Asterisk server using API of some sort.
Please do let me know.
Thanks, Sonny.
4 thoughts on - Asterisk 13.6.0: Is There A Way To Create PJSIP Users And Dialplans Programmatically Using API
You can use the Asterisk Manager Interface to modify the config files and reload. https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=4817239
Sonny
We use a real-time database for adding pjsip users. If you want to do it from the pjsip.conf you would have to write to the file from a script of some sort and then trigger a reload. There is a real-time implementation for the extensions.conf as well. I personally use scripts for most of my dialplan, but in some cases I write to files included in my dialplan from a script and force a reload.
To directly answer you question I do not believe there is an API baked into asterisk to update the pjsip.conf and extensions.conf directly from the dialplan.
Thanks
Bryant
————————————–
With the right Sorcery configuration, you can also use ARI push configuration. Creating a PJSIP endpoint, for example, can be done with the following:
$ curl -X PUT -H “Content-Type: application/json” -u asterisk:secret -d
‘{“fields”: [ { “attribute”: “from_user”, “value”: “alice” }, {
“attribute”: “allow”, “value”: “!all,g722,ulaw,alaw”}, {“attribute”:
“ice_support”, “value”: “yes”}, {“attribute”: “force_rport”, “value”:
“yes”}, {“attribute”: “rewrite_contact”, “value”: “yes”}, {“attribute”:
“rtp_symmetric”, “value”: “yes”}, {“attribute”: “context”, “value”:
“default” }, {“attribute”: “auth”, “value”: “alice” }, {“attribute”:
“aors”, “value”: “alice”} ] }’
https://localhost:8088/ari/asterisk/config/dynamic/res_pjsip/endpoint/alice
This wiki page describes how this works, as well as how to set it up:
https://wiki.asterisk.org/wiki/display/AST/ARI+Push+Configuration
Thanks to everyone for your responses. I grappled with this the past few days, but I have to confess any amount of poking around AMI has not yielded any result. I find the ARI based method most convenient as I am familiar with that interface already. I did not discover this as the ARI method is not documented under ARI information at https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ARI (but instead under a different left-hand navigation tree in your wiki). But thanks, Matt.
At any rate, I would like to setup pjsip using a mysql, rather than an astdb based setup with uses a LOCAL db. Is there an online document for configuring the mysql database backend for asterisk. If res_config_mysql.conf is setup, does it mean automatically that it is used instead of astdb sqllite? That part is not clear. Any help or documentation is appreciated.
Thanks, Sonny.