### Get All Templates (Node.js) Source: https://developers.dexatel.com/reference/templates-1 Example of fetching templates using Node.js. Ensure you have the necessary libraries installed. ```javascript const options = { method: 'GET', url: 'https://api.dexatel.com/v1/templates', headers: { accept: 'application/json' } }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); ``` -------------------------------- ### Get Users Request Example (PHP) Source: https://developers.dexatel.com/reference/account-get-users Example of how to make a GET request to the users endpoint using PHP. ```php ``` -------------------------------- ### Get Users Request Example (Node.js) Source: https://developers.dexatel.com/reference/account-get-users Example of how to make a GET request to the users endpoint using Node.js. ```javascript const options = { method: 'GET', url: 'https://api.dexatel.com/v1/users', headers: { 'Content-Type': 'application/json' } }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); }); ``` -------------------------------- ### Get All Templates (Python) Source: https://developers.dexatel.com/reference/templates-1 Example of fetching templates using Python. This snippet uses the 'requests' library for making the HTTP GET request. ```python import requests url = "https://api.dexatel.com/v1/templates" headers = { "accept": "application/json" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### Get Account Information (PHP) Source: https://developers.dexatel.com/reference/account-get This PHP example retrieves your account information using the Dexatel API. It utilizes cURL for making the HTTP GET request. ```php ``` -------------------------------- ### PHP Request to Verify OTP Source: https://developers.dexatel.com/reference/verify-get-verification Example using PHP to make a GET request for OTP verification. Includes setting headers and handling the response. ```php ``` -------------------------------- ### Make an Authenticated GET Request with Curl Source: https://developers.dexatel.com/docs/authentication This example demonstrates how to make an authenticated GET request to a Dexatel API resource using curl. Ensure your API key is correctly placed in the header. ```bash curl -X GET "https://api.dexatel.com/v1/resource" \ -H "X-Dexatel-Key: YOUR_API_KEY" ``` -------------------------------- ### Get Account Information (Node.js) Source: https://developers.dexatel.com/reference/account-get This Node.js example demonstrates how to fetch your account information using the Dexatel API. It requires the 'axios' library for making HTTP requests. ```javascript const axios = require('axios'); const getAccountInfo = async () => { try { const response = await axios.get('https://api.dexatel.com/v1/accounts/self', { headers: { 'accept': 'application/json' } }); console.log(response.data); } catch (error) { console.error('Error fetching account info:', error); } }; getAccountInfo(); ``` -------------------------------- ### Get Single User by ID (Python) Source: https://developers.dexatel.com/reference/account-get-single-user Example of how to retrieve a single user's details using their ID with Python. ```python import requests response = requests.get('https://api.dexatel.com/v1/users/{id}') print(response.json()) ``` -------------------------------- ### Create Audience Request Body Example Source: https://developers.dexatel.com/reference/audiences-create Example of the JSON body required to create a new audience. It includes name, channel, and contact details. ```json { "name": "New Audience Name", "channel": "SMS", "contacts": [ { "number": "+1234567890", "first_name": "John", "last_name": "Doe", "custom1": "Value1", "custom2": "Value2" } ] } ``` -------------------------------- ### Get Single User by ID (Shell) Source: https://developers.dexatel.com/reference/account-get-single-user Example of how to retrieve a single user's details using their ID via a shell command. ```Shell curl -X GET https://api.dexatel.com/v1/users/{id} ``` -------------------------------- ### Get Single User by ID (PHP) Source: https://developers.dexatel.com/reference/account-get-single-user Example of how to retrieve a single user's details using their ID with PHP. ```php ``` -------------------------------- ### Node.js Request to Verify OTP Source: https://developers.dexatel.com/reference/verify-get-verification Example of verifying an OTP code using Node.js. This demonstrates making a GET request to the API. ```javascript const axios = require('axios'); const options = { method: 'GET', url: 'https://api.dexatel.com/v1/verifications', params: {code: '123456', phone: '+1234567890'}, headers: { accept: 'application/json' } }; axios.request(options).then(function (response) { console.log(response.data); }).catch(function (error) { console.error(error); }); ``` -------------------------------- ### Create Template Request Example (cURL) Source: https://developers.dexatel.com/reference/verify-create-template This example demonstrates how to create a new template using a cURL request. Ensure you include the correct 'content-type' and 'accept' headers, and provide the template details in JSON format within the request body. ```shell curl --request POST \ --url https://api.dexatel.com/v1/templates \ --header 'accept: application/json' \ --header 'content-type: application/json' ``` -------------------------------- ### Get Media Details (cURL) Source: https://developers.dexatel.com/reference/medias-get-details Demonstrates how to make a GET request to retrieve media details using cURL. Ensure you replace '{id}' with the actual media ID. ```Shell curl --request GET \ --url https://api.dexatel.com/v1/media/id \ --header 'accept: application/json' ``` -------------------------------- ### Get Single User by ID (Ruby) Source: https://developers.dexatel.com/reference/account-get-single-user Example of how to retrieve a single user's details using their ID with Ruby. ```ruby require 'httparty' response = HTTParty.get('https://api.dexatel.com/v1/users/{id}') puts response.body ``` -------------------------------- ### Get Single User by ID (Node.js) Source: https://developers.dexatel.com/reference/account-get-single-user Example of how to retrieve a single user's details using their ID with Node.js. ```javascript const axios = require('axios'); axios.get('https://api.dexatel.com/v1/users/{id}') .then(response => { console.log(response.data); }) .catch(error => { console.error(error); }); ``` -------------------------------- ### Get Templates Source: https://developers.dexatel.com/reference/templates-get This snippet shows how to make a GET request to retrieve templates. Ensure you have the correct API endpoint and accept header. ```shell curl --request GET \ --url https://api.dexatel.com/v1/templates \ --header 'accept: application/json' ``` -------------------------------- ### Webhook Delivery Request Example Source: https://developers.dexatel.com/docs/webhooks-delivery This example demonstrates a POST request for a webhook delivery notification. It includes the necessary headers and the JSON payload with message status details. ```json POST: {configured url} X-Dexatel-Signature: tfohtYVSauiKc7jJncqDJ4I4RL6A2AKbCUQL6BfuMtk= Content-Type: application/json { "data": { "account_id": "72e47e47-95b9-41c2-bdcd-55dd9bb04e14", "message_id": "e4fb1353-8ded-4ec7-991e-a757ea213106", "event": "delivery", "status": "delivered", "channel": "sms", "to": "1222333333", "mccmnc": "310670", "price": 0.123, "timestamp": "2022-03-01 13:00:00", "payload": "testing payload" } } ``` -------------------------------- ### cURL Request Example Source: https://developers.dexatel.com/reference/hlr-lookups-create Demonstrates how to make a GET request to the HLR lookup endpoint using cURL. Ensure you replace 'number' with the actual phone number. ```Shell curl --request GET \ --url https://api.dexatel.com/v1/number-lookups/number \ --header 'accept: application/json' ``` -------------------------------- ### Message Webhook Request Example Source: https://developers.dexatel.com/docs/webhooks-message This example shows the structure of a POST request for the Message webhook, including the signature header and the JSON payload. Ensure your endpoint is configured to receive these requests. ```json POST: {configured url} X-Dexatel-Signature: tfohtYVSauiKc7jJncqDJ4I4RL6A2AKbCUQL6BfuMtk= Content-Type: application/json { "data": { "account_id": "72e47e47-95b9-41c2-bdcd-55dd9bb04e14", "message_id":"8cd2ac02-0cf6-4842-88a9-1b577ff97242", "event": "message", "from": "1222444444", "to": "1222333333", "text": "sign me in please", "channel": "SMS", "timestamp": "2022-03-01 13:00:00" } } ``` -------------------------------- ### Get Templates Source: https://developers.dexatel.com/reference/verification-templates Retrieves a list of available verification templates. ```APIDOC ## GET /v1/templates ### Description Retrieves a list of available verification templates. ### Method GET ### Endpoint https://api.dexatel.com/v1/templates ### Response #### Success Response (200) - **templates** (array) - A list of verification templates. ``` -------------------------------- ### Example Request in PHP Source: https://developers.dexatel.com/reference/media-files Demonstrates fetching media files using PHP with Guzzle HTTP client. ```php request('GET', 'https://api.dexatel.com/v1/media', [ 'query' => [ 'page_size' => 20, 'page_token' => 'abc' ], 'headers' => [ 'Authorization' => 'Bearer YOUR_API_KEY' ] ]); echo $response->getBody(); } catch ( GuzzleHttp\Exception\ClientException $e ) { echo 'Error: ' . $e->getMessage(); } ?> ``` -------------------------------- ### Example Request in Node.js Source: https://developers.dexatel.com/reference/media-files Shows how to fetch media files using Node.js with the 'axios' library. ```javascript const axios = require('axios'); const getMedia = async () => { try { const response = await axios.get('https://api.dexatel.com/v1/media', { params: { page_size: 20, page_token: 'abc' }, headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); console.log(response.data); } catch (error) { console.error('Error fetching media:', error); } }; getMedia(); ``` -------------------------------- ### Example Request in Ruby Source: https://developers.dexatel.com/reference/media-files Illustrates how to retrieve media files using Ruby with the 'httparty' gem. ```ruby require 'httparty' url = 'https://api.dexatel.com/v1/media' options = { query: { page_size: 20, page_token: 'abc' }, headers: { 'Authorization' => 'Bearer YOUR_API_KEY' } } response = HTTParty.get(url, options) puts response.parsed_response ``` -------------------------------- ### Get Audience Contact (cURL) Source: https://developers.dexatel.com/reference/audiences-get-contact Example of how to retrieve a contact from an audience using cURL. Ensure you replace 'id' and 'contact_id' with actual values. ```shell curl --request GET \ --url https://api.dexatel.com/v1/audiences/id/contacts/contact_id \ --header 'accept: application/json' ``` -------------------------------- ### Send a Rich Media WhatsApp Notification (Image) Source: https://developers.dexatel.com/docs/whatsapp-notify This example demonstrates sending an image notification. Provide a valid URL for the image. A text message can accompany the media. ```bash curl -X POST "https://api.dexatel.com/v1/messages" \ -H "X-Dexatel-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "data": { "channel": "WHATSAPP", "from": "MyBusiness", "to": ["14155552671"], "type": "image", "url": "https://cdn.example.com/order-receipt.jpg", "text": "Your order is on the way!" } }' ``` -------------------------------- ### Get Account Information (Python) Source: https://developers.dexatel.com/reference/account-get This Python script demonstrates how to fetch your account details using the Dexatel API. It uses the 'requests' library. ```python import requests url = "https://api.dexatel.com/v1/accounts/self" headers = { "accept": "application/json" } try: response = requests.get(url, headers=headers) response.raise_for_status() # Raise an exception for bad status codes print(response.json()) except requests.exceptions.RequestException as e: print(f"Error fetching account info: {e}") ``` -------------------------------- ### Create Media Resource (cURL) Source: https://developers.dexatel.com/reference/medias-create This cURL request demonstrates how to create a media resource by sending a POST request to the API. It includes the necessary headers and a JSON body specifying the media type and directory. ```Shell curl --request POST \ --url https://api.dexatel.com/v1/media \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data '{ "data": { "type": "image", "directory": "temp" } }' ``` -------------------------------- ### Get Users Endpoint Source: https://developers.dexatel.com/reference/account-get-users This snippet shows the GET request to retrieve all users from the API. ```Shell get https://api.dexatel.com/v1/users ``` -------------------------------- ### Get Account Information (Shell) Source: https://developers.dexatel.com/reference/account-get Use this Shell command to retrieve your account details. Ensure you have your API credentials configured. ```Shell curl -X GET "https://api.dexatel.com/v1/accounts/self" \ -H "accept: application/json" ``` -------------------------------- ### Get Media Details Source: https://developers.dexatel.com/reference/medias-get-details Fetches the details of a media resource by its unique ID. This is a GET request to the /v1/media/{id} endpoint. ```APIDOC ## GET /v1/media/{id} ### Description Retrieves detailed information about a specific media file using its unique identifier. ### Method GET ### Endpoint https://api.dexatel.com/v1/media/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Unique identifier of the resource. ### Responses #### Success Response (200 OK) - **data** (object) - **id** (uuid) - The unique identifier assigned to a media file. - **account_id** (uuid) - The unique identifier of the account. - **file_name** (string) - The name of the media file. - **status** (string) - enum: `pending`, `uploaded`, `in_use` - The current state of a media file. - **directory** (string) - enum: `temp`, `perm` - The directory setting determines how long files are stored. - **type** (string) - enum: `image`, `video`, `document` - The format of the media file. - **content_type** (string) - Content type of the media file. - **get_url** (string) - The URL used to get the media. - **create_date** (date-time) - Creation date of the media file in UTC. - **update_date** (date-time) - Update date of the media file in UTC. - **delete_url** (string) - The URL to delete the media file. - **thumbnail_url** (string) - The URL of thumbnail if the media file is in video format. - **links** (object) - links object #### Error Response (404 Not Found) - **Code**: 7700 - **Message**: Media not found ``` -------------------------------- ### Get Audiences cURL Request Source: https://developers.dexatel.com/reference/audiences-get Use this cURL command to make a GET request to retrieve audiences. Ensure you include the 'accept' header. ```shell curl --request GET \ --url https://api.dexatel.com/v1/audiences \ --header 'accept: application/json' ``` -------------------------------- ### Python Request to Verify OTP Source: https://developers.dexatel.com/reference/verify-get-verification Demonstrates how to verify an OTP code using Python's requests library. Shows setting parameters and headers. ```python import requests url = "https://api.dexatel.com/v1/verifications" params = { "code": "123456", "phone": "+1234567890" } headers = { "accept": "application/json" } response = requests.get(url, params=params, headers=headers) print(response.text) ``` -------------------------------- ### Node.js Update Template Example Source: https://developers.dexatel.com/reference/templates-update-single Example of updating a template using Node.js. This code sends a PATCH request to the API with updated template data. ```Node.js const axios = require('axios'); async function updateTemplate(templateId, updateData) { const token = 'YOUR_API_TOKEN'; const url = `https://api.dexatel.com/v2/templates/${templateId}`; try { const response = await axios.patch(url, { data: updateData }, { headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' } }); console.log('Template updated successfully:', response.data); return response.data; } catch (error) { console.error('Error updating template:', error.response ? error.response.data : error.message); throw error; } } // Example usage: // updateTemplate('YOUR_TEMPLATE_ID', { // name: 'Updated Name', // text: 'This is the updated text.' // }); ``` -------------------------------- ### Create a Campaign Source: https://developers.dexatel.com/docs/whatsapp-campaigns Initiates a new WhatsApp campaign. You can send messages immediately or schedule them for a future date and time. Requires a valid channel, sender, template ID, and audience ID. ```APIDOC ## POST /v1/campaigns ### Description Creates a new WhatsApp campaign for bulk broadcast messaging. ### Method POST ### Endpoint https://api.dexatel.com/v1/campaigns ### Parameters #### Request Body - **data** (object) - Required - **name** (string) - Optional - Internal campaign name (max 45 characters). Auto-assigned if omitted. - **channel** (string) - Required - Must be `whatsapp`. - **from** (string) - Required - WhatsApp sender name (unique identifier). - **template** (string (UUID)) - Required - ID of a COMPLETED WhatsApp template. - **audience** (string (UUID)) - Required - ID of the contact audience list to send to. - **schedule** (string) - Optional - Future datetime for scheduled sending: `yyyy-mm-dd hh:mm:ss`. If omitted, sends immediately. ### Request Example — Immediate Campaign ```bash curl -X POST "https://api.dexatel.com/v1/campaigns" \ -H "X-Dexatel-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d { "data": { "name": "January Flash Sale", "channel": "whatsapp", "from": "MyBusiness", "template": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "audience": "4f6b8d2a-1c3e-5a7f-9b0d-2e4c6a8f0b1d" } } ``` ### Request Example — Scheduled Campaign ```bash curl -X POST "https://api.dexatel.com/v1/campaigns" \ -H "X-Dexatel-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d { "data": { "name": "Product Launch — March 1", "channel": "whatsapp", "from": "MyBusiness", "template": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "audience": "4f6b8d2a-1c3e-5a7f-9b0d-2e4c6a8f0b1d", "schedule": "2024-03-01 09:00:00" } } ``` ### Response #### Success Response (201 Created) - **data** (object) - Contains campaign details. - **id** (string) - Unique identifier for the campaign. - **name** (string) - Name of the campaign. - **channel** (string) - The messaging channel used (e.g., `whatsapp`). - **status** (string) - Current status of the campaign (e.g., `scheduled`, `in_progress`, `completed`, `canceled`). - **sender** (string) - The sender identifier. - **template_id** (string) - The ID of the WhatsApp template used. - **audience_id** (string) - The ID of the contact audience list. - **schedule** (string) - The scheduled time for the campaign. - **create_date** (string) - The date and time the campaign was created. #### Response Example (201 Created) ```json { "data": { "id": "c3d4e5f6-a7b8-9012-cdef-123456789012", "name": "Product Launch — March 1", "channel": "whatsapp", "status": "scheduled", "sender": "MyBusiness", "template_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "audience_id": "4f6b8d2a-1c3e-5a7f-9b0d-2e4c6a8f0b1d", "schedule": "2024-03-01 09:00:00", "create_date": "2024-02-20 14:00:00" } } ``` ``` -------------------------------- ### cURL Request to Get Campaigns Source: https://developers.dexatel.com/reference/campaigns-get Use this cURL command to make a GET request to the campaigns endpoint. Ensure you include the 'accept' header for JSON responses. ```Shell curl --request GET \ --url https://api.dexatel.com/v1/campaigns \ --header 'accept: application/json' ``` -------------------------------- ### Create Contact in Audience (Ruby) Source: https://developers.dexatel.com/reference/audiences-create-contact Ruby example for creating a contact. This snippet demonstrates how to make a POST request with the necessary headers and JSON payload. ```Ruby require 'net/http' require 'uri' require 'json' api_key = 'YOUR_API_KEY' audience_id = '{id}' uri = URI.parse("https://api.dexatel.com/v1/audiences/#{audience_id}/contacts") request = Net::HTTP::Post.new(uri) request['Authorization'] = "Bearer #{api_key}" request['Content-Type'] = 'application/json' contact_data = { "data" => { "number" => "+12345678900", "first_name" => "John", "last_name" => "Doe", "custom1" => "Value1", "custom2" => "Value2" } } request.body = contact_data.to_json response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http| http.request(request) end puts "Status: #{response.code}" puts "Body: #{response.body}" ``` -------------------------------- ### Get Account Information (Ruby) Source: https://developers.dexatel.com/reference/account-get This Ruby script shows how to get your account details via the Dexatel API. It uses the 'httparty' gem for HTTP requests. ```ruby require 'httparty' url = 'https://api.dexatel.com/v1/accounts/self' response = HTTParty.get(url, headers: { 'accept' => 'application/json' }) if response.success? puts response.parsed_response else puts "Error: #{response.code} - #{response.message}" end ```