Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Send Event

POST

/

events

/

send

Node.js
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',
  },
});
PHP
$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'],
]);
Python
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)
Ruby
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)
Go
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)
}
Rust
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(())
}
Java
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);
    }
}
.NET
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,
} );
cURL
# 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"
  }
}'
CLI
# 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"}'
Response
{
  "object": "event",
  "event": "user.created"
}

string

required

The name of the event to trigger. Must match the event name configured in an automation trigger step.

Either contact_id or email must be provided, but not both.

string

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.

object

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.

Node.js
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',
  },
});
PHP
$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'],
]);
Python
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)
Ruby
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)
Go
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)
}
Rust
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(())
}
Java
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);
    }
}
.NET
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,
} );
cURL
# 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"
  }
}'
CLI
# 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"}'
JSON
{
  "object": "event",
  "event": "user.created"
}

Was this page helpful?

⌘I

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu