Skip to main content
POST
/
webhooks
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.webhooks.create({
  endpoint: 'https://example.com/handler',
  events: ['email.sent'],
});
$resend = Resend::client('re_xxxxxxxxx');

$resend->webhooks->create([
  'endpoint' => 'https://example.com/handler',
  'events' => ['email.sent'],
]);
import resend

resend.api_key = 're_xxxxxxxxx'

params: resend.Webhooks.CreateParams = {
    "endpoint": "https://example.com/handler",
    "events": ["email.sent"],
}

webhook = resend.Webhooks.create(params=params)
require 'resend'

Resend.api_key = 're_xxxxxxxxx'

params = {
  endpoint: 'https://example.com/handler',
  events: ['email.sent']
}

webhook = Resend::Webhooks.create(params)
package main

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

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

	params := &resend.CreateWebhookRequest{
		Endpoint: "https://example.com/handler",
		Events:   []string{"email.sent"},
	}

	client.Webhooks.Create(params)
}
use resend_rs::{
  events::EmailEventType::{EmailSent},
  types::CreateWebhookOptions,
  Resend, Result,
};

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

  let events = [EmailSent];
  let opts = CreateWebhookOptions::new("https://example.com/handler", events);
  let _webhook = resend.webhooks.create(opts).await?;

  Ok(())
}
import com.resend.*;
import static com.resend.services.webhooks.model.WebhookEvent.*;

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

        CreateWebhookOptions options = CreateWebhookOptions.builder()
              .endpoint("https://example.com/handler")
              .events(EMAIL_SENT)
              .build();

        CreateWebhookResponseSuccess response = resend.webhooks().create(options);
    }
}
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

var data = new WebhookData()
{
    EndpointUrl = "https://example.com/handler",
    Events = [ WebhookEventType.EmailSent ],
    Status = WebhookStatus.Disabled,
};

var resp = await resend.WebhookCreateAsync( data );
Console.WriteLine( "Webhook Id={0}", resp.Content.Id );
Console.WriteLine( "Signing secret={0}", resp.Content.SigningSecret );
curl -X POST 'https://api.resend.com/webhooks' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d '{
  "endpoint": "https://example.com/handler",
  "events": ["email.sent"]
}'
resend webhooks create \
  --endpoint https://example.com/handler \
  --events email.sent
{
  "object": "webhook",
  "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0",
  "signing_secret": "whsec_xxxxxxxxxx"
}

Body Parameters

endpoint
string
required
The URL where webhook events will be sent.
events
string[]
required
Array of event types to subscribe to.See event types for available options.
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.webhooks.create({
  endpoint: 'https://example.com/handler',
  events: ['email.sent'],
});
$resend = Resend::client('re_xxxxxxxxx');

$resend->webhooks->create([
  'endpoint' => 'https://example.com/handler',
  'events' => ['email.sent'],
]);
import resend

resend.api_key = 're_xxxxxxxxx'

params: resend.Webhooks.CreateParams = {
    "endpoint": "https://example.com/handler",
    "events": ["email.sent"],
}

webhook = resend.Webhooks.create(params=params)
require 'resend'

Resend.api_key = 're_xxxxxxxxx'

params = {
  endpoint: 'https://example.com/handler',
  events: ['email.sent']
}

webhook = Resend::Webhooks.create(params)
package main

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

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

	params := &resend.CreateWebhookRequest{
		Endpoint: "https://example.com/handler",
		Events:   []string{"email.sent"},
	}

	client.Webhooks.Create(params)
}
use resend_rs::{
  events::EmailEventType::{EmailSent},
  types::CreateWebhookOptions,
  Resend, Result,
};

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

  let events = [EmailSent];
  let opts = CreateWebhookOptions::new("https://example.com/handler", events);
  let _webhook = resend.webhooks.create(opts).await?;

  Ok(())
}
import com.resend.*;
import static com.resend.services.webhooks.model.WebhookEvent.*;

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

        CreateWebhookOptions options = CreateWebhookOptions.builder()
              .endpoint("https://example.com/handler")
              .events(EMAIL_SENT)
              .build();

        CreateWebhookResponseSuccess response = resend.webhooks().create(options);
    }
}
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

var data = new WebhookData()
{
    EndpointUrl = "https://example.com/handler",
    Events = [ WebhookEventType.EmailSent ],
    Status = WebhookStatus.Disabled,
};

var resp = await resend.WebhookCreateAsync( data );
Console.WriteLine( "Webhook Id={0}", resp.Content.Id );
Console.WriteLine( "Signing secret={0}", resp.Content.SigningSecret );
curl -X POST 'https://api.resend.com/webhooks' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d '{
  "endpoint": "https://example.com/handler",
  "events": ["email.sent"]
}'
resend webhooks create \
  --endpoint https://example.com/handler \
  --events email.sent
{
  "object": "webhook",
  "id": "4dd369bc-aa82-4ff3-97de-514ae3000ee0",
  "signing_secret": "whsec_xxxxxxxxxx"
}