Define the charging authority before sending
Record the Asterisk node and release, manager identity, unique ActionID, exact live channel and Uniqueid, message type, charge or rate structure, approved currency or unit policy, charging-association data, intended signaling recipient and synchronized time. Treat all monetary and subscriber data as sensitive.
AOCMessage generates an Advice of Charge message on a channel. It does not calculate a carrier tariff, rate a call, amend an invoice or prove that a remote device accepts or displays the information. Use only values produced by an authorized charging source.
Target one current channel, not a friendly prefix
Use the complete current channel name whenever possible and revalidate its Uniqueid immediately before the action. Channel is required unless ChannelPrefix is given. The documented prefix form matches only the first channel whose name begins with that text, so concurrent calls can make a broad prefix select an unintended leg.
Do not use Linkedid, bridge identity, endpoint name or caller ID as an undocumented substitute. If a prefix is unavoidable, enumerate matching channels, require one authorized match and abort when the set is empty or ambiguous.
Choose AOC-S, AOC-D or AOC-E deliberately
MsgType selects S, D or E. AOC-S describes charging information at the beginning of a call, AOC-D describes charge information during a call and AOC-E describes it at the end. Their fields are not interchangeable.
For AOC-D and AOC-E, ChargeType can be not available, free, currency or unit. For AOC-S, each ChargedItem owns the rate fields that follow it until the next item. Preserve message type, phase and field ownership in the evidence record.
Encode units and currency without inventing decimals
A unit charge uses indexed UnitAmount(n) entries; index zero is required when ChargeType=Unit, and each optional UnitType(n) remains paired with its amount. A currency charge uses a positive integer CurrencyAmount plus a required CurrencyMultiplier; retain both rather than flattening them into an assumed decimal.
CurrencyName is documented as truncated after ten characters. AOC-D distinguishes Total from SubTotal; AOC-S duration rates additionally require time scale and charging type, with granularity only under the documented step-function conditions.
Keep action response, event and remote outcome separate
Preserve the raw AMI response by ActionID, then collect the corresponding AOC-S, AOC-D or AOC-E event and channel identity as a separate layer. Those events are documented as raised when an AOC message is sent at the beginning, during or at the end of a call.
Neither action acceptance nor an AOC event proves carrier rating, protocol delivery, endpoint support, visible presentation, customer comprehension or invoice accuracy. Correlate the exact channel and time, then obtain independent downstream evidence where policy permits.
Validate with bounded values and negative controls
Use a dedicated least-privilege manager identity, a nonproduction channel and an approved test tariff. Cover one allowed message for each supported phase, wrong message-type fields, a missing required amount or multiplier, an ambiguous prefix, a replaced channel and a remote endpoint that must not be treated as supported without proof.
Compare the serialized action, AMI response, AOC event and authorized downstream observation without using a customer bill as a test surface. Remove temporary traces and sensitive values. Documentation does not establish deployed support, tariff correctness, delivery or presentation.
Sources & applicability
Primary references for the technical details above. Operational examples and planning checklists are VoIP.info editorial guidance.
- Asterisk 23 AOCMessage AMI action ↗
- Asterisk 22 AOCMessage AMI action ↗
- Certified Asterisk 22.8 AOCMessage AMI action ↗
- Asterisk 23 AOC-S AMI event ↗
- Asterisk 23 AOC-D AMI event ↗
- Asterisk 23 AOC-E AMI event ↗
- Asterisk 22 AOC-S AMI event ↗
- Asterisk 22 AOC-D AMI event ↗
- Asterisk 22 AOC-E AMI event ↗
- Asterisk AMI v2 specification ↗
Examples require adaptation to your topology. No live PBX or hardware testing is claimed.