npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mmpackagepublishnpm

v1.0.0

Published

# Introduction The MessageMedia APIs provide powerful business messaging capabilities across sending, receiving, and processing SMS, MMS, and rich messaging. All requests to the MessageMedia REST API must be authenticated, this can either be done using

Downloads

4

Readme

Getting started

Introduction

The MessageMedia APIs provide powerful business messaging capabilities across sending, receiving, and processing SMS, MMS, and rich messaging.

All requests to the MessageMedia REST API must be authenticated, this can either be done using Basic Authentication or by signing with a HMAC signature.

Credentials

To access the API, an API key and secret are required.

Sign up for a developer account here to get access: https://developers.messagemedia.com/register/.

Features

De-Duplication

De-Duplication helps you avoid having to undertake data cleansing before commencing send outs.
It automatically detects and withholds messages deemed to be duplicates through the use of a 24-hour window – if a message is sent to the same number with the same content within a 24hr period, the subsequent message(s) will be withheld and rejected. To enable this, you don't need to make any changes to your application, just an account configuration change by MessageMedia's support team.

Social Sending

Social Sending permits messages to be sent only during sociable hours - i.e. 8am to 6pm (based on your accounts local time zone - not local time). Messages sent outside of these hours are scheduled to be released during the next social time period. This feature helps businesses avoid send-outs during a time that would be deemed unsuitable by the customer. To enable this, you don't need to make any changes to your application, just an account configuration change by MessageMedia's support team.

Familiar Sender

Familiar Sender ensures all communication sent to a customer are from the same phone number. This allows businesses to build trust and familiarity with their customers and not confuse them by changing outgoing numbers. To enable this, you don't need to make any changes to your application, just an account configuration change by MessageMedia's support team.

Character Converter

Characters in a message may not always fall within the GSM-7 supported characterset, and when this occurs all outbound messages will be encoded using UCS-2 leading to the customer being double-charged for the SMS. Character Converter can help you avoid being double-charged for your SMS by converting all characters into the GSM-7 format ensuring you always get the maximum characters into an SMS. Bear in my mind, this will downgrade all your unicode characters so for instance, your emojis will be translated into a string of unknown characters (eg: �). To enable this, you don't need to make any changes to your application, just an account configuration change by MessageMedia's support team.

How to Build

The generated SDK relies on Node Package Manager (NPM) being available to resolve dependencies. If you don't already have NPM installed, please go ahead and follow instructions to install NPM from here. The SDK also requires Node to be installed. If Node isn't already installed, please install it from here

NPM is installed by default when Node is installed

To check if node and npm have been successfully installed, write the following commands in command prompt:

  • node --version
  • npm -version

Version Check

Now use npm to resolve all dependencies by running the following command in the root directory (of the SDK folder):

npm install

Resolve Dependencies

Resolve Dependencies

This will install all dependencies in the node_modules folder.

Once dependencies are resolved, you will need to move the folder Mmpackagepublishnpm in to your node_modules folder.

How to Use

The following section explains how to use the library in a new project.

1. Open Project Folder

Open an IDE/Text Editor for JavaScript like Sublime Text. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.

Click on File and select Open Folder.

Open Folder

Select the folder of your SDK and click on Select Folder to open it up in Sublime Text. The folder will become visible in the bar on the left.

Open Project

2. Creating a Test File

Now right click on the folder name and select the New File option to create a new test file. Save it as index.js Now import the generated NodeJS library using the following lines of code:

var lib = require('lib');

Save changes.

Create new file

Save new file

3. Running The Test File

To run the index.js file, open up the command prompt and navigate to the Path where the SDK folder resides. Type the following command to run the file:

node index.js

Run file

How to Test

These tests use Mocha framework for testing, coupled with Chai for assertions. These dependencies need to be installed for tests to run. Tests can be run in a number of ways:

Method 1 (Run all tests)

  1. Navigate to the root directory of the SDK folder from command prompt.
  2. Type mocha --recursive to run all the tests.

Method 2 (Run all tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha * to run all the tests.

Method 3 (Run specific controller's tests)

  1. Navigate to the ../test/Controllers/ directory from command prompt.
  2. Type mocha MessageMediaController to run all the tests in that controller file.

To increase mocha's default timeout, you can change the TEST_TIMEOUT parameter's value in TestBootstrap.js.

Run Tests

Initialization

Authentication

In order to setup authentication in the API client, you need the following information.

| Parameter | Description | |-----------|-------------| | basicAuthUserName | The username to use with basic authentication | | basicAuthPassword | The password to use with basic authentication |

API client can be initialized as following:

const lib = require('lib');

// Configuration parameters and credentials
lib.Configuration.basicAuthUserName = "basicAuthUserName"; // The username to use with basic authentication
lib.Configuration.basicAuthPassword = "basicAuthPassword"; // The password to use with basic authentication

Class Reference

List of Controllers

Class: MessagesController

Get singleton instance

The singleton instance of the MessagesController class can be accessed from the API Client.

var controller = lib.MessagesController;

Method: getMessageStatus

Retrieve the current status of a message using the message ID returned in the send messages end point.

A successful request to the get message status endpoint will return a response body as follows:


{
    "format": "SMS",
    "content": "My first message!",
    "metadata": {
        "key1": "value1",
        "key2": "value2"
    },
    "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
    "callback_url": "https://my.callback.url.com",
    "delivery_report": true,
    "destination_number": "+61401760575",
    "scheduled": "2016-11-03T11:49:02.807Z",
    "source_number": "+61491570157",
    "source_number_type": "INTERNATIONAL",
    "message_expiry_timestamp": "2016-11-03T11:49:02.807Z",
    "status": "enroute"
}

The status property of the response indicates the current status of the message. See the Delivery Reports section of this documentation for more information on message statues.

Note: If an invalid or non existent message ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned

function getMessageStatus(messageId, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | messageId | Required | 36 character UUID. |

Example Usage


    var messageId = 'messageId';

    controller.getMessageStatus(messageId, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unauthorised | | 404 | Resource not found |

Method: cancelScheduledMessage

Cancel a scheduled message that has not yet been delivered.

A scheduled message can be cancelled by updating the status of a message from scheduled to cancelled. This is done by submitting a PUT request to the messages endpoint using the message ID as a parameter (the same endpoint used above to retrieve the status of a message).

The body of the request simply needs to contain a status property with the value set to cancelled.


{
    "status": "cancelled"
}

Note: Only messages with a status of scheduled can be cancelled. If an invalid or non existent message ID parameter is specified in the request, then a HTTP 404 Not Found response will be returned

function cancelScheduledMessage(messageId, body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | messageId | Required | 36 character UUID. | | body | Required | Parameters of a message to change. |

Example Usage


    var messageId = 'messageId';
    var body = new Cancelscheduledmessagerequest({"key":"value"});

    controller.cancelScheduledMessage(messageId, body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad request | | 403 | Unauthorised | | 404 | Resource not found |

Method: sendMessages

Submit one or more (up to 100 per request) SMS, MMS or text to voice messages for delivery.

The most basic message has the following structure:


{
    "messages": [
        {
            "content": "My first message!",
            "destination_number": "+61491570156"
        }
    ]
}

More advanced delivery features can be specified by setting the following properties in a message:

  • callback_url A URL can be included with each message to which Webhooks will be pushed to via a HTTP POST request. Webhooks will be sent if and when the status of the message changes as it is processed (if the delivery report property of the request is set to true) and when replies are received. Specifying a callback URL is optional.

  • content The content of the message. This can be a Unicode string, up to 5,000 characters long. Message content is required.

  • delivery_report Delivery reports can be requested with each message. If delivery reports are requested, a webhook will be submitted to the callback_url property specified for the message (or to the webhooks) specified for the account every time the status of the message changes as it is processed. The current status of the message can also be retrieved via the Delivery Reports endpoint of the Messages API. Delivery reports are optional and by default will not be requested.

  • destination_number The destination number the message should be delivered to. This should be specified in E.164 international format. For information on E.164, please refer to http://en.wikipedia.org/wiki/E.164. A destination number is required.

  • format The format specifies which format the message will be sent as, SMS (text message), MMS (multimedia message) or TTS (text to speech). With TTS format, we will call the destination number and read out the message using a computer generated voice. Specifying a format is optional, by default SMS will be used.

  • source_number A source number may be specified for the message, this will be the number that the message appears from on the handset. By default this feature is not available and will be ignored in the request. Please contact [email protected] for more information. Specifying a source number is optional and a by default a source number will be assigned to the message.

  • media The media is used to specify a list of URLs of the media file(s) that you are trying to send. Supported file formats include png, jpeg and gif. format parameter must be set to MMS for this to work.

  • subject The subject field is used to denote subject of the MMS message and has a maximum size of 64 characters long. Specifying a subject is optional.

  • source_number_type If a source number is specified, the type of source number may also be specified. This is recommended when using a source address type that is not an internationally formatted number, available options are INTERNATIONAL, ALPHANUMERIC or SHORTCODE. Specifying a source number type is only valid when the source_number parameter is specified and is optional. If a source number is specified and no source number type is specified, the source number type will be inferred from the source number, however this may be inaccurate.

  • scheduled A message can be scheduled for delivery in the future by setting the scheduled property. The scheduled property expects a date time specified in ISO 8601 format. The scheduled time must be provided in UTC and is optional. If no scheduled property is set, the message will be delivered immediately.

  • message_expiry_timestamp A message expiry timestamp can be provided to specify the latest time at which the message should be delivered. If the message cannot be delivered before the specified message expiry timestamp elapses, the message will be discarded. Specifying a message expiry timestamp is optional.

  • metadata Metadata can be included with the message which will then be included with any delivery reports or replies matched to the message. This can be used to create powerful two-way messaging applications without having to store persistent data in the application. Up to 10 key / value metadata data pairs can be specified in a message. Each key can be up to 100 characters long, and each value up to 256 characters long. Specifying metadata for a message is optional.

The response body of a successful POST request to the messages endpoint will include a messages property which contains a list of all messages submitted. The list of messages submitted will reflect the list of messages included in the request, but each message will also contain two new properties, message_id and status. The returned message ID will be a 36 character UUID which can be used to check the status of the message via the Get Message Status endpoint. The status of the message which reflect the status of the message at submission time which will always be queued. See the Delivery Reports section of this documentation for more information on message statues.

Note: when sending multiple messages in a request, all messages must be valid for the request to be successful. If any messages in the request are invalid, no messages will be sent.

function sendMessages(body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | body | Required | TODO: Add a parameter description |

Example Usage


    var body = new Sendmessagesrequest({"messages":[{"callback_url":"https://my.callback.url.com","content":"My first message","destination_number":"+61491570156","delivery_report":true,"format":"SMS","message_expiry_timestamp":"2016-11-03T11:49:02.807Z","metadata":{"key1":"value1","key2":"value2"},"scheduled":"2016-11-03T11:49:02.807Z","source_number":"+61491570157","source_number_type":"INTERNATIONAL"},{"callback_url":"https://my.callback.url.com","content":"My second message","destination_number":"+61491570158","delivery_report":true,"format":"MMS","subject":"This is an MMS message","media":["https://images.pexels.com/photos/1018350/pexels-photo-1018350.jpeg?cs=srgb&dl=architecture-buildings-city-1018350.jpg"],"message_expiry_timestamp":"2016-11-03T11:49:02.807Z","metadata":{"key1":"value1","key2":"value2"},"scheduled":"2016-11-03T11:49:02.807Z","source_number":"+61491570159","source_number_type":"INTERNATIONAL"}]});

    controller.sendMessages(body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Unexpected error in API call. See HTTP response body for details. | | 403 | Unauthorised |

Back to List of Controllers

Class: DeliveryReportsController

Get singleton instance

The singleton instance of the DeliveryReportsController class can be accessed from the API Client.

var controller = lib.DeliveryReportsController;

Method: checkDeliveryReports

Check for any delivery reports that have been received. Delivery reports are a notification of the change in status of a message as it is being processed. Each request to the check delivery reports endpoint will return any delivery reports received that have not yet been confirmed using the confirm delivery reports endpoint. A response from the check delivery reports endpoint will have the following structure:

{
    "delivery_reports": [
        {
            "callback_url": "https://my.callback.url.com",
            "delivery_report_id": "01e1fa0a-6e27-4945-9cdb-18644b4de043",
            "source_number": "+61491570157",
            "date_received": "2017-05-20T06:30:37.642Z",
            "status": "enroute",
            "delay": 0,
            "submitted_date": "2017-05-20T06:30:37.639Z",
            "original_text": "My first message!",
            "message_id": "d781dcab-d9d8-4fb2-9e03-872f07ae94ba",
            "vendor_account_id": {
                "vendor_id": "MessageMedia",
                "account_id": "MyAccount"
            },
            "metadata": {
                "key1": "value1",
                "key2": "value2"
            }
        },
        {
            "callback_url": "https://my.callback.url.com",
            "delivery_report_id": "0edf9022-7ccc-43e6-acab-480e93e98c1b",
            "source_number": "+61491570158",
            "date_received": "2017-05-21T01:46:42.579Z",
            "status": "enroute",
            "delay": 0,
            "submitted_date": "2017-05-21T01:46:42.574Z",
            "original_text": "My second message!",
            "message_id": "fbb3b3f5-b702-4d8b-ab44-65b2ee39a281",
            "vendor_account_id": {
                "vendor_id": "MessageMedia",
                "account_id": "MyAccount"
            },
            "metadata": {
                "key1": "value1",
                "key2": "value2"
            }
        }
    ]
}

Each delivery report will contain details about the message, including any metadata specified and the new status of the message (as each delivery report indicates a change in status of a message) and the timestamp at which the status changed. Every delivery report will have a unique delivery report ID for use with the confirm delivery reports endpoint. Note: The source number and destination number properties in a delivery report are the inverse of those specified in the message that the delivery report relates to. The source number of the delivery report is the destination number of the original message. Subsequent requests to the check delivery reports endpoint will return the same delivery reports and a maximum of 100 delivery reports will be returned in each request. Applications should use the confirm delivery reports endpoint in the following pattern so that delivery reports that have been processed are no longer returned in subsequent check delivery reports requests.

  1. Call check delivery reports endpoint
  2. Process each delivery report
  3. Confirm all processed delivery reports using the confirm delivery reports endpoint Note: It is recommended to use the Webhooks feature to receive reply messages rather than polling the check delivery reports endpoint.
function checkDeliveryReports(callback)

Example Usage



    controller.checkDeliveryReports(function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unauthorised | | 404 | Resource not found |

Method: confirmDeliveryReportsAsReceived

Mark a delivery report as confirmed so it is no longer return in check delivery reports requests. The confirm delivery reports endpoint is intended to be used in conjunction with the check delivery reports endpoint to allow for robust processing of delivery reports. Once one or more delivery reports have been processed, they can then be confirmed using the confirm delivery reports endpoint so they are no longer returned in subsequent check delivery reports requests. The confirm delivery reports endpoint takes a list of delivery report IDs as follows:

{
    "delivery_report_ids": [
        "011dcead-6988-4ad6-a1c7-6b6c68ea628d",
        "3487b3fa-6586-4979-a233-2d1b095c7718",
        "ba28e94b-c83d-4759-98e7-ff9c7edb87a1"
    ]
}

Up to 100 delivery reports can be confirmed in a single confirm delivery reports request.

function confirmDeliveryReportsAsReceived(body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | body | Required | Delivery reports to confirm as received. |

Example Usage


    var body = new Confirmeliveryreportsasreceivedrequest({"delivery_report_ids":["011dcead-6988-4ad6-a1c7-6b6c68ea628d","3487b3fa-6586-4979-a233-2d1b095c7718","ba28e94b-c83d-4759-98e7-ff9c7edb87a1"]});

    controller.confirmDeliveryReportsAsReceived(body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad request | | 403 | Unauthorised | | 404 | Resource not found |

Back to List of Controllers

Class: RepliesController

Get singleton instance

The singleton instance of the RepliesController class can be accessed from the API Client.

var controller = lib.RepliesController;

Method: checkReplies

Check for any replies that have been received. Replies are messages that have been sent from a handset in response to a message sent by an application or messages that have been sent from a handset to a inbound number associated with an account, known as a dedicated inbound number (contact [email protected] for more information on dedicated inbound numbers). Each request to the check replies endpoint will return any replies received that have not yet been confirmed using the confirm replies endpoint. A response from the check replies endpoint will have the following structure:

{
    "replies": [
        {
            "metadata": {
                "key1": "value1",
                "key2": "value2"
            },
            "message_id": "877c19ef-fa2e-4cec-827a-e1df9b5509f7",
            "reply_id": "a175e797-2b54-468b-9850-41a3eab32f74",
            "date_received": "2016-12-07T08:43:00.850Z",
            "callback_url": "https://my.callback.url.com",
            "destination_number": "+61491570156",
            "source_number": "+61491570157",
            "vendor_account_id": {
                "vendor_id": "MessageMedia",
                "account_id": "MyAccount"
            },
            "content": "My first reply!"
        },
        {
            "metadata": {
                "key1": "value1",
                "key2": "value2"
            },
            "message_id": "8f2f5927-2e16-4f1c-bd43-47dbe2a77ae4",
            "reply_id": "3d8d53d8-01d3-45dd-8cfa-4dfc81600f7f",
            "date_received": "2016-12-07T08:43:00.850Z",
            "callback_url": "https://my.callback.url.com",
            "destination_number": "+61491570157",
            "source_number": "+61491570158",
            "vendor_account_id": {
                "vendor_id": "MessageMedia",
                "account_id": "MyAccount"
            },
            "content": "My second reply!"
        }
    ]
}

Each reply will contain details about the reply message, as well as details of the message the reply was sent in response to, including any metadata specified. Every reply will have a reply ID to be used with the confirm replies endpoint. Note: The source number and destination number properties in a reply are the inverse of those specified in the message the reply is in response to. The source number of the reply message is the same as the destination number of the original message, and the destination number of the reply message is the same as the source number of the original message. If a source number wasn't specified in the original message, then the destination number property will not be present in the reply message. Subsequent requests to the check replies endpoint will return the same reply messages and a maximum of 100 replies will be returned in each request. Applications should use the confirm replies endpoint in the following pattern so that replies that have been processed are no longer returned in subsequent check replies requests.

  1. Call check replies endpoint
  2. Process each reply message
  3. Confirm all processed reply messages using the confirm replies endpoint Note: It is recommended to use the Webhooks feature to receive reply messages rather than polling the check replies endpoint.
function checkReplies(callback)

Example Usage



    controller.checkReplies(function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unauthorised | | 404 | Resource not found |

Method: confirmRepliesAsReceived

Mark a reply message as confirmed so it is no longer returned in check replies requests. The confirm replies endpoint is intended to be used in conjunction with the check replies endpoint to allow for robust processing of reply messages. Once one or more reply messages have been processed they can then be confirmed using the confirm replies endpoint so they are no longer returned in subsequent check replies requests. The confirm replies endpoint takes a list of reply IDs as follows:

{
    "reply_ids": [
        "011dcead-6988-4ad6-a1c7-6b6c68ea628d",
        "3487b3fa-6586-4979-a233-2d1b095c7718",
        "ba28e94b-c83d-4759-98e7-ff9c7edb87a1"
    ]
}

Up to 100 replies can be confirmed in a single confirm replies request.

function confirmRepliesAsReceived(body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | body | Required | TODO: Add a parameter description |

Example Usage


    var body = new Confirmrepliesasreceivedrequest({"reply_ids":["011dcead-6988-4ad6-a1c7-6b6c68ea628d","3487b3fa-6586-4979-a233-2d1b095c7718","ba28e94b-c83d-4759-98e7-ff9c7edb87a1"]});

    controller.confirmRepliesAsReceived(body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad request | | 403 | Unauthorised | | 404 | Resource not found |

Back to List of Controllers

Class: LookupsController

Get singleton instance

The singleton instance of the LookupsController class can be accessed from the API Client.

var controller = lib.LookupsController;

Method: lookupAPhoneNumber

Use the Lookups API to find information about a phone number.

A request to the lookups API has the following format:

/v1/lookups/phone/{phone_number}?options={x}

where {x} is an individual value or a combination of values.

The {phone_number} parameter is a required field and should be set to the phone number to be looked up.

The options query parameter can also be used to request additional information about the phone number.

By default, a request will only return the country_code and phone_number properties in the response.

{  "country_code": "AU", "phone_number": "+61491570156"}

To request details about the the carrier, include carrier as a value of the options parameter and to request details about the type, include type as a value of the options parameter. The carrier and the type values can be used together using a comma separated list, i.e. carrier,type.

To request details about the location, include hlr as a value of the options parameter.

NOTE: The hlr value CANNOT be used in conjuction with the other values.

A successful request to the lookups endpoint with carrier and type as values will

return a response body as follows:

{  
  "country_code": "AU",
  "phone_number": "+61491570156",
  "type": "mobile",  "carrier": {"name": "Telstra"  }
}

A successful request to the lookups endpoint with hlr as the value will return a response body as follows:

{"result": "OK",    "imsi": 24008,    "location": 46}

Each property in the response body is defined as follows:- country_code ISO ALPHA 2 country code of the phone number

  • phone_number E.164 formatted phone number
  • type The type of number. This can be "mobile" or "landline"
  • carrier Holds information about the specific carrier (if available)
  • name The carrier's name as reported by the network
  • imsi A unique number identifying a GSM subscriber
  • location The location of the mobile number"
function lookupAPhoneNumber(phoneNumber, options, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | phoneNumber | Required | The phone number to be looked up | | options | Optional | The options query parameter can also be used to request additional information about the phone number. |

Example Usage


    var phoneNumber = phone_number;
    var options = 'options';

    controller.lookupAPhoneNumber(phoneNumber, options, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad request | | 403 | Unauthorised | | 404 | Resource not found |

Back to List of Controllers

Class: NumberAuthorisationController

Get singleton instance

The singleton instance of the NumberAuthorisationController class can be accessed from the API Client.

var controller = lib.NumberAuthorisationController;

Method: listAllBlockedNumbers

This endpoint returns a list of 100 numbers that are on the blacklist. There is a pagination token to retrieve the next 100 numbers

In the example response the numbers +61491570156 and +61491570157 are on the blacklist and therefore will never receive any messages from you.

function listAllBlockedNumbers(callback)

Example Usage



    controller.listAllBlockedNumbers(function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unauthorised |

Method: addOneOrMoreNumbersToYourBacklist

This endpoint allows you to add one or more numbers to your blacklist. You can add up to 10 numbers in one request. NOTE: numbers need to be in international format and therefore start with a +

function addOneOrMoreNumbersToYourBacklist(body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | body | Required | TODO: Add a parameter description |

Example Usage


    var body = new Addoneormorenumberstoyourbacklistrequest({"key":"value"});

    controller.addOneOrMoreNumbersToYourBacklist(body, function(error, response, context) {

    
    });

Method: removeANumberFromTheBlacklist

This endpoint allows you to remove a number from the blacklist. Only one number can be deleted per request. In the example +61491570157 will be removed from the blacklist. NOTE: numbers need to be in international format and therefore start with a +

function removeANumberFromTheBlacklist(number, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | number | Required | a number in international format e.g. +61491570156 |

Example Usage


    var number = 'number';

    controller.removeANumberFromTheBlacklist(number, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 404 | TODO: Add an error description |

Method: checkIfOneOrSeveralNumbersAreCurrentlyBlacklisted

This endpoints lists for each requested number if you are authorised (which means the number is not blacklisted) to send to this number. In the example given +61491570157 is on the blacklist. NOTE: We do this call for you internally no matter what. Use this endpoint only if you want to have some indication upfront. If you send a message which is on the blacklist, we issue a delivery receipt with the appropriate status code.

function checkIfOneOrSeveralNumbersAreCurrentlyBlacklisted(numbers, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | numbers | Required Collection | one or more numbers in international format seperate by a comma, e.g. +61491570156,+61491570157 |

Example Usage


    var numbers = ['numbers'];

    controller.checkIfOneOrSeveralNumbersAreCurrentlyBlacklisted(numbers, function(error, response, context) {

    
    });

Back to List of Controllers

Class: DedicatedNumbersController

Get singleton instance

The singleton instance of the DedicatedNumbersController class can be accessed from the API Client.

var controller = lib.DedicatedNumbersController;

Method: getNumbers

Get a list of available dedicated numbers, filtered by requirements.

function getNumbers(country, matching, pageSize, serviceTypes, token, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | country | Optional | ISO_3166 country code, 2 character code to filter available numbers by country | | matching | Optional | filters results by a pattern of digits contained within the number | | pageSize | Optional | number of results returned per page, default 50 | | serviceTypes | Optional | filter results to include numbers with certain capabilities | | token | Optional | In paginated data the original request will return with a "next_token" attribute. This token must be entered into subsequent call in the "token" query parameter to obtain the next set of records. |

Example Usage


    var country = 'AU';
    var matching = '223344';
    var pageSize = 3;
    var serviceTypes = new ServiceTypesEnum(SMS);
    var token = 'example';

    controller.getNumbers(country, matching, pageSize, serviceTypes, token, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unexpected error in API call. See HTTP response body for details. |

Method: getNumberById

Get details about a specific dedicated number.

function getNumberById(id, accept, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | id | Required | unique identifier | | accept | Required | TODO: Add a parameter description |

Example Usage


    var id = 'id';
    var accept = 'Accept';

    controller.getNumberById(id, accept, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unexpected error in API call. See HTTP response body for details. | | 404 | Unexpected error in API call. See HTTP response body for details. |

Method: getAssignment

Use this endpoint to view details of the assignment including the label and metadata.

function getAssignment(numberId, accept, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | numberId | Required | unique identifier | | accept | Required | TODO: Add a parameter description |

Example Usage


    var numberId = 'e2014bc7-5fed-4e27-bd8c-XXXXXXXXXXX';
    var accept = 'application/json;charset=UTF-8';

    controller.getAssignment(numberId, accept, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unexpected error in API call. See HTTP response body for details. | | 404 | Unexpected error in API call. See HTTP response body for details. |

Method: createAssignment

Assign the specified number to the authenticated account. Use the body of the request to specify a label or metadata for this number assignment.

If you receive a conflict error then the number that you have selected is unavailable for assignment. This means that the number is either already assigned to another account, or has an available_after date in the future. Should this occur, perform another search and select a different number.

function createAssignment(numberId, accept, body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | numberId | Required | unique identifier | | accept | Required | TODO: Add a parameter description | | body | Required | TODO: Add a parameter description |

Example Usage


    var numberId = 'e2014bc7-5fed-4e27-bd8c-XXXXXXXXXXX';
    var accept = 'application/json;charset=UTF-8';
    var body = new CreateAssignmentrequest({"label":"ExampleLabel","metadata":{"Key1":"value1","Key2":"value2"}});

    controller.createAssignment(numberId, accept, body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unexpected error in API call. See HTTP response body for details. | | 404 | Unexpected error in API call. See HTTP response body for details. |

Method: deleteAssignment

Release the dedicated number from your account.

function deleteAssignment(numberId, accept, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | numberId | Required | unique identifier | | accept | Required | TODO: Add a parameter description |

Example Usage


    var numberId = 'e2014bc7-5fed-4e27-bd8c-XXXXXXXXXXX';
    var accept = 'application/json;charset=UTF-8';

    TestHelper.getFileContents(, function(data) {
        controller.deleteAssignment(numberId, accept, function(error, response, context) {

        });
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unexpected error in API call. See HTTP response body for details. |

Method: updateAssignment

Retain the dedicated number assignment, and edit or add additional metadata or title information. You can exclude any data from the body of this request that you do not want updated.

function updateAssignment(numberId, accept, body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | numberId | Required | unique identifier | | accept | Required | TODO: Add a parameter description | | body | Required | TODO: Add a parameter description |

Example Usage


    var numberId = 'e2014bc7-5fed-4e27-bd8c-XXXXXXXXXXX';
    var accept = 'application/json;charset=UTF-8';
    var body = new UpdateAssignmentrequest({"label":"ExampleLabel","metadata":{"Key1":"value1","Key2":"value2"}});

    controller.updateAssignment(numberId, accept, body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unexpected error in API call. See HTTP response body for details. |

Method: getAssignedNumbers

Get assigned numbers

function getAssignedNumbers(accept, pageSize, token, numberId, matching, country, type, classification, serviceTypes, label, sortBy, sortDirection, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | accept | Required | TODO: Add a parameter description | | pageSize | Optional | Number of results returned per page, default 50 | | token | Optional | In paginated data the original request will return with a "next_token" attribute. This token must be entered into subsequent call in the "token" query parameter to obtain the next set of records. | | numberId | Optional | Unique identifier of a specific number | | matching | Optional | Filters results by a pattern of digits contained within the number | | country | Optional | Filter results by ISO_3166 country code, 2 character code to filter available numbers by country | | type | Optional | Filter results by Number type | | classification | Optional | Filter results by Number Classification | | serviceTypes | Optional | Filter results by capabilities | | label | Optional | Filter results by a matching label | | sortBy | Optional | Sort results by property | | sortDirection | Optional | Sort direction |

Example Usage


    var accept = 'Accept';
    var pageSize = 35;
    var token = 'token';
    var numberId = number_id;
    var matching = 'matching';
    var country = 'country';
    var type = Object.keys(Type1)[0];
    var classification = Object.keys(Classification)[0];
    var serviceTypes = Object.keys(service_types)[0];
    var label = 'label';
    var sortBy = Object.keys(sort_by)[0];
    var sortDirection = Object.keys(sort_direction)[0];

    controller.getAssignedNumbers(accept, pageSize, token, numberId, matching, country, type, classification, serviceTypes, label, sortBy, sortDirection, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 403 | Unauthorised |

Back to List of Controllers

Class: MessagingReportsController

Get singleton instance

The singleton instance of the MessagingReportsController class can be accessed from the API Client.

var controller = lib.MessagingReportsController;

Method: getMetadataKeys

Returns a list of metadata keys

function getMetadataKeys(messageType, startDate, endDate, accounts, timezone, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | messageType | Required | Message type. Possible values are sent messages and received messages. | | startDate | Required | Start date time for report window. By default, the timezone for this parameter will be taken from the account settings for the account associated with the credentials used to make the request, or the account included in the Account parameter. This can be overridden using the timezone parameter per request. The date must be in ISO8601 format | | endDate | Required | End date time for report window. By default, the timezone for this parameter will be taken from the account settings for the account associated with the credentials used to make the request, or the account included in the Account parameter. This can be overridden using the timezone parameter per request. The date must be in ISO8601 format | | accounts | Optional Collection | Filter results by a specific account. By default results

will be returned for the account associated with the authentication

credentials and all sub accounts. | | timezone | Optional | The timezone to use for the context of the request. If provided this will be used as the timezone for the start date and end date parameters, and all datetime fields returns in the response. The timezone should be provided as a IANA (Internet Assigned Numbers Authority) time zone database zone name, i.e., 'Australia/Melbourne'. |

Example Usage


    var messageType = new MessageTypeEnum(SENT_MESSAGES);
    var startDate = 2017-02-10T13:30:00.000Z;
    var endDate = 2017-02-12T13:30:00.000Z;
    var accounts = ['accounts'];
    var timezone = 'timezone';

    controller.getMetadataKeys(messageType, startDate, endDate, accounts, timezone, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad Request. Check the json response for more details on what went wrong. |

Method: getAsyncReports

Lists asynchronous reports.

function getAsyncReports(page, pageSize, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | page | Optional | Page number for paging through paginated result sets. | | pageSize | Optional | Number of results to return in a page for paginated result sets. |

Example Usage


    var page = 35.3608707410101;
    var pageSize = 35.3608707410101;

    controller.getAsyncReports(page, pageSize, function(error, response, context) {

    
    });

Method: getAsyncReportById

Gets a single asynchronous report.

function getAsyncReportById(reportId, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | reportId | Required | Unique ID of the async report |

Example Usage


    var reportId = report_id;

    controller.getAsyncReportById(reportId, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad Request. Check the json response for more details on what went wrong. | | 404 | The requested report was not found. |

Method: getAsyncReportDataById

Gets the data of an asynchronous report.

function getAsyncReportDataById(reportId, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | reportId | Required | Unique ID of the async report |

Example Usage


    var reportId = report_id;

    controller.getAsyncReportDataById(reportId, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad Request. Check the json response for more details on what went wrong. | | 404 | Report not found or not finished. |

Method: submitReceivedMessagesDetail

Submits a request to generate an async detail report

function submitReceivedMessagesDetail(body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | body | Required | TODO: Add a parameter description |

Example Usage


    var body = new Asyncreceivedmessagesdetailrequest({"end_date":"2017-02-10T13:30:00.000Z","start_date":"2017-02-12T13:30:00.000Z","period":"TODAY","sort_by":"ACCOUNT","sort_direction":"ASCENDING","timezone":"Australia/Melbourne","accounts":[],"delivery_options":[{"delivery_type":"EMAIL","delivery_addresses":[],"delivery_format":"CSV"}]});

    controller.submitReceivedMessagesDetail(body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad Request. Check the json response for more details on what went wrong. |

Method: getReceivedMessagesDetail

Returns a list message received

function getReceivedMessagesDetail(endDate, startDate, accounts, action, destinationAddressCountry, destinationAddress, messageFormat, metadataKey, metadataValue, page, pageSize, sortBy, sortDirection, sourceAddressCountry, sourceAddress, timezone, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | endDate | Required | End date time for report window. By default, the timezone for this parameter will be taken from the account settings for the account associated with the credentials used to make the request, or the account included in the Account parameter. This can be overridden using the timezone parameter per request. The date must be in ISO8601 format. | | startDate | Required | Start date time for report window. By default, the timezone for this parameter will be taken from the account settings for the account associated with the credentials used to make the request, or the account included in the Account parameter. This can be overridden using the timezone parameter per request. The date must be in ISO8601 format. | | accounts | Optional Collection | Filter results by a specific account. By default results

will be returned for the account associated with the authentication

credentials and all sub accounts. | | action | Optional | Filter results by the action that was invoked for this message. | | destinationAddressCountry | Optional | Filter results by destination address country. | | destinationAddress | Optional | Filter results by destination address. | | messageFormat | Optional | Filter results by message format. | | metadataKey | Optional | Filter results for messages that include a metadata key. | | metadataValue | Optional | Filter results for messages that include a metadata key containing this value. If this parameter is provided, the metadata_key parameter must also be provided. | | page | Optional | Page number for paging through paginated result sets. | | pageSize | Optional | Number of results to return in a page for paginated result sets. | | sortBy | Optional | Field to sort results set by | | sortDirection | Optional | Order to sort results by. | | sourceAddressCountry | Optional | Filter results by source address country. | | sourceAddress | Optional | Filter results by source address. | | timezone | Optional | The timezone to use for the context of the request. If provided this will be used as the timezone for the start date and end date parameters, and all datetime fields returns in the response. The timezone should be provided as a IANA (Internet Assigned Numbers Authority) time zone database zone name, i.e., 'Australia/Melbourne'. |

Example Usage


    var endDate = end_date;
    var startDate = start_date;
    var accounts = ['accounts'];
    var action = Object.keys(action)[0];
    var destinationAddressCountry = destination_address_country;
    var destinationAddress = destination_address;
    var messageFormat = Object.keys(format1)[0];
    var metadataKey = metadata_key;
    var metadataValue = metadata_value;
    var page = 35.3608707410101;
    var pageSize = 35.3608707410101;
    var sortBy = Object.keys(sort_by)[0];
    var sortDirection = Object.keys(sort_direction)[0];
    var sourceAddressCountry = source_address_country;
    var sourceAddress = source_address;
    var timezone = 'timezone';

    controller.getReceivedMessagesDetail(endDate, startDate, accounts, action, destinationAddressCountry, destinationAddress, messageFormat, metadataKey, metadataValue, page, pageSize, sortBy, sortDirection, sourceAddressCountry, sourceAddress, timezone, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad Request. Check the json response for more details on what went wrong. |

Method: submitSentMessagesDetail

Submits a request to generate an async detail report

function submitSentMessagesDetail(body, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | body | Required | TODO: Add a parameter description |

Example Usage


    var body = new Asyncsentmessagesdetailrequest({"key":"value"});

    controller.submitSentMessagesDetail(body, function(error, response, context) {

    
    });

Errors

| Error Code | Error Description | |------------|-------------------| | 400 | Bad Request. Check the json response for more details on what went wrong. |

Method: getSentMessagesDetail

Returns a list of message sent

function getSentMessagesDetail(endDate, startDate, accounts, deliveryReport, destinationAddressCountry, destinationAddress, messageFormat, metadataKey, metadataValue, statusCode, status, statuses, page, pageSize, sortBy, sortDirection, sourceAddressCountry, sourceAddress, timezone, callback)

Parameters

| Parameter | Tags | Description | |-----------|------|-------------| | endDate | Required | End date time for report window. By default, the timezone for this parameter will be taken from the account settings for the account associated with the credentials used to make the request, or the account included in the Account parameter. This can be overridden using the timezone parameter per request. The date must be in ISO8601 format. | | startDate | Required | Start date time for report window. By default, the timezone for this parameter will be taken from the account settings for the account associated with the credentials used to make the request, or the account included in the Account parameter. This can be overridden using the timezone parameter per request. The date must be in ISO8601 format. | | accounts | Optional Collection | Filter results by a specific account. By default results

will be returned for the account associated with the authentication

credentials and all sub accounts. | | deliveryReport | Optional | Filter results by delivery report. | | destinationAddressCountry | Optional | Filter results by destination address country. | | destinationAddress | Optional | Filter results by destination address. | | messageFormat | Optional | Filter results by message format. | | metadataKey | Optional | Filter results for messages that include a metadata key. | | metadataValue | Optional | Filter results for messages that include a metadata key containing this value. If this parameter is provided, the metadata_key parameter must also be provided. | | statusCode | Optional | Filter results by message status code. | | status | Optional | Filter results by message status. Can't be combined with statuses. | | statuses | Optional | Filter results by message status. Can't be combined with status.{array} | | page | Optional | Page number for paging through paginated result sets. | | pageSize | Optional | Number of results to return in a page for paginated result sets. | | sortBy | Optional | Field to sort results set by | | sortDirection | Optional | Order to sort results by. | | sourceAddressCountry | Optional | Filter results by source address country. | | sourceAddress | Optional | Filter results by source address. | | timezone | Optional | The timezone to use for the context of the request. If provided this will be used as the timezone for the start date and end date parameters, and all datetime fields returns in the response. The timezone should be provided as a IANA (Internet Assigned Numbers Authority) time zone database zone name, i.e., 'Australia/Melbourne'. |

Example Usage


    var endDate = end_date;
    var startDate = start_date;
    var accounts = ['accounts'];
    var deliveryReport = false;
    var destinationAddressCountry = destination_address_country;
    var destinationAddress = destination_address;
    var messageFormat = Object.keys(format1)[0];
    var metadataKey = metadata_key;
    var metadataValue = metadata_value;
    var statusCode = status_code;
    var status = Object.keys(status1)[0];
    var statuses = Object.keys(statuses)[0];
    var page = 35.3608707410101;
    var pageSize = 35.3608707410101;
    var sortBy = Object.keys(sort_by)[0];
    var sortDirection = Object.keys(sort_direction)[0];
    var sourceAddressCountry = source_address_country;
    var sourceAddress = source_address;
    var timezone = 'timezone';

    controller.getSentMessagesDetail(endDate, startDate, accounts, deliveryReport, destinationAddressCountry, destinationAddress, messageFormat, metadataKey, metadataValue, statusCode, status, statuses, page, pageSize, sortBy, sortDirectio