# Asterisk Project : Asterisk 12 Bridges REST API

Added by dlee , edited by wikibot on Dec 18, 2013

# Bridges

Method | Path | Return Model | Summary
--- | --- | --- | ---
GET | /bridges | List[Bridge] | List all active bridges in Asterisk.
POST | /bridges | Bridge | Create a new bridge.
GET | /bridges/{bridgeId} | Bridge | Get bridge details.
DELETE | /bridges/{bridgeId} | void | Shut down a bridge.
POST | /bridges/{bridgeId}/addChannel | void | Add a channel to a bridge.
POST | /bridges/{bridgeId}/removeChannel | void | Remove a channel from a bridge.
POST | /bridges/{bridgeId}/moh | void | Play music on hold to a bridge or change the MOH class that is playing.
DELETE | /bridges/{bridgeId}/moh | void | Stop playing music on hold to a bridge.
POST | /bridges/{bridgeId}/play | Playback | Start playback of media on a bridge.
POST | /bridges/{bridgeId}/record | LiveRecording | Start a recording.

## GET /bridges

List all active bridges in Asterisk.

## POST /bridges

Create a new bridge. This bridge persists until it has been shut down, or Asterisk has been shut down.

### Query parameters

- type: string - Type of bridge to create.
- name: string - Name to give to the bridge being created.

## GET /bridges/{bridgeId}

Get bridge details.

### Path parameters

- bridgeId: string - Bridge's id

### Error Responses

- 404 - Bridge not found

## DELETE /bridges/{bridgeId}

Shut down a bridge. If any channels are in this bridge, they will be removed and resume whatever they were doing beforehand.

### Path parameters

- bridgeId: string - Bridge's id

### Error Responses

- 404 - Bridge not found

## POST /bridges/{bridgeId}/addChannel

Add a channel to a bridge.

### Path parameters

- bridgeId: string - Bridge's id

### Query parameters

- channel: string - (required) Ids of channels to add to bridge
  - Allows comma separated values.
- role: string - Channel's role in the bridge

### Error Responses

- 400 - Channel not found
- 404 - Bridge not found
- 409 - Bridge not in Stasis application; Channel currently recording
- 422 - Channel not in Stasis application

## POST /bridges/{bridgeId}/removeChannel

Remove a channel from a bridge.

### Path parameters

- bridgeId: string - Bridge's id

### Query parameters

- channel: string - (required) Ids of channels to remove from bridge
  - Allows comma separated values.

### Error Responses

- 400 - Channel not found
- 404 - Bridge not found
- 409 - Bridge not in Stasis application
- 422 - Channel not in this bridge

## POST /bridges/{bridgeId}/moh

Play music on hold to a bridge or change the MOH class that is playing.

### Path parameters

- bridgeId: string - Bridge's id

### Query parameters

- mohClass: string - Channel's id

### Error Responses

- 404 - Bridge not found
- 409 - Bridge not in Stasis application

## DELETE /bridges/{bridgeId}/moh

Stop playing music on hold to a bridge. This will only stop music on hold being played via POST bridges/{bridgeId}/moh.

### Path parameters

- bridgeId: string - Bridge's id

### Error Responses

- 404 - Bridge not found
- 409 - Bridge not in Stasis application

## POST /bridges/{bridgeId}/play

Start playback of media on a bridge. The media URI may be any of a number of URI's. Currently sound: and recording: 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

- bridgeId: string - Bridge'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 = 3000 - Number of milliseconds to skip for forward/reverse operations.

### Error Responses

- 404 - Bridge not found
- 409 - Bridge not in a Stasis application

## POST /bridges/{bridgeId}/record

Start a recording. This records the mixed audio from all channels participating in this bridge.

### Path parameters

- bridgeId: string - Bridge'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.
- maxSilenceSeconds: int - Maximum duration of silence, in seconds. 0 for no limit.
- ifExists: string = fail - Action to take if a recording with the same name already exists.
- beep: boolean - Play beep when recording begins
- terminateOn: string = none - DTMF input to terminate recording.

### Error Responses

- 400 - Invalid parameters
- 404 - Bridge not found
- 409 - Bridge is not in a Stasis application; 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