### Use Textlinksms Package to Verify Code Source: https://docs.textlinksms.com/api Examples of using the official Textlinksms packages to verify a phone number's OTP code. Ensure you have installed the package using npm, yarn, or pip. ```javascript const result = await textlink.verifyCode("+11234567890", "USER_ENTERED_CODE"); //if `result.ok` is true, then the phone number is verified. ``` ```typescript const result = await TextLink.verifyCode("+11234567890", "USER_ENTERED_CODE"); //if `result.ok` is true, then the phone number is verified. ``` ```python result = tl.verifyCode("+11234567890", "USER_ENTERED_CODE") # if `result.ok` is true, then the phone number is verified. ``` -------------------------------- ### Send Verification SMS using Official Packages Source: https://docs.textlinksms.com/api Code examples for sending verification SMS using the official textlink-sms library. Requires installation of the library and authentication with an API key. The service_name is an optional parameter. ```javascript // Firstly, install the helper library using npm or yarn const textlink = require("textlink-sms"); textlink.useKey("YOUR_API_KEY"); // Replace with your API key const verificationOptions = { service_name: "Tribal" }; // This is optional await textlink.sendVerificationSMS("+11234567890", verificationOptions); ``` ```typescript // Firstly, install the helper library using npm or yarn import TextLink from "textlink-sms"; TextLink.useKey("YOUR_API_KEY"); const verificationOptions = { service_name: "Tribal" }; // This is optional await TextLink.sendVerificationSMS("+11234567890", verificationOptions); ``` ```python # Firstly, install the helper library using pip import textlink as tl tl.useKey("YOUR_API_KEY") # Replace with your API key result = tl.sendVerificationSMS("+11234567890", service_name="Tribal") print(result) ``` -------------------------------- ### SMS Sending Response Examples Source: https://docs.textlinksms.com/api These examples show the JSON response structure for sending an SMS. The first indicates a successful message send with a code, while the second indicates a failure with a reason. ```javascript { ok: true, code: "123456" // The code sent } ``` ```javascript { ok: false, message: "Reason string" } ``` -------------------------------- ### Send Media File via Textlinksms API (Node.js, Python) Source: https://docs.textlinksms.com/imessage This snippet demonstrates how to send a media file (like audio, images, videos, or general files) using the Textlinksms API. It requires installing dependencies like 'axios' and 'form-data' for Node.js, or 'requests' for Python. The function takes a phone number, file path, and SIM card ID as input, and sends a POST request to the API endpoint. ```javascript // Install dependencies first: // npm install axios form-data const axios = require('axios'); const FormData = require('form-data'); const fs = require('fs'); const path = require('path'); async function test() { const form = new FormData(); form.append('phone_number', PHONE_NUMBER); form.append('file', fs.createReadStream(path.resolve(FILE_PATH))); form.append('sim_card_id', SIM_CARD_ID); try { const response = await axios.post( 'https://textlinksms.com/media/send-file', form, { headers: { 'Authorization': 'Bearer ' + API_KEY, ...form.getHeaders(), }, maxBodyLength: Infinity, } ); console.log('Response data:', response.data); } catch (err) { console.log(err); } } test() ``` ```python # Install dependencies first: # pip install requests import requests def send_file(): url = "https://textlinksms.com/media/send-file" headers = { "Authorization": f"Bearer {API_KEY}" } data = { "phone_number": PHONE_NUMBER, "sim_card_id": SIM_CARD_ID } with open(FILE_PATH, "rb") as my_file: files = { "file": my_file } response = requests.post(url, headers=headers, data=data, files=files) try: response.raise_for_status() print("Response data:", response.json()) except requests.HTTPError as e: # If the API returns a non-2xx status code, print the error response print(f"Error sending file: {e}\n{response.text}") if __name__ == "__main__": send_file() ``` -------------------------------- ### Example Webhook Payload for Received SMS Source: https://docs.textlinksms.com/webhooks This is an example JSON payload that TextLink sends when a new SMS message is received. It includes the secret for authentication, the sender's phone number, the message text, and optional contact information like tag and name, along with the SIM card ID used. ```json { "secret": "YOUR_WEBHOOK_SECRET", "phone_number": "+381690156360", "text": "General Kenobi", "tag": "Cold", "name": "Aleksandar Spremo", "sim_card_id": 123 } ``` -------------------------------- ### Send Video Message using Node.js Source: https://docs.textlinksms.com/imessage This Node.js snippet demonstrates how to send a video message using the Textlinksms API. It utilizes the 'axios' library for HTTP requests and 'form-data' to construct the multipart request body. Ensure you have installed 'axios' and 'form-data' and replace placeholders like PHONE_NUMBER, FILE_PATH, SIM_CARD_ID, and API_KEY with your actual values. ```javascript // Install dependencies first: // npm install axios form-data const axios = require('axios'); const FormData = require('form-data'); const fs = require('fs'); const path = require('path'); async function test() { const form = new FormData(); form.append('phone_number', PHONE_NUMBER); form.append('video', fs.createReadStream(path.resolve(FILE_PATH))); form.append('sim_card_id', SIM_CARD_ID); try { const response = await axios.post( 'https://textlinksms.com/media/send-video', form, { headers: { 'Authorization': 'Bearer ' + API_KEY, ...form.getHeaders(), }, maxBodyLength: Infinity, } ); console.log('Response data:', response.data); } catch (err) { console.log(err); } } test() ``` -------------------------------- ### Example Webhook Payload for Contact Tag Change Source: https://docs.textlinksms.com/webhooks This JSON payload is triggered when a contact's tag is updated in TextLink. It includes the contact's name, phone number, the new tag assigned, and an optional subuser ID if the action was performed under a subuser account. ```json { "name": "Aleksandar Spremo", "phone_number": "+381690156360", "tag": "Warm", "subuser_id": 6 } ``` -------------------------------- ### Check iMessage Status Response Examples Source: https://docs.textlinksms.com/imessage These JSON objects represent the possible response structures when querying the iMessage status of a phone number. The API returns a boolean indicating if the number is registered with iMessage or an error message if the request fails. ```json { "ok": true, "imessage": true } ``` ```json { "ok": true, "imessage": false } ``` ```json { "ok": false, "message": "Reason string" } ``` -------------------------------- ### Example Webhook Payload for Failed Message Source: https://docs.textlinksms.com/webhooks This JSON payload is sent when a previously dispatched message fails to send. It includes the secret, recipient's phone number, message text, and details like `portal` status, timestamp, SIM card ID, and specific TextLink and custom message IDs for tracking. ```json { "secret": "YOUR_WEBHOOK_SECRET", "phone_number": "+381690156360", "text": "Hello there", "portal": true, "timestamp": 1748463114559, "textlink_id": 100123, "custom_id": "1234" "sim_card_id": 123 } ``` -------------------------------- ### Example Webhook Payload for Message Dispatch (Sent) Source: https://docs.textlinksms.com/webhooks This JSON payload represents a message that has been successfully dispatched for sending via TextLink. It contains the secret, recipient's phone number, message text, and details about whether it was sent via the Chat App, the timestamp, and the SIM card ID. ```json { "secret": "YOUR_WEBHOOK_SECRET", "phone_number": "+381690156360", "text": "Hello there", "portal": true, "timestamp": 1748463114559, "sim_card_id": 123 } ``` -------------------------------- ### Send SMS via Official SDKs Source: https://docs.textlinksms.com/api Demonstrates how to initialize the TextLink client with an API key and send an SMS message. Supported across Node.js, TypeScript, and Python environments. ```javascript const textlink = require("textlink-sms"); textlink.useKey("YOUR_API_KEY"); textlink.sendSMS("+381611231234", "Dummy message text..."); ``` ```typescript import TextLink from "textlink-sms"; TextLink.useKey("YOUR_API_KEY"); TextLink.sendSMS("+381611231234", "Dummy message text..."); ``` ```python import textlink as tl tl.useKey("YOUR_API_KEY") result = tl.sendSMS("+381637443242", "Your message text...") print(result) ``` -------------------------------- ### POST /media/send-file Source: https://docs.textlinksms.com/imessage This endpoint allows you to send various types of files (e.g., PDF, PPTX) as messages. It uses multipart form data for the request body to handle binary content. ```APIDOC ## POST /media/send-file ### Description This endpoint allows you to send various types of files (e.g., PDF, PPTX) as messages. It uses multipart form data for the request body to handle binary content. ### Method POST ### Endpoint https://textlinksms.com/media/send-file ### Parameters #### Headers - **Content-Type** (string) - Required - The value should be "multipart/form-data" - **Authorization** (string) - Required - The value should be "Bearer API_KEY" #### Request Body (As multipart form data) - **phone_number** (string) - Required - Phone number that you want to check. International format, with prefix, like **+11234567890** - **file** (File) - Required - Any file (PDF, PPTX, etc.) to send. The form‐field name must be `file`. - **sim_card_id** (number) - Optional - Id of the iMessage virtual SIM card that you want to use for the check. - **custom_id** (string) - Optional - Custom id that you want us to send to you in our failed message webhook ### Request Example ``` --boundary Content-Disposition: form-data; name="phone_number" +11234567890 --boundary Content-Disposition: form-data; name="file"; filename="example.pdf" Content-Type: application/pdf --boundary-- ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the message was successfully sent. - **price** (number) - The cost of the message. - **sim_card_id** (number) - The ID of the SIM card used. #### Response Example (Success) ```json { "ok": true, "price": 0, "sim_card_id": 1088 } ``` #### Response Example (Failure) ```json { "ok": false, "message": "Reason string" } ``` ``` -------------------------------- ### POST /media/send-image Source: https://docs.textlinksms.com/imessage Sends an image file as a media message. ```APIDOC ## POST /media/send-image ### Description Sends an image file to a specified recipient using multipart form data. ### Method POST ### Endpoint https://textlinksms.com/media/send-image ### Parameters #### Request Body - **phone_number** (String) - Required - Target phone number. - **image** (File) - Required - Image file to be sent. ### Request Example Content-Type: multipart/form-data ### Response #### Success Response (200) - **ok** (Boolean) - Status of the request. #### Response Example { "ok": true } ``` -------------------------------- ### Verify Phone Number Code Source: https://docs.textlinksms.com/api This snippet demonstrates how to verify a phone number using the provided OTP code. It shows success and failure responses. ```javascript { ok: true } ``` ```javascript { ok: false, message: "Reason string" } ``` -------------------------------- ### Send SMS using Textlinksms API with Make Source: https://docs.textlinksms.com/make This snippet demonstrates how to configure a 'Make a request' action in Make to send an SMS using the Textlinksms API. It requires setting the correct URL, HTTP method, Authorization header, and a JSON body containing the recipient's phone number and the message text. The phone number can be dynamically sourced from a webhook trigger. ```json { "phone_number": "", "text": "" } ``` -------------------------------- ### Send SMS (Python) Source: https://docs.textlinksms.com/api This snippet shows how to send an SMS using the TextLink SMS Python helper library. ```APIDOC ## Send SMS (Python) ### Description Sends an SMS message to a specified phone number using the TextLink SMS Python helper library. ### Method `POST` (Implicitly via library function) ### Endpoint (Not directly exposed, handled by the library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (handled by library) ### Request Example ```python import textlink as tl tl.useKey("YOUR_API_KEY") # Replace with your API key result = tl.sendSMS("+381637443242", "Your message text...") print(result) ``` ### Response #### Success Response (200) - **result** (any) - The result of the SMS sending operation. #### Response Example (Details not provided in the source text, but the code prints the result) ``` -------------------------------- ### POST /media/send-video Source: https://docs.textlinksms.com/imessage This endpoint allows you to send video messages. It requires authentication and accepts video files along with recipient and SIM card information. ```APIDOC ## POST /media/send-video ### Description This endpoint allows you to send video messages. It requires authentication and accepts video files along with recipient and SIM card information. ### Method POST ### Endpoint https://textlinksms.com/media/send-video ### Parameters #### Headers - **Authorization** (string) - Required - The value should be "Bearer API_KEY" #### Request Body - **phone_number** (string) - Required - The recipient's phone number. - **sim_card_id** (number) - Required - The ID of the SIM card to use. - **video** (file) - Required - The video file to send. ### Request Example ```json { "phone_number": "+1234567890", "sim_card_id": 123, "video": "" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Error Response - **error** (string) - Error message if sending fails. #### Response Example ```json { "message": "Video sent successfully" } ``` ``` -------------------------------- ### POST /media/send-voice Source: https://docs.textlinksms.com/imessage Sends a voice note as a media message using multipart form data. ```APIDOC ## POST /media/send-voice ### Description Sends a voice note or media file. This endpoint requires multipart/form-data encoding to support binary file uploads. ### Method POST ### Endpoint https://textlinksms.com/media/send-voice ### Parameters #### Request Body - **Content-Type** (Header) - Required - Must be set to multipart/form-data - **Authorization** (Header) - Required - Bearer API_KEY ### Request Example Content-Type: multipart/form-data ### Response #### Success Response (200) - **status** (String) - Confirmation of message delivery initiation ``` -------------------------------- ### Handle Incoming SMS Webhook with Express.js Source: https://docs.textlinksms.com/webhooks This snippet demonstrates how to set up an Express.js server to receive and process incoming SMS messages via a TextLink webhook. It includes basic validation using a secret key and extracts relevant data from the request body. The server listens on port 80 and returns a 200 status code on success or 401 for unauthorized requests. ```javascript const express = require("express"); const app = express() app.use(express.json()) app.post("/webhook-endpoint", (req, res) => { if (req.body.secret != "YOUR_WEBHOOK_SECRET") return res.status(401).json({ ok: false }); const { phone_number/* ... other fields */ } = req.body; res.status(200).json({ ok: true }); }) app.listen(80); ``` -------------------------------- ### Send SMS (Node.js) Source: https://docs.textlinksms.com/api This snippet shows how to send an SMS using the TextLink SMS Node.js helper library. ```APIDOC ## Send SMS (Node.js) ### Description Sends an SMS message to a specified phone number using the TextLink SMS Node.js library. ### Method `POST` (Implicitly via library function) ### Endpoint (Not directly exposed, handled by the library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (handled by library) ### Request Example ```javascript const textlink = require("textlink-sms"); textlink.useKey("YOUR_API_KEY"); // Replace with your API key textlink.sendSMS("+381611231234", "Dummy message text..."); ``` ### Response #### Success Response (200) (Details not provided in the source text) #### Response Example (Details not provided in the source text) ``` -------------------------------- ### Send SMS (TypeScript) Source: https://docs.textlinksms.com/api This snippet demonstrates sending an SMS using the TextLink SMS TypeScript helper library. ```APIDOC ## Send SMS (TypeScript) ### Description Sends an SMS message to a specified phone number using the TextLink SMS TypeScript helper library. ### Method `POST` (Implicitly via library function) ### Endpoint (Not directly exposed, handled by the library) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (handled by library) ### Request Example ```typescript import TextLink from "textlink-sms"; TextLink.useKey("YOUR_API_KEY"); // Replace with your API key TextLink.sendSMS("+381611231234", "Dummy message text..."); ``` ### Response #### Success Response (200) (Details not provided in the source text) #### Response Example (Details not provided in the source text) ``` -------------------------------- ### Send Video Message using Python Source: https://docs.textlinksms.com/imessage This Python snippet shows how to send a video message via the Textlinksms API. It uses the 'requests' library to handle the HTTP POST request and 'files' parameter for uploading the video. Replace PHONE_NUMBER, FILE_PATH, SIM_CARD_ID, and API_KEY with your specific details. ```python # Install dependencies first: # pip install requests import requests def send_video_message(phone_number, file_path, api_key, sim_card_id=None): url = "https://textlinksms.com/media/send-video" headers = { "Authorization": f"Bearer {api_key}" } files = { 'video': open(file_path, 'rb') } data = { 'phone_number': phone_number } if sim_card_id: data['sim_card_id'] = sim_card_id try: response = requests.post(url, headers=headers, files=files, data=data) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error sending video message: {e}") return None # Example usage: # PHONE_NUMBER = "+11234567890" # FILE_PATH = "/path/to/your/video.mp4" # API_KEY = "YOUR_API_KEY" # SIM_CARD_ID = 1088 # Optional # result = send_video_message(PHONE_NUMBER, FILE_PATH, API_KEY, SIM_CARD_ID) # if result: # print(result) ``` -------------------------------- ### Send File Message using API Source: https://docs.textlinksms.com/imessage This describes how to send a file message using the Textlinksms API. It utilizes multipart/form-data encoding and requires a phone number and the file itself. Optional parameters include sim_card_id and custom_id for tracking. ```javascript // Example of a successful response { ok: true, price: 0, sim_card_id: 1088 } // Example of a failed response { ok: false, message: "Reason string" } ``` -------------------------------- ### POST /api/verify-code Source: https://docs.textlinksms.com/api Verifies an OTP code provided by the user for a specific phone number. ```APIDOC ## POST /api/verify-code ### Description Verifies the OTP code sent to a phone number to confirm user identity. ### Method POST ### Endpoint /api/verify-code ### Parameters #### Request Body - **phone_number** (String) - Required - The phone number that you would like to verify - **code** (String) - Optional - The OTP code to verify ### Request Example { "phone_number": "+11234567890", "code": "123456" } ### Response #### Success Response (200) - **ok** (Boolean) - Status of the verification - **message** (String) - Optional error message if verification fails #### Response Example { "ok": true } ``` -------------------------------- ### POST /media/send-voice Source: https://docs.textlinksms.com/imessage Sends a voice message to a specified phone number using an audio file. ```APIDOC ## POST /media/send-voice ### Description Sends an audio file (MP3, WAV, etc.) as a voice message to a target phone number. ### Method POST ### Endpoint https://textlinksms.com/media/send-voice ### Parameters #### Request Body - **phone_number** (String) - Required - Phone number in international format (e.g., +11234567890). - **voice** (File) - Required - Audio file to send. Form-field name must be 'voice'. - **sim_card_id** (Number) - Optional - ID of the iMessage virtual SIM card. - **custom_id** (String) - Optional - Custom ID for webhook tracking. ### Request Example Content-Type: multipart/form-data ### Response #### Success Response (200) - **ok** (Boolean) - Status of the request. - **price** (Number) - Cost of the operation. - **sim_card_id** (Number) - Used SIM card ID. #### Response Example { "ok": true, "price": 0, "sim_card_id": 1088 } ``` -------------------------------- ### POST /media/send-video Source: https://docs.textlinksms.com/imessage Send a video message using the Textlinksms API. This endpoint requires the request body to be encoded as multipart/form-data. ```APIDOC ## POST /media/send-video ### Description Send a video message using the Textlinksms API. This endpoint requires the request body to be encoded as multipart/form-data. ### Method POST ### Endpoint https://textlinksms.com/media/send-video ### Headers - **Content-Type** (string) - Required - The value must be "multipart/form-data" - **Authorization** (string) - Required - The value must be "Bearer API_KEY", where API_KEY is your secret API key. ### Parameters #### Request Body (As multipart form data) - **phone_number** (string) - Required - Phone number to send the video to, in international format (e.g., +11234567890). - **video** (File) - Required - The video file to send. The form-field name must be `video`. - **sim_card_id** (number) - Optional - The ID of the iMessage virtual SIM card to use. - **custom_id** (string) - Optional - A custom ID to be sent in failed message webhooks. ### Request Example (See Node.js or Python code snippets for examples of how to construct the multipart/form-data request) ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the message was successfully sent. - **price** (number) - The cost of sending the message. - **sim_card_id** (number) - The ID of the SIM card used. #### Failure Response (200) - **ok** (boolean) - Set to false if sending failed. - **message** (string) - The reason for the failure. #### Response Example ```json { "ok": true, "price": 0, "sim_card_id": 1088 } ``` ```json { "ok": false, "message": "Reason string" } ``` ``` -------------------------------- ### Send Voice Message via TextLinkSMS API Source: https://docs.textlinksms.com/imessage Sends an audio file to a specified phone number using multipart/form-data. Requires an API key for authorization and supports optional parameters like sim_card_id and custom_id. ```javascript const axios = require('axios'); const FormData = require('form-data'); const fs = require('fs'); const path = require('path'); async function test() { const form = new FormData(); form.append('phone_number', PHONE_NUMBER); form.append('voice', fs.createReadStream(path.resolve(FILE_PATH))); form.append('sim_card_id', SIM_CARD_ID); try { const response = await axios.post( 'https://textlinksms.com/media/send-voice', form, { headers: { 'Authorization': 'Bearer ' + API_KEY, ...form.getHeaders(), }, maxBodyLength: Infinity, } ); console.log('Response data:', response.data); } catch (err) { console.log(err); } } test() ``` ```python import requests def send_voice(): url = "https://textlinksms.com/media/send-voice" headers = { "Authorization": f"Bearer {API_KEY}" } data = { "phone_number": PHONE_NUMBER, "sim_card_id": SIM_CARD_ID } with open(FILE_PATH, "rb") as voice_file: files = { "voice": voice_file } response = requests.post(url, headers=headers, data=data, files=files) try: response.raise_for_status() print("Response data:", response.json()) except requests.HTTPError as e: print(f"Error sending voice: {e}\n{response.text}") if __name__ == "__main__": send_voice() ``` -------------------------------- ### POST /api/update-contect-tag Source: https://docs.textlinksms.com/api Updates the tag associated with a specific contact to track communication status. ```APIDOC ## POST /api/update-contect-tag ### Description Updates a contact tag, which is used to track communication status and is reflected in the Chat app and webhooks. ### Method POST ### Endpoint https://textlinksms.com/api/update-contect-tag ### Parameters #### Headers - **Content-Type** (String) - Required - Must be "application/json" - **Authorization** (String) - Required - Must be "Bearer API_KEY" #### Request Body - **phone_number** (String) - Required - The phone number that you would like to update the tag for - **tag** (String) - Optional - Tag to set for your contact ### Request Example { "phone_number": "+11234567890", "tag": "VIP" } ### Response #### Success Response (200) - **ok** (Boolean) - Confirmation of the update #### Response Example { "ok": true } ``` -------------------------------- ### OTP / Phone Verification API Source: https://docs.textlinksms.com/api This endpoint allows for automated one-time-password (OTP) verification for phone numbers. OTP messages are prioritized for faster delivery. ```APIDOC ## OTP / Phone Verification API ### Description Automates one-time-password (OTP) verification for phone numbers. This service offers higher priority and faster delivery times for OTP messages compared to standard SMS. ### Method `POST` ### Endpoint `https://textlinksms.com/api/send-code` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body (The request body structure is not explicitly defined in the provided text, but it's implied to be JSON based on the Content-Type header.) ### Request Example (A specific JSON request body example is not provided, but the endpoint and headers are detailed below.) ```json { "phoneNumber": "+1234567890", "message": "Your verification code is: 123456" } ``` ### Headers #### Content-Type - **Content-Type** (string) - Required - The value must be "application/json". #### Authorization - **Authorization** (string) - Required - The value must be "Bearer API_KEY", where API_KEY is your registered API key. ### Response #### Success Response (200) (Details about the success response body are not provided in the source text.) #### Response Example (Details not provided in the source text) ``` -------------------------------- ### Send Video Message using Python Source: https://docs.textlinksms.com/imessage This Python function sends a video file to a specified phone number using the Textlinksms API. It requires the 'requests' library and an API key. The function handles success and error responses, printing the result or error details. ```python import requests API_KEY = "YOUR_API_KEY" PHONE_NUMBER = "+1234567890" SIM_CARD_ID = "1" FILE_PATH = "path/to/your/video.mp4" def send_video(): url = "https://textlinksms.com/media/send-video" headers = { "Authorization": f"Bearer {API_KEY}" } data = { "phone_number": PHONE_NUMBER, "sim_card_id": SIM_CARD_ID } with open(FILE_PATH, "rb") as video_file: files = { "video": video_file } response = requests.post(url, headers=headers, data=data, files=files) try: response.raise_for_status() print("Response data:", response.json()) except requests.HTTPError as e: print(f"Error sending video: {e}\n{response.text}") if __name__ == "__main__": send_video() ``` -------------------------------- ### POST /media/send-image Source: https://docs.textlinksms.com/imessage This endpoint allows you to send an image file to a specified phone number. You can optionally provide a SIM card ID and a custom ID for tracking purposes. ```APIDOC ## POST /media/send-image ### Description Sends an image file to a specified phone number via SMS. ### Method POST ### Endpoint https://textlinksms.com/media/send-image ### Parameters #### Headers - **Content-Type** (string) - Required - The value should be "multipart/form-data" - **Authorization** (string) - Required - The value should be "Bearer API_KEY" #### Request Body - **phone_number** (string) - Required - Phone number to send the image to, in international format (e.g., "+11234567890"). - **image** (File) - Required - The image file to send (JPG, PNG, etc.). The form-field name must be `image`. - **sim_card_id** (number) - Optional - The ID of the iMessage virtual SIM card to use. - **custom_id** (string) - Optional - A custom ID to be sent in the failed message webhook. ### Request Example ```json { "phone_number": "+11234567890", "image": "", "sim_card_id": 1088, "custom_id": "my_custom_id" } ``` ### Response #### Success Response (200) - **ok** (boolean) - Indicates if the message was successfully sent. - **price** (number) - The cost of sending the message. - **sim_card_id** (number) - The ID of the SIM card used. #### Error Response (200) - **ok** (boolean) - Indicates if the message sending failed. - **message** (string) - The reason for the failure. #### Response Example (Success) ```json { "ok": true, "price": 0, "sim_card_id": 1088 } ``` #### Response Example (Failure) ```json { "ok": false, "message": "Reason string" } ``` ``` -------------------------------- ### POST /api/send-sms Source: https://docs.textlinksms.com/api Endpoint to trigger an SMS message delivery to a specified phone number. ```APIDOC ## POST /api/send-sms ### Description Sends an SMS message to a recipient using the TextLink gateway. Requires authentication via a Bearer token. ### Method POST ### Endpoint https://textlinksms.com/api/send-sms ### Parameters #### Request Body - **phone_number** (String) - Required - Recipient phone number, with country prefix (e.g., +11234567890). - **text** (String) - Required - The content of the message body. - **sim_card_id** (Number) - Optional - ID of the specific SIM card to use for sending. - **custom_id** (String) - Optional - A custom identifier for tracking purposes in webhooks. ### Request Example { "phone_number": "+11234567890", "text": "Hello from TextLink!", "sim_card_id": 12345 } ### Response #### Success Response (200) - **ok** (Boolean) - Indicates if the request was processed. - **queued** (Boolean) - Optional - Indicates if the message is queued if senders are busy. - **message** (String) - Optional - Error reason if sending failed. #### Response Example { "ok": true } ``` -------------------------------- ### POST /verify-code Source: https://docs.textlinksms.com/api Validates a one-time password entered by the user against the TextLink SMS verification system. ```APIDOC ## POST /verify-code ### Description Validates the code entered by the user to confirm authenticity without requiring local storage of the code. ### Method POST ### Endpoint https://textlinksms.com/api/verify-code ### Parameters #### Headers - **Content-Type** (String) - Required - Should be "application/json" - **Authorization** (String) - Required - Should be "Bearer API_KEY" ### Request Example { "code": "123456", "phone_number": "+11234567890" } ### Response #### Success Response (200) - **ok** (Boolean) - Indicates if the code is valid #### Response Example { "ok": true } ``` -------------------------------- ### POST /send-verification-sms Source: https://docs.textlinksms.com/api Sends a verification SMS to a specified phone number. This endpoint allows for optional customization of the service name and SIM card selection. ```APIDOC ## POST /send-verification-sms ### Description Sends a one-time password or verification message to the recipient's phone number. ### Method POST ### Endpoint /send-verification-sms ### Parameters #### Request Body - **phone_number** (String) - Required - Recipient phone number, with country prefix. E.g. +11234567890 - **service_name** (String) - Optional - Your name to be shown in the message - **sim_card_id** (Number) - Optional - Id of the SIM card to send the message from - **custom_id** (String) - Optional - Custom id for failed message webhooks ### Request Example { "phone_number": "+11234567890", "service_name": "MyService" } ### Response #### Success Response (200) - **ok** (Boolean) - Status of the request - **code** (String) - The verification code sent (if successful) - **message** (String) - Error reason (if failed) #### Response Example { "ok": true, "code": "123456" } ``` -------------------------------- ### POST /webhook-endpoint Source: https://docs.textlinksms.com/webhooks The endpoint on your server that receives event notifications from TextLink SMS. The server must return a 200 OK status to acknowledge receipt. ```APIDOC ## POST /webhook-endpoint ### Description Receives event notifications from TextLink SMS. The endpoint should verify the 'secret' field to ensure the request originates from TextLink servers. ### Method POST ### Endpoint [Your configured webhook URL] ### Request Body - **secret** (string) - Required - The webhook secret configured in the TextLink dashboard for request verification. - **phone_number** (string) - Required - The phone number associated with the event. - **text** (string) - Optional - The content of the SMS message (if applicable). - **timestamp** (number) - Optional - Unix timestamp of the event. - **tag** (string) - Optional - The contact tag (for received messages or tag changes). - **name** (string) - Optional - The contact name. ### Request Example { "secret": "YOUR_WEBHOOK_SECRET", "phone_number": "+11234567890", "text": "Hello there", "timestamp": 1748463114559 } ### Response #### Success Response (200) - **ok** (boolean) - Confirmation that the webhook was processed successfully. #### Response Example { "ok": true } ``` -------------------------------- ### Update Contact Tag Source: https://docs.textlinksms.com/api This section details how to update contact tags using the TextLink API. It includes the API endpoint, required headers, and request body parameters. ```javascript { ok: true } ``` -------------------------------- ### POST /api/check-imessage Source: https://docs.textlinksms.com/imessage Checks if a specific phone number is registered with iMessage using a configured BluBubl device. ```APIDOC ## POST /api/check-imessage ### Description Checks if a given phone number has iMessage enabled. Requires an active iMessage device configured via BluBubl. ### Method POST ### Endpoint https://textlinksms.com/api/check-imessage ### Parameters #### Request Body - **phone_number** (String) - Required - Phone number in international format (e.g., +11234567890) - **sim_card_id** (Number) - Optional - ID of the iMessage virtual SIM card to use for the check. ### Request Example { "phone_number": "+11234567890", "sim_card_id": 12345 } ### Response #### Success Response (200) - **ok** (Boolean) - Indicates if the request was successful - **imessage** (Boolean) - Indicates if the number is registered for iMessage #### Response Example { "ok": true, "imessage": true } ``` -------------------------------- ### Send Image via TextLinkSMS API Source: https://docs.textlinksms.com/imessage Sends an image file to a specified phone number using the TextLinkSMS media endpoint. The request requires multipart/form-data with an authorization header and supports optional SIM card and custom ID parameters. ```javascript const axios = require('axios'); const FormData = require('form-data'); const fs = require('fs'); const path = require('path'); async function test() { const form = new FormData(); form.append('phone_number', PHONE_NUMBER); form.append('image', fs.createReadStream(path.resolve(FILE_PATH))); form.append('sim_card_id', SIM_CARD_ID); try { const response = await axios.post( 'https://textlinksms.com/media/send-image', form, { headers: { 'Authorization': 'Bearer ' + API_KEY, ...form.getHeaders(), }, maxBodyLength: Infinity, } ); console.log('Response data:', response.data); } catch (err) { console.log(err); } } test() ``` ```python import requests def send_image(): url = "https://textlinksms.com/media/send-image" headers = { "Authorization": f"Bearer {API_KEY}" } data = { "phone_number": PHONE_NUMBER, "sim_card_id": SIM_CARD_ID } with open(FILE_PATH, "rb") as image_file: files = { "image": image_file } response = requests.post(url, headers=headers, data=data, files=files) try: response.raise_for_status() print("Response data:", response.json()) except requests.HTTPError as e: print(f"Error sending image: {e}\n{response.text}") if __name__ == "__main__": send_image() ``` -------------------------------- ### Send SMS via REST API Source: https://docs.textlinksms.com/api Sends an SMS message by making a POST request to the TextLink API endpoint. Requires an Authorization header with a Bearer token and a JSON body containing the recipient's phone number and message text. ```json { "phone_number": "+11234567890", "text": "Hello, this is a test message.", "sim_card_id": 123, "custom_id": "my_ref_001" } ``` ```json { "ok": true } ``` ```json { "ok": false, "message": "Reason string" } ``` ```json { "ok": true, "queued": true } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.