ARI Setup and Stasis Application

Integrations Asterisk 18+ -- Last reviewed 2026-03-29 ari rest-api stasis http integrations Found this useful? Upvote it. ×

ARI Setup and Stasis Application

ARI exposes Asterisk primitives, channels, bridges, endpoints, media, over a REST interface, with real-time state delivered via WebSockets. It is the modern way to build custom communications applications on top of Asterisk.

Requirements

ARI User Configuration (ari.conf)

[general]
enabled = yes
pretty = yes
allowed_origins = *

[asterisk]
type = user
read_only = no
password = change_me_to_a_strong_password
password_format = plain
allowed_origins = *

HTTP Server (http.conf)

[general]
servername = Asterisk
enabled = yes
bindaddr = 0.0.0.0
bindport = 8088
; TLS for production use:
; tlsenable = yes
; tlsbindaddr = 0.0.0.0:8089
; tlscertfile = /etc/asterisk/keys/asterisk.pem
; tlsprivatekey = /etc/asterisk/keys/asterisk.key

Dialplan: Handing a Channel to Stasis

[from-trunk]
exten => 1000,1,NoOp(Sending channel to ARI application)
 same =>      n,Answer()
 same =>      n,Stasis(hello-world)
 same =>      n,Hangup()

Verify ARI is Running

*CLI> ari show status
ARI Status:
Enabled: Yes
Output format: pretty
Auth realm: Asterisk REST Interface
Allowed Origins: *
User count: 1

*CLI> http show status
HTTP Server Status:
Server Enabled and Bound to 0.0.0.0:8088

Enabled URI's:
/ari/... => Asterisk RESTful API
/ws => Asterisk HTTP WebSocket

How it works

  1. ARI users: Each ARI user in ari.conf defines credentials and permissions. read_only = no allows the user to create and manipulate resources (channels, bridges, recordings). Use a strong password in production.
  2. Stasis() application: Stasis(app-name) in the dialplan hands the channel to ARI. The channel enters a "Stasis" state where it can only be controlled by the external application via REST calls. When Stasis exits, the channel returns to dialplan execution.
  3. WebSocket events: ARI pushes channel state, DTMF, and bridge events over a WebSocket connection at ws://host:8088/ari/events?api_key=user:password&app=app-name. Your application listens here for real-time notifications.
  4. HTTP server: The built-in HTTP server serves both the REST API (/ari/...) and WebSocket endpoint (/ws). For production, enable TLS via tlsenable=yes in http.conf.
  5. allowed_origins: Controls CORS. Use * for development only. In production, restrict to your application's domain to prevent cross-site request abuse.

Tips

User Notes

No notes yet. Be the first to contribute a tip or example.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.

Related Snippets