Skip to main content

Schedule Messages

To ensure successful communication with the API, please include the following headers in all your requests:

  • Content-Type: application/json
  • Accept: application/json

In addition to the previous process, there are few parameters that may change on the request body; startTime, startDate, endDate, and scheduledOption.

To ensure successful communication with the API, please include the following headers in all your requests:

The API responses will be returned in the following format:

{
"success": true,
"message": "Message sent successfully",
"data": { }
}
const baseUrl = 'https://example.com/v2';
const url = `${baseUrl}/send-sms`
const token = `Your token from profile page`

// Define the payload for the API request
const payload = {
sender_id: 1,
sms: "Hello World! I am scheduling my first SMS message using Notify Africa API for 2 days every 8:27 AM",
schedule:"daily", //scheduled options "none","daily", "weekly", "monthly"
start_date:"2024-10-23", // year-month-date
end_date:"2024-10-25", //year-month-date
time:'8:27',
recipients: [{ number: 25571234567 }, { number: 25571234567 }]
};

// Make the API request using the fetch function
const response = await fetch(apiUrl, {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Bearer ${token}`
}
});

// Handle the response from the API
if (response.ok) {
const data = await response.json();
console.log("API response:", data);
} else {
console.error("API request failed with status:", response.status);
}

Request Parameters

The following parameters are required when sending an SMS message:

  • sender_id: The ID of the sender. This can be obtained from the sender ID list.
  • schedule: The schedule for sending the message. For schedules available values are daily, weekly, and monthly.
  • start_date: The date to start sending the message. The format is YYYY-MM-DD.
  • end_date: The date to stop sending the message. The format is YYYY-MM-DD.
  • time: The time to send the message. The format is HH:MM.
  • recipients: An array of recipient objects containing the number field. The recipient's phone number should be in international format (e.g., 25571234567).
  • sms: The message to be sent. The message should not exceed 160 characters for a single SMS. For longer messages, use concatenation or Unicode encoding.
  • token: The API token used to authenticate the request.
  • Content-Type: The content type of the request. Set this to application/json.
  • Accept: The expected response format. Set this to application/json.