The Flowroute .NET API Wrapper provides methods for interacting with Number Management v1 and Messaging v2 of the Flowroute API.
Requirements
- Flowroute API credentials
- Visual Studio 2012 or later
- Choice between Microsoft .NET Framework 4.5 and Microsoft.NETCore.App 1.0.0 or higher
- Json.NET 9.0.1 or higher
- NETStandard.Library 1.6.1 or higher (if you choose .NetCore.App)
Installation
Use the Package Manager Console built into Visual Studio (2012 or later) to install the Flowroute .NET SDK.
Install-Package Flowroute
Initialization
Initialize a new instance of the Flowroute client as follows:
string AccessKey = "accessKey";
string SecretKey = "secretKey";
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
Credentials
Replace accessKey:secretKey with your API credentials from the Flowroute Manager.
Usage
The Flowroute .NET SDK uses asynchronous methods to avoid performance bottlenecks and enhance the overall responsiveness of the application. Read more about asynchronous programming here.
Numbers SDK (v1)
View RepoNumber Management
After you have created an instance of the Flowroute client, you will have access to the PhoneNumbers client. This client provides the following methods:
-
Purchasable Phone Numbers
Contains all of the methods necessary to search through Flowroute's phone number inventory.
- ListAvailableNPAsAsync() - Retrieve available phone numbers (NPAs)
- RetrieveAvailableNPANetworkNumberingExchangesAsync() - Retrieve a list of area codes and exchanges (NPA NXXs)
- SearchAsync() - Search for purchasable phone numbers
-
Telephone Numbers
Contains all of the methods necessary to purchase a new phone number and manage your owned phone number inventory.
- PurchasePhoneNumber() - Purchase phone numbers
- ListTelephoneNumbers() - View the phone numbers you own
- ListTelephoneNumberDetails() - View details of the phone numbers you own
- UpdateTelephoneNumberRoutes() - Update the primary and failover route on a phone number
-
Inbound Rooutes
Contains the methods required to create new routes and view your current routes.
- ListInboundRoutes() - List existing inbound routes from your account
- CreateInboundRoute() - Create a new inbound route that can then be assigned as either a primary or failover route for a phone number
Methods
ListAvailableNPAsAsync()
The method accepts the limit and page parameters which you can learn more about in the API reference. The following example limits the number of NPAs returned to 2:
#List Available NPAs
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListAvailableNPAsAsync(2);
Example Response
{
"npas": {
"201": {
"nxxs": "/v1/available-tns/npanxxs/?npa=201",
"tns": "/v1/available-tns/tns/?npa=201"
},
"202": {
"nxxs": "/v1/available-tns/npanxxs/?npa=202",
"tns": "/v1/available-tns/tns/?npa=202"
}
},
"links": {
"next": "/v1/available-tns/npas/?limit=2&page=2"
}
}
RetrieveAvailableNPANetworkNumberingExchangesAsync()
The method accepts the limit, npa, and page parameters which you can learn more about in the API reference. The following example restricts the npa to 757:
#List NPA and NXX
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.RetrieveAvailableNPANetworkNumberingExchangesAsync(757);
Example Response
Results are returned in numerical order, starting with the lowest NPA number. The npaxxs parameter variable is formatted as a combination of the NPA and NXX. In the following example, 757258 is the combination of NPA 757 and NXX 258.
{
"npanxxs": {
"757258": {
"tns": "/v1/available-tns/tns/?npa=757"
},
"757238": {
"tns": "/v1/available-tns/tns/?npa=757"
}
},
"links": {
"next": "/v1/available-tns/npanxxs/?npa=757&page=2",
}
}
SearchAsync()
The search() method is the most robust option for searching through Flowroute's purchasable phone number inventory. It allows you to search by NPA, NXX, Ratecenter, State, and/or TN (telephone number). The method accepts the limit, npa, nxx, and page parameters which you can learn more about in the API reference.
In the following example, a search request sets the npa to 757, the ratecenter to "SEATTLE", and the state to "WA".
#Search
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.SearchAsync(new FlowroutePhoneNumberSearchCriteria() { NPA = 757 });
var results = await client.PhoneNumbers.SearchAsync(new FlowroutePhoneNumberSearchCriteria() { RateCenter = "SEATTLE", State = "WA" });
Example Response
{
"links": {
"next": "/v1/available-tns/tns/?npa=757&state=WA&ratecenter=SEATTLE"
},
"tns": {
"17576439178": {
"initial_cost": "1.00",
"monthly_cost": "1.25",
"state": "WA",
"ratecenter": "SEATTLE",
"billing_methods": [
"METERED"
]
}
}
}
PurchasePhoneNumber()
The purchase() method is used to purchase a telephone number from Flowroute's inventory. The method accepts the telephone_number parameter which you can learn more about in the API reference.
#Purchase a Telephone Number
var goodPhoneNumber = "17575555555";
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.PurchasePhoneNumberAsync(goodPhoneNumber);
Example Response
For a successful purchase, the API returns an empty line. No other success message is displayed.
201 Created
{ }
ListTelephoneNumbers()
The method accepts the limit, page, and pattern parameters which you can learn more about in the API reference.
#List Account Telephone Numbers
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListTelephoneNumbersAsync();
ListTelephoneNumberDetails()
The method accepts the telephone_number parameter which you can learn more about in the API reference. In the following example, details are requested for the telephone number just purchased using the purchase method.
#Telephone Number Details
var goodPhoneNumber = "17575555555";
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListTelephoneNumberDetailsAsync(goodPhoneNumber);
UpdateTelephoneNumberRoutes()
The method accepts the routes and telephone_number parameters which you can learn more about in the API reference.
#Update Telephone Number Routes
var goodPhoneNumber = "17575555555";
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.UpdateTelephoneNumberRoutesAsync(goodPhoneNumber,
new FlowrouteRoute() { Name = "Primary1" },
new FlowrouteRoute() { Name = "Primary2" });
ListInboundRoutes()
The method accepts the limit and page parameters which you can learn more about in the API reference.
#List Routes
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.ListInboundRoutesAsync();
createNewRoute()
The method accepts the route_name, type, and value parameters which you can learn more about in the API reference.
You can pass as many createNewRoute methods in a single operation. The following example creates a new HOST route:
#Create a New Route
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var results = await client.PhoneNumbers.CreateInboundRouteAsync("TestRoute", InboundRouteType.HOST, "example.com");
Example Response
An empty string ('') is returned for each successfully created route; no other code or message is returned. An error encountered for a specific irc->createNewRoute() line does not prevent the other routes from being created.
' '
Messaging SDK (v2)
View RepoMessaging
After you have created an instance of the Flowroute client, you will have access to the Messaging client. This client provides the following methods:
- SendMessageAsync() - Send outbound messages from a SMS-enabled Flowroute number
- GetMessageDetailsAsync() - Retrieve a message detail record (MDR) based on a specific record ID
Methods
SendMessageAsync()
The method accepts the msg, to, from, and body parameters which you can learn more about in the API reference.
#Create and send the message
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var response = await client.Messaging.SendMessageAsync("17578675309", "17575555555", $"TestMessage");
GetMessageDetailsAsync()
The method accepts the record_id parameter which you can learn more about in the API reference.
#Get the MDR
FlowrouteClient client = new FlowrouteClient(AccessKey, SecretKey);
var response = await client.Messaging.GetMessageDetailsAsync('mdr1-fab29a740129404a8ca794efc1359e12');