PJSIPHangup()

Since 18.21.0, 20.6.0, 21.1.0 Applications Found this useful? Upvote it. ×

Hangup an incoming PJSIP channel with a SIP response code

Last reviewed 2026-04-14

PJSIPHangup(Cause)
Dialplan Builder -- build your PJSIPHangup() command
May be one of...
Full arguments reference
  • Cause required - May be one of...
    • Response code - A numeric response code in the range 400 ->699
    • Response code name - A response code name from third-party/pjproject/source/pjsip/include/pjsip/sip_msg.h such as USE_IDENTITY_HEADER or PJSIP_SC_USE_IDENTITY_HEADER
Description

Hangs up an incoming PJSIP channel and returns the specified SIP response code in the final response to the caller.

Warning

This function must be called BEFORE anything that might cause any other final (non 1XX) response to be sent. For example calling Answer() or Playback without the noanswer option will cause the call to be answered and a final 200 response to be sent.

As with the Hangup application, the dialplan will terminate after calling this function.

The cause code set on the channel will be translated to a standard ISDN cause code using the table defined in ast_sip_hangup_sip2cause() in res_pjsip.c

``` title="Terminate call with 437 response code" same = n,PJSIPHangup(437)


``` title="Terminate call with 437 response code using the response code name"
same = n,PJSIPHangup(UNSUPPORTED_CERTIFICATE)

title="Terminate call with 437 response code based on condition" same = n,ExecIf($[${SOMEVALUE} = ${SOME_BAD_VALUE}]?PJSIPHangup(437))

Arguments
  • Cause required - May be one of...
    • Response code - A numeric response code in the range 400 ->699
    • Response code name - A response code name from third-party/pjproject/source/pjsip/include/pjsip/sip_msg.h such as USE_IDENTITY_HEADER or PJSIP_SC_USE_IDENTITY_HEADER

User Notes

No notes yet. Be the first to contribute a tip or example.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.
Applications
ConfBridge() MusicOnHold() StartMusicOnHold() StopMixMonitor() ADSIProg() AELSub() AGI() AMD() AddQueueMember() AgentLogin() AgentRequest() AlarmReceiver() Answer() AttendedTransfer() AudioSocket() Authenticate() Background() BackgroundDetect() BlindTransfer() Bridge() BridgeAdd() BridgeWait() Broadcast() Busy() CELGenUserEvent() CallCompletionCancel() CallCompletionRequest() ChanIsAvail() ChanSpy() ChangeMonitor() ChannelRedirect() ClearHash() ConfKick() Congestion() ContinueWhile() ControlPlayback() DAHDIAcceptR2Call() DAHDIRAS() DAHDIScan() DAHDISendCallreroutingFacility() DAHDISendKeypadFacility() DBdeltree() DISA() DateTime() DeadAGI() Dial() Dictate() Directory() DumpChan() EAGI() Echo() Else() ElseIf() EndIf() EndWhile() Exec() ExecIf() ExecIfTime() ExitIf() ExitWhile() ExtenSpy() ExternalIVR() Festival() Flash() FollowMe() ForkCDR() GetCPEID() Gosub() GosubIf() Goto() GotoIf() GotoIfTime() Hangup() HangupCauseClear() IAX2Provision() ICES() IVRDemo() If() ImportVar() Incomplete() JACK() JabberJoin() JabberLeave() JabberSend() JabberSendGroup() JabberStatus() Log() MP3Player() MSet() Macro() MacroExclusive() MacroExit() MacroIf() MailboxExists() MeetMe() MeetMeAdmin() MeetMeChannelAdmin() MeetMeCount() MessageSend() Milliwatt() MinivmAccMess() MinivmDelete() MinivmGreet() MinivmMWI() MinivmNotify() MinivmRecord() MixMonitor() Monitor() Morsecode() NBScat() NoCDR() NoOp() ODBCFinish() ODBC_Commit() ODBC_Rollback() OSPAuth() OSPFinish() OSPLookup() OSPNext() Originate() PJSIPHangup() PJSIPNotify() Page() Park() ParkAndAnnounce() ParkedCall() PauseMonitor() PauseQueueMember() Pickup() PickupChan() PlayTones() Playback() PrivacyManager() Proceeding() Progress() Queue() QueueLog() QueueUpdate() RaiseException() Read() ReadExten() ReceiveFAX() ReceiveMF() ReceiveSF() ReceiveText() Record() Reload() RemoveQueueMember() ResetCDR() RetryDial() Return() Ringing() SIPAddHeader() SIPDtmfMode() SIPRemoveHeader() SIPSendCustomINFO() SLAStation() SLATrunk() SMS() SayAlpha() SayAlphaCase() SayCountedAdj() SayCountedNoun() SayDigits() SayMoney() SayNumber() SayOrdinal() SayPhonetic() SayUnixTime() SendDTMF() SendFAX() SendImage() SendMF() SendSF() SendText() SendURL() Set() SetAMAFlags() Signal() SkelGuessNumber() SoftHangup() SpeechActivateGrammar() SpeechBackground() SpeechCreate() SpeechDeactivateGrammar() SpeechDestroy() SpeechLoadGrammar() SpeechProcessingSound() SpeechStart() SpeechUnloadGrammar() StackPop() Stasis() StatsD() StopMonitor() StopMusicOnHold() StopPlayTones() StoreDTMF() StreamEcho() System() TestClient() TestServer() ToneScan() Transfer() TryExec() TrySystem() UnpauseMonitor() UnpauseQueueMember() UserEvent() VMAuthenticate() VMSayName() Verbose() VoiceMail() VoiceMailMain() VoiceMailPlayMsg() Wait() WaitDigit() WaitExten() WaitForCondition() WaitForNoise() WaitForRing() WaitForSignal() WaitForSilence() WaitForTone() WaitUntil() While() Zapateller()
Applications
ConfBridge() MusicOnHold() StartMusicOnHold() StopMixMonitor() ADSIProg() AELSub() AGI() AMD() AddQueueMember() AgentLogin() AgentRequest() AlarmReceiver() Answer() AttendedTransfer() AudioSocket() Authenticate() Background() BackgroundDetect() BlindTransfer() Bridge() BridgeAdd() BridgeWait() Broadcast() Busy() CELGenUserEvent() CallCompletionCancel() CallCompletionRequest() ChanIsAvail() ChanSpy() ChangeMonitor() ChannelRedirect() ClearHash() ConfKick() Congestion() ContinueWhile() ControlPlayback() DAHDIAcceptR2Call() DAHDIRAS() DAHDIScan() DAHDISendCallreroutingFacility() DAHDISendKeypadFacility() DBdeltree() DISA() DateTime() DeadAGI() Dial() Dictate() Directory() DumpChan() EAGI() Echo() Else() ElseIf() EndIf() EndWhile() Exec() ExecIf() ExecIfTime() ExitIf() ExitWhile() ExtenSpy() ExternalIVR() Festival() Flash() FollowMe() ForkCDR() GetCPEID() Gosub() GosubIf() Goto() GotoIf() GotoIfTime() Hangup() HangupCauseClear() IAX2Provision() ICES() IVRDemo() If() ImportVar() Incomplete() JACK() JabberJoin() JabberLeave() JabberSend() JabberSendGroup() JabberStatus() Log() MP3Player() MSet() Macro() MacroExclusive() MacroExit() MacroIf() MailboxExists() MeetMe() MeetMeAdmin() MeetMeChannelAdmin() MeetMeCount() MessageSend() Milliwatt() MinivmAccMess() MinivmDelete() MinivmGreet() MinivmMWI() MinivmNotify() MinivmRecord() MixMonitor() Monitor() Morsecode() NBScat() NoCDR() NoOp() ODBCFinish() ODBC_Commit() ODBC_Rollback() OSPAuth() OSPFinish() OSPLookup() OSPNext() Originate() PJSIPHangup() PJSIPNotify() Page() Park() ParkAndAnnounce() ParkedCall() PauseMonitor() PauseQueueMember() Pickup() PickupChan() PlayTones() Playback() PrivacyManager() Proceeding() Progress() Queue() QueueLog() QueueUpdate() RaiseException() Read() ReadExten() ReceiveFAX() ReceiveMF() ReceiveSF() ReceiveText() Record() Reload() RemoveQueueMember() ResetCDR() RetryDial() Return() Ringing() SIPAddHeader() SIPDtmfMode() SIPRemoveHeader() SIPSendCustomINFO() SLAStation() SLATrunk() SMS() SayAlpha() SayAlphaCase() SayCountedAdj() SayCountedNoun() SayDigits() SayMoney() SayNumber() SayOrdinal() SayPhonetic() SayUnixTime() SendDTMF() SendFAX() SendImage() SendMF() SendSF() SendText() SendURL() Set() SetAMAFlags() Signal() SkelGuessNumber() SoftHangup() SpeechActivateGrammar() SpeechBackground() SpeechCreate() SpeechDeactivateGrammar() SpeechDestroy() SpeechLoadGrammar() SpeechProcessingSound() SpeechStart() SpeechUnloadGrammar() StackPop() Stasis() StatsD() StopMonitor() StopMusicOnHold() StopPlayTones() StoreDTMF() StreamEcho() System() TestClient() TestServer() ToneScan() Transfer() TryExec() TrySystem() UnpauseMonitor() UnpauseQueueMember() UserEvent() VMAuthenticate() VMSayName() Verbose() VoiceMail() VoiceMailMain() VoiceMailPlayMsg() Wait() WaitDigit() WaitExten() WaitForCondition() WaitForNoise() WaitForRing() WaitForSignal() WaitForSilence() WaitForTone() WaitUntil() While() Zapateller()