### Run Example Scripts Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Navigate to the 'examples' directory in the source tree, copy 'config.js.example' to 'config.js', and edit it with your credentials. Then, run individual example scripts like 'coveredRateCenters-sample.js'. ```bash $ cd examples $ cp config.js.example config.js ``` ```bash node coveredRateCenters-sample.js ``` -------------------------------- ### Install @bandwidth/numbers Package Source: https://context7.com/bandwidth/node-numbers/llms.txt Install the Bandwidth Numbers client library using npm. ```bash npm install @bandwidth/numbers ``` -------------------------------- ### Client Authentication and Setup with @bandwidth/numbers Source: https://context7.com/bandwidth/node-numbers/llms.txt Configure the Bandwidth Numbers client using global options for Basic Auth or instantiate a client with explicit credentials. Supports OAuth2 with automatic token refresh. Examples show callback and async/await usage. ```javascript const numbers = require("@bandwidth/numbers"); // Option 1: Basic Auth via global options (call once at startup) numbers.Client.globalOptions.accountId = "12345678"; numbers.Client.globalOptions.userName = "myUser"; numbers.Client.globalOptions.password = "myPassword"; // Now all API objects use the global client automatically numbers.Site.list((err, sites) => { if (err) { console.error(err); return; } console.log(sites); // [ { id: '1', name: 'My Site', ... }, ... ] }); ``` ```javascript // Option 2: Per-call explicit client const client = new numbers.Client("12345678", "myUser", "myPassword"); numbers.Site.list(client, (err, sites) => console.log(sites)); ``` ```javascript // Option 3: OAuth2 client-credentials with auto token refresh const oauthClient = new numbers.Client( "12345678", // accountId null, // userName (unused for OAuth) null, // password (unused for OAuth) "myClientId", // clientId "myClientSecret" // clientSecret ); // Token is fetched automatically; call destroy() when done to clear timers // oauthClient.destroy(); ``` ```javascript // Option 4: Promise / async-await using the Async variant (async () => { const sites = await numbers.Site.listAsync(); console.log(sites); })(); ``` -------------------------------- ### Order Instance Methods Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Provides examples of various instance methods available on an order object, including getting area codes, adding notes, retrieving NPA-NXX data, getting totals, fetching TNs, and accessing history and notes. ```Javascript // get Area Codes order.getAreaCodes(callback); // add note to order var note = {userId: "my id", description: "Test"}; order.addNote(note,callback); //get Npa Nxxs order.getNpaNxx(callback); // get number totals order.getTotals(callback); // get all Tns for an order order.getTns(callback) // get order history order.getHistory(callback); // get order notes order.getNotes(callback); ``` -------------------------------- ### PortIn File Management Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Provides examples for managing files associated with a PortIn request. This includes adding, updating, retrieving, and getting metadata for files. Requires the `fs` module to be imported for creating read streams. ```Javascript numbers.PortIn.get("id", function(err, portIn){ // Add File portIn.createFile(fs.createReadStream("myFile.txt"), callback); // Update File portIn.updateFile("myFile.txt", fs.createReadStream("myFile.txt"), callback); // Get File portIn.getFile("myFile.txt", callback); // Get File Metadata portIn.getFileMetadata("myFile.txt", callback); // Get Files portIn.getFiles(callback); }); ``` -------------------------------- ### Get Account Products Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Use this to retrieve the products associated with the account. ```javascript console.log(await numbers.Account.getProductsAsync()); ``` -------------------------------- ### List Available Numbers (Async/Await) Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Example of listing available numbers using async/await. ```javascript //Async/await try { const availableNumbers = await numbers.AvailableNumbers.listAsync(query); console.log(availableNumbers); } catch (e) { console.log(e) } ``` -------------------------------- ### Get Account Products Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a list of products associated with the account. ```APIDOC ## Get Account Products ### Description Retrieves a list of products associated with the account. ### Method ```javascript console.log(await numbers.Account.getProductsAsync()); ``` ### Parameters This method does not require any parameters. ### Response Returns a list of account products. ``` -------------------------------- ### Order Instance Methods Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Provides access to various instance methods for an order object, such as getting area codes, adding notes, retrieving NPA-NXX data, getting totals, and accessing history. ```APIDOC ## Order Instance Methods ### Description Provides access to various instance methods for an order object. ### Methods - **getAreaCodes(callback)**: Retrieves the area codes for the order. - **addNote(note, callback)**: Adds a note to the order. `note` is an object with `userId` and `description`. - **getNpaNxx(callback)**: Retrieves NPA-NXX data for the order. - **getTotals(callback)**: Retrieves the totals for the order. - **getTns(callback)**: Retrieves all telephone numbers (TNs) for the order. - **getHistory(callback)**: Retrieves the history of the order. - **getNotes(callback)**: Retrieves the notes for the order. ### Request Example ```javascript // Assuming 'order' is an order object obtained via Order.get() // get Area Codes order.getAreaCodes(callback); // add note to order var note = {userId: "my id", description: "Test"}; order.addNote(note,callback); //get Npa Nxxs order.getNpaNxx(callback); // get number totals order.getTotals(callback); // get all Tns for an order order.getTns(callback) // get order history order.getHistory(callback); // get order notes order.getNotes(callback); ``` ``` -------------------------------- ### Client Authentication and Setup Source: https://context7.com/bandwidth/node-numbers/llms.txt Demonstrates how to initialize and authenticate the Bandwidth Numbers client using global options or explicit client instances, supporting both Basic Auth and OAuth2. ```APIDOC ## Client Authentication and Setup The `Client` class manages credentials and all HTTP communication. It supports Basic Auth or OAuth2 client-credentials, and exposes global options so a single configuration is shared across all API calls. ```js const numbers = require("@bandwidth/numbers"); // Option 1: Basic Auth via global options (call once at startup) numbers.Client.globalOptions.accountId = "12345678"; numbers.Client.globalOptions.userName = "myUser"; numbers.Client.globalOptions.password = "myPassword"; // Now all API objects use the global client automatically numbers.Site.list((err, sites) => { if (err) { console.error(err); return; } console.log(sites); // [ { id: '1', name: 'My Site', ... }, ... ] }); // Option 2: Per-call explicit client const client = new numbers.Client("12345678", "myUser", "myPassword"); numbers.Site.list(client, (err, sites) => console.log(sites)); // Option 3: OAuth2 client-credentials with auto token refresh const oauthClient = new numbers.Client( "12345678", // accountId null, // userName (unused for OAuth) null, // password (unused for OAuth) "myClientId", // clientId "myClientSecret" // clientSecret ); // Token is fetched automatically; call destroy() when done to clear timers // oauthClient.destroy(); // Option 4: Promise / async-await using the Async variant (async () => { const sites = await numbers.Site.listAsync(); console.log(sites); })(); ``` ``` -------------------------------- ### List Available Numbers (Callbacks) Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Example of listing available numbers using callbacks. ```javascript // Callbacks numbers.AvailableNumbers.list(query, (err, availableNumbers) => { if (err) { console.log(err); } else { console.log(availableNumbers); } }); ``` -------------------------------- ### List Available Numbers (Promise Chaining) Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Example of listing available numbers using promise chaining. ```javascript //Promise chaining numbers.AvailableNumbers.listAsync(query) .then(availableNumbers => { console.log(availableNumbers); }) .catch(e => { console.log(e); }); ``` -------------------------------- ### Get an Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves details for a specific application using its ID. ```APIDOC ## Get an Application ### Description Retrieves details for a specific application using its ID. ### Method numbers.Application.get(id, callback) ### Parameters - **id** (string) - Required - The unique identifier of the application. - **callback**: A function to handle the response or error. ``` -------------------------------- ### Get an Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Fetches a specific application by its unique ID. The `id` parameter is required. ```javascript numbers.Application.get(id, callback); ``` -------------------------------- ### Manage Bandwidth Sites (Sub-Accounts) Source: https://context7.com/bandwidth/node-numbers/llms.txt Create, update, list, and delete Bandwidth sites. Sites are top-level containers for SIP peers and phone numbers. Ensure the '@bandwidth/numbers' package is installed. ```javascript const numbers = require("@bandwidth/numbers"); // Create a site numbers.Site.create({ name: "Main Office", description: "Primary office location", address: { houseNumber: "900", streetName: "Main Campus", streetSuffix: "Dr", city: "Raleigh", stateCode: "NC", zip: "27606", addressType: "Service" } }, (err, site) => { console.log("Created site ID:", site.id); // Update the site site.update({ name: "HQ Office" }, (err) => console.log("Updated")); // List all SIP peers for this site site.getSipPeers((err, peers) => console.log(peers)); // Get in-service numbers site.getInserviceNumbers({ areaCode: "919" }, (err, numbers) => console.log(numbers)); // Delete the site site.delete((err) => console.log("Deleted")); }); // List all sites numbers.Site.list((err, sites) => { sites.forEach(s => console.log(s.id, s.name)); }); // Get a specific site by ID numbers.Site.get("1111", (err, site) => { site.getOrders({}, (err, orders) => console.log(orders)); site.getTotalTns({}, (err, total) => console.log(total)); }); ``` -------------------------------- ### Site SipPeer Methods Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Manage SIP peers associated with a site. Includes retrieving all SIP peers for a site, getting a specific SIP peer, and creating a new SIP peer within the site. ```javascript numbers.Site.get(id, function(err,site){ // get Sip Peers site.getSipPeers(callback); // get Sip Peer site.getSipPeer(id, callback); // create Sip Peer var sipPeer = {name:"SIP Peer"}; site.createSipPeer(sipPeer, callback); }); ``` -------------------------------- ### Update an Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Updates an existing application's details. First, retrieve the application using `get`, modify its properties, and then call the `update` method. ```javascript numbers.Application.get(id, (err, app) => { app.appName = "new name"; app.update(app, callback); }); ``` -------------------------------- ### TN Instance Methods Source: https://github.com/bandwidth/node-numbers/blob/main/README.md After retrieving a TN object, you can call instance methods to get its details, associated sites, SIP peers, or rate center information. ```Javascript numbers.Tn.get(fullNumber, function(err, tn){ // Get TN Details tn.getTnDetails(callback); // Get Sites tn.getSites(callback); // Get Sip Peers tn.getSipPeers(callback); // Get Rate Center tn.getRateCenter(callback) }); ``` -------------------------------- ### Delete an Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Deletes an application from the account. Retrieve the application first using `get`, then call its `delete` method. ```javascript numbers.Application.get(id, (err, app) => { app.delete(callback) }); ``` -------------------------------- ### Initialize Client Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Demonstrates how to initialize the Bandwidth client directly or using global options. ```javascript var numbers = require("@bandwidth/numbers"); // Using client directly var client = new numbers.Client("accountId", "userName", "password"); numbers.Site.list(client, function(err, sites){...}); // Or you can use default client instance (do this only once) numbers.Client.globalOptions.accountId = "accountId"; numbers.Client.globalOptions.userName = "userName"; numbers.Client.globalOptions.password = "password"; // Now you can call any functions without first arg 'client' numbers.Site.list(function(err, sites){ //Default client will be used to do this call }); ``` -------------------------------- ### Manage Bandwidth SIP Peers (Locations) Source: https://context7.com/bandwidth/node-numbers/llms.txt Create, update, list, and delete SIP peers, which represent locations within a site. Associate messaging applications and manage SMS settings. Ensure the '@bandwidth/numbers' package is installed. ```javascript const numbers = require("@bandwidth/numbers"); // Create a SIP peer numbers.SipPeer.create({ siteId: "1111", peerName: "Primary Location", isDefaultPeer: true, shortMessagingProtocol: "HTTP", voiceHosts: [{ host: { hostName: "1.2.3.4" } }], smsHosts: [{ host: { hostName: "1.2.3.4" } }] }, (err, peer) => { console.log("Peer ID:", peer.id); // Associate a messaging application peer.editApplication({ httpMessagingV2AppId: "app-id-abc" }, (err, result) => { console.log(result); }); // Get/update/delete SMS settings peer.getSmsSettings((err, settings) => console.log(settings)); peer.editSmsSettings({ sipPeerSmsFeatureSettings: { tollFree: true, zone1: true, protocol: "HTTP" } }, (err, updated) => console.log(updated)); // Get all TNs on this peer peer.getTns((err, tns) => console.log(tns)); // Move TNs to this peer peer.moveTns(["9195551212", "9195554321"], (err) => console.log("Moved")); // Create voice origination settings peer.createOriginationSettings({ voiceProtocol: "HTTP", httpSettings: { httpVoiceV2AppId: "voice-app-id" } }, (err, settings) => console.log(settings)); // Delete peer peer.delete((err) => console.log("Deleted")); }); // List peers for a site numbers.SipPeer.list("1111", (err, peers) => console.log(peers)); // Get a specific peer numbers.SipPeer.get("1111", "2222", (err, peer) => { peer.listApplication((err, apps) => console.log(apps)); peer.removeApplication((err) => console.log("App removed")); }); ``` -------------------------------- ### Enable SMS for TN Options Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Create a TN option order to enable SMS functionality for a telephone number. The callback example is referenced from TnOption.get. ```Javascript const tnOptionsOrder = { customerOrderId: 'myOrderId', tnOptionGroups: [ { sms: 'on', telephoneNumbers: ['1234567890'] } ] } numbers.TnOption.create(tnOptionsOrder, callback) //for callback example see TnOption.get ``` -------------------------------- ### Create Site and Delete Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Demonstrates creating a site and then immediately deleting it using the returned item object. The client instance is automatically available for subsequent calls on the item. ```javascript numbers.Site.create({siteObject}, function(err,item){ console.log("the site ID is: " + item.id); item.delete(function(err,res){ //no need to pass the client again }); }); ``` -------------------------------- ### Create, Get, and List Telephone Number Orders Source: https://context7.com/bandwidth/node-numbers/llms.txt Use the `Order` module to create new telephone number orders, retrieve existing ones by ID, or list orders with filters. Requires siteId and peerId for creation. ```javascript const numbers = require("@bandwidth/numbers"); // Create a new number order numbers.Order.create({ name: "My Order", siteId: "1111", peerId: "2222", quantity: 1, areaCodeSearchAndOrderType: { areaCode: "919", quantity: 1 } }, (err, result) => { const order = result.order; console.log("Order ID:", order.id); // Poll order history for status order.getHistory((err, history) => console.log(history)); // Get TNs associated with the order order.getTns((err, tns) => console.log(tns)); // Get area codes in order order.getAreaCodes((err, areaCodes) => console.log(areaCodes)); // Get order totals order.getTotals((err, totals) => console.log(totals)); // Add a note order.addNote({ userId: "user1", description: "Approved" }, (err, note) => { console.log("Note ID:", note.id); }); }); // Get an existing order numbers.Order.get("order-id-123", (err, result) => { console.log(result.order); }); // List orders with filter numbers.Order.list({ status: "COMPLETE", modifiedDateFrom: "2024-01-01" }, (err, result) => { console.log(result); }); ``` -------------------------------- ### Get SipPeers Associated With an Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a list of SIP peers associated with a specific application. Requires fetching the application first. ```javascript numbers.Application.get(id, (err, app) => { app.getSipPeers(callback); }); ``` -------------------------------- ### Create Call Forward Number for TN Options Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Create a TN option order to set up call forwarding for a telephone number. The callback example is referenced from TnOption.get. ```Javascript const tnOptionsOrder = { customerOrderId: 'myOrderId', tnOptionGroups: [ { callForward: '2345678901', telephoneNumbers: ['1234567890'] } ] } numbers.TnOption.create(tnOptionsOrder, callback) //for callback example see TnOption.get ``` -------------------------------- ### Initialize and Use Bandwidth Numbers Client Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Demonstrates two ways to initialize and use the Bandwidth Numbers client: directly with credentials or by setting global options for a default instance. Use the direct client for specific instances or global options for a single, application-wide client. ```javascript var numbers = require("@bandwidth/numbers"); //Using client directly var client = new numbers.Client("accountId", "userName", "password"); numbers.Site.list(client, function(err, sites){}); //Or you can use default client instance (do this only once) numbers.Client.globalOptions.accountId = "accountId"; numbers.Client.globalOptions.userName = "userName"; numbers.Client.globalOptions.password = "password"; //Now you can call any functions without first arg 'client' numbers.Site.list(function(err, sites){ //Default client will be used to do this call }); ``` -------------------------------- ### Get DLDA History Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Fetches the history of a DLDA record. This requires retrieving the DLDA record first using `get`, then calling its `getHistory` method. ```javascript numbers.Dlda.get(id, function(err,dlda){ dlda.getHistory(callback); }); ``` -------------------------------- ### Create A Site Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Create a new site, which corresponds to a Sub-Account in the web UI. Requires site details including name, description, and address information. ```javascript var site = { name:"A new site", description:"A new description", address:{ houseNumber: "123", streetName: "Anywhere St", city: "Raleigh", stateCode:"NC", zip: "27609", addressType: "Service" } }; numbers.Site.create(site, callback); ``` -------------------------------- ### Get LSR Order History Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves the history of a specific LSR order. This involves first getting the order by its ID and then calling the `getHistory` method on the order object. ```Javascript numbers.LsrOrder.get("id", function(err, order){ order.getHistory(callback); }); ``` -------------------------------- ### Add a Port Out Passcode to TN Options Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Create a TN option order that includes a port out passcode for a specified telephone number. The callback example is referenced from TnOption.get. ```Javascript const tnOptionsOrder = { customerOrderId: 'myOrderId', tnOptionGroups: [ { portOutPasscode: 'mypass1', telephoneNumbers: ['1234567890'] } ] } numbers.TnOption.create(tnOptionsOrder, callback) //for callback example see TnOption.get ``` -------------------------------- ### Create Site Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Creates a new site (sub-account) with address details. ```APIDOC ## Create A Site ### Description Creates a new site, referred to as a Sub-Account in the web UI, with specified address information. ### Method POST (implied by SDK method) ### Endpoint `/sites` (inferred) ### Parameters #### Request Body - **site** (object) - Required - The site object. - **name** (string) - Required - The name of the site. - **description** (string) - Optional - A description for the site. - **address** (object) - Required - The address details. - **houseNumber** (string) - Required. - **streetName** (string) - Required. - **city** (string) - Required. - **stateCode** (string) - Required. - **zip** (string) - Required. - **addressType** (string) - Required - e.g., "Service". ### Request Example ```javascript var site = { name:"A new site", description:"A new description", address:{ houseNumber: "123", streetName: "Anywhere St", city: "Raleigh", stateCode:"NC", zip: "27609", addressType: "Service" } }; numbers.Site.create(site, callback); ``` ``` -------------------------------- ### Get Subscription Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific subscription by its ID. ```APIDOC ## Get Subscription ### Description Retrieves a specific subscription using its unique identifier. ### Method GET (implied by SDK method) ### Endpoint `/subscriptions/{id}` (inferred) ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the subscription. ### Response #### Success Response (200) - **subscription** (object) - The subscription object. ### Request Example ```javascript numbers.Subscription.get(id, callback); ``` ``` -------------------------------- ### List All Applications Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a list of all applications associated with your Bandwidth account. ```APIDOC ## List All Applications ### Description Retrieves a list of all applications associated with your Bandwidth account. ### Method numbers.Application.list(callback) ### Parameters - **callback**: A function to handle the response or error. ``` -------------------------------- ### Get Order Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific order by its ID. ```APIDOC ## Get Order ### Description Retrieves a specific order by its ID. ### Method ```javascript numbers.Order.get ``` ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the order to retrieve. ### Request Example ```javascript numbers.Order.get(id, callback); ``` ``` -------------------------------- ### Get Group Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific group for an emergency notification. ```APIDOC ## Get Group ### Description Retrieves a specific group for an emergency notification. ### Method ```javascript const response = await EmergencyNotification.getGroupAsync(client, "engid"); ``` ### Parameters - `client`: The client object for authentication. - `engid`: The ID of the group to retrieve. ### Response - `emergencyNotificationGroup.identifier`: The identifier of the retrieved group. ``` -------------------------------- ### Site Instance Methods Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Perform various operations on a site instance, including retrieving in-service numbers, orders, port-ins, and total TNs. Requires a site ID to fetch the site object first. ```javascript numbers.Site.get(id, function(err,site){ // getInService numbers site.getInserviceNumbers(query, callback); // get Orders site.getOrders(query, callback); // get PortIns site.getPortIns(query, callback); // get Total Tns site.getTotalTns(query, callback); }); ``` -------------------------------- ### Get TN Reservation Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves an existing TN reservation by its ID. ```APIDOC ## Get TN Reservation ### Description Retrieves an existing TN reservation by its ID. ### Method ```javascript numbers.TnReservation.get(id, callback); ``` ``` -------------------------------- ### Get TN Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves details for a specific Telephone Number (TN). ```APIDOC ## Get TN ### Description Retrieves details for a specific Telephone Number (TN). ### Method ```javascript numbers.Tn.get(fullNumber, callback); ``` ``` -------------------------------- ### Get PortOut Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves the status of a port out request for a given ID. ```APIDOC ## Get PortOut ### Description Retrieves the status of a port out request. ### Method GET (implied by SDK method) ### Endpoint `/numbers/portout/{id}` (inferred) ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the port out request. ### Response #### Success Response (200) - **status** (string) - The status of the port out request. ### Request Example ```javascript numbers.PortOut.get(id, callback); ``` ``` -------------------------------- ### PortIn Instance Methods Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Demonstrates various instance methods available on a PortIn object after it has been fetched. These include updating, deleting, retrieving associated data like area codes and TNs, managing notes, and checking activation status. ```Javascript // fetch instance using PortIn.get(callback, portIn) portIn.update(data, callback); portIn.delete(callback); portIn.getAreaCodes(callback); portIn.getNpaNxx(callback); portIn.getTotals(callback); portIn.getTns(callback); portIn.getNotes(callback); portIn.addNote(callback); portIn.getActivationStatus(callback); ``` -------------------------------- ### Get PortIn Request Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific Port In request by its ID. ```APIDOC ## Get PortIn Request ### Description Retrieves a specific Port In request by its ID. ### Method ```javascript numbers.PortIn.get ``` ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the Port In request to retrieve. ### Request Example ```javascript numbers.PortIn.get("id", callback) ``` ``` -------------------------------- ### Get LSR Order Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific LSR order by its ID. ```APIDOC ## Get LSR Order ### Description Retrieves a specific LSR order by its ID. ### Method ```javascript numbers.LsrOrder.get ``` ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the LSR order to retrieve. ### Request Example ```javascript numbers.LsrOrder.get(id, callback); ``` ``` -------------------------------- ### Listing All Sites Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieve a list of all available sites. No parameters are required. ```javascript numbers.Site.list(callback); ``` -------------------------------- ### Get Lidb Entry Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific Lidb entry by its ID. ```APIDOC ## Get Lidb Entry ### Description Retrieves a specific Lidb entry by its ID. ### Method ```javascript numbers.Lidbs.get ``` ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the Lidb entry to retrieve. ### Request Example ```javascript numbers.Lidbs.get(id, callback); ``` ``` -------------------------------- ### Create Subscription Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Create a new subscription with specified order type and callback details. Includes URL, user, and expiry time for the callback. ```javascript var subscription = { orderType:"orders", callbackSubscription: { URL:"http://mycallbackurl.com", user:"userid", expiry: 12000 } }; numbers.Subscription.create(subscription, callback); ``` -------------------------------- ### Get Aeuis Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific Alternate End User Identifier (Aeuis). ```APIDOC ## Get Aeuis ### Description Retrieves a specific Alternate End User Identifier (Aeuis). ### Method ```javascript const response = await Aeuis.getAsync(client, "acid" ); ``` ### Parameters - `client`: The client object for authentication. - `acid`: The ID of the Aeuis to retrieve. ### Response - `AlternateEndUserIdentifier.Identifier`: The identifier of the retrieved Aeuis. ``` -------------------------------- ### Set SipPeer Origination Settings Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Use this to set HTTP voice origination settings for a SipPeer. Requires a SipPeer object and voice HTTP settings. ```javascript var sipPeer = ; var voiceHttpSettings = { httpVoiceV2AppId: "abcd-1234" } await sipPeer.createOriginationSettingsAsync({voiceProtocol: "HTTP", httpSettings: voiceHttpSettings}) ``` -------------------------------- ### Get Endpoint Order Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific endpoint order for an emergency notification. ```APIDOC ## Get Endpoint Order ### Description Retrieves a specific endpoint order for an emergency notification. ### Method ```javascript const response = await EmergencyNotification.getEndpointOrderAsync(client, "orderId" ); ``` ### Parameters - `client`: The client object for authentication. - `orderId`: The ID of the endpoint order to retrieve. ### Response - `emergencyNotificationEndpointOrder.orderId`: The ID of the retrieved endpoint order. ``` -------------------------------- ### Set SipPeer Origination Settings Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Sets the origination settings for a SIP peer. ```APIDOC ## Set SipPeer Origination Settings ### Description Sets the origination settings for a SIP peer. ### Method ```javascript await sipPeer.createOriginationSettingsAsync({voiceProtocol: "HTTP", httpSettings: voiceHttpSettings}) ``` ### Parameters - `sipPeer`: The SIP peer object. - `options`: An object containing origination settings, including `voiceProtocol` and `httpSettings`. ``` -------------------------------- ### Get Group Order Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific group order for an emergency notification. ```APIDOC ## Get Group Order ### Description Retrieves a specific group order for an emergency notification. ### Method ```javascript const response = await EmergencyNotification.getGroupOrderAsync(helper.createClient(), "orderId"); ``` ### Parameters - `client`: The client object for authentication. - `orderId`: The ID of the group order to retrieve. ### Response - `emergencyNotificationGroup.orderId`: The ID of the retrieved group order. ``` -------------------------------- ### Get Subscription Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieve a specific subscription by its ID. Requires the subscription ID. ```javascript numbers.Subscription.get(id, callback); ``` -------------------------------- ### Site Instance Methods Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Provides methods to retrieve information about numbers, orders, and port-ins associated with a specific site. ```APIDOC ## Site Instance Methods ### Description Provides methods to retrieve various data associated with a specific site instance. ### Methods #### Get In-Service Numbers Retrieves numbers that are currently in service for the site. - **Method**: GET (implied) - **Endpoint**: `/sites/{siteId}/inservice-numbers` (inferred) - **Parameters**: `query` (object) - Optional query parameters for filtering. - **Request Example**: `site.getInserviceNumbers(query, callback);` #### Get Orders Retrieves orders associated with the site. - **Method**: GET (implied) - **Endpoint**: `/sites/{siteId}/orders` (inferred) - **Parameters**: `query` (object) - Optional query parameters for filtering. - **Request Example**: `site.getOrders(query, callback);` #### Get PortIns Retrieves port-in requests associated with the site. - **Method**: GET (implied) - **Endpoint**: `/sites/{siteId}/portins` (inferred) - **Parameters**: `query` (object) - Optional query parameters for filtering. - **Request Example**: `site.getPortIns(query, callback);` #### Get Total TNs Retrieves the total count of Telephone Numbers (TNs) for the site. - **Method**: GET (implied) - **Endpoint**: `/sites/{siteId}/total-tns` (inferred) - **Parameters**: `query` (object) - Optional query parameters for filtering. - **Request Example**: `site.getTotalTns(query, callback);` ``` -------------------------------- ### Get LSR Order History Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves the history of a specific LSR order. ```APIDOC ## Get LSR Order History ### Description Retrieves the history of a specific LSR order. ### Method ```javascript order.getHistory ``` ### Parameters None ### Request Example ```javascript numbers.LsrOrder.get("id", function(err, order){ order.getHistory(callback); }); ``` ``` -------------------------------- ### Create Voice Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Creates a new voice application with specified callback URLs and authentication credentials. Ensure `callInitiatedCallbackUrl` and `callStatusCallbackUrl` are correctly configured. ```javascript var data = { appName:"test app", callInitiatedCallbackUrl: "http://example.com", callInitiatedMethod: "POST", callStatusCallbackUrl: "http://example.com", callStatusMethod: "POST" callbackCreds: { userId: 'my-id', password: 'my-password' } }; numbers.Application.createVoiceApplication(data, callback); ``` -------------------------------- ### Get Emergency Notification Recipient Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific Emergency Notification recipient by their ID. ```APIDOC ## Get Recipient ### Description Retrieves a specific Emergency Notification recipient by their ID. ### Method ```javascript try { const response = await EmergencyNotification.getRecipientAsync(client, "enrid" ); console.log(response.emergencyNotificationRecipient.identifier); //63865500-0904-46b1-9b4f-7bd237a26363 } catch (e) { console.log(e); } ``` ``` -------------------------------- ### Create Messaging Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Creates a new messaging application, defining its name and callback URL for message events. Requires `msgCallbackUrl` and `callbackCreds`. ```javascript var data = { appName:"test app", msgCallbackUrl: "http://example.com", callbackCreds: { userId: 'my-id', password: 'my-password' } }; numbers.Application.createMessagingApplication(data, callback); ``` -------------------------------- ### Get a TN Reservation Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieve details of an existing TN reservation using its ID. ```Javascript numbers.TnReservation.get(id, callback); ``` -------------------------------- ### ImportTnOrder.createAsync Source: https://context7.com/bandwidth/node-numbers/llms.txt Asynchronously creates a new import TN order using async/await syntax. ```APIDOC ## ImportTnOrder.createAsync ### Description Asynchronously creates a new import TN order using async/await syntax. This is an alternative to the callback-based `create` method. ### Method `await numbers.ImportTnOrder.createAsync(options, telephoneNumbers)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (object) - Required - Configuration options for the import order (same as `ImportTnOrder.create`). - **telephoneNumbers** (array) - Required - An array of telephone numbers to import. ``` -------------------------------- ### Get Area Codes for Order Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves the area codes associated with a specific order. ```APIDOC ## Get Area Codes for Order ### Description Retrieves the area codes associated with a specific order. ### Method ```javascript order.getAreaCodes ``` ### Parameters None ### Request Example ```javascript numbers.Order.get(id, function(err, order){ order.getAreaCodes(callback); }); ``` ``` -------------------------------- ### Get LSR Order Notes Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves the notes associated with a specific LSR order. ```APIDOC ## Get LSR Order Notes ### Description Retrieves the notes associated with a specific LSR order. ### Method ```javascript order.getNotes ``` ### Parameters None ### Request Example ```javascript numbers.LsrOrder.get("id", function(err,order){ order.getNotes(callback); }); ``` ``` -------------------------------- ### List All Applications Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a list of all applications associated with the account. This is a simple retrieval operation. ```javascript numbers.Application.list(callback); ``` -------------------------------- ### Get DLDA Information Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves details for a specific DLDA record using its ID. ```APIDOC ## Get DLDA ### Description Retrieves details for a specific DLDA record using its ID. ### Method numbers.Dlda.get(id, callback) ### Parameters - **id** (string) - Required - The unique identifier of the DLDA record. - **callback**: A function to handle the response or error. ``` -------------------------------- ### Create Voice Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Creates a new voice application within your Bandwidth account. This allows you to configure callbacks for call events. ```APIDOC ## Create Voice Application ### Description Creates a new voice application within your Bandwidth account. This allows you to configure callbacks for call events. ### Method numbers.Application.createVoiceApplication(data, callback) ### Parameters - **data** (object) - Required - Application configuration details: - **appName** (string) - Required - The name of the application. - **callInitiatedCallbackUrl** (string) - Required - The URL to receive notifications when a call is initiated. - **callInitiatedMethod** (string) - Required - The HTTP method for the `callInitiatedCallbackUrl` (e.g., POST). - **callStatusCallbackUrl** (string) - Required - The URL to receive notifications about call status changes. - **callStatusMethod** (string) - Required - The HTTP method for the `callStatusCallbackUrl` (e.g., POST). - **callbackCreds** (object) - Optional - Credentials for authenticating callbacks: - **userId** (string) - Required if `callbackCreds` is provided. - **password** (string) - Required if `callbackCreds` is provided. - **callback**: A function to handle the response or error. ``` -------------------------------- ### Create SIP Peer Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Creates a new SIP peer with specified configuration details. ```APIDOC ## Create SIP Peer ### Description Creates a new SIP peer with configuration for voice and SMS hosts. ### Method POST (implied by SDK method) ### Endpoint `/sip-peers` (inferred) ### Parameters #### Request Body - **peerName** (string) - Required - The name of the SIP peer. - **isDefaultPeer** (boolean) - Optional - Indicates if this is the default peer. - **shortMessagingProtocol** (string) - Optional - The SMS protocol to use (e.g., `SMPP`, `HTTP`). - **siteId** (string) - Required - The ID of the site associated with the peer. - **voiceHosts** (array) - Optional - List of voice host configurations. - **host** (object) - **hostName** (string) - Required - The hostname or IP address. - **smsHosts** (array) - Optional - List of SMS host configurations. - **host** (object) - **hostName** (string) - Required - The hostname or IP address. ### Request Example ```javascript var data = { peerName:"A New SIP Peer", isDefaultPeer:false, shortMessagingProtocol:"SMPP", // `HTTP` for use with the v2 messaging API siteId:selectedSite, voiceHosts:[ // optional { host:{ hostName:"1.1.1.1" } } ], smsHosts:[ // optional { host:{ hostName:"1.1.1.1" } } ] }; numbers.SipPeer.create(data, callback); ``` ``` -------------------------------- ### Get Disconnect Order Information Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves the status and details of a specific disconnect order. ```APIDOC ## Get Disconnect Order Information ### Description Retrieves the status and details of a specific disconnect order. ### Method numbers.Disconnect.get(orderId, options, callback) ### Parameters - **orderId** (string) - Required - The ID of the disconnect order to retrieve. - **options** (object) - Optional - Additional options: - **tnDetail** (boolean) - If true, includes detailed information about each telephone number in the order. - **callback**: A function to handle the response or error. ``` -------------------------------- ### Get InService Number Detail Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves detailed information for a specific in-service phone number. ```APIDOC ## Get InService Number Detail ### Description Retrieves detailed information for a specific in-service phone number. ### Method ```javascript numbers.InServiceNumber.get ``` ### Parameters #### Path Parameters - **telephoneNumber** (string) - Required - The telephone number to retrieve details for. ### Request Example ```javascript numbers.InServiceNumber.get("9195551212", callback); ``` ``` -------------------------------- ### Create Messaging Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Creates a new messaging application within your Bandwidth account. This allows you to configure callbacks for message events. ```APIDOC ## Create Messaging Application ### Description Creates a new messaging application within your Bandwidth account. This allows you to configure callbacks for message events. ### Method numbers.Application.createMessagingApplication(data, callback) ### Parameters - **data** (object) - Required - Application configuration details: - **appName** (string) - Required - The name of the application. - **msgCallbackUrl** (string) - Required - The URL to receive notifications for incoming messages. - **callbackCreds** (object) - Optional - Credentials for authenticating callbacks: - **userId** (string) - Required if `callbackCreds` is provided. - **password** (string) - Required if `callbackCreds` is provided. - **callback**: A function to handle the response or error. ``` -------------------------------- ### Get SipPeers Associated With an Application Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a list of SIP peers associated with a specific application. ```APIDOC ## Get SipPeers Associated With an Application ### Description Retrieves a list of SIP peers associated with a specific application. ### Method app.getSipPeers(callback) ### Parameters - **callback**: A function to handle the response or error. ``` -------------------------------- ### Manage Port-In (LNP) Orders and Files Source: https://context7.com/bandwidth/node-numbers/llms.txt The `PortIn` module handles Local Number Portability orders. It requires subscriber details and allows uploading LOA files, checking status, and managing the order lifecycle. ```javascript const numbers = require("@bandwidth/numbers"); const fs = require("fs"); // Create a port-in order numbers.PortIn.create({ siteId: "1111", peerId: "2222", billingTelephoneNumber: "9195551212", subscriber: { subscriberType: "BUSINESS", businessName: "Acme Corp", serviceAddress: { houseNumber: "123", streetName: "Main", streetSuffix: "St", city: "Raleigh", stateCode: "NC", county: "Wake" } }, loaAuthorizingPerson: "Jane Doe", listOfPhoneNumbers: { phoneNumber: ["9195551212"] }, billingType: "PORTIN" }, (err, portIn) => { console.log("PortIn order ID:", portIn.id); // Upload LOA (Letter of Authorization) file portIn.createFile(fs.createReadStream("./loa.pdf"), "application/pdf", (err, filename) => { console.log("Uploaded:", filename); }); // Get all uploaded files portIn.getFiles((err, files) => console.log(files)); // Check activation status portIn.getActivationStatus((err, status) => console.log(status)); // Poll order history portIn.getHistory((err, history) => console.log(history)); // Add note portIn.addNote({ userId: "user1", description: "LOA received" }, (err, note) => { console.log(note); }); // Update the order (supplement) portIn.update({ requestedFocDate: "2024-06-15" }, (err) => console.log("Updated")); // Cancel the order portIn.delete((err) => console.log("Cancelled")); }); // List port-in orders numbers.PortIn.list({ pon: "PON-12345" }, (err, result) => { console.log(result); }); ``` -------------------------------- ### Get DLDA Record Source: https://github.com/bandwidth/node-numbers/blob/main/README.md Retrieves a specific DLDA record by its ID. The `id` parameter is required. ```javascript numbers.Dlda.get(id, callback); ``` -------------------------------- ### Create and Manage Voice and Messaging Applications Source: https://context7.com/bandwidth/node-numbers/llms.txt Register voice and messaging applications. Associated applications can be updated, have SIP peers retrieved, and be deleted. Requires the '@bandwidth/numbers' package. ```javascript const numbers = require("@bandwidth/numbers"); // Create a voice application numbers.Application.createVoiceApplication({ appName: "My Voice App", callInitiatedCallbackUrl: "https://myapp.example.com/voice/initiated", callInitiatedMethod: "POST", callStatusCallbackUrl: "https://myapp.example.com/voice/status", callStatusMethod: "POST", callbackCreds: { userId: "user", password: "pass" } }, (err, app) => { console.log("App ID:", app.applicationId); }); // Create a messaging application numbers.Application.createMessagingApplication({ appName: "My Messaging App", msgCallbackUrl: "https://myapp.example.com/messaging/inbound", callbackCreds: { userId: "user", password: "pass" } }, (err, app) => { console.log("App ID:", app.applicationId); // Update application app.update({ appName: "Renamed App" }, (err) => console.log("Updated")); // Get SIP peers associated with the application app.getSipPeers((err, peers) => console.log(peers)); // Delete application app.delete((err) => console.log("Deleted")); }); // List all applications numbers.Application.list((err, apps) => { apps.forEach(a => console.log(a.applicationId, a.appName)); }); ```