Define one message transaction before sending
Record the Asterisk node and release, manager identity, unique ActionID, intended message technology, Destination, To, From, body representation, approved variables, expected recipient, privacy classification and synchronized time. Redact bodies and credentials unless a tightly controlled investigation requires them.
AMI MessageSend is documented as an out-of-call action. It does not require or select a live call channel, and Channel, Uniqueid, Linkedid or bridge membership must not be invented as message-routing keys.
Keep Destination separate from To and From
Destination selects the message technology and route. For PJSIP it constructs the Request-URI and supports endpoint, endpoint/AoR, endpoint plus explicit URI, default-endpoint URI and PJSIP/user@endpoint forms, all under the documented pjsip: technology prefix.
To and From describe message headers where the technology uses them. If Destination is omitted, To becomes the backwards-compatible destination and is required. That fallback does not make the SIP To header, Request-URI, endpoint, AoR and current contact interchangeable.
Choose endpoint, contact and transport evidence explicitly
An endpoint-based destination may derive its Request-URI from the endpoint’s default AoR and contact. Capture the exact endpoint, selected AoR/contact, resulting Request-URI, DNS result and transport decision rather than recording only a friendly recipient name.
PJSIP transport selection is URI-driven: scheme, transport parameter, configured transport objects, DNS and reusable connections can all matter. A reachable voice registration or successful call does not prove an out-of-dialog MESSAGE will use the intended route or be accepted.
Preserve body and variable semantics
Body cannot contain newlines because they conflict with AMI framing. Use Base64Body when newlines are required; the action documentation says it is decoded before sending and takes precedence over Body. Multiple Variable headers are allowed, with comma-separated name=value pairs.
Define a narrow content class, size limit and allowed header set. MESSAGE and MESSAGE_DATA describe dialplan message fields, but do not authorize arbitrary AMI variables or private headers. Never place passwords, tokens or unbounded user input into routine manager messages or logs.
Separate acceptance, protocol response and recipient outcome
Preserve the raw AMI response by ActionID, then collect message-handler, SIP transaction and authorized recipient observations as different layers. An accepted manager action is not proof of a transmitted request, final SIP response, remote delivery, client notification, display, storage or human acknowledgement.
The dialplan MessageSend application explicitly defines SUCCESS as successful handoff to the protocol handler without guaranteeing delivery. Treat that as a useful boundary, not as an undocumented AMI result field. ARI endpoint messaging is another interface with its own response contract.
Validate with a bounded, disposable recipient
Use a dedicated least-privilege manager identity, an approved nonproduction endpoint and a non-sensitive marker. Prove action availability, constructed Request-URI, To and From headers, selected transport, bounded protocol result, endpoint presentation and cleanup. Include a negative destination that must fail without reaching another recipient.
Remove temporary tracing and retain only the minimum evidence. Documentation does not establish installed capability, compatibility, confidentiality, delivery or presentation, and no live system was tested for this guide.
Sources & applicability
Primary references for the technical details above. Operational examples and planning checklists are VoIP.info editorial guidance.
- Asterisk 23 MessageSend AMI action ↗
- Asterisk 22 MessageSend AMI action ↗
- Certified Asterisk 22.8 MessageSend AMI action ↗
- Asterisk 23 MessageSend dialplan application ↗
- Asterisk 23 MESSAGE dialplan function ↗
- Asterisk 23 MESSAGE_DATA dialplan function ↗
- Asterisk 23 ARI endpoints resource ↗
- Asterisk PJSIP transport selection ↗
- Asterisk AMI v2 specification ↗
- Asterisk Manager TCP/IP API ↗
Examples require adaptation to your topology. No live PBX or hardware testing is claimed.