Permalink
3720 lines (3058 sloc) 156 KB

Classes

Account
AccountResponse : Object
TransactionListResponse : Object
TransactionResponse : Object
Application
ApplicationListResponse : Object
ApplicationResponse : Object
AvailableNumber
AvailableNumberResponse : Object
OrderedNumberResponse : Object
Bridge
BridgeListResponse : Object
BridgeResponse : Object
Call
CallResponse : Object
GatherResponse : Object
EventResponse : Object
RecordingResponse : Object
TranscriptionResponse : Object
Conference
ConferenceResponse : Object
Domain
DomainResponse : Object
Endpoint
EndpointResponse : Object
Error
ErrorResponse : Object
CatapultClient
Media
DownloadMediaFileResponse : Object
MediaFileResponse : Object
Message
MessageListResponse : Object
ExtendedMessageResponse : Object
MessageError : Object
MessageResponse : Object
NumberInfo
NumberInfoResponse : Object
PhoneNumber
PhoneNumberResponse : Object
Recording
RecordingResponse : Object
TranscriptionResponse : Object
BXMLResponse

Functions

getNextLink(response)

getNextLink

Account

Kind: global class

new Account()

Account

account.get(accountId, callback) ⇒ AccountResponse

Gets information about user's account.

Kind: instance method of Account
Returns: AccountResponse - A promise for the account information

Param Type Description
accountId String The ID of the account to get
callback function A callback with the account information

Example

// Promise
client.Account.get().then(function(info){});

// Callback
client.Account.get(function(err, info){});

account.getTransactions(params, callback) ⇒ TransactionListResponse

Gets a list of transactions from user's account.

Kind: instance method of Account
Returns: TransactionListResponse - A promise for the list of transactions

Param Type Default Description
params Object Query parameters for listing accounts
[params.size] Number 25 Used for pagination to indicate the size of each page requested for querying a list of transactions. If no value is specified the default value is 25 (maximum value 1000).
[params.maxItems] Number Limit the number of transactions that will be returned
[params.toDate] String Return only transactions that are newer than the parameter.
[params.fromDate] String Return only transactions that are older than the parameter.
[params.type] String Return only transactions that are this type.
callback function A callback with the list of transactions

Example

//Promise
client.Account.getTransactions()
	.then(function (response) {
		console.log(response.transactions);
		if(response.hasNextPage) {
			return response.getNextPage();
		}
		else {
			return {transactions: []};
		}
	})
	.then(function(response) {
		console.log(response.transactions);
	});

Example

//Get transactions filtering by date
//Promise
var params = {
	fromDate: "2013-02-21T13:38:00"
};
client.Account.getTransactions(params)
	.then(function (response) {
		console.log(response.transactions);
		if(response.hasNextPage) {
			return response.getNextPage();
		}
		else {
			return {transactions: []};
		}
	})
	.then(function(response) {
		console.log(response.transactions);
	});

Example

//Get transactions filtering by date
//Promise
var params = {
	fromDate: "2013-02-21T13:38:00",
	toDate:   "2013-02-21T13:40:00"
};
client.Account.getTransactions(params)
	.then(function (response) {
		console.log(response.transactions);
		if(response.hasNextPage) {
			return response.getNextPage();
		}
		else {
			return {transactions: []};
		}
	})
	.then(function(response) {
		console.log(response.transactions);
	});

Example

//Get transactions limiting result
//Promise
var params = {
	maxItems: 1
};
client.Account.getTransactions(params)
	.then(function (response) {
		console.log(response.transactions);
		if(response.hasNextPage) {
			return response.getNextPage();
		}
		else {
			return {transactions: []};
		}
	})
	.then(function(response) {
		console.log(response.transactions);
	});

Example

//Get transactions of `payment` type
//Promise
var params = {
	type: "Payment"
};
client.Account.getTransactions(params)
	.then(function (response) {
		console.log(response.transactions);
		if(response.hasNextPage) {
			return response.getNextPage();
		}
		else {
			return {transactions: []};
		}
	})
	.then(function(response) {
		console.log(response.transactions);
	});

AccountResponse : Object

Kind: global class
Properties

Name Type Description
balance String User's account balance in dollars, as a string; the currency symbol is not included.
type String The type of account configured for your user.

TransactionListResponse : Object

Kind: global class
Properties

Name Type Description
transactions Array.<TransactionResponse> Array of transactions
getNextPage function Calls the next page function
hasNextPage boolean True/False flag for next

TransactionResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique identifier for the transaction.
time String The time the transaction was processed.
amount String The transaction amount in dollars, as a string; the currency symbol is not included.
type String The type of transaction.
units String The number of product units the transaction charged or credited.
productType String The product the transaction was related to
number String The phone number the transaction was related to

Application

Kind: global class

new Application(client)

Application

Param Type Description
client Object Catapult client

application.list(params, [callback]) ⇒ ApplicationListResponse

List the user's applications

Kind: instance method of Application
Returns: ApplicationListResponse - A promise for the list of applications, has a getNextPage function if the number of applications returned by the query exceeds the page size.

Param Type Description
params Object Parameters for filtering applications.
[params.size] Number The maximum number of applications returned by the query per page (Max size: 1000).
[callback] function A callback for the list of applications.

Example

//Promise
client.Application.list()
.then(function (response) {
	console.log(response.applications);
	if(response.hasNextPage) {
		return response.getNextPage();
	}
	else {
		return {applications: []};
	}
})
.then(function(response) {
	console.log(response.applications);
});

application.create(params, [callback]) ⇒ ApplicationResponse

Create a new application

Kind: instance method of Application
Returns: ApplicationResponse - A promise for the newly created application.

Param Type Default Description
params Object Parameters for creating a new call
params.name String A name you choose for this application.
params.incomingCallUrl String A URL where call events will be sent for an inbound call. This is the endpoint where the Application Platform will send all call events. Either incomingCallUrl or incomingMessageUrl is required.
[params.incomingCallUrlCallbackTimeout] String Determine how long should the platform wait for incomingCallUrl's response before timing out in milliseconds.
[params.incomingCallFallbackUrl] String The URL used to send the callback event if the request to incomingCallUrl fails.
params.incomingMessageUrl String A URL where message events will be sent for an inbound message. This is the endpoint where the Application Platform will send all message events. Either incomingMessageUrl or incomingCallUrl is required.
[params.incomingMessageUrlCallbackTimeout] Number Determine how long should the platform wait for incomingMessageUrl's response before timing out in milliseconds.
[params.incomingMessageFallbackUrl] String The URL used to send the callback event if the request to incomingMessageUrl fails.
[params.callbackHttpMethod] String Determine if the callback event should be sent via HTTP GET or HTTP POST. Values are "get" or "post", default: "post".
[params.autoAnswer] Boolean true Determines whether or not an incoming call should be automatically answered. Default value is 'true'.
[callback] function A callback for the list of applications

Example

//Promise
client.Application.create({
	name: 'SampleApp',
	incomingCallUrl: 'http://your-server.com/CallCallback',
	incomingMessageUrl: 'http://your-server.com/MsgCallback'
})
.then(function (response) {
	console.log(response);
});

//Callback
client.Application.create({
	name: 'SampleApp2',
	incomingCallUrl: 'http://your-server.com/CallCallback',
	incomingMessageUrl: 'http://your-server.com/MsgCallback'
}, function (err, response) {
	if (err) {
		console.log(err);
	}
	else {
		console.log(response)
	}
});

application.get(applicationId, [callback]) ⇒ ApplicationResponse

Get an application.

Kind: instance method of Application
Returns: ApplicationResponse - A promise for the application.

Param Type Description
applicationId String The ID of the application to get.
[callback] function A callback for the application.

Example

// Promise
client.Application.get('a-j4f2jz53mq')
.then(function (response) {
	console.log(response);
});

// Callback
client.Application.get('a-zuwwfzzrbea',
	function (err, response) {
		if (err) {
			console.log(err);
		}
		else {
			console.log(response);
		}
});

application.update(applicationId, params, [callback])

Make changes to an application.

Kind: instance method of Application

Param Type Description
applicationId String The ID of the application to modify.
params Object Parameters for creating a new call
[params.name] String A name you choose for this application.
[params.incomingCallUrl] String A URL where call events will be sent for an inbound call. This is the endpoint where the Application Platform will send all call events. Either incomingCallUrl or incomingMessageUrl is required.
[params.incomingCallUrlCallbackTimeout] String Determine how long should the platform wait for incomingCallUrl's response before timing out in milliseconds.
[params.incomingCallFallbackUrl] String The URL used to send the callback event if the request to incomingCallUrl fails.
[params.incomingMessageUrl] String A URL where message events will be sent for an inbound message. This is the endpoint where the Application Platform will send all message events. Either incomingMessageUrl or incomingCallUrl is required.
[params.incomingMessageUrlCallbackTimeout] Number Determine how long should the platform wait for incomingMessageUrl's response before timing out in milliseconds.
[params.incomingMessageFallbackUrl] String The URL used to send the callback event if the request to incomingMessageUrl fails.
[params.callbackHttpMethod] String Determine if the callback event should be sent via HTTP GET or HTTP POST. Values are "get" or "post", default: "post".
[params.autoAnswer] Boolean Determines whether or not an incoming call should be automatically answered. Default value is 'true'.
[callback] function A callback for the list of applications

Example

// Promise
client.Application.update('a-j4f2j6vjmqz53mq', {
	name: 'Rename App1',
	autoAnswer: false
})
.then(function (response) {
	console.log(response);
});

// Callback
client.Application.update('a-zudcfzzrbea',
	{
		name: 'Rename App2',
		autoAnswer: false
	},
	function (err, response) {
		if (err) {
			console.log(err);
		}
		else {
			console.log(response);
		}
});

application.delete(applicationId, [callback])

Delete an application.

Kind: instance method of Application

Param Type Description
applicationId String The ID of the application to delete.
[callback] function A callback for the application.

Example

// Promise
client.Application.delete('a-j4f2j6mqz53mq')
.then(function (response) {
	console.log(response);
});

// Callback
client.Application.delete('a-zuwwzrbea',
	function (err, response) {
		if (err) {
			console.log(err);
		}
		else {
			console.log(response);
		}
});

ApplicationListResponse : Object

Kind: global class
Properties

Name Type Description
applications Array.<ApplicationResponse> Array of applications
getNextPage function Calls the next page function
hasNextPage boolean True/False flag for next

ApplicationResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique identifier for the application.
name String A name you choose for this application.
incomingCallUrl String A URL where call events will be sent for an inbound call. This is the endpoint where the Application Platform will send all call events. Either incomingCallUrl or incomingMessageUrl is required.
incomingCallUrlCallbackTimeout String Determine how long should the platform wait for incomingCallUrl's response before timing out in milliseconds.
incomingCallFallbackUrl String The URL used to send the callback event if the request to incomingCallUrl fails.
callbackHttpMethod String Determine if the callback event should be sent via HTTP GET or HTTP POST. Values are "get" or "post", default: "post".
autoAnswer Boolean Determines whether or not an incoming call should be automatically answered. Default value is 'true'.
incomingMessageUrl String A URL where message events will be sent for an inbound message. This is the endpoint where the Application Platform will send all message events. Either incomingMessageUrl or incomingCallUrl is required.
incomingMessageUrlCallbackTimeout Number Determine how long should the platform wait for incomingMessageUrl's response before timing out in milliseconds.
incomingMessageFallbackUrl String The URL used to send the callback event if the request to incomingMessageUrl fails.

new ApplicationResponse()

ApplicationResponse

AvailableNumber

Kind: global class

new AvailableNumber()

Available numbers

availableNumber.search(type, params, callback) ⇒ Array.<AvailableNumberResponse>

Search for available local or tollFree numbers

Kind: instance method of AvailableNumber
Returns: Array.<AvailableNumberResponse> - A promise for the list of available numbers

Param Type Description
type String Type of number to search (local or tollFree)
params Object Search parameters
[params.city] String A city name (only for local numbers)
[params.state] String A state name (only for local numbers)
[params.zip] String A 5-digit US ZIP code (only for local numbers)
[params.areaCode] String A 3-digit telephone area code (only for local numbers)
[params.localNumber] String First digits of a telephone number inside an area code for filtering the results (only for local numbers)
[params.inLocalCallingArea] String Boolean value to indicate that the search for available numbers must consider overlayed areas. Only applied for localNumber searching. (only for local numbers)
[params.quantity] String The maximum number of numbers to return (default 10, maximum 5000)
[params.pattern] String A number pattern that may include letters, digits, and the following wildcard characters: ? - matches any single digit, * - matches zero or more digits
callback function A callback with the list of available numbers

Example

// Search 3 available local phone numbers with area code 910

// Promise
client.AvailableNumber.search("local", { areaCode : "910", quantity : 3 }).then(function (numbers) {});

// Callback
client.AvailableNumber.search("local", { areaCode : "910", quantity : 3 }, function (err, numbers) {});

Example

//Promise
client.AvailableNumber.search("tollFree", {
	quantity : 3 })
.then(function (numbers) {
	console.log(numbers)
});

// Callback
client.AvailableNumber.search("tollFree", {
	quantity : 3 },
	function (err, numbers) {
		if(err) {
			console.log(err);
		}
		else {
			console.log(numbers);
		}
	});

availableNumber.searchAndOrder(type, params, callback) ⇒ Array.<OrderedNumberResponse>

Search for available local or tollFree numbers and order them

Kind: instance method of AvailableNumber
Returns: Array.<OrderedNumberResponse> - A promise for the list of ordered numbers

Param Type Description
type String Type of number to search (local or tollFree)
params Object Search parameters
[params.city] String A city name (only for local numbers)
[params.state] String A state name (only for local numbers)
[params.zip] String A 5-digit US ZIP code (only for local numbers)
[params.areaCode] String A 3-digit telephone area code (only for local numbers)
[params.localNumber] String First digits of a telephone number inside an area code for filtering the results (only for local numbers)
[params.pattern] String A number pattern that may include letters, digits, and the following wildcard characters: ? - matches any single digit, * - matches zero or more digits
[params.inLocalCallingArea] String Boolean value to indicate that the search for available numbers must consider overlayed areas. Only applied for localNumber searching. (only for local numbers)
[params.quantity] String The maximum number of numbers to return (default 10, maximum 5000)
callback function A callback with the list of ordered numbers

Example

// Search 2 available local phone numbers with area code 910 and order them

// Promise
client.AvailableNumber.searchAndOrder("local", { areaCode : "910", quantity : 2 }).then(function (numbers) {});

// Callback
client.AvailableNumber.serchAndOrder("local", { areaCode : "910", quantity : 2 }, function (err, numbers) {});

Example

//Search and order tollfree numbers
//Promise
client.AvailableNumber.searchAndOrder("tollFree", {
	quantity : 1 })
.then(function (numbers) {
	console.log(numbers)
});

// Callback
client.AvailableNumber.searchAndOrder("tollFree", {
	quantity : 1 },
	function (err, numbers) {
		if(err) {
			console.log(err);
		}
		else {
			console.log(numbers);
		}
	});

AvailableNumberResponse : Object

Kind: global class
Properties

Name Type Description
number String Phone number.
nationalNumber String Phone number in national format.
price String Price of this phone number.
city String A city name of number (only for local numbers).
rateCenter String A rate center (only for local numbers).
state String A state of number (only for local numbers).

OrderedNumberResponse : Object

Kind: global class
Properties

Name Type Description
id String Id of ordered number.
number String Phone number.
nationalNumber String Phone number in national format.
price String Price of this phone number.

Bridge

Kind: global class

new Bridge()

Bridge

bridge.create(params, [callback]) ⇒ BridgeResponse

Create a new bridge

Kind: instance method of Bridge
Returns: BridgeResponse - A promise for the newly created bridge

Param Type Default Description
params Object Parameters for creating a bridge
[params.bridgeAudio] Boolean true Enable/Disable two way audio path.
[params.callIds] Array.<String> The list of call ids in the bridge. If the list of call ids is not provided the bridge is logically created and it can be used to place calls later.
[callback] function Callback with the newly created bridge

Example

//Promise
client.Bridge.create({
	bridgeAudio: true,
	callIds: ['c-qbs5kwrsyx6wsdi', 'c-zan4g74pprsq']
})
.then(function (response) {
	console.log(response);
});

//Callback
client.Bridge.create({
	bridgeAudio: true,
	callIds: ['c-qbsx6wsdi', 'c-zan4g7prsq']
}, function (err, response) {
		if(err) {
			console.log(err);
		}
		else {
			console.log(response);
		}
	});

bridge.get(bridgeId, callback) ⇒ BridgeResponse

Gets information about a bridge.

Kind: instance method of Bridge
Returns: BridgeResponse - A promise for the call information

Param Type Description
bridgeId String The ID of the bridge to get
callback function A callback with the call information

Example

//Promise
client.Bridge.get('brg-65dhjwrmbasiei')
.then(function (response) {
	console.log(response);
});

//Callback
client.Bridge.get('brg-65dhmbasiei',
	function (err, response) {
		if(err) {
			console.log(err);
		}
		else {
			console.log(response);
		}
	});

bridge.list(params, callback) ⇒ BridgeListResponse

Gets a list of bridges.

Kind: instance method of Bridge
Returns: BridgeListResponse - A promise for the list of bridges

Param Type Default Description
params Object Query parameters for listing bridges
[params.size] Number 25 Used for pagination to indicate the size of each page requested for querying a list of bridges. If no value is specified the default value is 25 (maximum value 1000).
callback function A callback with the list of bridges

Example

client.Bridge.list()
.then(function (response) {
	console.log(response.bridges);
	if(response.hasNextPage) {
		return response.getNextPage();
	}
	else {
		return {bridges: []};
	}
})
.then(function(response) {
	console.log(response.bridges);
});

bridge.update(bridgeId, params, [callback]) ⇒ BridgeResponse

Update the bridge

Kind: instance method of Bridge
Returns: BridgeResponse - A promise for the operation

Param Type Description
bridgeId String The ID of the bridge
params Object Changed parameters of the bridge
params.bridgeAudio Boolean Enable/Disable two way audio path (default = true).
params.callIds Array.<String> The list of call ids in the bridge.
[callback] function Callback with the newly created bridge

Example

//Promise
client.Bridge.update('brg-65dasiei', {
	bridgeAudio: false
})
.then(function (response) {
	console.log(response);
});

//Callback
client.Bridge.update('brg-65dhjbanasiei', {
	bridgeAudio: false
}, function (err, response) {
		if(err) {
			console.log(err);
		}
		else {
			console.log(response);
		}
	});

Example

// end bridge
var bridgeOptions = {
	callIds: []
};

client.Bridge.update("{bridgeId}", bridgeOptions)
.then(function () {
	// continue
});

Example

// Add two calls to bridge then remove one
var bridgeOptions = {
	bridgeAudio : true,
	callIds: ["{callId1}","{callId2}"]
};

client.Bridge.update("{bridgeId}", bridgeOptions)
.then(function () {
	var callIdsToRemainInBridge = {
		callIds: ["{callId1"]
	};
	return client.Bridge.update("{bridgeId}", callIdsToRemainInBridge)
})
.then(function () {
	//continue
});

bridge.speakSentence(bridgeId, sentence, [callback]) ⇒ Promise

Speak sentence to the bridge using default values

Kind: instance method of Bridge
Returns: Promise - A promise for the operation

Param Type Description
bridgeId String The ID of the bridge
sentence String A sentence to speak to the bridge.
[callback] function Callback for the operation

Example

//Speak sentence in a bridge

//Promise
client.Bridge.speakSentence("bridgeID", "Hello From Bandwidth").then(function (res) {});

//Callback
client.Bridge.speakSentence("bridgeID", "Hello From Bandwidth", function (err, res) {});

bridge.stopSpeaking(bridgeId) ⇒ Promise

This stops any file audio playback on the bridge

Kind: instance method of Bridge
Returns: Promise - A promise of the operation

Param Type Description
bridgeId String the Id of the bridge to stop speaking

Example

//Promise
client.Bridge.stopSpeaking("bridgeId").then(function (res) {});

bridge.playAudioFile(bridgeId, fileUrl, [callback]) ⇒ Promise

Play audio url to the bridge

Kind: instance method of Bridge
Returns: Promise - A promise for the operation

Param Type Description
bridgeId String The ID of the bridge
fileUrl String The http location of an audio file to play (WAV and MP3 supported).
[callback] function Callback for the operation

Example

//Play Audio file on bridge

//Promise
client.Bridge.playAudioFile("bridgeID", "http://myurl.com/file.mp3").then(function (res) {});

//Callback
client.Bridge.playAudioFile("bridgeID", "http://myurl.com/file.wav", function (err, res) {});

bridge.playAudioAdvanced(bridgeId, params, [callback]) ⇒ Promise

Play audio file or speak sentence in bridge

Kind: instance method of Bridge
Returns: Promise - A promise for the operation

Param Type Default Description
bridgeId String The ID of the bridge
params Object Parameters to play audio in bridge.
[params.fileUrl] String The http location of an audio file to play (WAV and MP3 supported).
[params.sentence] String The sentence to speak.
[params.gender] String female The gender of the voice used to synthesize the sentence. It will be considered only if sentence is not null. The female gender will be used by default.
[params.locale] String en_US The locale used to get the accent of the voice used to synthesize the sentence. Check out docs for list of supported locales. It will be considered only if sentence is not null/empty. The en_US will be used by default.
[params.voice] String Susan The voice to speak the sentence. Check out docs for list of supported voices It will be considered only if sentence is not null/empty. Susan's voice will be used by default.
[params.loopEnabled] Boolean false When value is true, the audio will keep playing in a loop. Default: false.
[callback] function Callback for the operation

Example

//Play Audio File on loop
var options = {
	fileUrl     : "http://myurl.com/file.mp3",
	loopEnabled : true
}
//Promise
client.Bridge.playAudioAdvanced("bridgeId", options).then(function (res) {});

//Callback
client.Bridge.playAudioAdvanced("bridgeId", options, function (err,res) {});

Example

//Speak sentence with options
var options = {
	sentence : "hola de Bandwidth",
	gender   : "male",
	locale   : "es",
	voice    : "Jorge"
}
//Promise
client.Bridge.playAudioAdvanced("bridgeId", options).then(function (res) {});

//Callback
client.Bridge.playAudioAdvanced("bridgeId", options, function (err,res) {});

bridge.stopAudioFilePlayback(bridgeId) ⇒ Promise

This stops any file audio playback on the bridge

Kind: instance method of Bridge
Returns: Promise - A promise of the operation

Param Type Description
bridgeId String the Id of the bridge to stop file playback

Example

//Promise
client.Bridge.stopAudioFilePlayback("bridgeId").then(function (res) {});

bridge.getCalls(bridgeId, callback) ⇒ Promise

Gets information about a bridge.

Kind: instance method of Bridge
Returns: Promise - A promise for the call information

Param Type Description
bridgeId String The ID of the bridge to get
callback function A callback with the call information

Example

//Promise
client.Bridge.getCalls('brg-65dhjbiei')
.then(function (response) {
	console.log(response);
});

//Callback
client.Bridge.getCalls('brg-65dhjrmbasiei',
	function (err, response) {
		if(err) {
			console.log(err);
		}
		else {
			console.log(response);
		}
	});

BridgeListResponse : Object

Kind: global class
Properties

Name Type Description
bridges Array.<BridgeResponse> Array of bridges
getNextPage function Calls the next page function
hasNextPage boolean True/False flag for next

BridgeResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the bridge.
state String Bridge state. Possible state values are described here.
callIds Array.<String> List of call Ids that will be in the bridge.
bridgeAudio Boolean Enable/Disable two way audio path.
completedTime String The time when the bridge was completed.
createdTime String The time that bridge was created.
activatedTime String The time that the bridge got into active state.

Call

Kind: global class

new Call()

Voice call

call.create(params, [callback]) ⇒ CallResponse

Create a new voice call

Kind: instance method of Call
Returns: CallResponse - A promise for the newly created call

Param Type Description
params Object Parameters for creating a new call
params.from String A Bandwidth phone number on your account the call should come from (must be in E.164 format, like +19195551212).
params.to String The number to call (must be either an E.164 formated number, like +19195551212, or a valid SIP URI, like sip:someone@somewhere.com).
[params.callTimeout] Number Determine how long should the platform wait for] call answer before timing out in seconds.
[params.callbackUrl] String The full server URL where the call events related to the Call will be sent to.
[params.callbackTimeout] Number Determine how long should the platform wait for callbackUrl's response before timing out in milliseconds.
[params.callbackHttpMethod] String Determine if the callback event should be sent via HTTP GET or HTTP POST. Values are "GET" or "POST" (if not set the default is POST).
[params.fallbackUrl] String The full server URL used to send the callback event if the request to callbackUrl fails.
[params.bridgeId] String The id of the bridge where the call will be added.
[params.conferenceId] String Id of the conference where the call will be added. This property is required if you want to add this call to a conference.
[params.recordingEnabled] String Indicates if the call should be recorded after being created. Set to "true" to enable. Default is "false".
[params.recordingMaxDuration] String Indicates the maximum duration of call recording in seconds. Default value is 1 hour.
[params.transcriptionEnabled] String Whether all the recordings for this call is going to be automatically transcribed.
[params.tag] String A string that will be included in the callback events of the call.
[params.sipHeaders] Object Map of Sip headers prefixed by "X-". Up to 5 headers can be sent per call.
[callback] function Callback with the newly created call

call.get(callId, callback) ⇒ Promise

Gets information about an active or completed call.

Kind: instance method of Call
Returns: Promise - A promise for the call information

Param Type Description
callId String The ID of the call to get
callback function A callback with the call information

call.list(params, callback) ⇒ Promise

Gets a list of active and historic calls you made or received.

Kind: instance method of Call
Returns: Promise - A promise for the list of calls

Param Type Default Description
params Object Query parameters for listing calls
[params.bridgeId] String The id of the bridge for querying a list of calls history (pagination does not apply).
[params.conferenceId] String The id of the conference for querying a list of calls history
[params.from] String The number to filter calls that came from (must be either an E.164 formated number,like +19195551212, or a valid SIP URI, like sip:someone@somewhere.com).
[params.to] String The number to filter calls that was called to (must be either an E.164 formated number,like +19195551212, or a valid SIP URI, like sip:someone@somewhere.com).
[params.page] Number 0 Used for pagination to indicate the page requested for querying a list of calls. If no value is specified the default is 0.
[params.size] Number 25 Used for pagination to indicate the size of each page requested for querying a list of calls. If no value is specified the default value is 25 (maximum value 1000).
callback function A callback with the list of calls

call.update(callId, params, [callback]) ⇒ Promise

Update properties of an active phone call.

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the incoming call
params Object The propreties to update
[params.state] string The call state. Possible values: rejected to reject not answer, active to answer the call, completed to hangup the call, transferring to start and connect call to a new outbound call.
[params.recordingEnabled] string Indicates if the call should be recorded. Values true or false. You can turn recording on/off and have multiple recordings on a single call.
[params.recordingFileFormat] string The file format of the recorded call. Supported values are wav (default) and mp3.
[params.transferTo] string Phone number or SIP address that the call is going to be transferred to.
[params.transferCallerId] string This is the caller id that will be used when the call is transferred. This parameter is only considered in transfer state.
- transferring an incoming call: Allowed values are 1) "private" 2) the incoming call "from" number or 3) any Bandwidth number owned by user.
- transferring an outgoing call call: allowed values are 1) "private" or 2) any Bandwidth phone number owned by user.
[params.whisperAudio] string Audio to be played to the caller that the call will be transferred to.
[params.callbackUrl] string The server URL where the call events for the new call will be sent.
[callback] function Callback for the operation

Example

//Start recording a mp3 and update the callback url
var payLoad = {
	recordingEnabled: "true",
	recordingFileFormat = "mp3",
	callbackUrl: "http://yourUrl.com/callbacks/callrecording"
};

client.call.update("callId", payload)
.then(function () {
	// keep on keeping on here;
});

call.answer(callId, [callback]) ⇒ Promise

Answer an incoming call

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the incoming call
[callback] function Callback for the operation

Example

//Promise
client.Call.answer("callID").then(function () {});

//Callback
client.Call.answer("callID", function (err) {});

call.reject(callId, [callback]) ⇒ Promise

Reject an incoming call

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the incoming call
[callback] function Callback for the operation

Example

//Promise
client.Call.reject("callID").then(function () {});

//Callback
client.Call.reject("callID", function (err) {});

call.hangup(callId, [callback]) ⇒ Promise

Complete active call

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the call
[callback] function Callback for the operation

Example

//Promise
client.Call.hangup("callID").then(function () {});

//Callback
client.Call.hangup("callID", function (err) {});

call.transfer(params, [callback]) ⇒ CallResponse

Transfer a call

Kind: instance method of Call
Returns: CallResponse - A promise for the transfered call

Param Type Default Description
params Object Parameters for transfering of the call
params.transferTo String Phone number or SIP address that the call is going to be transferred to.
[params.transferCallerId] String The caller id that will be used when the call is transferred see the docs for supported options.
[params.whisperAudio] Object Audio to be played to the caller that the call will be transferred to. Uses the same parameters as call.playAudioAdvanced. See the docs.
[params.whisperAudio.gender] String female The gender of the voice used to synthesize the sentence
[params.whisperAudio.voice] String Susan The voice to speak the sentence
[params.whisperAudio.locale] String en_US The locale used to get the accent of the voice used to synthesize the sentence.
[params.whisperAudio.fileUrl] String The location of an audio file to play WAV and MP3 supported
[params.whisperAudio.loopEnabled] Boolean false Loop media
[callback] function Callback with the transfered call

Example

//Transfer call
var speakSentence = {
	transferTo       : "+15555555555",
	transferCallerId : "private",
	whisperAudio     : {
		sentence : "You have an incoming call",
		gender   : "female",
		voice    : "julie",
		locale   : "en"
	}
};

//Using Promises
client.Call.transfer("callId", speakSentence).then(function (res) {});

var playAudio = {
	fileUrl     : "http://mysite.com/file.wav",
	loopEnabled : true
}
//Using callbacks
client.Call.transfer("callId", playAudio, function (err, res) {});

Example

//Example: Transfer a call using the caller Id of the party being transferred
var transferPayload = {
	transferTo       : "+18382947878",
};

//Using Promises
client.Call.transfer("callId", transferPayload).then(function (res) {});

call.speakSentence(callId, sentence, [callback]) ⇒ Promise

Speak sentence to the call using default values

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the call
sentence String A sentence to speak to the call.
[callback] function Callback for the operation

Example

//Speak sentence in a call

//Promise
client.Call.speakSentence("callID", "Hello From Bandwidth").then(function (res) {});

//Callback
client.Call.speakSentence("callID", "Hello From Bandwidth", function (err, res) {});

call.stopSpeaking(callId) ⇒ Promise

This stops any speak sentence audio playback on the call

Kind: instance method of Call
Returns: Promise - A promise for the call information

Param Type Description
callId String The ID of the call to stop file playback

Example

//Stop Audio file on call
client.Call.stopSpeaking("callId").then(function (res) {});

call.playAudioFile(callId, fileUrl, [callback]) ⇒ Promise

Play audio url to the call

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the call
fileUrl String The http location of an audio file to play (WAV and MP3 supported).
[callback] function Callback for the operation

Example

//Play Audio file on call

//Promise
client.Call.playAudioFile("callId", "http://myurl.com/file.mp3").then(function (res) {});

//Callback
client.Call.playAudioFile("callId", "http://myurl.com/file.wav", function (err, res) {});

call.stopAudioFilePlayback(callId) ⇒ Promise

This stops any stop file audio playback on the call

Kind: instance method of Call
Returns: Promise - A promise for the call information

Param Type Description
callId String The ID of the call to stop file playback

Example

//Stop Audio file on call
client.Call.stopAudioFilePlayback("callId").then(function (res) {});

call.playAudioAdvanced(callId, params, [callback]) ⇒ Promise

Play audio file or speak sentence in call

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Default Description
callId String The ID of the call
params Object Parameters to play audio in call.
[params.fileUrl] String The http location of an audio file to play (WAV and MP3 supported).
[params.sentence] String The sentence to speak.
[params.gender] String female The gender of the voice used to synthesize the sentence. It will be considered only if sentence is not null. The female gender will be used by default.
[params.locale] String en_US The locale used to get the accent of the voice used to synthesize the sentence. Check out docs for list of supported locales. It will be considered only if sentence is not null/empty. The en_US will be used by default.
[params.voice] String Susan The voice to speak the sentence. Check out docs for list of supported voices It will be considered only if sentence is not null/empty. Susan's voice will be used by default.
[params.loopEnabled] Boolean false When value is true, the audio will keep playing in a loop. Default: false.
[callback] function Callback for the operation

Example

//Play Audio File on loop
var options = {
	fileUrl     : "http://myurl.com/file.mp3",
	loopEnabled : true
}
//Promise
client.Call.playAudioAdvanced("callId", options).then(function (res) {});

//Callback
client.Call.playAudioAdvanced("callId", options, function (err,res) {});

Example

//Speak sentence with options
var options = {
	sentence : "hola de Bandwidth",
	gender   : "male",
	locale   : "es",
	voice    : "Jorge"
}
//Promise
client.Call.playAudioAdvanced("callId", options).then(function (res) {});

//Callback
client.Call.playAudioAdvanced("callId", options, function (err,res) {});

call.enableRecording(callId, [callback]) ⇒ Promise

Turns on call recording for the active call

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the call
[callback] function Callback for the operation

Example

//Turn on recording

//Promise
client.Call.enableRecording("callId").then(function (res) {});

//Callback
client.Call.enableRecording("callId", function (err, res) {});

call.disableRecording(callId, [callback]) ⇒ Promise

Turns off call recording for the active call

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the call
[callback] function Callback for the operation

Example

//Turn off recording

//Promise
client.Call.disableRecording("callId").then(function (res) {});

//Callback
client.Call.disableRecording("callId", function (err, res) {});

call.createGather(callId, params, [callback]) ⇒ CallResponse

Collects a series of DTMF digits from a phone call with an optional prompt.

Kind: instance method of Call
Returns: CallResponse - A promise for the newly created call

Param Type Default Description
callId String The ID of the call
params Object Parameters for creating a gather
[params.maxDigits] String The maximum number of digits to collect (max: 30)
[params.interDigitTimeout] String 5 Stop gathering if a DTMF digit is not detected in this many seconds (max: 30s)
[params.terminatingDigits] String # A string of DTMF digits that end the gather operation immediately if any one of them is detected
[params.tag] String A string you choose that will be included with the response and events for this gather operation.
[params.prompt.sentence] String The text to speak for the prompt. Uses the same defaults as call.playAudioAdvanced. See the docs
[params.prompt.gender] String The gender to use for the voice reading the prompt sentence
[params.prompt.locale] String The language and region to use for the voice reading the prompt sentence
[params.prompt.loopEnabled] Boolean false When value is true, the audio will keep playing in a loop
[params.prompt.bargeable] Boolean true Make the prompt (audio or sentence) bargeable (will be interrupted at first digit gathered).
[params.prompt.fileUrl] Strings Make the prompt (audio or sentence) bargeable (will be interrupted at first digit gathered).
[callback] function Callback with the newly created call

Example

//Create Gather
//The gather ends if either 0, #, or * is detected
var options = {
	maxDigits         : 30,
	interDigitTimeout : "30",
	terminatingDigits : "0#*",
	prompt            : {
		sentence    : "Please enter your account number and press pound",
		gender      : "male",
		voice       : "Simon",
		locale      : "en_UK",
		loopEnabled : true,
		bargeable   : true
	}
};
//Promise
client.Call.createGather("callId", options).then(function(res) {});

//Callback
client.Call.createGather("callId", options, function(err, res) {});

call.getGather(callId, gatherId, [callback]) ⇒ GatherResponse

Get the gather DTMF parameters and results.

Kind: instance method of Call
Returns: GatherResponse - A promise for the gather

Param Type Description
callId String The ID of the call
gatherId String The ID of the gather
[callback] function Callback with the gather

call.completeGather(callId, gatherId, [callback]) ⇒ Promise

Complete the gather.

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the call
gatherId String The ID of the gather
[callback] function Callback of the operation

call.getEvents(callId, [callback]) ⇒ Array.<EventResponse>

Get events for the call.

Kind: instance method of Call
Returns: Array.<EventResponse> - A promise for the event list

Param Type Description
callId String The ID of the call
[callback] function Callback with the event list

Example

// Promise
client.Call.getEvents(callId).then(function (events) {});
// Callback
client.Call.getEvents(callId, function (err, events) {});

call.getEvent(callId, eventId, [callback]) ⇒ EventResponse

Get a single event for the call.

Kind: instance method of Call
Returns: EventResponse - A promise for the event list

Param Type Description
callId String The ID of the call
eventId String The ID of the event to get
[callback] function Callback with the event list

Example

// Promise
client.Call.getEvent(callId, evenId).then(function (callEvent) {});
// Callback
client.Call.getEvent(callId, eventId, function (err, callEvent) {});

call.getRecordings(callId, [callback]) ⇒ Array.<RecordingResponse>

Get recordings for the call.

Kind: instance method of Call
Returns: Array.<RecordingResponse> - A promise for the recording list

Param Type Description
callId String The ID of the call
[callback] function Callback with the recording list

Example

// Promise
client.Call.getRecordings(callId).then(function (list) {});
// Callback
client.Call.getRecordings(callId, function (err, list) {});

call.getTranscriptions(callId, [callback]) ⇒ Array.<TranscriptionResponse>

Get transcriptions for the call.

Kind: instance method of Call
Returns: Array.<TranscriptionResponse> - A promise for the transcription list

Param Type Description
callId String The ID of the call
[callback] function Callback with the transcription list

Example

// Promise
client.Call.getTranscriptions(callId).then(function (list) {});
// Callback
client.Call.getTranscriptions(callId, function (err, list) {});

call.sendDtmf(callId, dtmfOut, [callback]) ⇒ Promise

Send DTMF (phone keypad digit presses).

Kind: instance method of Call
Returns: Promise - A promise for the operation

Param Type Description
callId String The ID of the call
dtmfOut String String containing the DTMF characters to be sent in a call.
[callback] function Callback for the operation

Example

// Promise
client.Call.sendDtmf(callId, "1").then(function () {});
// Callback
client.Call.sendDtmf(callId, "1", function (err) {});

CallResponse : Object

Kind: global class
Properties

Name Type Default Description
id String The unique ID of the call.
direction String Call direction: values are 'in' for an incoming call, 'out' for an outgoing call
from String The phone number or SIP address that made the call. Phone numbers are in E.164 format (e.g. +15555555555) -or- SIP addresses (e.g. identify@domain.com).
to String The phone number or SIP address that received the call. Phone numbers are in E.164 format (e.g. +15555555555) -or- SIP addresses (e.g. identify@domain.com).
state String The call state. Described below, values are 'started' 'rejected' 'active' 'completed' 'transferring'
startTime String Date when the call was created. Timestamp follows the ISO8601 format.
activeTime String Date when the call was answered. Timestamp follows the ISO8601 format.
endTime String Date when the call ended. Timestamp follows the ISO8601 format.
callTimeout Number Determine how long should the platform wait for call answer before timing out in seconds
callbackUrl String The server URL where the call events related to the call will be sent.
callbackHttpMethod String Determine if the callback event should be sent via HTTP GET or HTTP POST. Values are 'get' or 'post' Default is 'post'
callbackTimeout Number Determine how long should the platform wait for callbackUrl's response before timing out (milliseconds).
fallbackUrl String The server URL used to send the call events if the request to callbackUrl fails.
chargeableDuration Number The number of seconds the call will be billed for.
transferTo String Phone number or SIP address that the call is going to be transferred to.
transferCallerId String This is the caller id that will be used when the call is transferred. This parameter is only considered in transfer state.
whisperAudio String Audio to be played to the caller that the call will be transferred to.
bridgeId String The id of the bridge where the call will be added.
bridge String The URL of the bridge, if any, that contains the call.
conferenceId String The id of the conference where the call will be added. This property is required if you want to add this call to a conference.
conference String The complete URL of the conference resource the call is associated with.
events String The URL to retrieve the events related to the call.
recordingEnabled String false Indicates if the call should be recorded after being created. Set to 'true' to enable. Default is 'false'
recordingFileFormat String wav The file format of the recorded call. Supported values are 'wav' (default) and 'mp3'.
recordingMaxDuration Number 3600 Indicates the maximum duration of call recording in seconds. Default value is 1 hour.
transcriptionEnabled Boolean Whether all the recordings for this call should be be automatically transcribed. tag Any string, it will be included in the callback events of the call.
page Number 0 Used for pagination to indicate the page requested for querying a list of calls. If no value is specified the default is 0.
size Number 25 Used for pagination to indicate the size of each page requested for querying a list of calls. If no value is specified the default value is 25 (maximum value 1000).
sipHeaders Object Map of Sip headers prefixed by "X-". Up to 5 headers can be sent per call. Max length for header and value is 256 characters.

GatherResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the gather.
state String The state of the gather.
reason String The reason of completing of the gather.
createdTime String Time of creation of the gather.
completedTime String TIme of completion of the gather.
digits String Gathered digits.

EventResponse : Object

Kind: global class
Properties

Name Type Description
id String The call event id.
time String The time the event occurred.
name String The name of the event.
data String Data about event.

RecordingResponse : Object

Kind: global class
Properties

Name Type Description
id String The recording id.
startTime String Date/time when the recording started.
endTime String Date/time when the recording ended.
call String The complete URL to the call resource this recording is associated with.
media String The complete URL to the media resource this recording is associated with.
state String The state of the recording

TranscriptionResponse : Object

Kind: global class
Properties

Name Type Description
id String The transcription id.
state String The state of the transcription
text String The transcribed text (only first 1000 characters)
time String The date/time the transcription resource was created
chargeableDuration Number The seconds between activeTime and endTime for the recording; this is the time that is going to be used to charge the resource.
textSize Number The size of the transcribed text.
textUrl String An url to the full text

Conference

Kind: global class

new Conference()

Conference

conference.create(params, [callback]) ⇒ ConferenceResponse

Create a new conference

Kind: instance method of Conference
Returns: ConferenceResponse - A promise for the newly created conference

Param Type Default Description
params Object Parameters for creating a conference
params.from String The phone number that will host the conference.
[params.callbackUrl] String The complete URL where the events related to the Conference will be sent to.
[params.callbackHttpMethod] String post Determine if the callback event should be sent via HTTP GET or HTTP POST.
[params.callbackTimeout] String Determine how long should the platform wait for callbackUrl's response before timing out in milliseconds.
[params.fallbackUrl] String Determine how long should the platform wait for callbackUrl's response before timing out in milliseconds.
[params.profile] String Determines how DTMF is used. Values are: interpret_digits: the conference will handle DTMF with the default behavior, or passthru_digits: allows the application to receive DTMF events and use the gather API.
[params.tag] String A string that will be included in the callback events of the conference.
[callback] function Callback with the newly created conference

Example

// Promise
client.Conference.create({from: "+1234567890"}).then(function(conference){});
// Callback
client.Conference.create({from: "+1234567890"}, function(err, conference){});

conference.get(conferenceId, [callback]) ⇒ ConferenceResponse

Gets information about a conference.

Kind: instance method of Conference
Returns: ConferenceResponse - A promise for the conference information

Param Type Description
conferenceId String The ID of the conference to get
[callback] function A callback with the conference information

Example

// Promise
client.Conference.get("conferenceId").then(function(conference){});
// Callback
client.Conference.get("conferenceId", function(err, conference){});

conference.update(conferenceId, params, [callback]) ⇒ Promise

Update the conference

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Default Description
conferenceId String The ID of the conference
params Object Changed parameters of the conference
[params.state] String Conference state. Possible state values are: "completed" to terminate the conference.
[params.hold] String If "true", all member can't hear or speak in the conference. If "false", all members can hear and speak in the conference (unless set at the member level).
[params.mute] String If "true", all member can't speak in the conference. If "false", all members can speak in the conference (unless set at the member level).
[params.callbackUrl] String The complete URL where the events related to the Conference will be sent to.
[params.callbackHttpMethod] String post Determine if the callback event should be sent via HTTP GET or HTTP POST.
[params.callbackTimeout] String Determine how long should the platform wait for callbackUrl's response before timing out in milliseconds.
[params.fallbackUrl] String Determine how long should the platform wait for callbackUrl's response before timing out in milliseconds.
[params.tag] String A string that will be included in the callback events of the conference.
[callback] function Callback for the operation

Example

// Promise
client.Conference.update("conferenceID", {mute: "true"}).then(function(){});
// Callback
client.Conference.update("conferenceID", {mute: "true"}, function(err){});

conference.remove(conferenceId, [callback]) ⇒ Promise

Remove the conference

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Description
conferenceId String The ID of the conference
[callback] function Callback for the operation

Example

// Promise
client.Conference.remove("conferenceID").then(function(){});
// Callback
client.Conference.remove("conferenceID", function(err){});

conference.speakSentence(conferenceId, sentence, [callback]) ⇒ Promise

Speak sentence to the conference using default values

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Description
conferenceId String The ID of the conference
sentence String A sentence to speak to the conference.
[callback] function Callback for the operation

Example

//Speak sentence in a conference

//Promise
client.Conference.speakSentence("conferenceID", "Hello From Bandwidth").then(function (res) {});

//Callback
client.Conference.speakSentence("conferenceID", "Hello From Bandwidth", function (err, res) {});

conference.stopSpeaking(conferenceId) ⇒ Promise

This stops any file audio playback on the conference

Kind: instance method of Conference
Returns: Promise - A promise of the operation

Param Type Description
conferenceId String the Id of the conference to stop speaking

Example

//Promise
client.Conference.stopSpeaking("conferenceId").then(function (res) {});

conference.playAudioFile(conferenceId, fileUrl, [callback]) ⇒ Promise

Play audio url to the conference

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Description
conferenceId String The ID of the conference
fileUrl String The http location of an audio file to play (WAV and MP3 supported).
[callback] function Callback for the operation

Example

//Play Audio file on conference

//Promise
client.Conference.playAudioFile("conferenceID", "http://myurl.com/file.mp3").then(function (res) {});

//Callback
client.Conference.playAudioFile("conferenceID", "http://myurl.com/file.wav", function (err, res) {});

conference.playAudioAdvanced(conferenceId, params, [callback]) ⇒ Promise

Play audio file or speak sentence in conference

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Default Description
conferenceId String The ID of the conference
params Object Parameters to play audio in conference.
[params.fileUrl] String The http location of an audio file to play (WAV and MP3 supported).
[params.sentence] String The sentence to speak.
[params.gender] String female The gender of the voice used to synthesize the sentence. It will be considered only if sentence is not null. The female gender will be used by default.
[params.locale] String en_US The locale used to get the accent of the voice used to synthesize the sentence. It will be considered only if sentence is not null/empty. The en_US will be used by default.
[params.voice] String Susan The voice to speak the sentence. for list of supported voices It will be considered only if sentence is not null/empty. Susan's voice will be used by default.
[params.loopEnabled] Boolean false When value is true, the audio will keep playing in a loop. Default: false.
[callback] function Callback for the operation

Example

//Play Audio File on loop
var options = {
	fileUrl     : "http://myurl.com/file.mp3",
	loopEnabled : true
}
//Promise
client.Conference.playAudioAdvanced("conferenceId", options).then(function (res) {});

//Callback
client.Conference.playAudioAdvanced("conferenceId", options, function (err,res) {});

Example

//Speak sentence with options
var options = {
	sentence : "hola de Bandwidth",
	gender   : "male",
	locale   : "es",
	voice    : "Jorge"
}
//Promise
client.Conference.playAudioAdvanced("conferenceId", options).then(function (res) {});

//Callback
client.Conference.playAudioAdvanced("conferenceId", options, function (err,res) {});

conference.stopAudioFilePlayback(conferenceId) ⇒ Promise

This stops any file audio playback on the conference

Kind: instance method of Conference
Returns: Promise - A promise of the operation

Param Type Description
conferenceId String the Id of the conference to stop file playback

Example

//Promise
client.Conference.stopAudioFilePlayback("conferenceId").then(function (res) {});

conference.getMembers(conferenceId, callback) ⇒ Promise

Gets information about a conference members.

Kind: instance method of Conference
Returns: Promise - A promise for member list

Param Type Description
conferenceId String The ID of the conference to get memebers
callback function A callback with member list

Example

// Promise
client.Conference.getMembers("conferenceId").then(function(members){});
// Callback
client.Conference.getMembers("conferenceId", function(err, members){});

conference.getMember(conferenceId, memberId, callback) ⇒ Promise

Gets information about a single conference member.

Kind: instance method of Conference
Returns: Promise - A promise for the member

Param Type Description
conferenceId String The ID of the conference
memberId String The ID of the member
callback function A callback with the member

Example

// Promise
client.Conference.getMember("conferenceId", "memberId").then(function(member){});
// Callback
client.Conference.getMember("conferenceId", "memberId", function(err, member){});

conference.createMember(params, [callback]) ⇒ ConferenceResponse

Add members to a conference.

Kind: instance method of Conference
Returns: ConferenceResponse - A promise for the added member

Param Type Description
params Object Parameters for new member
params.callId String The callId must refer to an active call that was created using this conferenceId.
[params.joinTone] String If "true", will play a tone when the member joins the conference. If "false", no tone is played when the member joins the conference.
[params.leavingTone] String If "true", will play a tone when the member leaves the conference. If "false", no tone is played when the member leaves the conference.
[params.mute] String If "true", member can't speak in the conference. If "false", this members can speak in the conference (unless set at the conference level).
[params.hold] String If "true", member can't hear or speak in the conference. If "false", member can hear and speak in the conference (unless set at the conference level).
[callback] function Callback with the added member

Example

// Promise
client.Conference.createMember("conferenceId", {callId: "callID"}).then(function(member){});
// Callback
client.Conference.createMember("conferenceId", {callId: "callID"}, function(err, member){});

conference.updateMember(conferenceId, memberId, params, [callback]) ⇒ Promise

Update the conference member

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Description
conferenceId String The ID of the conference
memberId String The ID of the member
params Object Changed parameters of the member
[params.joinTone] String If "true", will play a tone when the member joins the conference. If "false", no tone is played when the member joins the conference.
[params.leavingTone] String If "true", will play a tone when the member leaves the conference. If "false", no tone is played when the member leaves the conference.
[params.mute] String If "true", member can't speak in the conference. If "false", this members can speak in the conference (unless set at the conference level).
[params.hold] String If "true", member can't hear or speak in the conference. If "false", member can hear and speak in the conference (unless set at the conference level).
[callback] function Callback for the operation

Example

// Promise
client.Conference.updateMember("conferenceID", "memberId", {mute: "true"}).then(function(){});
// Callback
client.Conference.updateMember("conferenceID", "memberId", {mute: "true"}, function(err){});

conference.removeMember(conferenceId, memberId, [callback]) ⇒ Promise

Remove the conference member

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Description
conferenceId String The ID of the conference
memberId String The ID of the member
[callback] function Callback for the operation

Example

// Promise
client.Conference.removeMember("conferenceID", "memberId").then(function(){});
// Callback
client.Conference.removeMember("conferenceID", "memberId", function(err){});

conference.speakSentenceToMember(conferenceId, memberId, sentence, [callback]) ⇒ Promise

Speak sentence to the conference member using default values

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Description
conferenceId String The ID of the conference
memberId String The ID of the member
sentence String A sentence to speak to the member.
[callback] function Callback for the operation

Example

//Speak sentence

//Promise
client.Conference.speakSentenceToMember("conferenceID", "memberID", Hello From Bandwidth")
  .then(function (res) {});

//Callback
client.Conference.speakSentenceToMember("conferenceID", "memberID", "Hello From Bandwidth",
  function (err, res) {});

conference.playAudioFileToMember(conferenceId, memberId, fileUrl, [callback]) ⇒ Promise

Play audio url to the conference member

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Description
conferenceId String The ID of the conference
memberId String The ID of the member
fileUrl String The http location of an audio file to play (WAV and MP3 supported).
[callback] function Callback for the operation

Example

//Play Audio file

//Promise
client.Conference.playAudioFileToMember("conferenceID", "memberId", http://myurl.com/file.mp3")
  .then(function (res) {});

//Callback
client.Conference.playAudioFileToMember("conferenceID", "memberId", http://myurl.com/file.wav",
   function (err, res) {});

conference.playAudioAdvancedToMember(conferenceId, memberId, params, [callback]) ⇒ Promise

Play audio file or speak sentence to the conference member

Kind: instance method of Conference
Returns: Promise - A promise for the operation

Param Type Default Description
conferenceId String The ID of the conference
memberId String The ID of the member
params Object Parameters to play audio.
[params.fileUrl] String The http location of an audio file to play (WAV and MP3 supported).
[params.sentence] String The sentence to speak.
[params.gender] String female The gender of the voice used to synthesize the sentence. It will be considered only if sentence is not null. The female gender will be used by default.
[params.locale] String en_US The locale used to get the accent of the voice used to synthesize the sentence. It will be considered only if sentence is not null/empty. The en_US will be used by default.
[params.voice] String Susan The voice to speak the sentence. It will be considered only if sentence is not null/empty. Susan's voice will be used by default.
[params.loopEnabled] Boolean false When value is true, the audio will keep playing in a loop. Default: false.
[callback] function Callback for the operation

Example

//Play Audio File on loop
var options = {
	fileUrl     : "http://myurl.com/file.mp3",
	loopEnabled : true
}
//Promise
client.Conference.playAudioAdvancedToMember("conferenceId", "memberId", options)
 .then(function (res) {});

//Callback
client.Conference.playAudioAdvancedToMember("conferenceId", "memberId", options,
  function (err,res) {});

Example

//Speak sentence with options
var options = {
	sentence : "hola de Bandwidth",
	gender   : "male",
	locale   : "es",
	voice    : "Jorge"
}
//Promise
client.Conference.playAudioAdvancedToMember("conferenceId", "memberId", options)
  .then(function (res) {});

//Callback
client.Conference.playAudioAdvanced("conferenceId", options, function (err,res) {});

ConferenceResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the conference.
state String Conference state. Possible state values are described here.
from String The phone number that will host the conference.
createdTime String The time that the Conference was created (UTC).
completedTime String The time that the Conference was completed (UTC).
activeMembers Number The number of active conference members.
hold String If "true", all member can't hear or speak in the conference. If "false", all members can hear and speak in the conference (unless set at the member level).
mute String If "true", all member can't speak in the conference. If "false", all members can speak in the conference (unless set at the member level).
callbackUrl String The complete URL where the events related to the Conference will be sent to.
profile String If "interpret_digits": the conference will handle DTMF with the default behavior or if "passthru_digits": allows the application to receive DTMF events and use the gather API.
callbackHttpMethod String Determine if the callback event should be sent via HTTP GET or HTTP POST.
callbackTimeout String Determine how long should the platform wait for callbackUrl's response before timing out in milliseconds.
fallbackUrl String Determine how long should the platform wait for callbackUrl's response before timing out in milliseconds.
tag String A string that will be included in the callback events of the conference.

Domain

Kind: global class

new Domain()

Domain

domain.create(params, [callback]) ⇒ DomainResponse

Create a domain

Kind: instance method of Domain
Returns: DomainResponse - A promise for the newly created domain

Param Type Description
params Object Parameters for creating a new domain
params.name String The name is a unique URI to be used in DNS lookups.
params.description String String to describe the domain.
[callback] function Callback with the newly created domain

domain.list(callback) ⇒ Array.<DomainResponse>

Gets a list of all domains.

Kind: instance method of Domain
Returns: Array.<DomainResponse> - A promise for the list of domains.

Param Type Description
callback function A callback with the list of calls
[params.size] Number the maximum number of domains returned by the query per page (Max size: 100).

domain.delete(domainId, [callback]) ⇒ Promise

Delete a domain.

Kind: instance method of Domain
Returns: Promise - A promise for current operation.

Param Type Description
domainId String ID of the domain to delete.
[callback] function A callback for the domain.

DomainResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique identifier for the domain.
name String A name you choose for this domain.
description String A description of this domain.

Endpoint

Kind: global class

new Endpoint()

Endpoint

endpoint.create(domainId, params, [callback]) ⇒ EndpointResponse

Create a new endpoint for the domain

Kind: instance method of Endpoint
Returns: EndpointResponse - A promise for the newly created endpoint

Param Type Description
domainId String Id of domain
params Object Parameters for creating a new endpoint
params.name String The endpoint's name, which SIP clients use as the "address of record" .
params.description String String to describe the endpoint. 0param {String} params.applicationId The id of the application associated with this endpoint.
params.enabled Boolean Allow or not to receive and make calls.
params.credentials Object Auth parameters
[callback] function Callback with the newly created endpoint

Example

// Promise
client.Endpoint.create("domainId", { name : "my-endpoint", applicationId : "appId",
credentials : { password : "123456" }}).then(function (endpoint) {});
// Callback
client.Endpoint.create("domainId", { name : "my-endpoint", applicationId : "appId",
credentials : { password : "123456" }}, function (err, endpoint) {});

endpoint.list(domainId, params, [callback]) ⇒ Array.<EndpointResponse>

Gets a list of all endpoints for the domain.

Kind: instance method of Endpoint
Returns: Array.<EndpointResponse> - A promise for the list of endpoints.

Param Type Description
domainId String Id of the domain to list the endpoints
params Object Parameters for listing endpoints on domain
[params.size] Number OPTIONAL The maximum number of endpoints returned by the query per page (Max size: 1000).
[callback] function A callback with the list of endpoints

Example

// Default size (25) using promises
 client.Endpoint.list("domainId")
 	.then(function (res) {});

Example

// Default size (25) using callbacks
client.Endpoint.list("domainId", function (err, res) {});

Example

// Specify number of endpoints using promises
client.Endpoint.list("domainId", {size: 1000})
		.then(function (res) {});

Example

// Specify number of endpoints using callbacks
client.Endpoint.list("domainId" {size: 1000}, function (err, res) {});

endpoint.get(domainId, endpointId, [callback]) ⇒ EndpointResponse

Get a single endpoint.

Kind: instance method of Endpoint
Returns: EndpointResponse - A promise for the endpoint.

Param Type Description
domainId String Id of the domain
endpointId String Id of the endpoint
[callback] function A callback with the endpoint

Example

// Promise
client.Endpoint.get(domainId, endpointId).then(function(endpoint){});

// Callback
client.Endpoint.get(domainId, endpointId, function(err, endpoint){});

endpoint.delete(domainId, endpointId, [callback]) ⇒ Promise

Delete an endpoint.

Kind: instance method of Endpoint
Returns: Promise - A promise for current operation.

Param Type Description
domainId String Id of domain
endpointId String ID of the endpoint to delete.
[callback] function A callback for the operation.

Example

// Promise
client.Endpoint.delete("domainId", "endpointId").then(function (endpoint) {});
// Callback
client.Endpoint.delete("domainId", "endpointId", function (err, endpoint) {});

endpoint.update(domainId, endpointId, params, [callback]) ⇒ Promise

Update an endpoint.

Kind: instance method of Endpoint
Returns: Promise - A promise for current operation.

Param Type Description
domainId String Id of domain
endpointId String ID of the endpoint to update.
params Object Changed parameters for the endpoint
params.description String String to describe the endpoint. 0param {String} params.applicationId The id of the application associated with this endpoint.
params.enabled Boolean Allow or not to receive and make calls.
params.credentials Object Auth parameters
[callback] function A callback for the operation.

Example

// Promise
client.Endpoint.update("domainId", "endpointId", { enabled : true }).then(function (endpoint) {});
// Callback
client.Endpoint.update("domainId", "endpointId", { enabled : true }, function (err, endpoint) {});

endpoint.createAuthToken(domainId, endpointId, params, [callback]) ⇒ Promise

Generate auth token for the endpoint.

Kind: instance method of Endpoint
Returns: Promise - A promise with token value.

Param Type Description
domainId String Id of domain
endpointId String ID of the endpoint to update.
params Object parameters of token.
params.expires Number Expiration time of token in seconds
[callback] function A callback with token value.

Example

// Promise
client.Endpoint.createAuthToken("domainId", "endpointId", { expires : 3600 }).then(function (endpoint) {});
// Callback
client.Endpoint.createAuthToken("domainId", "endpointId", { expires : 3600 }, function (err, endpoint) {});

EndpointResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique identifier for the application.

new EndpointResponse(name, description, enabled, credentials)

Param Type Description
name String The endpoint's name, which SIP clients use as the "address of record" .
description String String to describe the endpoint. 0param {String} applicationId The id of the application associated with this endpoint.
enabled Boolean Allow or not to receive and make calls.
credentials Object Auth parameters

Error

Kind: global class

new Error()

Error

error.get(errorId, [callback]) ⇒ ErrorResponse

Gets information about a error.

Kind: instance method of Error
Returns: ErrorResponse - A promise for the error information

Param Type Description
errorId String The ID of the error to get
[callback] function A callback with the error information

Example

// Promise
client.Error.get(errorId).then(function(errorInfo){});

// Callback
client.Error.get(errorId, function(err, errorInfo){});

error.list(params, [callback]) ⇒ Array.<ErrorResponse>

Gets a list of errors.

Kind: instance method of Error
Returns: Array.<ErrorResponse> - A promise for the list of errors

Param Type Default Description
params Object Query parameters for listing errors
[params.size] Number 25 Used for pagination to indicate the size of each page requested for querying a list of errors. If no value is specified the default value is 25.
[callback] function A callback with the list of errors

Example

// Promise
client.Error.list({size: 1000}).then(function(errorResponse){});

// Callback
client.Error.list({size: 1000}, function(err, errorResponse){});

ErrorResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the error.
time String The time the error occurred (UTC).
category String The error category.
code String A specific error code string that identifies the type of error
message String A message that describes the error condition in detail.
details Object A list of name/value pairs of additional details.

CatapultClient

Kind: global class

new CatapultClient(config)

Catapult API Client

Param Type Default Description
config Object Client configuration parameters
config.userId String Your Catapult user ID
config.apiToken String Your Catapult API token
config.apiSecret String Your Catapult API secret
[config.baseUrl] String https://api.catapult.inetwork.com The catapult base URL. Configurable for using alternative Catapult environments.

Media

Kind: global class

new Media()

Media

media.upload(name, data, contentType, [callback]) ⇒ Promise

Upload a media file

Kind: instance method of Media
Returns: Promise - A promise for the operation

Param Type Description
name String The name of uploaded file.
data String | Buffer | Readable Data to upload. If data is string it should be path to file to upload.
contentType String Optional MIME type of uploaded data (default: application/octet-stream).
[callback] function Callback for the operation

media.download(name, [callback]) ⇒ DownloadMediaFileResponse

Download a media file

Kind: instance method of Media
Returns: DownloadMediaFileResponse - A promise for the operation

Param Type Description
name String The name of downloaded file.
[callback] function Callback for the operation

media.list([callback]) ⇒ Array.<MediaFileResponse>

Gets a list of your media files.

Kind: instance method of Media
Returns: Array.<MediaFileResponse> - A promise for the operation

Param Type Description
[callback] function Callback for the operation

media.delete(name, [callback]) ⇒ Promise

Remove a media file

Kind: instance method of Media
Returns: Promise - A promise for the operation

Param Type Description
name String The name of file to remove.
[callback] function Callback for the operation

DownloadMediaFileResponse : Object

Kind: global class
Properties

Name Type Description
contentType String MIME type of downloaded file.
content String | Buffer | Readable Content of file.

MediaFileResponse : Object

Kind: global class
Properties

Name Type Description
mediaName String name of media file.
contentLength Number Length of media file.

Message

Kind: global class

new Message(client)

SMS or MMS Message

Param Type Description
client Object Catapult client

message.send(params, [callback]) ⇒ MessageResponse

Send a new SMS or MMS message

Kind: instance method of Message
Returns: MessageResponse - A promise for the new message object

Param Type Default Description
params Object Parameters for sending a new message.
params.text String The message text to send
params.from String The message sender"s telephone number (or short code) This must be a Catapult number that you own
[params.to] String Message recipient telephone number (or short code)
[params.media] Array Json array containing list of media urls to be sent as content for an mms. Valid URLs are: https://api.catapult.inetwork.com/v1/users//media/ We also support media URLs that are external to Bandwidth API, http:// or https:// format: Example: http://customer-web-site.com/file.jpg
[params.callbackUrl] String The complete URL where the events related to the outgoing message will be sent
[params.callbackTimeout] Number Determine how long should the platform wait for callbackUrl"s response before timing out (milliseconds)
[params.fallbackUrl] String The server URL used to send message events if the request to callbackUrl fails
[params.tag] String A string that will be included in the callback events of the message
[params.receiptRequested] String none Requested receipt option for outbound messages: none all error
[callback] function A callback for the new message object

Example

client.Message.send({
  from : "+19195551212",
  to   : "+19195551213",
  text : "Thank you for susbcribing to Unicorn Enterprises!"
})
.then(function(message){
  console.log(message);
});
//{
//  from : "+19195551212",
//  to   : "+19195551213",
//  text : "Thank you for susbcribing to Unicorn Enterprises!",
//  id   : "..."
//}

message.sendMultiple(params, [callback]) ⇒ ExtendedMessageResponse

Send multiple SMS or MMS messages with one API call. This is much more performant than calling send multiple times.

Kind: instance method of Message
Returns: ExtendedMessageResponse - A promise for the array of ExtendedMessageResponses

Param Type Default Description
params Array An array of params objects, each of which represents a single text message. The returned array will be in the same order as this array, so you can iterate over it.
params.text String The message text to send
params.from String The message sender's telephone number (or short code) This must be a Catapult number that you own.
params.to String Message recipient telephone number (or short code)
[params.media] Array Json array containing list of media urls to be sent as content for an mms. Valid URLs are: https://api.catapult.inetwork.com/v1/users//media/ We also support media URLs that are external to Bandwidth API, http:// or https:// format: Example: http://customer-web-site.com/file.jpg
[params.callbackUrl] String The complete URL where the events related to the outgoing message will be sent
[params.callbackTimeout] Number Determine how long should the platform wait for callbackUrl's response before timing out (milliseconds)
[params.fallbackUrl] String The server URL used to send message events if the request to callbackUrl fails
[params.tag] String A string that will be included in the callback events of the message
[params.receiptRequested] String none Requested receipt option for outbound messages: none all error
[callback] function A callback for the array of ExtendedMessageResponse

Example

client.Message.sendMultiple({
  from : "+19195551211",
  to   : "+19195551213",
  text : "Thank you for susbcribing to Unicorn Enterprises!"
}, {
  from : "+19195151212",
  to   : "+19195551214",
  text : "Thank you for susbcribing to Unicorn Enterprises!"
})
.then(function(messages){
  console.log(messages);
});
//[{
//  result : "failed",
//  error: {
//    category : "authorization",
//    code     : "number-access-denied",
//    message  : "User ... does not have permission to use number +19195551211",
//    details  : [
//      {
//        name  : "userId",
//        value : "..."
//      },
//      {
//        name  : "number",
//        value : "+19195551211"
//      }
//    ],
//  },
//  message : {
//    from : "+19195551211",
//    to   : "+19195551213",
//    text : "Thank you for susbcribing to Unicorn Enterprises!"
//  }
//},{
//  result  : "accepted",
//  message : {
//    from : "+19195551212",
//    to   : "+19195551214",
//    text : "Thank you for susbcribing to Unicorn Enterprises!",
//    id   : "..."
//  }
//}]

message.get(messageId, [callback]) ⇒ MessageResponse

Get a message

Kind: instance method of Message
Returns: MessageResponse - A promise for the message

Param Type Description
messageId String The ID of the message to get
[callback] function A callback for the message

message.patch(messageId, data, [callback]) ⇒ Promise

Redact the text of a previously sent message

Kind: instance method of Message
Returns: Promise - A promise for the message

Param Type Description
messageId String The ID of the message to patch
data Object data to patch (only text is supported now)
data.text Object the contents of the text must be the empty string (""). Any other value will fail.
[callback] function A callback for the message

message.list(params, [callback]) ⇒ MessageListResponse

Gets a list of messages

Kind: instance method of Message
Returns: MessageListResponse - A promise for the list of messages

Param Type Description
params Object Search parameters
[params.from] String The phone number to filter the messages that came from (must be in E.164 format, like +19195551212).
[params.to] String The phone number to filter the messages that was sent to (must be in E.164 format, like +19195551212).
[params.fromDateTime] String The starting date time to filter the messages (must be in yyyy-MM-dd hh:mm:ss format, like 2014-05-25 12:00:00. You can suppress parts of the date or time, like 2014-05-25, but the missing parameters will be filled with zeros).
[params.toDateTime] String The ending date time to filter the messages (must be in yyyy-MM-dd hh:mm:ss format, like 2014-05-25 12:00:00. You can suppress parts of the date or time, like 2014-05-25, but the missing parameters will be filled with zeros)
[params.size] Number Used for pagination to indicate the size of each page requested \ for querying a list of messages. If no value is specified the default value is 25. (Maximum value 1000)
[params.direction] String Filter by direction of message, in - a message that came from the telephone network to one of your numbers (an "inbound" message) or out - a message that was sent from one of your numbers to the telephone network (an "outbound" message)
[params.state] String The message state to filter. Values are: received, queued, sending, sent, error
[params.deliveryState] String The message delivery state to filter. Values are waiting, delivered, not-delivered
[params.sortOrder] String How to sort the messages. Values are asc or desc If no value is specified the default value is asc
[callback] function A callback for the list of messages

Example

//Download the node sdk from ap.bandwidth.com/docs/helper-libraries/node-js
//API credentials which can be found on your account page at https://catapult.inetwork.com/pages/login.jsf
var userId = 'u-userid';  //{user_id}
var token = 't-token'; //{token}
var secret = 'secret'; //{secret}

var Bandwidth = require('node-bandwidth');

var client = new Bandwidth({
	userId: userId,
	apiToken: token,
	apiSecret: secret
});

client.Message.list()
.then(function (response) {
	console.log(response.messages);
	if(response.hasNextPage) {
		return response.getNextPage();
	}
	else {
		return {messages: []};
	}
})
.then(function(response) {
	console.log(response.messages);
});

MessageListResponse : Object

Kind: global class
Properties

Name Type Description
messages Array.<MessageResponse> Array of messages
getNextPage function Calls the next page function
hasNextPage boolean True/False flag for next
nextLink Object The values to attach to the next get request for messages.

ExtendedMessageResponse : Object

Kind: global class
Properties

Name Type Description
result String Either "accepted" or "failed".
The MessageResponse message. Will consist of the params queried with, if the query failed, or the complete message response, if the message was accepted.
Defined MessageError only if result is "failed".

MessageError : Object

Kind: global class
Properties

Name Type Description
category String The type of error (e.g. "authorization").
code String The exact error string provided by the API.
message String A human-readable error message.
details Object Additional details on the error.

MessageResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the message.
from String The message sender's telephone number (or short code).
to String Message recipient telephone number (or short code).
direction String Direction of message, in - a message that came from the telephone network to one of your numbers (an "inbound" message) or out - a message that was sent from one of your numbers to the telephone network (an "outbound" message)
text String The message contents.
media Array Json array containing list of media urls to be sent as content for an mms.
state String Message state, values are received, queued, sending, sent, error
time String The time the message resource was created (UTC, follows the ISO 8601 format).
callbackUrl String The complete URL where the events related to the outgoing message will be sent.
callbackTimeout Number Determine how long should the platform wait for callbackUrl's response before timing out. (milliseconds)
fallbackUrl String The server URL used to send message events if the request to callbackUrl fails.
size Number Used for pagination to indicate the size of each page requested for querying a list of messages. If no value is specified the default value is 25. (Maximum value 1000)
tag String A string that will be included in the callback events of the message.
receiptRequested String Requested receipt option for outbound messages: none, all, error Default is none.
deliveryState String One of the message delivery states: waiting, delivered, not-delivered.
deliveryCode Number Numeric value of deliver code.
deliveryDescription String Message delivery description for the respective delivery code.

NumberInfo

Kind: global class

new NumberInfo()

NumberInfo

numberInfo.get(number, [callback]) ⇒ NumberInfoResponse

Gets information about a number.

Kind: instance method of NumberInfo
Returns: NumberInfoResponse - A promise for the number information

Param Type Description
number String The ID of the numberInfo to get
[callback] function A callback with the number information

Example

// Promise
client.NumberInfo.get("+1234567890").then(function(info){});

// Callback
client.NumberInfo.get("+1234567890", function(err, info){});

NumberInfoResponse : Object

Kind: global class
Properties

Name Type Description
name String The Caller ID name information.
number String Phone number in E164 format.
created String The time this Caller ID information was first queried (UTC).
updated String The time this Caller ID information was last updated (UTC).

PhoneNumber

Kind: global class

new PhoneNumber()

Phone numbers

phoneNumber.create(params, [callback]) ⇒ PhoneNumberResponse

Allocates a number

Kind: instance method of PhoneNumber
Returns: PhoneNumberResponse - A promise for the newly created number

Param Type Description
params Object Parameters for allocating a number
params.number String A number to allocate.
[params.name] String A name you choose for this number.
[params.applicationId] String The unique id of an Application you want to associate with this number.
[params.fallbackNumber] String Number to transfer an incoming call when the callback/fallback events can't be delivered.
[callback] function Callback with the newly created number

Example

//Allocate number +1234567980

// Promise
client.PhoneNumber.create({ number : "+1234567890" }).then(function(number){});

// Callback
client.PhoneNumber.create({ number : "+1234567890" }, function(err, number){});

phoneNumber.get(phoneNumberOrId, callback) ⇒ PhoneNumberResponse

Gets information about a phoneNumber.

Kind: instance method of PhoneNumber
Returns: PhoneNumberResponse - A promise for the call information

Param Type Description
phoneNumberOrId String The ID of the number or number in format E.164 (like +1234567980) to get
callback function A callback with the call information

Example

// Promise
client.PhoneNumber.get(numberId).then(function(number){});
// or
client.PhoneNumber.get("+1234567890").then(function(number){});

// Callback
client.PhoneNumber.get(numberId, function(err, number){});
// or
client.PhoneNumber.get("+1234567890", function(err, number){});

phoneNumber.list(params, callback) ⇒ Array.<PhoneNumberResponse>

Gets a list of allocated numbers.

Kind: instance method of PhoneNumber
Returns: Array.<PhoneNumberResponse> - A promise for the list of phone numbers

Param Type Default Description
params Object Query parameters for listing numbers
[params.size] Number 25 Used for pagination to indicate the size of each page requested for querying a list numbers. If no value is specified the default value is 25 (maximum value 1000).
[params.applicationId] String Used to filter the retrieved list of numbers by an associated application ID
[params.state] String Used to filter the retrieved list of numbers by a US state.
[params.name] String Used to filter the retrieved list of numbers by name
[params.city] String Used to filter the retrieved list of numbers by city name
[params.numberState] String Used to filter the retrieved list of numbers by number state
callback function A callback with the list of numbers

Example

// Promise
client.PhoneNumber.list({size: 1000}).then(function(numbersResponse){});

// Callback
client.PhoneNumber.list({size: 1000}, function(err, numbersResponse){});

phoneNumber.update(phoneNumberId, params, [callback]) ⇒ Promise

Update the number

Kind: instance method of PhoneNumber
Returns: Promise - A promise for the operation

Param Type Description
phoneNumberId String The ID of the number
params Object Changed parameters of the number
params.applicationId String The unique id of an Application resource you want to associate with this number for incoming calls and messages.
params.name String A name you choose for this number.
params.fallbackNumber String Number to transfer an incoming call when the callback/fallback events can't be delivered.
[callback] function Callback for the operation

Example

// Promise
client.PhoneNumber.update(numberId, {name: "Another Name"}).then(function(){});

// Callback
client.PhoneNumber.update(numberId, {name: "Another Name"}, function(err){});

phoneNumber.delete(phoneNumberId, [callback]) ⇒ Promise

Remove the number

Kind: instance method of PhoneNumber
Returns: Promise - A promise for the operation

Param Type Description
phoneNumberId String The ID of the number
[callback] function Callback for the operation

Example

// Promise
client.PhoneNumber.delete(numberId).then(function(){});

// Callback
client.PhoneNumber.delete(numberId, function(err){});

PhoneNumberResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the number.
state String Number state
name String Number name
number String Number in E.164 format.
nationalNumber String Number in natinal friendly format (like (555) 5555-5555).
city String Number city.
state String Number state.
applicationId String The unique id of an linked Application.
fallbackNumber String Number to transfer an incoming call when the callback/fallback events can't be delivered.
price String The monthly price for this number.
numberState String The phone number state, values are enabled or released
createdTime String Date when the number was created.

Recording

Kind: global class

new Recording()

Retrieve information about call recordings

recording.get(recordingId, [callback]) ⇒ RecordingResponse

Get a recording

Kind: instance method of Recording
Returns: RecordingResponse - A promise for the recording object

Param Type Description
recordingId String The ID of the recording to retrieve
[callback] function Callback with the recording object

recording.list(params, [callback]) ⇒ RecordingResponse

Get a list of recordings

Kind: instance method of Recording
Returns: RecordingResponse - A promise for the recording objects

Param Type Description
params Object [description]
[callback] function Callback with the recording objects

recording.createTranscription(recordingId, [callback]) ⇒ TranscriptionResponse

Create a transcription

Kind: instance method of Recording
Returns: TranscriptionResponse - A promise for the created transcription

Param Type Description
recordingId String The ID of the recording
[callback] function Callback with the create transcription

Example

// Promise
client.Recording.createTranscription(recordingId).then(function(transcription){});

// Callback
client.Recording.createTranscription(recordingId, function(err, transcription){});

recording.getTranscription(recordingId, transcriptionId, [callback]) ⇒ TranscriptionResponse

Get information about the transcription

Kind: instance method of Recording
Returns: TranscriptionResponse - A promise for the transcription

Param Type Description
recordingId String The ID of the recording
transcriptionId String The ID of the transcription
[callback] function Callback with the transcription

Example

// Promise
client.Recording.getTranscription(recordingId, transcriptionId).then(function(transcription){});

// Callback
client.Recording.getTranscription(recordingId, transcriptionId, function(err, transcription){});

recording.getTranscriptions(recordingId, [callback]) ⇒ TranscriptionResponse

Get list of all transcriptions for recording

Kind: instance method of Recording
Returns: TranscriptionResponse - A promise for the transcriptions

Param Type Description
recordingId String The ID of the recording
[callback] function Callback with the transcriptions

Example

// Promise
client.Recording.getTranscriptions(recordingId).then(function(transcriptions){});

// Callback
client.Recording.getTranscriptions(recordingId, function(err, transcriptions){});

RecordingResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the recording.
startTime String Date/time when the recording started.
endTime String Date/time when the recording ended.
media String The complete URL to the media resource this recording is associated with.
call String The complete URL to the call resource this recording is associated with.
state String The state of the recording,

TranscriptionResponse : Object

Kind: global class
Properties

Name Type Description
id String The unique ID of the transcription.
text String The transcribed text (only first 1000 characters).
chargeableDuration Number The seconds between activeTime and endTime for the recording; this is the time that is going to be used to charge the resource.
textSize Number The size of the transcribed text.
state String The state of the transcription,
textUrl String A url to the full text,

BXMLResponse

Kind: global class

new BXMLResponse()

Creates a new BXML Response object. Call .toString() on this method to obtain the BXML string.

bxmlResponse.speakSentence(sentence, params) ⇒ BXMLResponse

Create a SpeakSentence tag.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining

Param Type Default Description
sentence string The sentence to have the voice say.
params Object The parameters for the API SpeakSentence call.
[params.gender] string "&quot;female&quot;" The gender of the speaker.
[params.locale] string "&quot;en_US&quot;" The locale for the speaker.
[params.voice] string "&quot;julie&quot;" The voice for the speaker.

Example

//This app will speak two sentences.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.speakSentence("Thanks for calling Unicorn Enterprises.")
     .speakSentence("Someone will be with you shortly.");
myApp = myApp.toString();

bxmlResponse.gather(params, [callback]) ⇒ BXMLResponse

Create a Gather call, which collects pressed numbers.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining

Param Type Default Description
params Object The parameters for the Gather verb.
params.requestURL string Relative or absolute URL to send events to and request new BXML.
[params.requestURLTimeout] number 3000 Time to wait for requestURL response in ms.
[params.terminatingDigits] string "#" Digits to stop gather.
[params.maxDigits] number 128 Maximum number of digits to collect.
[params.integerDigitTimeout] number 5 Timeout between digits.
[params.bargeable] boolean true Boolean indicating if audio should stop when digit is pressed.
[callback] function A function containing the verbs to be nested inside the Gather call.

Example

//This app will collect a PIN code.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.gather({
    requestUrl : 'http://unico.rn/pinApiEndpoint',
    maxDigits  : 4
}, function () {
    this.speakSentence("Please enter your PIN code.")
});
myApp = myApp.toString();

bxmlResponse.toString() ⇒ string

Kind: instance method of BXMLResponse
Returns: string - A string representation of the object's BXML.

bxmlResponse.call(params, [callback]) ⇒ BXMLResponse

OBSOLETE: Create a new call to another phone number.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining

Param Type Description
params Object The parameters for the Call verb.
params.from string Defines the number the call will be created from.
params.to string Defines the number the call will be made to.
[params.requestUrl] string URL to send event
[params.timeout] number The timeout, in seconds, for the call to answer
[params.requestUrlTimeout] number Timeout, in ms, to request new BXML document
[callback] function A function containing the verbs to be nested inside the Call verb

Example

//This app will create a call and tell the callee they are being called.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.call({
     from : '+19195551212',
     to   : '+19195551213'
}, function () {
     this.speakSentence("You are recieving a call from 919 555 1212.");
});
myApp = myApp.toString();

bxmlResponse.conference(params) ⇒ BXMLResponse

OBSOLETE: Create a new conference call.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Default Description
params Object The parameters for the Conference verb.
params.from string The phone number that will host the conference.
[params.statusCallbackUrl] string URL to which conference callbacks will be POSTed
[params.joinTone] boolean true Determines whether or not a tone is played on join.
[params.leavingTone] boolean true Determines whether or not a tone is played on leave.
[params.tag] string A string that will be included in the callback events of the conference.
[params.mute] boolean false Determines whether or not the member will join muted.
[params.hold] boolean false Determines whether or not the member will join on hold.

Example

//This app will create a conference call. Callers to (919) 555 1212 will be patched in.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.conference({
    from : '+19195551212'
});
myApp = myApp.toString();

bxmlResponse.hangup() ⇒ BXMLResponse

Terminates an outgoing call.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.
Example

//This app will speak two sentences and hang up.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.speakSentence("Thanks for calling Unicorn Enterprises.")
     .speakSentence("We have been acquired by BigCorp.")
     .hangup();
myApp = myApp.toString();

bxmlResponse.playAudio(audio) ⇒ BXMLResponse

Plays an audio file located at a specified URL.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Description
audio string The URL of the audio to be played.

Example

var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.speakSentence("Thanks for calling Unicorn Enterprises.")
     .speakSentence("All agents are currently busy playing ping-pong. Please hold.")
     .playAudio("http://unico.rn/assets/postglamspeedfolk.mp3");
myApp = myApp.toString();

bxmlResponse.record(params) ⇒ BXMLResponse

Records the call. At end of call, a call recording event is sent to the callback URL.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Default Description
params Object The parameters for the Record verb.
[params.requestUrl] string URL to send event and request new BXML.
[params.requestUrlTimeout] number Timeout, in ms, to wait for requestUrl response.
[params.fileFormat] string The format in which to save the recording - mp3 or wav.
[params.terminatingDigits] string OBSOLETE: One or more digits that will finish the recording.
[params.maxDuration] number 300 OBSOLETE: Time, in seconds, for max duration. Up to 3600 sec (1hr)
[params.transcribe] boolean false Boolean to indicate transcription of the recording.
[params.transcribeCallbackUrl] string URL to send transcribed event.

Example

//This app will record a message.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.speakSentence("Thanks for calling Unicorn Enterprises.")
     .speakSentence("Your call may be recorded for quality assurance.")
     .record({
           requestUrl : "http://unico.rn/recordsGetPutHere",
           fileFormat : "mp3"
		});

bxmlResponse.redirect(params) ⇒ BXMLResponse

Redirects the current execution to run XML at another URL.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Description
params Object The parameters for the Redirect verb.
params.requestUrl string The URL to send event to and request new BXML.
params.requestUrlTimeout number Timeout, in ms, to wait for requestUrl to respond.

bxmlResponse.sendMessage(message, params) ⇒ BXMLResponse

OBSOLETE: Sends a text message.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Default Description
message string The message to send.
params Object The parameters for the SendMessage verb
params.from string The number to send the message from.
params.to string The number to send the message to.
[params.requestUrl] string The URL to send events to and request new BXML from.
[params.requestUrlTimeout] number 30 Timeout, in seconds, to wait for requestUrl to respond.
[params.statusCallbackUrl] string URL to send the message callback to.

Example

// This app will text a customer.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.sendMessage("Get $20 off your next purchase!", {
		from : "+19195551212",
		to   : "+19195551213"
});

bxmlResponse.phoneNumber(phoneNumber) ⇒ BXMLResponse

Used to direct call flow for multiple transfer

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Description
phoneNumber String The phone number to try for a transfer

bxmlResponse.transfer(params, callback) ⇒ BXMLResponse

Transfers the call to another number.

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Description
params Object The parameters for the Transfer verb.
params.transferTo string The number to transfer the call to.
[params.transferCallerId] string The caller ID to use on the transferred call.
[params.callTimeout] number The timeout, in seconds, for the call to be answered.
[params.requestUrl] string URL to send event to and request new BXML from.
[params.requestUrlTimeout] number Timeout, in msec, to wait for requestUrl to respond.
[params.tag] string A string that will be included in the callback events.
callback function The verbs to nest inside the Transfer verb.

Example

// This app will transfer a call.
var Bandwidth = require("node-bandwidth");
var myApp = new Bandwidth.BXMLResponse();
myApp.speakSentence("Your call is somewhat important to us.")
		.speakSentence("Please wait while it is being transferred.")
		.transfer({
			transferTo: "+19195551213"
		}, function (){
			this.speakSentence("A call is being transferred to you from Customer Service.");
		});

Example

// Multiple transfer with speak senetence - Try 3 numbers
var myApp = new Bandwidth.BXMLResponse();
myApp.speakSentence("Your call is somewhat important to us.")
	.speakSentence("Please wait while it is being transferred.")
	.transfer({}, function (){
		this.phoneNumber("+13334445555");
		this.phoneNumber("+13334445556");
		this.phoneNumber("+13334445557");
		this.speakSentence("A call is being transferred to you from Customer Service.");
	});
console.log(myApp.toString());

bxmlResponse.pause(params) ⇒ BXMLResponse

Pause the execution of an ongoing BXML document

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Description
params Object The parameters for the Pause verb.
params.length string How many seconds Bandwidth will wait silently before continuing on.

Example

// This app will transfer a call.
var Bandwidth = require("node-bandwidth");
var r = new Bandwidth.BXMLResponse();
r.pause({length: 5})
console.log(r.toString());

bxmlResponse.sendDtmf(value) ⇒ BXMLResponse

Send digits on a live call

Kind: instance method of BXMLResponse
Returns: BXMLResponse - this, for chaining.

Param Type Description
value string string containing the DTMF characters to be sent in a call (maximum of 92 characters)

Example

// This app will transfer a call.
var Bandwidth = require("node-bandwidth");
var r = new Bandwidth.BXMLResponse();
r.dtmf('1');
console.log(r.toString());

getNextLink(response) ⇒

getNextLink

Kind: global function
Returns: A parsed version of the link to the subsequent page, or null if no such page exists.

Param Type Description
response Object A headers object returned from calling 'client.makeRequest' (response.headers)