SDK Code Examples — WhatsAppController
Base URL: https://{tenant}.shumoul.app · Token variable: $TOKEN (bash) / %TOKEN% (cmd) / token (JS/C#/Dart), obtained per §19 SDK Usage Guide.
1. POST /api/v1/WhatsApp/SendTestText
Permission: WhatsApp.SendText
cURL — Linux/macOS:
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestText" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"to":"966501112222","body":"This is a test message from Shumoul","previewUrl":false}'
cURL — Windows (cmd.exe):
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestText" ^
-H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: application/json" ^
-d "{\"to\":\"966501112222\",\"body\":\"This is a test message from Shumoul\",\"previewUrl\":false}"
JavaScript — fetch():
const response = await fetch("https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestText", {
method: "POST",
headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json" },
body: JSON.stringify({
"to": "966501112222",
"body": "This is a test message from Shumoul",
"previewUrl": false
})
});
const result = await response.json();
JavaScript — Axios:
const { data } = await axios.post(
"https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestText",
{
"to": "966501112222",
"body": "This is a test message from Shumoul",
"previewUrl": false
},
{ headers: { Authorization: `Bearer ${token}` } }
);
C# — HttpClient:
var client = httpClientFactory.CreateClient("Shumoul"); // BaseAddress = "https://{tenant}.shumoul.app"
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var payload = new { to = "966501112222", body = "This is a test message from Shumoul", previewUrl = false };
var response = await client.PostAsJsonAsync("/api/v1/WhatsApp/SendTestText", payload);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<Result<object>>();
Flutter — Dio:
final response = await dio.post(
"/api/v1/WhatsApp/SendTestText",
data: {
"to": "966501112222",
"body": "This is a test message from Shumoul",
"previewUrl": false
},
options: Options(headers: {"Authorization": "Bearer $token"}),
);
2. POST /api/v1/WhatsApp/SendTestTemplate
Permission: WhatsApp.SendTemplate
cURL — Linux/macOS:
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestTemplate" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"to":"966501112222","templateName":"hello_world","languageCode":"en","components":[{"type":"body","parameters":[{"type":"text","text":"Test"}]}]}'
cURL — Windows (cmd.exe):
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestTemplate" ^
-H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: application/json" ^
-d "{\"to\":\"966501112222\",\"templateName\":\"hello_world\",\"languageCode\":\"en\",\"components\":[{\"type\":\"body\",\"parameters\":[{\"type\":\"text\",\"text\":\"Test\"}]}]}"
JavaScript — fetch():
const response = await fetch("https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestTemplate", {
method: "POST",
headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json" },
body: JSON.stringify({
"to": "966501112222",
"templateName": "hello_world",
"languageCode": "en",
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Test"
}
]
}
]
})
});
const result = await response.json();
JavaScript — Axios:
const { data } = await axios.post(
"https://{tenant}.shumoul.app/api/v1/WhatsApp/SendTestTemplate",
{
"to": "966501112222",
"templateName": "hello_world",
"languageCode": "en",
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Test"
}
]
}
]
},
{ headers: { Authorization: `Bearer ${token}` } }
);
C# — HttpClient:
var client = httpClientFactory.CreateClient("Shumoul"); // BaseAddress = "https://{tenant}.shumoul.app"
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var payload = new { to = "966501112222", templateName = "hello_world", languageCode = "en", components = new[] { new { type = "body", parameters = new[] { new { type = "text", text = "Test" } } } } };
var response = await client.PostAsJsonAsync("/api/v1/WhatsApp/SendTestTemplate", payload);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<Result<object>>();
Flutter — Dio:
final response = await dio.post(
"/api/v1/WhatsApp/SendTestTemplate",
data: {
"to": "966501112222",
"templateName": "hello_world",
"languageCode": "en",
"components": [
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "Test"
}
]
}
]
},
options: Options(headers: {"Authorization": "Bearer $token"}),
);
3. POST /api/v1/WhatsApp/SendActivationTest
Permission: WhatsApp.SendTemplate
cURL — Linux/macOS:
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendActivationTest" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"to":"966501112222","customerName":"Ahmed Al-Otaibi","organizationName":"Al-Otaibi Trading Co.","languageCode":"ar"}'
cURL — Windows (cmd.exe):
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendActivationTest" ^
-H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: application/json" ^
-d "{\"to\":\"966501112222\",\"customerName\":\"Ahmed Al-Otaibi\",\"organizationName\":\"Al-Otaibi Trading Co.\",\"languageCode\":\"ar\"}"
JavaScript — fetch():
const response = await fetch("https://{tenant}.shumoul.app/api/v1/WhatsApp/SendActivationTest", {
method: "POST",
headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json" },
body: JSON.stringify({
"to": "966501112222",
"customerName": "Ahmed Al-Otaibi",
"organizationName": "Al-Otaibi Trading Co.",
"languageCode": "ar"
})
});
const result = await response.json();
JavaScript — Axios:
const { data } = await axios.post(
"https://{tenant}.shumoul.app/api/v1/WhatsApp/SendActivationTest",
{
"to": "966501112222",
"customerName": "Ahmed Al-Otaibi",
"organizationName": "Al-Otaibi Trading Co.",
"languageCode": "ar"
},
{ headers: { Authorization: `Bearer ${token}` } }
);
C# — HttpClient:
var client = httpClientFactory.CreateClient("Shumoul"); // BaseAddress = "https://{tenant}.shumoul.app"
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var payload = new { to = "966501112222", customerName = "Ahmed Al-Otaibi", organizationName = "Al-Otaibi Trading Co.", languageCode = "ar" };
var response = await client.PostAsJsonAsync("/api/v1/WhatsApp/SendActivationTest", payload);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<Result<object>>();
Flutter — Dio:
final response = await dio.post(
"/api/v1/WhatsApp/SendActivationTest",
data: {
"to": "966501112222",
"customerName": "Ahmed Al-Otaibi",
"organizationName": "Al-Otaibi Trading Co.",
"languageCode": "ar"
},
options: Options(headers: {"Authorization": "Bearer $token"}),
);
4. POST /api/v1/WhatsApp/SendOtpTest
Permission: WhatsApp.SendTemplate
cURL — Linux/macOS:
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendOtpTest" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"to":"966501112222","otpCode":"482913","languageCode":"ar"}'
cURL — Windows (cmd.exe):
curl -X POST "https://{tenant}.shumoul.app/api/v1/WhatsApp/SendOtpTest" ^
-H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: application/json" ^
-d "{\"to\":\"966501112222\",\"otpCode\":\"482913\",\"languageCode\":\"ar\"}"
JavaScript — fetch():
const response = await fetch("https://{tenant}.shumoul.app/api/v1/WhatsApp/SendOtpTest", {
method: "POST",
headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json" },
body: JSON.stringify({
"to": "966501112222",
"otpCode": "482913",
"languageCode": "ar"
})
});
const result = await response.json();
JavaScript — Axios:
const { data } = await axios.post(
"https://{tenant}.shumoul.app/api/v1/WhatsApp/SendOtpTest",
{
"to": "966501112222",
"otpCode": "482913",
"languageCode": "ar"
},
{ headers: { Authorization: `Bearer ${token}` } }
);
C# — HttpClient:
var client = httpClientFactory.CreateClient("Shumoul"); // BaseAddress = "https://{tenant}.shumoul.app"
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var payload = new { to = "966501112222", otpCode = "482913", languageCode = "ar" };
var response = await client.PostAsJsonAsync("/api/v1/WhatsApp/SendOtpTest", payload);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadFromJsonAsync<Result<object>>();
Flutter — Dio:
final response = await dio.post(
"/api/v1/WhatsApp/SendOtpTest",
data: {
"to": "966501112222",
"otpCode": "482913",
"languageCode": "ar"
},
options: Options(headers: {"Authorization": "Bearer $token"}),
);
