import { Resend } from 'resend';
const resend = new Resend('re_xxxxxxxxx');
// Trigger with a contact ID
const { data, error } = await resend.events.send({
event: 'user.created',
contactId: '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
payload: {
plan: 'pro',
},
});
// Trigger with an email address
const { data, error } = await resend.events.send({
event: 'user.created',
email: 'steve.wozniak@gmail.com',
payload: {
plan: 'pro',
},
});
{
"object": "workflow_event",
"event": "user.created",
"event_instance_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b"
}
Send a named event to trigger matching workflows.
import { Resend } from 'resend';
const resend = new Resend('re_xxxxxxxxx');
// Trigger with a contact ID
const { data, error } = await resend.events.send({
event: 'user.created',
contactId: '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
payload: {
plan: 'pro',
},
});
// Trigger with an email address
const { data, error } = await resend.events.send({
event: 'user.created',
email: 'steve.wozniak@gmail.com',
payload: {
plan: 'pro',
},
});
{
"object": "workflow_event",
"event": "user.created",
"event_instance_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b"
}
npm install resend@6.10.0-preview-workflows.0
contact_id or email must be provided, but not both.
contact_id is not
provided.import { Resend } from 'resend';
const resend = new Resend('re_xxxxxxxxx');
// Trigger with a contact ID
const { data, error } = await resend.events.send({
event: 'user.created',
contactId: '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
payload: {
plan: 'pro',
},
});
// Trigger with an email address
const { data, error } = await resend.events.send({
event: 'user.created',
email: 'steve.wozniak@gmail.com',
payload: {
plan: 'pro',
},
});
{
"object": "workflow_event",
"event": "user.created",
"event_instance_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b"
}
Was this page helpful?