Skip to end of metadata
Go to start of metadata

Channels

Method

Path<br>h5. Parameters are case-sensitive

Return Model

Summary

GET

/channels

List[Channel]

List all active channels in Asterisk.

POST

/channels

Channel

Create a new channel (originate).

GET

/channels/{channelId}

Channel

Channel details.

POST

/channels/{channelId}

Channel

Create a new channel (originate with id).

DELETE

/channels/{channelId}

void

Delete (i.e. hangup) a channel.

POST

/channels/{channelId}/continue

void

Exit application; continue execution in the dialplan.

POST

/channels/{channelId}/move

void

Move the channel from one Stasis application to another.

POST

/channels/{channelId}/redirect

void

Redirect the channel to a different location.

POST

/channels/{channelId}/answer

void

Answer a channel.

POST

/channels/{channelId}/ring

void

Indicate ringing to a channel.

DELETE

/channels/{channelId}/ring

void

Stop ringing indication on a channel if locally generated.

POST

/channels/{channelId}/dtmf

void

Send provided DTMF to a given channel.

POST

/channels/{channelId}/mute

void

Mute a channel.

DELETE

/channels/{channelId}/mute

void

Unmute a channel.

POST

/channels/{channelId}/hold

void

Hold a channel.

DELETE

/channels/{channelId}/hold

void

Remove a channel from hold.

POST

/channels/{channelId}/moh

void

Play music on hold to a channel.

DELETE

/channels/{channelId}/moh

void

Stop playing music on hold to a channel.

POST

/channels/{channelId}/silence

void

Play silence to a channel.

DELETE

/channels/{channelId}/silence

void

Stop playing silence to a channel.

POST

/channels/{channelId}/play

Playback

Start playback of media.

POST

/channels/{channelId}/play/{playbackId}

Playback

Start playback of media and specify the playbackId.

POST

/channels/{channelId}/record

LiveRecording

Start a recording.

GET

/channels/{channelId}/variable

Variable

Get the value of a channel variable or function.

POST

/channels/{channelId}/variable

void

Set the value of a channel variable or function.

POST

/channels/{channelId}/snoop

Channel

Start snooping.

POST

/channels/{channelId}/snoop/{snoopId}

Channel

Start snooping.

GET

/channels/{channelId}/rtp_statistics

RTPstat

RTP stats on a channel.

list: GET /channels

List all active channels in Asterisk.

originate: POST /channels

Create a new channel (originate). The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further events and updates.

Query parameters

  • endpoint: string - (required) Endpoint to call.
  • extension: string - The extension to dial after the endpoint answers. Mutually exclusive with 'app'.
  • context: string - The context to dial after the endpoint answers. If omitted, uses 'default'. Mutually exclusive with 'app'.
  • priority: long - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with 'app'.
  • label: string - The label to dial after the endpoint answers. Will supersede 'priority' if provided. Mutually exclusive with 'app'.
  • app: string - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive with 'context', 'extension', 'priority', and 'label'.
  • appArgs: string - The application arguments to pass to the Stasis application provided by 'app'. Mutually exclusive with 'context', 'extension', 'priority', and 'label'.
  • callerId: string - CallerID to use when dialing the endpoint or extension.
  • timeout: int - Timeout (in seconds) before giving up dialing, or -1 for no timeout.
    • Default: 30
  • channelId: string - The unique id to assign the channel on creation.
  • otherChannelId: string - The unique id to assign the second channel when using local channels.
  • originator: string - The unique id of the channel which is originating this one.
  • formats: string - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs".

Body parameter

  • variables: containers - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }

Error Responses

  • 400 - Invalid parameters for originating a channel.
  • 409 - Channel with given unique ID already exists.

get: GET /channels/{channelId}

Channel details.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found

originateWithId: POST /channels/{channelId}

Create a new channel (originate with id). The new channel is created immediately and a snapshot of it returned. If a Stasis application is provided it will be automatically subscribed to the originated channel for further events and updates.

Path parameters

Parameters are case-sensitive.

  • channelId: string - The unique id to assign the channel on creation.

Query parameters

  • endpoint: string - (required) Endpoint to call.
  • extension: string - The extension to dial after the endpoint answers. Mutually exclusive with 'app'.
  • context: string - The context to dial after the endpoint answers. If omitted, uses 'default'. Mutually exclusive with 'app'.
  • priority: long - The priority to dial after the endpoint answers. If omitted, uses 1. Mutually exclusive with 'app'.
  • label: string - The label to dial after the endpoint answers. Will supersede 'priority' if provided. Mutually exclusive with 'app'.
  • app: string - The application that is subscribed to the originated channel. When the channel is answered, it will be passed to this Stasis application. Mutually exclusive with 'context', 'extension', 'priority', and 'label'.
  • appArgs: string - The application arguments to pass to the Stasis application provided by 'app'. Mutually exclusive with 'context', 'extension', 'priority', and 'label'.
  • callerId: string - CallerID to use when dialing the endpoint or extension.
  • timeout: int - Timeout (in seconds) before giving up dialing, or -1 for no timeout.
    • Default: 30
  • otherChannelId: string - The unique id to assign the second channel when using local channels.
  • originator: string - The unique id of the channel which is originating this one.
  • formats: string - The format name capability list to use if originator is not specified. Ex. "ulaw,slin16". Format names can be found with "core show codecs".

Body parameter

  • variables: containers - The "variables" key in the body object holds variable key/value pairs to set on the channel on creation. Other keys in the body object are interpreted as query parameters. Ex. { "endpoint": "SIP/Alice", "variables": { "CALLERID(name)": "Alice" } }

Error Responses

  • 400 - Invalid parameters for originating a channel.
  • 409 - Channel with given unique ID already exists.

hangup: DELETE /channels/{channelId}

Delete (i.e. hangup) a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • reason: string - Reason for hanging up the channel
    • Allowed values: normal, busy, congestion, no_answer

Error Responses

  • 400 - Invalid reason for hangup provided
  • 404 - Channel not found

continueInDialplan: POST /channels/{channelId}/continue

Exit application; continue execution in the dialplan.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • context: string - The context to continue to.
  • extension: string - The extension to continue to.
  • priority: int - The priority to continue to.
  • label: string - The label to continue to - will supersede 'priority' if both are provided.

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

move: POST /channels/{channelId}/move

Move the channel from one Stasis application to another.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • app: string - (required) The channel will be passed to this Stasis application.
  • appArgs: string - The application arguments to pass to the Stasis application provided by 'app'.

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

redirect: POST /channels/{channelId}/redirect

Redirect the channel to a different location.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • endpoint: string - (required) The endpoint to redirect the channel to

Error Responses

  • 400 - Endpoint parameter not provided
  • 404 - Channel or endpoint not found
  • 409 - Channel not in a Stasis application
  • 422 - Endpoint is not the same type as the channel

answer: POST /channels/{channelId}/answer

Answer a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

ring: POST /channels/{channelId}/ring

Indicate ringing to a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

ringStop: DELETE /channels/{channelId}/ring

Stop ringing indication on a channel if locally generated.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

sendDTMF: POST /channels/{channelId}/dtmf

Send provided DTMF to a given channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • dtmf: string - DTMF To send.
  • before: int - Amount of time to wait before DTMF digits (specified in milliseconds) start.
  • between: int - Amount of time in between DTMF digits (specified in milliseconds).
    • Default: 100
  • duration: int - Length of each DTMF digit (specified in milliseconds).
    • Default: 100
  • after: int - Amount of time to wait after DTMF digits (specified in milliseconds) end.

Error Responses

  • 400 - DTMF is required
  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

mute: POST /channels/{channelId}/mute

Mute a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • direction: string - Direction in which to mute audio
    • Default: both
    • Allowed values: both, in, out

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

unmute: DELETE /channels/{channelId}/mute

Unmute a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • direction: string - Direction in which to unmute audio
    • Default: both
    • Allowed values: both, in, out

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

hold: POST /channels/{channelId}/hold

Hold a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

unhold: DELETE /channels/{channelId}/hold

Remove a channel from hold.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

startMoh: POST /channels/{channelId}/moh

Play music on hold to a channel. Using media operations such as /play on a channel playing MOH in this manner will suspend MOH without resuming automatically. If continuing music on hold is desired, the stasis application must reinitiate music on hold.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • mohClass: string - Music on hold class to use

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

stopMoh: DELETE /channels/{channelId}/moh

Stop playing music on hold to a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

startSilence: POST /channels/{channelId}/silence

Play silence to a channel. Using media operations such as /play on a channel playing silence in this manner will suspend silence without resuming automatically.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

stopSilence: DELETE /channels/{channelId}/silence

Stop playing silence to a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

play: POST /channels/{channelId}/play

Start playback of media. The media URI may be any of a number of URI's. Currently sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a playback resource that can be used to control the playback of media (pause, rewind, fast forward, etc.)

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • media: string - (required) Media's URI to play.
  • lang: string - For sounds, selects language for sound.
  • offsetms: int - Number of media to skip before playing.
  • skipms: int - Number of milliseconds to skip for forward/reverse operations.
    • Default: 3000
  • playbackId: string - Playback ID.

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

playWithId: POST /channels/{channelId}/play/{playbackId}

Start playback of media and specify the playbackId. The media URI may be any of a number of URI's. Currently sound:, recording:, number:, digits:, characters:, and tone: URI's are supported. This operation creates a playback resource that can be used to control the playback of media (pause, rewind, fast forward, etc.)

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id
  • playbackId: string - Playback ID.

Query parameters

  • media: string - (required) Media's URI to play.
  • lang: string - For sounds, selects language for sound.
  • offsetms: int - Number of media to skip before playing.
  • skipms: int - Number of milliseconds to skip for forward/reverse operations.
    • Default: 3000

Error Responses

  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

record: POST /channels/{channelId}/record

Start a recording. Record audio from a channel. Note that this will not capture audio sent to the channel. The bridge itself has a record feature if that's what you want.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • name: string - (required) Recording's filename
  • format: string - (required) Format to encode audio in
  • maxDurationSeconds: int - Maximum duration of the recording, in seconds. 0 for no limit
    • Allowed range: Min: 0; Max: None
  • maxSilenceSeconds: int - Maximum duration of silence, in seconds. 0 for no limit
    • Allowed range: Min: 0; Max: None
  • ifExists: string - Action to take if a recording with the same name already exists.
    • Default: fail
    • Allowed values: fail, overwrite, append
  • beep: boolean - Play beep when recording begins
  • terminateOn: string - DTMF input to terminate recording
    • Default: none
    • Allowed values: none, any, *, #

Error Responses

  • 400 - Invalid parameters
  • 404 - Channel not found
  • 409 - Channel is not in a Stasis application; the channel is currently bridged with other hcannels; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail
  • 422 - The format specified is unknown on this system

getChannelVar: GET /channels/{channelId}/variable

Get the value of a channel variable or function.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • variable: string - (required) The channel variable or function to get

Error Responses

  • 400 - Missing variable parameter.
  • 404 - Channel or variable not found
  • 409 - Channel not in a Stasis application

setChannelVar: POST /channels/{channelId}/variable

Set the value of a channel variable or function.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • variable: string - (required) The channel variable or function to set
  • value: string - The value to set the variable to

Error Responses

  • 400 - Missing variable parameter.
  • 404 - Channel not found
  • 409 - Channel not in a Stasis application

snoopChannel: POST /channels/{channelId}/snoop

Start snooping. Snoop (spy/whisper) on a specific channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Query parameters

  • spy: string - Direction of audio to spy on
    • Default: none
    • Allowed values: none, both, out, in
  • whisper: string - Direction of audio to whisper into
    • Default: none
    • Allowed values: none, both, out, in
  • app: string - (required) Application the snooping channel is placed into
  • appArgs: string - The application arguments to pass to the Stasis application
  • snoopId: string - Unique ID to assign to snooping channel

Error Responses

  • 400 - Invalid parameters
  • 404 - Channel not found

snoopChannelWithId: POST /channels/{channelId}/snoop/{snoopId}

Start snooping. Snoop (spy/whisper) on a specific channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id
  • snoopId: string - Unique ID to assign to snooping channel

Query parameters

  • spy: string - Direction of audio to spy on
    • Default: none
    • Allowed values: none, both, out, in
  • whisper: string - Direction of audio to whisper into
    • Default: none
    • Allowed values: none, both, out, in
  • app: string - (required) Application the snooping channel is placed into
  • appArgs: string - The application arguments to pass to the Stasis application

Error Responses

  • 400 - Invalid parameters
  • 404 - Channel not found

rtpstatistics: GET /channels/{channelId}/rtp_statistics

RTP stats on a channel.

Path parameters

Parameters are case-sensitive.

  • channelId: string - Channel's id

Error Responses

  • 404 - Channel cannot be found.
  • No labels

9 Comments

  1. I am not sure where it should go, but there needs to be some indication that you CAN get in and out audio recording on a single channel (bridged or unbridged) by using the snoop function.  I dug an explanation out of here and finally figured it out.  Right now the description reads "Start a recording. Record audio from a channel. Note that this will not capture audio sent to the channel. The bridge itself has a record feature if that's what you want."  Something along the lines of "Start a recording. Record audio from a channel. Note that this will not capture audio sent to the channel. The bridge itself has a record feature if you want all bridged channels mixed.  Alternatively you can use the snoop function to create two spy channels and record the 'in' and 'out' streams. "

    1. On this page the documentation of the Snoop channel already describes its behavior.

      Are you saying that you want the documentation of the Record channel to reference the Snoop channel?

      I think that makes sense. However the documentation here is pulled from the Asterisk source. You can file an issue on http://issues.asterisk.org/jira to make the documentation improvement suggestion. Thanks!

      1. I will do that.  The issue is that little "tricks" like using the Snoop channel to get in/out audio streams for recording isn't very intuitive.  If you're switching from AGI (MixMonitor/Monitor) like I was, you'd be looking to do the recording on the SIP channel.  I honestly feel like there is a lot of "caveats" that I wish could be added to some sort of tips/tricks/command pitfalls section for each command.  There's a few ARI/Stasis documents that outline the design philosophy, but there definitely needs to be more linkage between ARI events and commands issued for people just starting out.

        1. The kind of documentation you describe is often best written by someone new to the interface. It is hard for someone who wrote the interface to come up with that sort of content as they already know the internals and how things work.

          I look forward to any suggestions you can provide. If you have enough to write out an ARI tips and tricks guide we could certainly look at getting you edit access and putting up a page for that on the wiki.

          1. Sounds like a plan.  I'm busy this/next week to finish doing a lot of ARI stuff for my company but I can work on a document and submit it sometime in the near future.

            1. Excellent! We can use all the help we can get!

  2. I think what you are referring to is a document detailing ways to accomplish different goals. "I want to whisper to a channel". "I want to passively record a channel". How to do it using ARI. That sort of thing. I'm more a fan of creating document on here for that versus cramming it into the other commands.

    1. I want to Listen, whisper and Barge on a channel using RESTAPI (ari.channels().snoopChannel(.......). Please explain the parameters given in documentation which does not make any sense to me. Help me to find a detail documentation of ARI for Java.

  3. I want to Listen, whisper and Barge on a channel using RESTAPI (ari.channels().snoopChannel(.......). Please explain the parameters given in documentation which does not make any sense to me.