Comment on page
Backend API
The backend API is used by your SaaS server to send messages and sync your users profiles.
In Notifuse, a notification is not a message, it defines which channels the messages will be sent to and contains templates for each language.
When you want to notify your users, you will actually send a message.
The backend API endpoint is:
https://api.notifuse.com/
and the data is sent as JSON.All the following methods require to be authenticated with the
Authorization
HTTP header and your project API Key like this: Authorization: Bearer YOUR_PROJECT_API_KEY
The project API Key is provided in your projects settings.
When you send a message to a user, the required fields are
notificationId
and userId
. If the user you are sending a message to, doesn't exist yet in Notifuse, it will be automatically created. The user profile fields (userEmail
, userTelephone
...) provided with your message, will update the user profile in Notifuse if missing.The messages.send endpoint accepts a batch of 50 messages max. Messages will be processed in parallel, and emails/sms are sent synchronously.
If you don't provide a unique
id
for your messages, Notifuse will generate one. If you provide an id
and you send it many times, an error "id/exists" will be returned for your message.The endpoint returns the results for each message. If nothing bad happened on the Notifuse side, the
ok
field will be true
. If an error occurred within Notifuse, the
ok
field will be false
and the error
field will be set. If an error occurred with the email and/or SMS provider, the
ok
field will still be true
but the emailError
and/or smsError
fields will be set.POST https://api.notifuse.com/messages.send
Request payload
Response
{
"messages": [
{
"notificationId": "welcome", // REQUIRED
"userId": "xxxx", // REQUIRED
// optional fields
"data": {}, // JSON payload to customize your templates
"id": "your-unique-id", // Notifuse will generate one otherwise
"userEmail": "[email protected]", // Provide an email if the user doesn't exist yet in Notifuse
"userTelephone": "+44 123456789", // International format
"userLanguage": "en",
"userTimezone": "Europe/London",
"userFirstName": "John",
"userLastName": "Doe",
"userPhotoURL": "https://....jpg",
"userCountry": "GB",
"incrementId": "xxxx", // Used to increment a counter on similar notifications to avoid spamming your users.
// Override template settings at the message level
"widgetSettingsOverride": {
"iconURL": "https://..." // widget notification icon
},
"emailSettingsOverride": {
"subject": "Hello {{ firstName }}", // overrided subject for this message
"replyTo": "[email protected]", // replyTo email address
"cc": "[email protected],[email protected]", // CC emails separated by a comma
"bcc": "[email protected],[email protected]" // BCC emails separated by a comma
}
},
...
]
}
{
"code": 200,
"results": [
{"id": "xxxx", "ok": true, "stackIncremented": false},
{"id": "xxxx", "ok": false, "stackIncremented": false, "error": "notificationId/invalid"},
{"id": "xxxx", "ok": true, "stackIncremented": false, "emailError": "Your sending address is blacklisted."},
...
]
}
Message fields | Type | Description |
notificationId | String - Required | The notification ID |
userId | String - Required | The user ID |
data | JSON object | A JSON object that contains the data required to customize your templates. |
id | String | Unique message ID. Notifuse will generate one otherwise. |
incrementId | String | Increment ID used to increment similar notifications instead of spamming your user. When the stack timeout is passed, a new message is created. |
userEmail | String | Provide an email if your notification is sent by email and the user profile doesn't exist yet in Notifuse. |
userTelephone | String | Provide a mobile phone number in international format if your notification is sent by SMS and the user profile doesn't exist yet in Notifuse. |
userLanguage | String | User preferred language for notifications. |
userTimezone | String | User preferred timezone for scheduled notifications. |
userFirstName | String | User first name, in case the user profile doesn't exist yet in Notifuse. |
userLastName | String | User last name, in case the user profile doesn't exist yet in Notifuse. |
userPhotoURL | String | User photo URL, in case the user profile doesn't exist yet in Notifuse. |
userCountry | String | User country in ISO format (US, GB, FR...), in case the user profile doesn't exist yet in Notifuse. |
widgetSettingsOverride | Object | Object of widget template settings to override. |
emailSettingsOverride | Object | Object of email template settings to override. |
It is important to import your contacts (= users) into Notifuse before sending notifications so you can avoid attaching the user profile fields (
userEmail
, userLanguage
etc...) when you send messages (see Send Message).This endpoint will create the user profiles if they don't exist yet or update them with missing fields.
This endpoint will create the user profiles if they don't exist yet or update them with missing fields. It accepts a batch of 100 users max.
POST https://api.notifuse.com/users.upsert
Request payload
Response
{
"users": [
{
"id": "your-user-unique-id",
"email": "[email protected]",
"telephone": "+44 123456789", // International format
"language": "en",
"timezone": "Europe/London",
"firstName": "John",
"lastName": "Doe",
"photoURL": "https://....jpg",
"country": "GB"
},
...
]
}
{
"code": 200,
"users": [
{"id": "xxxx", "ok": true},
{"id": "xxxx", "ok": false, "error": "country/invalid"}
...
]
}
Last modified 14d ago