Send Event
Send a named event to trigger matching automations.
POST
/
events
/
send
import { Resend } from 'resend';
const resend = new Resend('re_xxxxxxxxx');
const { data, error } = await resend.events.send({
event: 'user.created',
contactId: '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
// or: email: 'steve.wozniak@gmail.com',
payload: {
plan: 'pro',
},
});
$resend = Resend::client('re_xxxxxxxxx');
// Trigger with a contact ID
$resend->events->send([
'event' => 'user.created',
'contact_id' => '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
'payload' => ['plan' => 'pro'],
]);
// Trigger with an email address
$resend->events->send([
'event' => 'user.created',
'email' => 'steve.wozniak@gmail.com',
'payload' => ['plan' => 'pro'],
]);
import resend
resend.api_key = "re_xxxxxxxxx"
# Trigger with a contact ID
params: resend.Events.SendParams = {
"event": "user.created",
"contact_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
"payload": {
"plan": "pro",
},
}
resend.Events.send(params)
# Trigger with an email address
params: resend.Events.SendParams = {
"event": "user.created",
"email": "steve.wozniak@gmail.com",
"payload": {
"plan": "pro",
},
}
resend.Events.send(params)
require "resend"
Resend.api_key = "re_xxxxxxxxx"
# Trigger with a contact ID
params = {
event: "user.created",
contact_id: "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
payload: {
plan: "pro",
},
}
Resend::Events.send(params)
# Trigger with an email address
params = {
event: "user.created",
email: "steve.wozniak@gmail.com",
payload: {
plan: "pro",
},
}
Resend::Events.send(params)
package main
import "github.com/resend/resend-go/v4"
func main() {
client := resend.NewClient("re_xxxxxxxxx")
// Trigger with a contact ID
params := &resend.SendEventRequest{
Event: "user.created",
ContactId: "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
Payload: map[string]any{
"plan": "pro",
},
}
client.Events.Send(params)
// Trigger with an email address
params = &resend.SendEventRequest{
Event: "user.created",
Email: "steve.wozniak@gmail.com",
Payload: map[string]any{
"plan": "pro",
},
}
client.Events.Send(params)
}
use resend_rs::{
json,
types::{ContactIdOrEmail, SendEventOptions},
Resend, Result,
};
#[tokio::main]
async fn main() -> Result<()> {
let resend = Resend::new("re_xxxxxxxxx");
let opts = SendEventOptions {
event: "user.created".to_owned(),
contact_id_or_email: ContactIdOrEmail::ContactId(
"7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b".to_owned(),
),
// or: ContactIdOrEmail::Email("steve.wozniak@gmail.com".to_owned())
payload: json!({
"plan": "pro"
}),
};
let _event = resend.events.send(opts).await?;
Ok(())
}
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.events.model.SendEventOptions;
import com.resend.services.events.model.SendEventResponseSuccess;
public class Main {
public static void main(String[] args) throws ResendException {
Resend resend = new Resend("re_xxxxxxxxx");
SendEventOptions params = SendEventOptions.builder()
.event("user.created")
.contactId("7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b") // or: .email("steve.wozniak@gmail.com")
.addPayload("plan", "pro")
.build();
SendEventResponseSuccess data = resend.events().send(params);
}
}
using Resend;
using System.Text.Json;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" );
var payload = JsonSerializer.SerializeToElement( new { plan = "pro" } );
// Trigger with a contact ID
var resp = await resend.EventSendAsync( new EventSendData()
{
Event = "user.created",
ContactId = new Guid( "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b" ),
Payload = payload,
} );
Console.WriteLine( "Event={0}", resp.Content.Event );
// Trigger with an email address
await resend.EventSendAsync( new EventSendData()
{
Event = "user.created",
Email = "steve.wozniak@gmail.com",
Payload = payload,
} );
# Trigger with a contact ID
curl -X POST 'https://api.resend.com/events/send' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"event": "user.created",
"contact_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
"payload": {
"plan": "pro"
}
}'
# Trigger with an email address
curl -X POST 'https://api.resend.com/events/send' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"event": "user.created",
"email": "steve.wozniak@gmail.com",
"payload": {
"plan": "pro"
}
}'
# Trigger with a contact ID
resend events send \
--event user.created \
--contact-id 7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b \
--payload '{"plan":"pro"}'
# Trigger with an email address
resend events send \
--event user.created \
--email steve.wozniak@gmail.com \
--payload '{"plan":"pro"}'
{
"object": "event",
"event": "user.created"
}
Body Parameters
The name of the event to trigger. Must match the event name configured in an
Automation trigger step.
contact_id or email must be provided, but not both.
The email address to associate with this event. Exactly one of
contact_id or
email must be provided. If no contact with this email exists in your
Audience, one will be created automatically when the Automation runs.An optional object containing custom data to pass to the Automation. This data
can be used in template variables and conditions. If the event has a schema
defined, the payload values will be validated and coerced to match the schema
types.
Headers
Add an idempotency key to prevent duplicate Automation runs.
- Use a key that identifies the event in your system, like
order/123 - Idempotency keys expire after 24 hours
- Have a maximum length of 256 characters
- Keys are scoped to the event name and the contact (
contact_idoremail), so the same key with another event or contact is a separate request - The
emailandcontact_idare compared case-insensitively - The same contact sent once by
contact_idand once byemailcounts as two requests - A retry with the same key returns the first successful response, with the
Idempotent-Replayed: trueheader, and starts no runs, even if thepayloadchanged - A failed request isn’t stored, so you can retry it with the same key
- Reusing the key while the first request is still running returns a
409
import { Resend } from 'resend';
const resend = new Resend('re_xxxxxxxxx');
const { data, error } = await resend.events.send({
event: 'user.created',
contactId: '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
// or: email: 'steve.wozniak@gmail.com',
payload: {
plan: 'pro',
},
});
$resend = Resend::client('re_xxxxxxxxx');
// Trigger with a contact ID
$resend->events->send([
'event' => 'user.created',
'contact_id' => '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
'payload' => ['plan' => 'pro'],
]);
// Trigger with an email address
$resend->events->send([
'event' => 'user.created',
'email' => 'steve.wozniak@gmail.com',
'payload' => ['plan' => 'pro'],
]);
import resend
resend.api_key = "re_xxxxxxxxx"
# Trigger with a contact ID
params: resend.Events.SendParams = {
"event": "user.created",
"contact_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
"payload": {
"plan": "pro",
},
}
resend.Events.send(params)
# Trigger with an email address
params: resend.Events.SendParams = {
"event": "user.created",
"email": "steve.wozniak@gmail.com",
"payload": {
"plan": "pro",
},
}
resend.Events.send(params)
require "resend"
Resend.api_key = "re_xxxxxxxxx"
# Trigger with a contact ID
params = {
event: "user.created",
contact_id: "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
payload: {
plan: "pro",
},
}
Resend::Events.send(params)
# Trigger with an email address
params = {
event: "user.created",
email: "steve.wozniak@gmail.com",
payload: {
plan: "pro",
},
}
Resend::Events.send(params)
package main
import "github.com/resend/resend-go/v4"
func main() {
client := resend.NewClient("re_xxxxxxxxx")
// Trigger with a contact ID
params := &resend.SendEventRequest{
Event: "user.created",
ContactId: "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
Payload: map[string]any{
"plan": "pro",
},
}
client.Events.Send(params)
// Trigger with an email address
params = &resend.SendEventRequest{
Event: "user.created",
Email: "steve.wozniak@gmail.com",
Payload: map[string]any{
"plan": "pro",
},
}
client.Events.Send(params)
}
use resend_rs::{
json,
types::{ContactIdOrEmail, SendEventOptions},
Resend, Result,
};
#[tokio::main]
async fn main() -> Result<()> {
let resend = Resend::new("re_xxxxxxxxx");
let opts = SendEventOptions {
event: "user.created".to_owned(),
contact_id_or_email: ContactIdOrEmail::ContactId(
"7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b".to_owned(),
),
// or: ContactIdOrEmail::Email("steve.wozniak@gmail.com".to_owned())
payload: json!({
"plan": "pro"
}),
};
let _event = resend.events.send(opts).await?;
Ok(())
}
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.events.model.SendEventOptions;
import com.resend.services.events.model.SendEventResponseSuccess;
public class Main {
public static void main(String[] args) throws ResendException {
Resend resend = new Resend("re_xxxxxxxxx");
SendEventOptions params = SendEventOptions.builder()
.event("user.created")
.contactId("7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b") // or: .email("steve.wozniak@gmail.com")
.addPayload("plan", "pro")
.build();
SendEventResponseSuccess data = resend.events().send(params);
}
}
using Resend;
using System.Text.Json;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" );
var payload = JsonSerializer.SerializeToElement( new { plan = "pro" } );
// Trigger with a contact ID
var resp = await resend.EventSendAsync( new EventSendData()
{
Event = "user.created",
ContactId = new Guid( "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b" ),
Payload = payload,
} );
Console.WriteLine( "Event={0}", resp.Content.Event );
// Trigger with an email address
await resend.EventSendAsync( new EventSendData()
{
Event = "user.created",
Email = "steve.wozniak@gmail.com",
Payload = payload,
} );
# Trigger with a contact ID
curl -X POST 'https://api.resend.com/events/send' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"event": "user.created",
"contact_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
"payload": {
"plan": "pro"
}
}'
# Trigger with an email address
curl -X POST 'https://api.resend.com/events/send' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"event": "user.created",
"email": "steve.wozniak@gmail.com",
"payload": {
"plan": "pro"
}
}'
# Trigger with a contact ID
resend events send \
--event user.created \
--contact-id 7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b \
--payload '{"plan":"pro"}'
# Trigger with an email address
resend events send \
--event user.created \
--email steve.wozniak@gmail.com \
--payload '{"plan":"pro"}'
Successful requests return 202 Accepted with the JSON body below. If the
request includes an
Idempotency-Key, the response also includes an
Idempotent-Replayed header. It’s true when Resend returns the stored
response of an earlier request, and false when it processes the request.{
"object": "event",
"event": "user.created"
}
Was this page helpful?
⌘I
import { Resend } from 'resend';
const resend = new Resend('re_xxxxxxxxx');
const { data, error } = await resend.events.send({
event: 'user.created',
contactId: '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
// or: email: 'steve.wozniak@gmail.com',
payload: {
plan: 'pro',
},
});
$resend = Resend::client('re_xxxxxxxxx');
// Trigger with a contact ID
$resend->events->send([
'event' => 'user.created',
'contact_id' => '7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b',
'payload' => ['plan' => 'pro'],
]);
// Trigger with an email address
$resend->events->send([
'event' => 'user.created',
'email' => 'steve.wozniak@gmail.com',
'payload' => ['plan' => 'pro'],
]);
import resend
resend.api_key = "re_xxxxxxxxx"
# Trigger with a contact ID
params: resend.Events.SendParams = {
"event": "user.created",
"contact_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
"payload": {
"plan": "pro",
},
}
resend.Events.send(params)
# Trigger with an email address
params: resend.Events.SendParams = {
"event": "user.created",
"email": "steve.wozniak@gmail.com",
"payload": {
"plan": "pro",
},
}
resend.Events.send(params)
require "resend"
Resend.api_key = "re_xxxxxxxxx"
# Trigger with a contact ID
params = {
event: "user.created",
contact_id: "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
payload: {
plan: "pro",
},
}
Resend::Events.send(params)
# Trigger with an email address
params = {
event: "user.created",
email: "steve.wozniak@gmail.com",
payload: {
plan: "pro",
},
}
Resend::Events.send(params)
package main
import "github.com/resend/resend-go/v4"
func main() {
client := resend.NewClient("re_xxxxxxxxx")
// Trigger with a contact ID
params := &resend.SendEventRequest{
Event: "user.created",
ContactId: "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
Payload: map[string]any{
"plan": "pro",
},
}
client.Events.Send(params)
// Trigger with an email address
params = &resend.SendEventRequest{
Event: "user.created",
Email: "steve.wozniak@gmail.com",
Payload: map[string]any{
"plan": "pro",
},
}
client.Events.Send(params)
}
use resend_rs::{
json,
types::{ContactIdOrEmail, SendEventOptions},
Resend, Result,
};
#[tokio::main]
async fn main() -> Result<()> {
let resend = Resend::new("re_xxxxxxxxx");
let opts = SendEventOptions {
event: "user.created".to_owned(),
contact_id_or_email: ContactIdOrEmail::ContactId(
"7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b".to_owned(),
),
// or: ContactIdOrEmail::Email("steve.wozniak@gmail.com".to_owned())
payload: json!({
"plan": "pro"
}),
};
let _event = resend.events.send(opts).await?;
Ok(())
}
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.events.model.SendEventOptions;
import com.resend.services.events.model.SendEventResponseSuccess;
public class Main {
public static void main(String[] args) throws ResendException {
Resend resend = new Resend("re_xxxxxxxxx");
SendEventOptions params = SendEventOptions.builder()
.event("user.created")
.contactId("7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b") // or: .email("steve.wozniak@gmail.com")
.addPayload("plan", "pro")
.build();
SendEventResponseSuccess data = resend.events().send(params);
}
}
using Resend;
using System.Text.Json;
IResend resend = ResendClient.Create( "re_xxxxxxxxx" );
var payload = JsonSerializer.SerializeToElement( new { plan = "pro" } );
// Trigger with a contact ID
var resp = await resend.EventSendAsync( new EventSendData()
{
Event = "user.created",
ContactId = new Guid( "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b" ),
Payload = payload,
} );
Console.WriteLine( "Event={0}", resp.Content.Event );
// Trigger with an email address
await resend.EventSendAsync( new EventSendData()
{
Event = "user.created",
Email = "steve.wozniak@gmail.com",
Payload = payload,
} );
# Trigger with a contact ID
curl -X POST 'https://api.resend.com/events/send' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"event": "user.created",
"contact_id": "7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b",
"payload": {
"plan": "pro"
}
}'
# Trigger with an email address
curl -X POST 'https://api.resend.com/events/send' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"event": "user.created",
"email": "steve.wozniak@gmail.com",
"payload": {
"plan": "pro"
}
}'
# Trigger with a contact ID
resend events send \
--event user.created \
--contact-id 7f2e4a3b-dfbc-4e9a-8b2c-5f3a1d6e7c8b \
--payload '{"plan":"pro"}'
# Trigger with an email address
resend events send \
--event user.created \
--email steve.wozniak@gmail.com \
--payload '{"plan":"pro"}'
{
"object": "event",
"event": "user.created"
}