paulgorman.org/technical

Asterisk ARI

Asterisk 12 introduced ARI, the Asterisk REST Interface.

Enable it. First, enable Asterisk’s built-in http server by editing /etc/asterisk/http.conf:

[general]
enabled = yes
bindaddr=::
bindport=8088

Edit /etc/asterisk/ari.conf:

[general]
enabled = yes
pretty = yes

[asterisk]
type = user
read_only = no
password = mysecret

Restart Asterisk:

asterisk*CLI> core restart now

We can curl, but since the ARI requires WebSockets all we get is:

curl http://asterisk:mysecret@localhost:8088/ari/events?api_key=asterisk:mysecret&app=hello-world
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>426 Upgrade Required</title>
</head><body>
<h1>Upgrade Required</h1>
<p></p>
<hr />
<address>Asterisk/13.13.1</address>
</body></html>

The ARI consists of three interrelated pieces:

  1. A RESTful interface through which a client controls resources in Asterisk.
  2. A WebSocket that conveys Asterisk events to a client in JSON.
  3. The Stasis dialplan application that gives a client control of an Asterisk channel.

Together, the three pieces allow a developer to build a custom communication application to manipulate and control Asterisk.