Asterisk Manager API Action ExtensionState
Action: ExtensionState
Parameters: Exten, Context, ActionID
SEND:
RECEIVE:
Status codes:
-1 = Extension not found
0 = Idle
1 = In Use
2 = Busy
4 = Unavailable
8 = Ringing
16 = On Hold
Parameters: Exten, Context, ActionID
SEND:
ACTION: ExtensionState
Context: default
Exten: idonno
ActionID: 1
Context: default
Exten: idonno
ActionID: 1
RECEIVE:
Response: Success
ActionID: 1
Message: Extension Status
Exten: idonno
Context: default
Hint:
Status: -1
ActionID: 1
Message: Extension Status
Exten: idonno
Context: default
Hint:
Status: -1
Status codes:
-1 = Extension not found
0 = Idle
1 = In Use
2 = Busy
4 = Unavailable
8 = Ringing
16 = On Hold

Comments
333
but do I have to send it? polling extension state is not very good solution, I would like to subscribe to extension event status automatically.
333using Hint with SIP
exten => 201,hint,SIP/201 (do this for each extension) in the context where the extensions are that you want to monitor
Then when doing the ExtensionState command you just use the extesion number (in this case 201)
EG
Action: ExtensionState
Exten: 201
Context: intern
ActionID: (whatever)