FreePBX has a GraphQL API which allows us to make requests such as the ones documented here.
I would like to use the fwconsole api
command to make these API requests at the command line. There's no documentation for how to do this - the only forum post I could find was someone asking exactly this question, and the post was closed automatically due to lack of responses.
I've tried things like
$ fwconsole api gql voicemail 'mutation { moduleOperations(input: { module: "voicemail", action: "enableVoiceMail", extensionId: "1081", password: "1234" }) { status message }}'
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `/usr/sbin/fwconsole ma mutation { moduleoperations(input: { module: "voicemail", action: "enablevoicemail", extensionid: "1081", password: "1234" }) { status message }} voicemail --'
and even-closer-to-their-api-docs:
$ fwconsole api gql voicemail 'mutation { enableVoiceMail(input: {extensionId: "1081", password: "1234" }) { status message }}'
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `/usr/sbin/fwconsole ma mutation { enablevoicemail(input: {extensionid: "1081", password: "1234" }) { status message }} voicemail --'
It looks like my output is being piped to the fwconsole ma
subcommand somehow, though my attempts to trace through the code don't indicate why this would be the case. Perhaps there's simply no way to do this at the command line?
Freepbx API is a very limited REST interface.
For sure there is no GraphQL or anything fancy. Freepbx core is one from 200x, not new things.
All REST, GraphQL on FreePBX are just words. Most structures have zero support of even simple REST.
Some fields are missing, some MODULES are missing completely. Documentation is mess. You need the ability to read PHP complex code to use that API.
After adding extension you have issue "apply config" call to reload text files and asterisk core.
Generally speaking, it is much simpler to write directly to the database for most cases you can image.