Asterisk ARI and Stasis: configuration and call ownership
An ARI application needs more than an HTTP request that returns successfully. It needs the Asterisk service, an authorised application identity, event handling and a deliberate dialplan handover for the channels it controls.
Source-reviewed, 18 October 2026. Prepared from the cited documentation. Examples have not been independently tested by Phone Guides. Scope: the conventional REST plus WebSocket ARI model on Asterisk 22. Later transport/API additions need their own patch-specific references.
Identify the pieces before opening ports
| Piece | Purpose | Configuration or application owner |
|---|---|---|
| Asterisk HTTP service | Provides the HTTP transport used by ARI | http.conf and host/network policy |
| ARI user | Authenticates and limits API access | ari.conf and secret management |
| Event connection | Delivers asynchronous resource events | Backend application's WebSocket client |
| Stasis application name | Associates dialplan handover with the application | Dialplan and backend application |
| Backend service | Applies business rules and handles resource lifetime | Your application deployment |
The official ARI configuration guide describes the Asterisk files. Select bind addresses, transport protection and allowed access from the actual topology. Do not expose an unauthenticated management service as a side effect of copying a tutorial.
Keep credentials on the application server
Use a dedicated ARI identity with only the access the application needs, a generated secret and a protected storage location. A browser-facing application should authenticate its own users and authorise their actions before its backend communicates with Asterisk. It should not distribute the PBX password in page source or JavaScript.
The ARI overview describes that server-side boundary. Do not treat a broad allowed-origin setting as user authorisation. For a remote backend, establish the protected network/transport path rather than sending the example's local assumptions across the Internet.
Hand over a selected channel
This original dialplan illustration invokes application name pg-call-app:
[pg-ari-entry]
exten => 7800,1,Answer()
same => n,Stasis(pg-call-app)
same => n,Hangup()
It is only a handover illustration. It does not configure the HTTP service, ARI user, event connection, application logic or access route. The backend must be ready for that name and the channel lifecycle. Do not route production traffic into it while the application is absent.
The upstream getting-started walkthrough explains the relationship between the event connection, StasisStart and resource requests. Its deliberately weak example credentials and old driver alternatives are not copied here. The branch-22 Stasis reference defines the application call.
Handle changes that occur outside your request
A caller can hang up while your application is waiting for another service. A resource may therefore disappear before a delayed operation reaches Asterisk. Design cleanup and state reconciliation around actual events and resource responses, not only the sequence your program hoped to run.
Keep the application's record of channel/bridge identifiers, expected ownership and outstanding operations. After a disconnect, decide how to discover current state before repeating operations. Do not assume every retry is safe; origination and other resource-creating work need deliberate duplicate handling.
Plan reader checks
Check the HTTP listener and ARI authentication separately from the event connection. Then verify an intended channel enters Stasis, generates the expected event and is cleaned up after hangup. Include an unavailable backend, a lost event connection and a caller hanging up during a pending operation. Expected event output should not be presented as a trace Phone Guides recorded.
Use the Asterisk 22 ARI resource reference for exact operations and schemas. If the application only needs a dialplan lookup or management events, compare AGI, AMI and ARI before taking ownership of a larger call lifecycle.
Return to Asterisk documentation.