import { Novu } from '@novu/node';
const novu = new Novu("<NOVU_API_KEY>");
await novu.events.broadcast("<WORKFLOW_TRIGGER_IDENTIFIER>", {
payload: {
customKey: "customValue",
customKey1: {
nestedkey1: "nestedValue1"
}
},
overrides: {
email: {
from: "support@novu.co"
}
},
tenant: "tenantIdentifier"
})
use Novu\SDK\Novu;
$novu = new Novu(<NOVU_API_KEY>);
$novu->broadcastEvent([
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => ['customVariables' => 'Hello'],
'transactionId' => '<REPLACE_WITH_TRANSACTION_ID>'
])->toArray();
require 'novu'
client = Novu::Client.new('<NOVU_API_KEY>')
payload = {
'name' => 'Trigger',
'payload' => {
'first-name' => 'Adam',
'last-name' => 'Eve'
},
'transactionId' => 'sw900999as' #optional
}
client.broadcast_event(payload)
curl -X POST https://api.novu.co/v1/events/trigger/broadcast \
-H "Authorization: ApiKey <NOVU_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "<WORKFLOW_TRIGGER_IDENTIFIER>",
"payload": {
"customKey": "customValue",
"customKey1": {
"nestedkey1": "nestedValue1"
}
},
"overrides": {
"email": {
"from": "support@novu.co"
}
},
"tenant": "tenantIdentifier"
}'
package main
import (
"context"
"fmt"
novu "github.com/novuhq/go-novu/lib"
"log"
)
func main() {
apiKey := "<NOVU_API_KEY>"
ctx := context.Background()
novuClient := novu.NewAPIClient(apiKey, &novu.Config{})
name := interface{}{"<WORKFLOW_TRIGGER_IDENTIFIER>"}
payload := map[string]interface{}{
"name": "Hello World",
"organization": map[string]interface{}{
"logo": "https://happycorp.com/logo.png",
},
}
data := novu.BroadcastEventToAll{Name: name, Payload: payload}
resp, err := novuClient.EventApi.BroadcastToAll(ctx, data)
if err != nil {
log.Fatal("novu error", err.Error())
return
}
}
from novu.api import EventApi
url = "https://api.novu.co"
api_key = "<NOVU_API_KEY>"
novu = EventApi(url, api_key).broadcast(
name="<WORKFLOW_TRIGGER_IDENTIFIER>",
payload={"customVariable": "value"}, # Optional
)
import co.novu.common.base.Novu;
import co.novu.api.common.SubscriberRequest;
import co.novu.api.events.requests.TriggerEventRequest;
import co.novu.api.events.responses.TriggerEventResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "<NOVU_API_KEY>";
Novu novu = new Novu(apiKey);
SubscriberRequest subscriberRequest = new SubscriberRequest();
subscriberRequest.setEmail("<EMAIL_ADDRESS>");
subscriberRequest.setFirstName("<FIRST_NAME>");
subscriberRequest.setLastName("<LAST_NAME>");
subscriberRequest.setPhone("<PHONE_NUMBER>");
subscriberRequest.setAvatar("<AVATAR>");
subscriberRequest.setSubscriberId("<SUBSCRIBER_ID>");
TriggerEventRequest triggerEventRequest = new TriggerEventRequest();
triggerEventRequest.setName("<NAME>");
triggerEventRequest.setTo(subscriberRequest);
triggerEventRequest.setPayload(Collections.singletonMap("<CUSTOM_VARIABLE_NAME>", "<CUSTOM_VARIABLE_VALUE>"));
TriggerEventResponse response = novu.broadcastEvent(triggerEventRequest);
}
}
using Novu.DTO;
using Novu.Models;
using Novu;
var novuConfiguration = new NovuClientConfiguration
{
/**
* Defaults to https://api.novu.co/v1
*/
Url = "https://novu-api.my-domain.com/v1",
ApiKey = "12345",
};
var novu = new NovuClient(novuConfiguration);
var testRecord = new TestRecord
{
Message = "This is a test message"
};
var dto = new EventTriggerDataDto()
{
EventName = "<WORKFLOW_TRIGGER_IDENTIFIER>",
To =
{
SubscriberId = "<UNIQUE_SUBSCRIBER_IDENTIFIER>"
},
Payload = testRecord
};
var trigger = await novu.Event.TriggerBroadcastAsync(dto);
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "string"
}
}
Broadcast event to all
Trigger a broadcast event to all existing subscribers, could be used to send announcements, etc. In the future could be used to trigger events to a subset of subscribers based on defined filters.
import { Novu } from '@novu/node';
const novu = new Novu("<NOVU_API_KEY>");
await novu.events.broadcast("<WORKFLOW_TRIGGER_IDENTIFIER>", {
payload: {
customKey: "customValue",
customKey1: {
nestedkey1: "nestedValue1"
}
},
overrides: {
email: {
from: "support@novu.co"
}
},
tenant: "tenantIdentifier"
})
use Novu\SDK\Novu;
$novu = new Novu(<NOVU_API_KEY>);
$novu->broadcastEvent([
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => ['customVariables' => 'Hello'],
'transactionId' => '<REPLACE_WITH_TRANSACTION_ID>'
])->toArray();
require 'novu'
client = Novu::Client.new('<NOVU_API_KEY>')
payload = {
'name' => 'Trigger',
'payload' => {
'first-name' => 'Adam',
'last-name' => 'Eve'
},
'transactionId' => 'sw900999as' #optional
}
client.broadcast_event(payload)
curl -X POST https://api.novu.co/v1/events/trigger/broadcast \
-H "Authorization: ApiKey <NOVU_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "<WORKFLOW_TRIGGER_IDENTIFIER>",
"payload": {
"customKey": "customValue",
"customKey1": {
"nestedkey1": "nestedValue1"
}
},
"overrides": {
"email": {
"from": "support@novu.co"
}
},
"tenant": "tenantIdentifier"
}'
package main
import (
"context"
"fmt"
novu "github.com/novuhq/go-novu/lib"
"log"
)
func main() {
apiKey := "<NOVU_API_KEY>"
ctx := context.Background()
novuClient := novu.NewAPIClient(apiKey, &novu.Config{})
name := interface{}{"<WORKFLOW_TRIGGER_IDENTIFIER>"}
payload := map[string]interface{}{
"name": "Hello World",
"organization": map[string]interface{}{
"logo": "https://happycorp.com/logo.png",
},
}
data := novu.BroadcastEventToAll{Name: name, Payload: payload}
resp, err := novuClient.EventApi.BroadcastToAll(ctx, data)
if err != nil {
log.Fatal("novu error", err.Error())
return
}
}
from novu.api import EventApi
url = "https://api.novu.co"
api_key = "<NOVU_API_KEY>"
novu = EventApi(url, api_key).broadcast(
name="<WORKFLOW_TRIGGER_IDENTIFIER>",
payload={"customVariable": "value"}, # Optional
)
import co.novu.common.base.Novu;
import co.novu.api.common.SubscriberRequest;
import co.novu.api.events.requests.TriggerEventRequest;
import co.novu.api.events.responses.TriggerEventResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "<NOVU_API_KEY>";
Novu novu = new Novu(apiKey);
SubscriberRequest subscriberRequest = new SubscriberRequest();
subscriberRequest.setEmail("<EMAIL_ADDRESS>");
subscriberRequest.setFirstName("<FIRST_NAME>");
subscriberRequest.setLastName("<LAST_NAME>");
subscriberRequest.setPhone("<PHONE_NUMBER>");
subscriberRequest.setAvatar("<AVATAR>");
subscriberRequest.setSubscriberId("<SUBSCRIBER_ID>");
TriggerEventRequest triggerEventRequest = new TriggerEventRequest();
triggerEventRequest.setName("<NAME>");
triggerEventRequest.setTo(subscriberRequest);
triggerEventRequest.setPayload(Collections.singletonMap("<CUSTOM_VARIABLE_NAME>", "<CUSTOM_VARIABLE_VALUE>"));
TriggerEventResponse response = novu.broadcastEvent(triggerEventRequest);
}
}
using Novu.DTO;
using Novu.Models;
using Novu;
var novuConfiguration = new NovuClientConfiguration
{
/**
* Defaults to https://api.novu.co/v1
*/
Url = "https://novu-api.my-domain.com/v1",
ApiKey = "12345",
};
var novu = new NovuClient(novuConfiguration);
var testRecord = new TestRecord
{
Message = "This is a test message"
};
var dto = new EventTriggerDataDto()
{
EventName = "<WORKFLOW_TRIGGER_IDENTIFIER>",
To =
{
SubscriberId = "<UNIQUE_SUBSCRIBER_IDENTIFIER>"
},
Payload = testRecord
};
var trigger = await novu.Event.TriggerBroadcastAsync(dto);
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "string"
}
}
Authorization field like the example shown below:E.g ApiKey 18d2e625f05d80eimport { Novu } from '@novu/node';
const novu = new Novu("<NOVU_API_KEY>");
await novu.events.broadcast("<WORKFLOW_TRIGGER_IDENTIFIER>", {
payload: {
customKey: "customValue",
customKey1: {
nestedkey1: "nestedValue1"
}
},
overrides: {
email: {
from: "support@novu.co"
}
},
tenant: "tenantIdentifier"
})
use Novu\SDK\Novu;
$novu = new Novu(<NOVU_API_KEY>);
$novu->broadcastEvent([
'name' => '<WORKFLOW_TRIGGER_IDENTIFIER>',
'payload' => ['customVariables' => 'Hello'],
'transactionId' => '<REPLACE_WITH_TRANSACTION_ID>'
])->toArray();
require 'novu'
client = Novu::Client.new('<NOVU_API_KEY>')
payload = {
'name' => 'Trigger',
'payload' => {
'first-name' => 'Adam',
'last-name' => 'Eve'
},
'transactionId' => 'sw900999as' #optional
}
client.broadcast_event(payload)
curl -X POST https://api.novu.co/v1/events/trigger/broadcast \
-H "Authorization: ApiKey <NOVU_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"name": "<WORKFLOW_TRIGGER_IDENTIFIER>",
"payload": {
"customKey": "customValue",
"customKey1": {
"nestedkey1": "nestedValue1"
}
},
"overrides": {
"email": {
"from": "support@novu.co"
}
},
"tenant": "tenantIdentifier"
}'
package main
import (
"context"
"fmt"
novu "github.com/novuhq/go-novu/lib"
"log"
)
func main() {
apiKey := "<NOVU_API_KEY>"
ctx := context.Background()
novuClient := novu.NewAPIClient(apiKey, &novu.Config{})
name := interface{}{"<WORKFLOW_TRIGGER_IDENTIFIER>"}
payload := map[string]interface{}{
"name": "Hello World",
"organization": map[string]interface{}{
"logo": "https://happycorp.com/logo.png",
},
}
data := novu.BroadcastEventToAll{Name: name, Payload: payload}
resp, err := novuClient.EventApi.BroadcastToAll(ctx, data)
if err != nil {
log.Fatal("novu error", err.Error())
return
}
}
from novu.api import EventApi
url = "https://api.novu.co"
api_key = "<NOVU_API_KEY>"
novu = EventApi(url, api_key).broadcast(
name="<WORKFLOW_TRIGGER_IDENTIFIER>",
payload={"customVariable": "value"}, # Optional
)
import co.novu.common.base.Novu;
import co.novu.api.common.SubscriberRequest;
import co.novu.api.events.requests.TriggerEventRequest;
import co.novu.api.events.responses.TriggerEventResponse;
public class Main {
public static void main(String[] args) {
String apiKey = "<NOVU_API_KEY>";
Novu novu = new Novu(apiKey);
SubscriberRequest subscriberRequest = new SubscriberRequest();
subscriberRequest.setEmail("<EMAIL_ADDRESS>");
subscriberRequest.setFirstName("<FIRST_NAME>");
subscriberRequest.setLastName("<LAST_NAME>");
subscriberRequest.setPhone("<PHONE_NUMBER>");
subscriberRequest.setAvatar("<AVATAR>");
subscriberRequest.setSubscriberId("<SUBSCRIBER_ID>");
TriggerEventRequest triggerEventRequest = new TriggerEventRequest();
triggerEventRequest.setName("<NAME>");
triggerEventRequest.setTo(subscriberRequest);
triggerEventRequest.setPayload(Collections.singletonMap("<CUSTOM_VARIABLE_NAME>", "<CUSTOM_VARIABLE_VALUE>"));
TriggerEventResponse response = novu.broadcastEvent(triggerEventRequest);
}
}
using Novu.DTO;
using Novu.Models;
using Novu;
var novuConfiguration = new NovuClientConfiguration
{
/**
* Defaults to https://api.novu.co/v1
*/
Url = "https://novu-api.my-domain.com/v1",
ApiKey = "12345",
};
var novu = new NovuClient(novuConfiguration);
var testRecord = new TestRecord
{
Message = "This is a test message"
};
var dto = new EventTriggerDataDto()
{
EventName = "<WORKFLOW_TRIGGER_IDENTIFIER>",
To =
{
SubscriberId = "<UNIQUE_SUBSCRIBER_IDENTIFIER>"
},
Payload = testRecord
};
var trigger = await novu.Event.TriggerBroadcastAsync(dto);
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "string"
}
}
Authorizations
API key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".
Body
The trigger identifier associated for the template you wish to send. This identifier can be found on the template page.
The payload object is used to pass additional custom information that could be used to render the template, or perform routing rules based on it. This data will also be available when fetching the notifications feed from the API to display certain parts of the UI.
{
"comment_id": "string",
"post": { "text": "string" }
}
This could be used to override provider specific configurations
{ "fcm": { "data": { "key": "value" } } }
A unique identifier for this transaction, we will generated a UUID if not provided.
It is used to display the Avatar of the provided actor's subscriber id or actor object. If a new actor object is provided, we will create a new subscriber in our system
It is used to specify a tenant context during trigger event. If a new tenant object is provided, we will create a new tenant.
Response
Ok
If trigger was acknowledged or not
Status for trigger
error, trigger_not_active, no_workflow_active_steps_defined, no_workflow_steps_defined, processed, subscriber_id_missing, no_tenant_found In case of an error, this field will contain the error message
Transaction id for trigger
Was this page helpful?