1.2.3
Node SDK
Instantiate the instance with clientId & clientSecret.
(Object)
Name | Description |
---|---|
params.clientId string
|
Private project key / Account client ID. If Private project key is used then client_secret is mandatory. If account client ID is used then email and password are mandatory. |
params.baseUrl string
|
URL of the server to be used. |
params.clientSecret string?
|
Private project secret |
params.email string?
|
Account login email. |
params.password string?
|
Account login password. |
const client = createClient({
clientId: '<private project key>',
clientSecret: '<private project secret>',
baseUrl: '<base url>'
})
or
const client = createClient({
clientId: '<account client ID>',
email: '<account email>',
password: '<account password>',
baseUrl: '<base url>'
})
CPaaS conversation.
Send a new outbound message
(Object)
Name | Description |
---|---|
params.type string
(default this.types.SMS )
|
Type of conversation. Possible value(s) - sms. Check conversation.types for more options |
params.destinationAddress (Array<string> | string)
|
Indicates which DID number(s) used as destination for this SMS. |
params.message string
|
SMS text message |
params.senderAddress string
|
Sender address information, basically the from address. E164 formatted DID number passed as a value, which is owned by the user. If the user wants to let CPaaS uses the default assigned DID number, this field can either has "default" value or the same value as the userId. |
Promise<Object>
:
Gets all messages.
(Object
= {}
)
Name | Description |
---|---|
params.type string
(default this.types.SMS )
|
Type of conversation. Possible value(s) - sms. Check conversation.types for more options |
params.query Object?
|
|
params.query.name string?
|
Performs search operation on firstName and lastName fields. |
params.query.firstName string?
|
Performs search for the firstName field of the directory items. |
params.query.lastName string?
|
Performs search for the lastName field of the directory items. |
params.query.userName string?
|
Performs search for the userName field of the directory items. |
params.query.phoneNumber string?
|
Performs search for the fields containing a phone number, like businessPhoneNumber, homePhoneNumber, mobile, pager, fax. |
params.query.order string?
|
Ordering the contact results based on the requested sortBy value, order query parameter should be accompanied by sortBy query parameter. |
params.query.sortBy string?
|
SortBy value is used to detect sorting the contact results based on which attribute. If order is not provided with that, ascending order is used. |
params.query.max number?
|
Maximum number of contact results that has been requested from CPaaS for this query. |
params.query.next string?
|
Pointer for the next chunk of contacts, should be gathered from the previous query results. |
params.remoteAddress string?
|
Remote address information while retrieving the SMS history, basically the destination telephone number that user exchanged SMS before. E164 formatted DID number passed as a value. |
params.localAddress string?
|
Local address information while retrieving the SMS history, basically the source telephone number that user exchanged SMS before. |
Promise<Object>
:
Read a conversation message status
(Object)
Name | Description |
---|---|
params.type string
(default this.types.SMS )
|
Type of conversation. Possible value(s) - sms. Check conversation.types for more options |
params.localAddress string
|
Local address information while retrieving the SMS history, basically the source telephone number that user exchanged SMS before. |
params.messageId string
|
Identification of the SMS message. |
params.remoteAddress string
|
Remote address information while retrieving the SMS history, basically the destination telephone number that user exchanged SMS before. E164 formatted DID number passed as a value. |
Promise<Object>
:
Read all messages in a thread
(Object)
Name | Description |
---|---|
params.type string
(default this.types.SMS )
|
Type of conversation. Possible value(s) - sms. Check conversation.types for more options |
params.localAddress string
|
Local address information while retrieving the SMS history, basically the source telephone number that user exchanged SMS before. |
params.remoteAddress string
|
Remote address information while retrieving the SMS history, basically the destination telephone number that user exchanged SMS before. E164 formatted DID number passed as a value. |
params.query Object?
|
|
params.query.max number?
|
Number of messages that is requested from CPaaS. |
params.query.next string?
|
Pointer for the next page to retrieve for the messages, provided by CPaaS in previous GET response. |
params.query.new string?
|
Filters the messages or threads having messages that are not received by the user yet |
params.query.lastMessageTime number?
|
Filters the messages or threads having messages that are sent/received after provided Epoch time |
Promise<Object>
:
Delete conversation message
(Object)
Name | Description |
---|---|
params.type string
(default this.types.SMS )
|
Type of conversation. Possible value(s) - sms. Check conversation.types for more options |
params.localAddress string
|
Local address information while retrieving the SMS history, basically the source telephone number that user exchanged SMS before. |
params.messageId string?
|
Identification of the SMS message. If messageId is not passed then the SMS thread is deleted with all messages. |
params.remoteAddress string
|
Remote address information while retrieving the SMS history, basically the destination telephone number that user exchanged SMS before. E164 formatted DID number passed as a value. |
Promise<Object>
:
Create a new subscription
(Object)
Name | Description |
---|---|
params.type string
(default this.types.SMS )
|
Type of conversation. Possible value(s) - sms. Check conversation.types for more options |
params.destinationAddress string?
|
The address that incoming messages are received for this subscription. If does not exist, CPaaS uses the default assigned DID number to subscribe against. It is suggested to provide the intended E164 formatted DID number within this parameter. |
params.webhookURL string
|
HTTPS URL that is present in your application server which is accessible from the public web where the notifications should be sent to. Note: Should be a
POST
endpoint.
|
Promise<Object>
:
CPaaS notification helper methods
CPaaS provides Authentication API where a two-factor authentication (2FA) flow can be implemented by using that.
Create a new authentication code
(Object)
Name | Description |
---|---|
params.destinationAddress (Array<string> | string)
|
Destination address of the authentication code being sent. For sms type authentication codes, it should contain a E164 phone number. For e-mail type authentication codes, it should contain a valid e-mail address. |
params.message string
|
Message text sent to the destination, containing the placeholder for the code within the text. CPaaS requires to have {code} string within the text in order to generate a code and inject into the text. For email type code, one usage is to have the {code} string located within the link in order to get a unique link. |
params.subject string?
|
When the method is passed as email then subject becomes a mandatory field to pass. The value passed becomes the subject line of the 2FA code email that is sent out to the destinationAddress. |
params.expiry number
(default 120 )
|
Lifetime duration of the code sent in seconds. This can contain values between 30 and 3600 seconds. |
params.length number
(default 6 )
|
Length of the authentication code tha CPaaS should generate for this request. It can contain values between 4 and 10. |
params.method string
(default 'sms' )
|
Type of the authentication code delivery method, sms and email are supported types. Possible values: sms, email |
params.type string
(default 'numeric' )
|
Type of the code that is generated. If not provided, default value is numeric. Possible values: numeric, alphanumeric, alphabetic |
Promise<Object>
:
Resending the authentication code via same code resource, invalidating the previously sent code.
(Object)
Name | Description |
---|---|
params.destinationAddress (Array<string> | string)
|
Destination address of the authentication code being sent. For sms type authentication codes, it should contain a E164 phone number. For e-mail type authentication codes, it should contain a valid e-mail address. |
params.codeId string
|
ID of the authentication code. |
params.message string
|
Message text sent to the destination, containing the placeholder for the code within the text. CPaaS requires to have {code} string within the text in order to generate a code and inject into the text. For email type code, one usage is to have the {code} string located within the link in order to get a unique link. |
params.subject string?
|
When the method is passed as email then subject becomes a mandatory field to pass. The value passed becomes the subject line of the 2FA code email that is sent out to the destinationAddress. |
params.expiry number
(default 120 )
|
Lifetime duration of the code sent in seconds. This can contain values between 30 and 3600 seconds. |
params.length number
(default 6 )
|
Length of the authentication code tha CPaaS should generate for this request. It can contain values between 4 and 10. |
params.method string
(default 'sms' )
|
Type of the authentication code delivery method, sms and email are supported types. Possible values: sms, email |
params.type string
(default 'numeric' )
|
Type of the code that is generated. If not provided, default value is numeric. Possible values: numeric, alphanumeric, alphabetic |
Promise<Object>
: