Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Custom Events

Custom events are used to trigger automations and can be defined with an optional schema for payload validation.

If a schema is defined, payloads are validated when the event is sent. Fields that don't match the expected type are rejected with a 422 error and the event is not delivered.

  1. Navigate to the Events Page

    The Events page shows all existing events.

  2. Click the Add Event button

    Click Add event to create a new event.

  3. Enter Event Details

    Enter the event name and optional schema to define the event payload you will send with the event.

    Add Event

  4. Save the Event

    When you're done, Save the event.

All existing events can be retrieved using the List Events API.

To create a new event, use the Create Event API and provide an event name and optional schema.

Node.js
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.events.create({
  name: 'user.created',
  schema: {
    plan: 'string',
  },
});
PHP
$resend = Resend::client('re_xxxxxxxxx');

$resend->events->create([
  'name' => 'user.created',
  'schema' => ['plan' => 'string'],
]);
Python
import resend

resend.api_key = "re_xxxxxxxxx"

params: resend.Events.CreateParams = {
  "name": "user.created",
  "schema": {
    "plan": "string",
  },
}

resend.Events.create(params)
Ruby
require "resend"

Resend.api_key = "re_xxxxxxxxx"

params = {
  name: "user.created",
  schema: {
    plan: "string",
  },
}

Resend::Events.create(params)
Go
package main

import "github.com/resend/resend-go/v4"

func main() {
	client := resend.NewClient("re_xxxxxxxxx")

	params := &resend.CreateEventRequest{
		Name: "user.created",
		Schema: map[string]string{
			"plan": resend.EventSchemaTypeString,
		},
	}

	client.Events.Create(params)
}
Rust
use resend_rs::{json, types::CreateEventOptions, Resend, Result};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let opts = CreateEventOptions {
    name: "user.created".to_owned(),
    schema: json!({
      "plan": "string",
    }),
  };

  let _event = resend.events.create(opts).await?;

  Ok(())
}
Java
import com.resend.*;
import com.resend.core.exception.ResendException;
import com.resend.services.events.model.CreateEventOptions;
import com.resend.services.events.model.CreateEventResponseSuccess;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        CreateEventOptions params = CreateEventOptions.builder()
                .name("user.created")
                .addSchema("plan", "string")
                .build();

        CreateEventResponseSuccess data = resend.events().create(params);
    }
}
.NET
using Resend;
using System.Text.Json;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" );

var schema = JsonSerializer.SerializeToElement( new { plan = "string" } );

var resp = await resend.EventCreateAsync( new EventCreateData()
{
    Name = "user.created",
    Schema = schema,
} );
Console.WriteLine( "EventId={0}", resp.Content );
cURL
curl -X POST 'https://api.resend.com/events' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d '{
  "name": "user.created",
  "schema": {
    "plan": "string"
  }
}'
CLI
resend events create --name user.created --schema '{"plan":"string"}'

View the Create Event API reference for the full endpoint specification.

  • config.name (string, required) — The name of the custom event to create. Used to match events to automation triggers.
  • config.schema (object) — An optional schema definition for the event payload. Must be an object with flat key/type pairs. Supported types: string, number, boolean, date.
Example
{
  "schema": {
    "plan": "string",
    "amount": "number",
    "date": "date",
    "is_active": "boolean"
  }
}
Suggest an edit

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

Export
Documentation menu