Send message to phone number
Sends a message to a phone number using a template. The phone number doesn't need to be a pre-existing contact. The message can be sent via SMS or WhatsApp. Optionally specify a webhook URL to receive delivery status updates. The customer ID is extracted from the authentication token.
x-sender-id<token>
In: header
Header Parameters
x-sender-idstring
Format
guid
x-api-keystring
phoneNumber?string
templateId?string
Format
guid
messageBody?object
Empty Object
webhookUrl?string
Response Body
curl -X POST "https://api.sent.dm/v1/messages/phone" \
-H "x-sender-id: string" \
-H "x-api-key: string" \
-H "Content-Type: application/json" \
-d '{
"phoneNumber": "+1234567890",
"templateId": "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
"messageBody": {
"name": "John Doe",
"order_id": "12345"
},
"webhookUrl": "https://example.com/webhook/message-status"
}'
const body = JSON.stringify({
"phoneNumber": "+1234567890",
"templateId": "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
"messageBody": {
"name": "John Doe",
"order_id": "12345"
},
"webhookUrl": "https://example.com/webhook/message-status"
})
fetch("https://api.sent.dm/v1/messages/phone", {
headers: {
"x-sender-id": "string",
"x-api-key": "string"
},
body
})
package main
import (
"fmt"
"net/http"
"io/ioutil"
"strings"
)
func main() {
url := "https://api.sent.dm/v1/messages/phone"
body := strings.NewReader(`{
"phoneNumber": "+1234567890",
"templateId": "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
"messageBody": {
"name": "John Doe",
"order_id": "12345"
},
"webhookUrl": "https://example.com/webhook/message-status"
}`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("x-sender-id", "string")
req.Header.Add("x-api-key", "string")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
import requests
url = "https://api.sent.dm/v1/messages/phone"
body = {
"phoneNumber": "+1234567890",
"templateId": "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
"messageBody": {
"name": "John Doe",
"order_id": "12345"
},
"webhookUrl": "https://example.com/webhook/message-status"
}
response = requests.request("POST", url, json = body, headers = {
"x-sender-id": "string",
"x-api-key": "string",
"Content-Type": "application/json"
})
print(response.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.time.Duration;
import java.net.http.HttpRequest.BodyPublishers;
var body = BodyPublishers.ofString("""{
"phoneNumber": "+1234567890",
"templateId": "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
"messageBody": {
"name": "John Doe",
"order_id": "12345"
},
"webhookUrl": "https://example.com/webhook/message-status"
}""");
HttpClient client = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
.uri(URI.create("https://api.sent.dm/v1/messages/phone"))
.header("x-sender-id", "string")
.header("x-api-key", "string")
.header("Content-Type", "application/json")
.POST(body)
.build();
try {
HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString());
System.out.println("Status code: " + response.statusCode());
System.out.println("Response body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
using System;
using System.Net.Http;
using System.Text;
var body = new StringContent("""
{
"phoneNumber": "+1234567890",
"templateId": "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
"messageBody": {
"name": "John Doe",
"order_id": "12345"
},
"webhookUrl": "https://example.com/webhook/message-status"
}
""", Encoding.UTF8, "application/json");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-sender-id", "string");
client.DefaultRequestHeaders.Add("x-api-key", "string");
var response = await client.PostAsync("https://api.sent.dm/v1/messages/phone", body);
var responseBody = await response.Content.ReadAsStringAsync();
Empty
Empty
Empty