Send message to contact

Sends a message to a specific contact using a template. The message can be sent via SMS or WhatsApp depending on the contact's capabilities. Optionally specify a webhook URL to receive delivery status updates. The customer ID is extracted from the authentication token.

POST
/v1/messages/contact
x-sender-id<token>

In: header

Header Parameters

x-sender-idstring
Formatguid
x-api-keystring
contactId?string
Formatguid
templateId?string
Formatguid
messageBody?object

Empty Object

webhookUrl?string

Response Body

curl -X POST "https://api.sent.dm/v1/messages/contact" \
  -H "x-sender-id: string" \
  -H "x-api-key: string" \
  -H "Content-Type: application/json" \
  -d '{
    "contactId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
    "templateId": "7ba7b820-9dad-11d1-80b4-00c04fd430c8",
    "messageBody": {
      "name": "John Doe",
      "order_id": "12345"
    },
    "webhookUrl": "https://example.com/webhook/message-status"
  }'
const body = JSON.stringify({
  "contactId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
  "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/contact", {
  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/contact"
  body := strings.NewReader(`{
    "contactId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
    "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/contact"
body = {
  "contactId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
  "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("""{
  "contactId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
  "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/contact"))
  .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("""
{
  "contactId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
  "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/contact", body);
var responseBody = await response.Content.ReadAsStringAsync();
Empty
Empty
Empty