Skip to main content

File 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 sendFileMessage = async() => {
const token = 'YOUR_API_TOKEN'
const selectedFile = document.getElementById('file').files[0]
const baseUrl = 'https://example.com/v2'
try {
const formData = new FormData()
formData.append('contacts', selectedFile) // can be from html <input type="file" />
formData.append('sender_id', 1) //see the ID of the sender-ID on system dashboard
formData.append('message', "Hello World! I am sending my first SMS message using Notify Africa API to contacts in a file")

const response = await fetch(`${baseUrl}/smses/file/send`, {
method: 'POST',
body: formData,
headers: {
'Authorization': `Bearer ${token}`
},
});

const json = await response.json()

if (response.ok) {
console.log(json.message)
}

if (!response.ok) {
console.log(json.message);
}

} catch (err) {
console.log('Error while uploading file');
}
}

Request Parameters

The following parameters are required when sending an SMS message:

  • contacts: The file containing the contacts to send the message to.
  • sender_id: The ID of the sender ID to use when sending the message.
  • message: The message to send to the contacts in the file.
  • Content-Type: multipart/form-data