src/api/ChannelsAPI.js
/**
   * POST /channels/{channelId}
   *
   * Create a new channel (originate with id). The new channel is created
   * immediately and a snapshot of it is returned. If a stasis application
   * is provided, that application will be automatically subscribed to the
   * originated channel for further events and updates.
   *
   * *API available since Asterisk 12.2*
   *
   * @param {object} params
   * @param {string} params.channelId The unique id to assign the channel
   *  on creation.
   * @param {string} params.endpoint The endpoint to call
   * @param {string} [params.extension] The extension to dial after the endpoint
   *  answers. Mutually exclusive with `app`.
   * @param {string} [params.context] The context to dial after the endpoint
   *  answers. If omitted, uses 'default'. Mutually exclusive with `app`.
   * @param {number} [params.priority] The priority to dial after the endpoint
   *  answers. If omitted, uses 1. Mutually exclusive with `app`.
   * @param {string} [params.label] The label to dial after the endpoint
   *  answers. Will supersede `params.priority` if both are provided. Mutually
   *  exclusive with `app`. *Param available since Asterisk 13.2*
   * @param {string} [params.app] 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`.
   * @param {string} [params.appArgs] The application arguments to pass to
   *  the stasis application provided by `app`. Mutually exclusive with
   *  `context`, `extension`, `priority`, and `label`.
   * @param {string} [params.callerId] CallerID to use when dialing the
   *  endpoint or extension.
   * @param {number} [params.timeout=30] The timeout in seconds before giving
   *  up dialing, or -1 for no timeout.
   * @param {string} [params.otherChannelId] The unique id to assign the
   *  second channel when using local channels.
   * @param {string} [params.originator] The unique id of the channel which
   *  is originating this one. *Param available since Asterisk 13.2*
   * @param {string|Array.<string>} [params.formats] The format name
   *  capability list to use if originator is not specified. For example,
   *  ['ulaw', 'slin16']. Format names can be found by executing the
   *  `core show codecs` command in the Asterisk console. *Param available
   *  since Asterisk 13.10*
   * @param {object} [params.variables] An object of key/value pairs that
   *  should be set on the channel on creation.
   * @returns {Promise.<Channel>} Resolves with the newly created channel.
   *  Rejects when invalid params are passed (status 400).
   */
POST /channels/{channelId}
Create a new channel (originate with id). The new channel is created
immediately and a snapshot of it is returned. If a stasis application
is provided, that application will be automatically subscribed to the
originated channel for further events and updates.

*API available since Asterisk 12.2

@param {object} params
@param {string} params.channelId The unique id to assign the channel
on creation.
@param {string} params.endpoint The endpoint to call
@param {string} [params.extension] The extension to dial after the endpoint
answers. Mutually exclusive with `app`.
@param {string} [params.context] The context to dial after the endpoint
answers. If omitted, uses 'default'. Mutually exclusive with `app`.
@param {number} [params.priority] The priority to dial after the endpoint
answers. If omitted, uses 1. Mutually exclusive with `app`.
@param {string} [params.label] The label to dial after the endpoint
answers. Will supersede `params.priority` if both are provided. Mutually
exclusive with `app`. *Param available since Asterisk 13.2
@param {string} [params.app] The application that is subscribed to the
originated channel. When the channel is answered, it will be passed to
this stasis application.
POST / channels / { channelId } Create a new channel ( originate with id ) . The new channel is created immediately and a snapshot of it is returned . If a stasis application is provided that application will be automatically subscribed to the originated channel for further events and updates . * API available since Asterisk 12 . 2 @param { object } params @param { string } params . channelId The unique id to assign the channel on creation . @param { string } params . endpoint The endpoint to call @param { string } [ params . extension ] The extension to dial after the endpoint answers . Mutually exclusive with ` app ` . @param { string } [ params . context ] The context to dial after the endpoint answers . If omitted uses ' default ' . Mutually exclusive with ` app ` . @param { number } [ params . priority ] The priority to dial after the endpoint answers . If omitted uses 1 . Mutually exclusive with ` app ` . @param { string } [ params . label ] The label to dial after the endpoint answers . Will supersede ` params . priority ` if both are provided . Mutually exclusive with ` app ` . * Param available since Asterisk 13 . 2 @param { string } [ params . app ] The application that is subscribed to the originated channel . When the channel is answered it will be passed to this stasis application .
originateWithId(params) {
    const {
      channelId,
      endpoint,
      extension,
      context,
      priority,
      label,
      app,
      appArgs,
      callerId,
      timeout = 30,
      otherChannelId,
      originator,
      formats,
      variables,
    } = params;
    const id = encodeURIComponent(channelId);
    return this._request({
      method: "POST",
      url: `${this._baseUrl}/channels/${id}`,
      params: {
        endpoint,
        extension,
        context,
        priority,
        label,
        app,
        appArgs,
        callerId,
        timeout,
        otherChannelId,
        originator,
        formats: [].concat(formats).join(","),
      },
      data: { variables },
    });
  }
originateWithId ( params ) { const { channelId , endpoint , extension , context , priority , label , app , appArgs , callerId , timeout = 30 , otherChannelId , originator , formats , variables , } = params ; const id = encodeURIComponent ( channelId ) ; return this . _request ( { method : "POST" , url : ` ${ this . _baseUrl } ${ id } ` , params : { endpoint , extension , context , priority , label , app , appArgs , callerId , timeout , otherChannelId , originator , formats : [ ] . concat ( formats ) . join ( "," ) , } , data : { variables } , } ) ; }
POST /channels/{channelId}
 Create a new channel (originate with id).
POST / channels / { channelId } Create a new channel ( originate with id ) .