# Manager API

#### Введение

Для работы с интерфейсом событий существует несколько вариантов взаимодействия.

/arawman =&gt; Raw HTTP Manager Event Interface with Digest authentication  
/rawman =&gt; Raw HTTP Manager Event Interface  
/amxml =&gt; XML Manager Event Interface with Digest authentication  
/mxml =&gt; XML Manager Event Interface

Документация описывает взаимодействие с интерфейсом событий через необработанные HTTP запросы. Аналогичная документация применима и к другим вариантам.

#### Авторизация

GET /rawman?action=login

<table border="1" id="bkmrk-action-%D0%94%D0%B5%D0%B9%D1%81%D1%82%D0%B2%D0%B8%D0%B5-user" style="border-collapse: collapse; width: 100%; height: 130px;"><colgroup><col style="width: 25.0931%;"></col><col style="width: 23.7271%;"></col><col style="width: 27.191%;"></col><col style="width: 23.9775%;"></col></colgroup><thead><tr style="height: 29.7017px;"><td style="height: 29.7017px;">Параметр</td><td style="height: 29.7017px;">Тип</td><td style="height: 29.7017px;">Обязательный</td><td style="height: 29.7017px;">Описание</td></tr></thead><tbody><tr style="height: 35.2983px;"><td style="height: 35.2983px;">username

</td><td style="height: 35.2983px;">String

</td><td style="height: 35.2983px;">Да</td><td style="height: 35.2983px;">Пользователь</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">secret

</td><td style="height: 35.2983px;">String

</td><td style="height: 35.2983px;">Да</td><td style="height: 35.2983px;">Пароль</td></tr></tbody></table>

Пример запроса: [http://&lt;ip&gt;:8088/rawman?action=login&amp;username=test&amp;secret=test](http://192.168.0.84:8088/asterisk/rawman?action=login&username=test&secret=test)

Пример ответа:

```
Response: Success
Message: Authentication accepted
```

#### Проверка доступности

GET /rawman?action=ping

Пример ответа:

```
Response: Success
Ping: Pong
Timestamp: 1711272193.709205
```

#### Запрос статуса телефонной станции

GET /rawman?action=status

<table border="1" id="bkmrk-%D0%9F%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80-%D0%A2%D0%B8%D0%BF-%D0%9E%D0%B1%D1%8F%D0%B7%D0%B0%D1%82%D0%B5-1" style="border-collapse: collapse; width: 100%; height: 165.298px;"><colgroup><col style="width: 25.0931%;"></col><col style="width: 23.7271%;"></col><col style="width: 27.191%;"></col><col style="width: 23.9775%;"></col></colgroup><thead><tr style="height: 29.7017px;"><td style="height: 29.7017px;">Параметр</td><td style="height: 29.7017px;">Тип</td><td style="height: 29.7017px;">Обязательный</td><td style="height: 29.7017px;">Описание</td></tr></thead><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">actionid</td><td style="height: 29.7017px;">String</td><td style="height: 29.7017px;">Нет</td><td style="height: 29.7017px;">Идентификатор запроса</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">channel

</td><td style="height: 35.2983px;">String

</td><td style="height: 35.2983px;">Нет</td><td style="height: 35.2983px;">Канал</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">variables

</td><td style="height: 35.2983px;">String

</td><td style="height: 35.2983px;">Нет</td><td style="height: 35.2983px;">Переменные</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">allvariables

</td><td style="height: 35.2983px;">Boolean

</td><td style="height: 35.2983px;">Нет</td><td style="height: 35.2983px;">Все переменные</td></tr></tbody></table>

Пример ответа:

```
Response: Success
EventList: start
Message: Channel status will follow

Event: Status
Privilege: Call
Channel: PJSIP/user
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 110
CallerIDName: 
ConnectedLineNum: <unknown>
ConnectedLineName: <unknown>
Language: ru
AccountCode: 
Context: outgoing
Exten: 153
Priority: 3
Uniqueid: 1711273253.11
Linkedid: 1711273253.11
Type: PJSIP
DNID: 153
EffectiveConnectedLineNum: <unknown>
EffectiveConnectedLineName: <unknown>
TimeToHangup: 0
BridgeID: 
Application: Queue
Data: queue
Nativeformats: (alaw)
Readformat: alaw
Readtrans: 
Writeformat: slin
Writetrans: (slin@8000)->(alaw@8000)
Callgroup: 0
Pickupgroup: 0
Seconds: 21

Event: StatusComplete
EventList: Complete
ListItems: 1
Items: 1
```

#### Запрос создания звонка

GET /rawman?action=originate

<table border="1" id="bkmrk-%D0%9F%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80-%D0%A2%D0%B8%D0%BF-%D0%9E%D0%B1%D1%8F%D0%B7%D0%B0%D1%82%D0%B5-2" style="border-collapse: collapse; width: 100%; height: 165.298px;"><colgroup><col style="width: 25.0899%;"></col><col style="width: 23.7303%;"></col><col style="width: 27.191%;"></col><col style="width: 23.9775%;"></col></colgroup><thead><tr style="height: 29.7017px;"><td style="height: 29.7017px;">Параметр</td><td style="height: 29.7017px;">Тип</td><td style="height: 29.7017px;">Обязательный</td><td style="height: 29.7017px;">Описание</td></tr></thead><tbody><tr style="height: 29.7017px;"><td style="height: 29.7017px;">actionid</td><td style="height: 29.7017px;">String</td><td style="height: 29.7017px;">Нет</td><td style="height: 29.7017px;">Идентификатор запроса</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">channel

</td><td style="height: 35.2983px;">String

</td><td style="height: 35.2983px;">Да</td><td style="height: 35.2983px;">Канал</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">exten

</td><td style="height: 35.2983px;">String

</td><td style="height: 35.2983px;">Да</td><td style="height: 35.2983px;">Расширение</td></tr><tr style="height: 35.2983px;"><td style="height: 35.2983px;">context

</td><td style="height: 35.2983px;">String

</td><td style="height: 35.2983px;">Да</td><td style="height: 35.2983px;">Маршрутизация</td></tr><tr><td>priority

</td><td>Integer

</td><td>Да</td><td>Приоритет</td></tr><tr><td>application

</td><td>String

</td><td>Нет</td><td>Приложение</td></tr><tr><td>data

</td><td>String

</td><td>Да</td><td>Данные приложение</td></tr><tr><td>timeout

</td><td>Integer

</td><td>Да</td><td>Таймаут</td></tr><tr><td>callerid

</td><td>String

</td><td>Нет</td><td>АОН</td></tr><tr><td>variable

</td><td>String

</td><td>Нет</td><td>Переменные</td></tr><tr><td>account

</td><td></td><td>  
</td><td>  
</td></tr><tr><td>earlymedia

</td><td></td><td>  
</td><td>  
</td></tr><tr><td>async

</td><td>Boolean

</td><td>Нет</td><td>Асинхронный ввод</td></tr><tr><td>codecs

</td><td></td><td>  
</td><td>  
</td></tr><tr><td>channelid

</td><td></td><td>  
</td><td>  
</td></tr><tr><td>otherchannelid

</td><td></td><td>  
</td><td>  
</td></tr></tbody></table>

Пример запроса: [http://&lt;ip&gt;:8088/rawman?action=originate&amp;channel=PJSIP/user&amp;context=outgoing&amp;exten=100&amp;priority=1&amp;async=true](http://192.168.0.84:8088/asterisk/rawman?action=login&username=test&secret=test)

#### Список команд

GET /rawman?action=listcommands

Пример ответа:

```
Response: Success
AbsoluteTimeout: Set absolute timeout.  (Priv: system,call,all)
AGI: Add an AGI command to execute by Async AGI.  (Priv: agi,all)
AOCMessage: Generate an Advice of Charge message on a channel.  (Priv: aoc,all)
Atxfer: Attended transfer.  (Priv: call,all)
BlindTransfer: Blind transfer channel(s) to the given destination  (Priv: call,all)
Bridge: Bridge two channels already in the PBX.  (Priv: call,all)
BridgeDestroy: Destroy a bridge.  (Priv: <none>)
BridgeInfo: Get information about a bridge.  (Priv: <none>)
BridgeKick: Kick a channel from a bridge.  (Priv: <none>)
BridgeList: Get a list of bridges in the system.  (Priv: <none>)
BridgeTechnologyList: List available bridging technologies and their statuses.  (Priv: <none>)
BridgeTechnologySuspend: Suspend a bridging technology.  (Priv: <none>)
BridgeTechnologyUnsuspend: Unsuspend a bridging technology.  (Priv: <none>)
CancelAtxfer: Cancel an attended transfer.  (Priv: call,all)
Challenge: Generate Challenge for MD5 Auth.  (Priv: <none>)
Command: Execute Asterisk CLI Command.  (Priv: command,all)
ConfbridgeKick: Kick a Confbridge user.  (Priv: call,all)
ConfbridgeList: List participants in a conference.  (Priv: reporting,all)
ConfbridgeListRooms: List active conferences.  (Priv: reporting,all)
ConfbridgeLock: Lock a Confbridge conference.  (Priv: call,all)
ConfbridgeMute: Mute a Confbridge user.  (Priv: call,all)
ConfbridgeSetSingleVideoSrc: Set a conference user as the single video source
  distributed toall other participants.  (Priv: call,all)
ConfbridgeStartRecord: Start recording a Confbridge conference.  (Priv: system,all)
ConfbridgeStopRecord: Stop recording a Confbridge conference.  (Priv: system,all)
ConfbridgeUnlock: Unlock a Confbridge conference.  (Priv: call,all)
ConfbridgeUnmute: Unmute a Confbridge user.  (Priv: call,all)
CoreSettings: Show PBX core settings (version etc).  (Priv: system,reporting,all)
CoreShowChannelMap: List all channels connected to the specified channel.  (Priv: system,reporting,all)
CoreShowChannels: List currently active channels.  (Priv: system,reporting,all)
CoreStatus: Show PBX core status variables.  (Priv: system,reporting,all)
CreateConfig: Creates an empty file in the configuration directory.  (Priv: config,all)
DBDel: Delete DB entry.  (Priv: system,all)
DBDelTree: Delete DB Tree.  (Priv: system,all)
DBGet: Get DB Entry.  (Priv: system,reporting,all)
DBGetTree: Get DB entries, optionally at a particular family/key  (Priv: system,reporting,all)
DBPut: Put DB entry.  (Priv: system,all)
DialplanExtensionAdd: Add an extension to the dialplan  (Priv: system,all)
DialplanExtensionRemove: Remove an extension from the dialplan  (Priv: system,all)
Events: Control Event Flow.  (Priv: <none>)
ExtensionState: Check Extension Status.  (Priv: call,reporting,all)
ExtensionStateList: List the current known extension states.  (Priv: call,reporting,all)
FAXSession: Responds with a detailed description of a single FAX session  (Priv: call,all)
FAXSessions: Lists active FAX sessions  (Priv: call,all)
FAXStats: Responds with fax statistics  (Priv: reporting,all)
Filter: Dynamically add filters for the current manager session.  (Priv: system,all)
GetConfig: Retrieve configuration.  (Priv: system,config,all)
GetConfigJSON: Retrieve configuration (JSON format).  (Priv: system,config,all)
Getvar: Gets a channel variable or function value.  (Priv: call,reporting,all)
Hangup: Hangup channel.  (Priv: system,call,all)
ListCategories: List categories in configuration file.  (Priv: config,all)
ListCommands: List available manager commands.  (Priv: <none>)
LocalOptimizeAway: Optimize away a local channel when possible.  (Priv: system,call,all)
LoggerRotate: Reload and rotate the Asterisk logger.  (Priv: system,reporting,all)
Login: Login Manager.  (Priv: <none>)
Logoff: Logoff Manager.  (Priv: <none>)
MailboxCount: Check Mailbox Message Count.  (Priv: call,reporting,all)
MailboxStatus: Check mailbox.  (Priv: call,reporting,all)
MessageSend: Send an out of call message to an endpoint.  (Priv: message,all)
MixMonitor: Record a call and mix the audio during the recording.
  Use of StopMixMonitor is required to guarantee the audio file
  is available for processing during dialplan execution.  (Priv: system,all)
MixMonitorMute: Mute / unMute a Mixmonitor recording.  (Priv: system,call,all)
ModuleCheck: Check if module is loaded.  (Priv: system,all)
ModuleLoad: Module management.  (Priv: system,all)
Originate: Originate a call.  (Priv: originate,all)
Ping: Keepalive command.  (Priv: <none>)
PJSIPHangup: Hangup an incoming PJSIP channel with a SIP response code  (Priv: system,call,all)
PJSIPQualify: Qualify a chan_pjsip endpoint.  (Priv: system,reporting,all)
PJSIPRegister: Register an outbound registration.  (Priv: system,reporting,all)
PJSIPShowAors: Lists PJSIP AORs.  (Priv: system,all)
PJSIPShowAuths: Lists PJSIP Auths.  (Priv: system,all)
PJSIPShowContacts: Lists PJSIP Contacts.  (Priv: system,all)
PJSIPShowEndpoint: Detail listing of an endpoint and its objects.  (Priv: system,all)
PJSIPShowEndpoints: Lists PJSIP endpoints.  (Priv: system,all)
PJSIPShowRegistrationInboundContactStatuses: Lists ContactStatuses
  for PJSIP inbound registrations.  (Priv: system,all)
PJSIPShowRegistrationsInbound: Lists PJSIP inbound registrations.  (Priv: system,all)
PJSIPShowRegistrationsOutbound: Lists PJSIP outbound registrations.  (Priv: system,reporting,all)
PJSIPShowResourceLists: Displays settings for configured resource lists.  (Priv: system,all)
PJSIPShowSubscriptionsInbound: Lists subscriptions.  (Priv: system,all)
PJSIPShowSubscriptionsOutbound: Lists subscriptions.  (Priv: system,all)
PJSIPUnregister: Unregister an outbound registration.  (Priv: system,reporting,all)
PresenceState: Check Presence State  (Priv: call,reporting,all)
QueueAdd: Add interface to queue.  (Priv: agent,all)
QueueChangePriorityCaller: Change priority of a caller on queue.  (Priv: <none>)
QueueLog: Adds custom entry in queue_log.  (Priv: agent,all)
QueueMemberRingInUse: Set the ringinuse value for a queue member.  (Priv: agent,all)
QueuePause: Makes a queue member temporarily unavailable.  (Priv: agent,all)
QueuePenalty: Set the penalty for a queue member.  (Priv: agent,all)
QueueReload: Reload a queue, queues, or any sub-section of a queue or queues.  (Priv: <none>)
QueueRemove: Remove interface from queue.  (Priv: agent,all)
QueueReset: Reset queue statistics.  (Priv: <none>)
QueueRule: Queue Rules.  (Priv: <none>)
QueueStatus: Show queue status.  (Priv: <none>)
QueueSummary: Show queue summary.  (Priv: <none>)
QueueWithdrawCaller: Request to withdraw a caller from the queue back to the dialplan.  (Priv: <none>)
Redirect: Redirect (transfer) a call.  (Priv: call,all)
Reload: Send a reload event.  (Priv: system,config,all)
SendText: Sends a text message to channel. A content type
  can be optionally specified. If not set it is set to an empty
  string allowing a custom handler to default it as it sees fit.  (Priv: call,all)
Setvar: Sets a channel variable or function value.  (Priv: call,all)
ShowDialPlan: Show dialplan contexts and extensions  (Priv: config,reporting,all)
Status: List channel status.  (Priv: system,call,reporting,all)
StopMixMonitor: Stop recording a call through MixMonitor,
  and free the recording's file handle.  (Priv: system,call,all)
UpdateConfig: Update basic configuration.  (Priv: config,all)
UserEvent: Send an arbitrary event.  (Priv: user,all)
WaitEvent: Wait for an event to occur.  (Priv: <none>)
```

#### Описание команд

GET /rawman?action=command&amp;command=manager show command waitevent

Пример ответа:

```
Response: Success
Message: Command output follows
Output: [Syntax]
Output: Action: WaitEvent
Output: [ActionID:] <value>
Output: Timeout: <value>
Output: 
Output: [Synopsis]
Output: Wait for an event to occur. 
Output: 
Output: [Description]
Output: This action will elicit a 'Success' response. Whenever a manager event is
Output: queued. Once WaitEvent has been called on an HTTP manager session, events will
Output: be generated and queued.
Output: 
Output: [Arguments]
Output: ActionID
Output:     ActionID for this transaction. Will be returned.
Output: Timeout
Output:     Maximum time (in seconds) to wait for events, '-1' means forever.
Output: 
Output: [See Also]
Output: Not available
Output: 
Output: [Privilege]
Output: <none>
Output: 
Output: [List Responses]
Output: None
Output: 
Output: [Final Response]
Output: None
Output: 
Output: 
```