### Get Spending Statistics (Node.js Example) Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Example demonstrating how to fetch spending statistics using the TextMagic Node.js client. It shows authentication setup and calling the getSpendingStat method with optional parameters for pagination and date range. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'page': 1, // Number | Fetch specified results page. 'limit': 10, // Number | The number of results per page. 'start': "2018-11-11 11:11", // String | Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is 7 days prior. 'end': "2019-11-11 11:11" // String | Time period start in [UNIX timestamp](https://en.wikipedia.org/wiki/Unix_time) format. The default is today. }; apiInstance.getSpendingStat(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Initialize TextMagic Client and Get Template Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Example of how to use the TextMagic Node.js client to fetch a specific message template by its ID. It shows the client initialization, authentication setup, and the call to the getTemplate method. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1; // Number | apiInstance.getTemplate(id).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Install TextMagic JavaScript SDK Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/README.md Installs the TextMagic JavaScript SDK version 2.0.43640 using npm. This command is essential for setting up the library in your project. ```shell npm install textmagic-client@2.0.43640 --save ``` -------------------------------- ### Initialize TextMagic Client and Get Timezones Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Example demonstrating how to fetch timezone information using the TextMagic Node.js client. It covers client setup, authentication, and calling the getTimezones method with an optional parameter to get full timezone details. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'full': 0 // Number | Return full info about timezones in array (0 or 1). Default is 0. }; apiInstance.getTimezones(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### JavaScript Example: Search Lists Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Demonstrates how to use the Textmagic Node.js client to search for lists with various options, including pagination and filtering. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'page': 1, // Number | Fetch specified results page. 'limit': 10, // Number | The number of results per page. 'ids': "1,2,3,4", // String | Find lists by IDs. 'query': "A", // String | Find lists by specified search query. 'onlyMine': 0, // Number | Return only current user lists. 'onlyDefault': 0, // Number | Return only default lists. 'orderBy': "id", // String | Order results by some field. Default is id. 'direction': "desc" // String | Order direction. Default is desc. }; apiInstance.searchLists(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Send Message API Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md The main entrypoint to send messages. This method allows users to dispatch messages, with examples provided for reference. ```APIDOC sendMessage(sendMessageInputObject) Send message This is the main entrypoint to send messages. See the examples above for the reference. ``` -------------------------------- ### Initialize TextMagic Client and Get Unread Messages Total Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Example showing how to retrieve the total number of unread messages using the TextMagic Node.js client. It includes client initialization, authentication configuration, and the call to the getUnreadMessagesTotal method. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); apiInstance.getUnreadMessagesTotal().then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get Message Price using Textmagic Node.js Client Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md This example demonstrates how to configure the Textmagic Node.js client, authenticate using basic authorization, and call the `getMessagePrice` method. It shows how to pass various options such as message text, template ID, sending time, contacts, and more to retrieve pricing information. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'includeBlocked': 0, // Number | Should we show the pricing for blocked contacts? 'text': "Test message test", // String | Message text. Required if the **template_id** is not set. 'templateId': 1, // Number | Template used instead of message text. Required if the **text** is not set. 'sendingTime': 1565606455, // Number | DEPRECATED, consider using the sendingDateTime and sendingTimezone parameters instead: optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. 'sendingDateTime': "2020-05-27 13:02:33", // String | Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. 'sendingTimezone': "America/Buenos_Aires", // String | The ID or ISO-name of the timezone used for sending when sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \"2016-05-27 13:02:33\" and sendingTimezone = \"America/Buenos_Aires\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. 'contacts': "1,2,3,4", // String | Comma-separated array of contact resources id message will be sent to. 'lists': "1,2,3,4", // String | Comma-separated array of list resources id message will be sent to. 'phones': "447860021130,447860021131", // String | Comma-separated array of E.164 phone numbers message will be sent to. 'cutExtra': 0, // Number | Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. 'partsCount': 6, // Number | Maximum message parts count (Textmagic allows sending 1 to 6 message parts). 'referenceId': 1, // Number | Custom message reference id which can be used in your application infrastructure. 'from': "Test Sender ID", // String | One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). 'rule': "FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1;COUNT=1", // String | An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. 'createChat': 0, // Number | Should the sending method try to create new Chat (if not exist) with specified recipients? 'tts': 0, // Number | Send a Text-to-Speech message. 'local': 0, // Number | Treat phone numbers passed in the \'phones\' field as local. 'localCountry': "US" // String | The 2-letter ISO country code for local phone numbers, used when \'local\' is set to true. Default is the account country. }; apiInstance.getMessagePrice(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get All Templates - Textmagic Node.js API Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves all user-defined templates. Supports pagination. Authentication is handled via BasicAuth. ```APIDOC getAllTemplates(opts) - Get all templates. - Parameters: - opts (Object): Options for the request. - page (Number): Fetch specified results page. [optional] - limit (Number): The number of results per page. [optional] - Returns: GetAllTemplatesPaginatedResponse - Authorization: [BasicAuth](../README.md#BasicAuth) - HTTP request headers: - Content-Type: application/json - Accept: application/json - Example: ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'page': 1, 'limit': 10 }; apiInstance.getAllTemplates(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` ``` -------------------------------- ### Textmagic API Endpoints Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Comprehensive documentation for Textmagic API endpoints, including method signatures, parameter details, return types, and usage examples. All endpoints require Basic Authentication. ```APIDOC getBalanceNotificationSettings() - Description: Get balance notification settings. - Parameters: None. - Return Type: GetBalanceNotificationSettingsResponse - Authorization: BasicAuth - HTTP Request Headers: Content-Type: application/json, Accept: application/json getBlockedContacts(opts) - Description: Get blocked contacts. - Parameters: - page (Number, optional): Fetch specified results page. Default is 1. - limit (Number, optional): The number of results per page. Default is 10. - query (String, optional): Find blocked contacts by specified search query. - orderBy (String, optional): Order results by some field. Default is id. - direction (String, optional): Order direction. Default is desc. - Return Type: GetBlockedContactsPaginatedResponse - Authorization: BasicAuth - HTTP Request Headers: Content-Type: application/json, Accept: application/json getBulkSession(id) - Description: Get bulk session status. - Parameters: - id (Number): The ID of the bulk session. - Return Type: BulkSession - Authorization: BasicAuth - HTTP Request Headers: Content-Type: application/json, Accept: application/json getCallbackSettings() - Description: Fetch callback URL settings. - Parameters: None. - Return Type: GetCallbackSettingsResponse - Authorization: BasicAuth - HTTP Request Headers: Content-Type: application/json, Accept: application/json ``` -------------------------------- ### Get Callback Settings (JavaScript) Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Fetches the current callback URL settings for the account. This endpoint requires Basic Authentication and returns the configured callback URLs. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); apiInstance.getCallbackSettings().then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### JavaScript Example: Search Outbound Messages Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Demonstrates how to use the Textmagic Node.js client to search for outbound messages with various filtering options, including pagination and status. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'page': 1, // Number | Fetch specified results page. 'limit': 10, // Number | The number of results per page. 'lastId': 56, // Number | Filter results by ID, selecting all values lesser than the specified ID. Note that the \'page\' parameter is ignored when \'lastId\' is specified. 'ids': "ids_example", // String | Find message by ID(s). 'sessionId': 56, // Number | Find messages by session ID. 'statuses': "q", // String | Find messages by status. 'includeDeleted': 0, // Number | Search also in deleted messages. 'query': "query_example" // String | Find messages by specified search query. }; apiInstance.searchOutboundMessages(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Initialize TextMagic Client and Fetch Subaccounts Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Demonstrates how to initialize the TextMagic Node.js client, configure Basic Authentication, and fetch subaccounts with pagination options. It includes setting username, password, and optional parameters for page and limit. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var getSubaccountsWithTokensInputObject = new TextmagicClient.GetSubaccountsWithTokensInputObject(); // GetSubaccountsWithTokensInputObject | var opts = { 'page': 1, // Number | Fetch specified results page. 'limit': 10 // Number | The number of results per page. }; apiInstance.getSubaccountsWithTokens(getSubaccountsWithTokensInputObject, opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get Outbound Messages History (JavaScript) Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Provides an example of retrieving the history of outbound messages using the TextMagic Node.js client. Demonstrates optional parameters for filtering, sorting, and pagination. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'limit': 10, // Number | The number of results per page. 'lastId': 56, // Number | Filter results by ID, selecting all values lesser than the specified ID. 'query': "query_example", // String | Find message by specified search query. 'orderBy': "id", // String | Order results by some field. Default is id. 'direction': "desc" // String | Order direction. Default is desc. }; apiInstance.getOutboundMessagesHistory(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get Outbound Message (JavaScript) Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Shows how to fetch a single outgoing message by its ID using the TextMagic Node.js client. Includes authentication setup and calling the specific API method. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1; // Number | apiInstance.getOutboundMessage(id).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### TextMagic API Methods Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Comprehensive documentation for various TextMagic API methods, including fetching inbound messages, notification settings, invoices, and list details. Each method includes its signature, parameter descriptions, return types, and JavaScript usage examples. ```APIDOC getInboundMessage(id) - Get a single inbound message. - Parameters: - id (Number): The unique numeric ID for the inbound message. - Returns: MessageIn - Example: ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1782832; // Number | The unique numeric ID for the inbound message. apiInstance.getInboundMessage(id).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` ``` ```APIDOC getInboundMessagesNotificationSettings() - Get inbound messages notification settings. - Parameters: None. - Returns: GetInboundMessagesNotificationSettingsResponse - Example: ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); apiInstance.getInboundMessagesNotificationSettings().then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` ``` ```APIDOC getInvoices(opts) - Get all invoices. - With the TextMagic API, you can check the invoices and transactions for your account. - Parameters: - page (Number, optional): Fetch specified results page. Defaults to 1. - limit (Number, optional): The number of results per page. Defaults to 10. - Returns: GetInvoicesPaginatedResponse - Example: ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'page': 1, // Number | Fetch specified results page. 'limit': 10 // Number | The number of results per page. }; apiInstance.getInvoices(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` ``` ```APIDOC getList(id) - Get the details of a specific list. - Parameters: - id (Number): The ID of the list. - Returns: List - Example: ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1; // Number | apiInstance.getList(id).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` ``` ```APIDOC getListContactsIds(id) - Get all contact IDs in a list. - Parameters: - id (Number): The ID of the list. - Returns: GetListContactsIdsResponse ``` -------------------------------- ### Delete Contact using TextMagic API (JavaScript) Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Provides a JavaScript example for deleting a specific contact by its ID using the TextMagic Node.js client. It includes authentication setup and the API call to `deleteContact`. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1; // Number | apiInstance.deleteContact(id).then(function() { console.log('API called successfully.'); }, function(error) { console.error(error); }); ``` -------------------------------- ### Initialize and Update Current User (Node.js) Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Demonstrates how to initialize the Textmagic Node.js client, configure basic authentication, and call the API to update the current user's details. It shows the typical setup for API calls. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var updateCurrentUserInputObject = new TextmagicClient.UpdateCurrentUserInputObject(); // UpdateCurrentUserInputObject | apiInstance.updateCurrentUser(updateCurrentUserInputObject).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get Contact Note Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves a specific note associated with a contact. Requires authentication. ```APIDOC APIDOC: getContactNote(id) Description: Get a contact note. Parameters: id (Number): The ID of the contact note. Return type: ContactNote Authorization: BasicAuth HTTP request headers: Content-Type: application/json Accept: application/json ``` -------------------------------- ### TextMagic API Endpoints Overview Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md This section lists available API endpoints for interacting with the TextMagic service. It includes HTTP methods, paths, and a brief description of each operation. ```APIDOC GET /api/v2/replies/search | Find inbound messages GET /api/v2/lists/search | Find lists by given criteria GET /api/v2/messages/search | Find messages GET /api/v2/schedules/search | Find scheduled messages GET /api/v2/templates/search | Find templates by criteria POST /api/v2/messages | Send message POST /api/v2/chats/status | Change chat status POST /api/v2/contacts/unblock | Unblock a contact by phone number POST /api/v2/contacts/unblock/bulk | Unblock contacts (bulk) POST /api/v2/chats/unmute/bulk | Unmute chats (bulk) POST /api/v2/unsubscribers | Manually unsubscribe a contact PUT /api/v2/user/notification/balance | Update balance notification settings PUT /api/v2/callback/settings | Update callback URL settings PUT /api/v2/user/desktop/notification | Update chat desktop notification settings PUT /api/v2/contacts/{id}/normalized | Edit a contact PUT /api/v2/notes/{id} | Update a contact note PUT /api/v2/user | Edit current account info PUT /api/v2/customfields/{id} | Edit a custom field PUT /api/v2/customfields/{id}/update | Edit the custom field value of a specified contact PUT /api/v2/user/notification/inbound | Update inbound messages notification settings PUT /api/v2/lists/{id} | Edit a list PUT /api/v2/sender/settings | Change sender settings PUT /api/v2/templates/{id} | Update a template POST /api/v2/user/avatar | Upload an avatar POST /api/v2/contacts/{id}/avatar | Upload an avatar POST /api/v2/lists/{id}/avatar | Add an avatar for a list POST /api/v2/messages/attachment | Upload message attachment POST /api/v2/messages/mms/attachment | Upload message mms attachment ``` -------------------------------- ### Get Unsubscribed Contact Details Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves the details of a specific unsubscribed contact by its ID. Requires authentication. ```APIDOC getUnsubscribedContact(id) - Retrieves details for a specific unsubscribed contact. - Parameters: - id (Number): The unique identifier of the unsubscribed contact. - Returns: - UnsubscribedContact: An object containing the unsubscribed contact's details. - Authorization: - BasicAuth - HTTP Request Headers: - Content-Type: application/json - Accept: application/json ``` ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1; // Number | apiInstance.getUnsubscribedContact(id).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get Contact Details by ID Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves the details of a specific contact using their unique ID. Requires authentication. ```APIDOC APIDOC: getContact(id) Description: Get the details of a specific contact. Parameters: id (Number): Contact ID. Return type: Contact Authorization: BasicAuth HTTP request headers: Content-Type: application/json Accept: application/json Example: var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1; // Number | Contact ID. apiInstance.getContact(id).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### TextMagic SDK Usage Examples Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/README.md Demonstrates how to use the TextMagic JavaScript SDK to send SMS messages, retrieve outgoing messages, and upload contact avatars. It requires authentication with TextMagic API keys and uses Node.js modules like 'fs'. ```javascript const textmagicClient = require('textmagic-client'); const fs = require('fs'); const client = textmagicClient.ApiClient.instance; const auth = client.authentications['BasicAuth']; // put your Username and API Key from https://my.textmagic.com/online/api/rest-api/keys page. auth.username = 'YOUR_USERNAME'; auth.password = 'YOUR_API_KEY'; const api = new textmagicClient.TextMagicApi(); // Simple ping request example api.ping().then(function (data) { console.log(data.ping); }).catch(function(err){ console.error(err); }); // Send a new message request example api.sendMessage({ 'text': 'I love TextMagic!', 'phones': '+12341234123' }).then(function (data) { console.log(data.id); }).catch(function(err){ console.error(err); }); // Get all outgoing messages request example api.getAllOutboundMessages({ 'page': 1, 'limit': 200 }).then(function (data) { console.log(data.resources[0].text); }).catch(function(err){ console.error(err); }); // Upload new avatar for contacts list (group) with Id 3223 example let stream = new fs.ReadStream('test.jpg'); api.uploadListAvatar(stream, 3223).then(function (data) { console.log(data.id); }).catch(function(err){ console.error(err); }); ``` -------------------------------- ### Get All Unsubscribed Contacts Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves a paginated list of all unsubscribed contacts. Users are opted out when they send STOP-words. Supports pagination. ```APIDOC getUnsubscribers(opts) - Retrieves a paginated list of all unsubscribed contacts. - Parameters: - opts (Object): Optional parameters for pagination. - page (Number): Fetch specified results page. [optional] [default to 1] - limit (Number): The number of results per page. [optional] [default to 10] - Returns: - GetUnsubscribersPaginatedResponse: A paginated response object containing unsubscribed contacts. - Authorization: - BasicAuth - HTTP Request Headers: - Content-Type: application/json - Accept: application/json ``` ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'page': 1, // Number | Fetch specified results page. 'limit': 10 // Number | The number of results per page. }; apiInstance.getUnsubscribers(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Send Message with TextMagic Node.js Client Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md This snippet shows how to initialize the TextMagic Node.js client, configure basic authentication with username and password, and set various options for sending a message. It includes parameters for message text, template ID, scheduled sending time, recipient contacts, lists, phone numbers, sender ID, and custom rules for recurrent messages. The example calls the `getMessagePreview` method and handles success or error responses. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'text': "Test message test", // String | Message text. Required if **template_id** is not set. 'templateId': 1, // Number | Template used instead of message text. Required if **text** is not set. 'sendingTime': 1565606455, // Number | DEPRECATED, consider using sendingDateTime and sendingTimezone parameters instead: Optional (required with rrule set). Message sending time is in unix timestamp format. Default is now. 'sendingDateTime': "2020-05-27 13:02:33", // String | Sending time is in Y-m-d H:i:s format (e.g. 2016-05-27 13:02:33). This time is relative to the sendingTimezone. 'sendingTimezone': "America/Buenos_Aires", // String | The ID or ISO-name of the timezone used for sending when the sendingDateTime parameter is set, e.g. if you specify sendingDateTime = \"2016-05-27 13:02:33\" and sendingTimezone = \"America/Buenos_Aires\", your message will be sent on May 27, 2016 13:02:33 Buenos Aires time, or 16:02:33 UTC. Default is the account timezone. 'contacts': "1,2,3,4", // String | Comma-separated array of contact resources id message will be sent to. 'lists': "1,2,3,4", // String | Comma-separated array of list resources id message will be sent to. 'phones': "447860021130,447860021131", // String | Comma-separated array of E.164 phone numbers message will be sent to. 'cutExtra': 0, // Number | Should sending method cut extra characters which not fit supplied partsCount or return 400 Bad request response instead. 'partsCount': 6, // Number | Maximum message parts count (Textmagic allows sending of 1 to 6 message parts). 'referenceId': 1, // Number | Custom message reference id which can be used in your application infrastructure. 'from': "Test Sender ID", // String | One of the allowed Sender ID (phone number or alphanumeric sender ID). If the specified Sender ID is not allowed for some destinations, a fallback default Sender ID will be used to ensure delivery. See [Get timezones](https://docs.textmagic.com/#tag/Sender-IDs). 'rule': "FREQ=YEARLY;BYMONTH=1;BYMONTHDAY=1;COUNT=1", // String | An iCal RRULE parameter to create recurrent scheduled messages. When used, sendingTime is mandatory as the start point of sending. See https://www.textmagic.com/free-tools/rrule-generator for format details. 'createChat': 0, // Number | Should the sending method try to create new Chat(if not exist) with specified recipients? 'tts': 0, // Number | Send Text-to-Speech message. 'local': 0, // Number | Treat phone numbers passed in the \'phones\' field as local. 'localCountry': "US" // String | The 2-letter ISO country code for local phone numbers, used when \'local\' is set to true. Default is the account country. }; apiInstance.getMessagePreview(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get Contact Details by Phone Number Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves the details of a specific contact using their phone number. Requires authentication. ```APIDOC APIDOC: getContactByPhone(phone) Description: Get the details of a specific contact by phone number. Parameters: phone (String): Phone number to query. Return type: Contact Authorization: BasicAuth HTTP request headers: Content-Type: application/json Accept: application/json Example: var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var phone = "447860021130"; // String | apiInstance.getContactByPhone(phone).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Retrieve All Bulk Sessions using TextMagic Node.js API Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Provides an example of fetching all bulk sessions using the TextMagic Node.js client. It demonstrates how to paginate results by specifying page number and limit. Basic Authentication is required. ```javascript var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; // Configure HTTP basic authorization: BasicAuth var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var opts = { 'page': 1, // Number | Fetch specified results page. 'limit': 10 // Number | The number of results per page. }; apiInstance.getAllBulkSessions(opts).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### APIDOC: Create List Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Creates a new list within the Textmagic account. Requires authentication and specifies content type and accept headers. ```APIDOC createList(createListInputObject) - Creates a new list. - Parameters: - createListInputObject [CreateListInputObject]: Object containing list details. - Return type: [ResourceLinkResponse](ResourceLinkResponse.md) - Authorization: BasicAuth - HTTP request headers: - Content-Type: application/json - Accept: application/json - Example: var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var createListInputObject = new TextmagicClient.CreateListInputObject(); apiInstance.createList(createListInputObject).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### TextmagicClient.MessagePayload Properties Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/MessagePayload.md Defines the properties available for the TextmagicClient.MessagePayload object. This includes the type of payload and an optional link to a media preview. ```APIDOC TextmagicClient.MessagePayload: Properties: type: String Description: Payload type. mediaPreview: String Description: Media preview link. ``` -------------------------------- ### TextmagicClient.File Properties Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/File.md Defines the properties of a File object within the Textmagic API. It details fields like id, name, mimeType, size, and creation timestamp, along with optional preview and download URLs and associated metadata. ```APIDOC TextmagicClient.File: Properties: id: Number - Unique identifier for the file. name: String - The name of the file. originalName: String - The original name of the file. mimeType: String - The MIME type of the file. size: Number - The size of the file in bytes. type: String - The type of the file (e.g., 'attachment'). createdAt: Date - The timestamp when the file was created. previewUrl: String (optional) - URL for a preview of the file. url: String (optional) - URL to download the file. metadata: FileMetadata (optional) - Additional metadata associated with the file. ``` -------------------------------- ### Textmagic API: Get Messaging Counters Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves counters for sent and received messages, as well as total contacts. This endpoint does not require any parameters. ```APIDOC APIDOC: Method: getMessagingCounters Description: Get sent/received messages counters values. Get total contacts, sent messages and received messages counters values. Signature: getMessagingCounters() Parameters: This endpoint does not need any parameter. Return Type: GetMessagingCountersResponse Authorization: BasicAuth HTTP Request Headers: - Content-Type: application/json - Accept: application/json Example: var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); apiInstance.getMessagingCounters().then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ``` -------------------------------- ### Get Contact Import Session Progress Source: https://github.com/textmagic/textmagic-rest-nodejs-v2/blob/master/docs/TextMagicApi.md Retrieves the current progress status of a contact import session identified by its ID. Requires authentication. ```APIDOC APIDOC: getContactImportSessionProgress(id) Description: Check import progress. Get contact import session progress. Parameters: id (Number): The ID of the import session. Return type: GetContactImportSessionProgressResponse Authorization: BasicAuth HTTP request headers: Content-Type: application/json Accept: application/json Example: var TextmagicClient = require('textmagic-client'); var defaultClient = TextmagicClient.ApiClient.instance; var BasicAuth = defaultClient.authentications['BasicAuth']; BasicAuth.username = 'YOUR USERNAME'; BasicAuth.password = 'YOUR PASSWORD'; var apiInstance = new TextmagicClient.TextMagicApi(); var id = 1; // Number | apiInstance.getContactImportSessionProgress(id).then(function(data) { console.log('API called successfully. Returned data: ' + data); }, function(error) { console.error(error); }); ```