Was macht resend?
Diese Fähigkeit bei der Arbeit mit der Resend-E-Mail-API verwenden – Senden von Transaktions-E-Mails (einzeln oder als Stapel), Empfangen eingehender E-Mails über Webhooks, Verwalten von E-Mail-Vorlagen, Verfolgen von Zustellereignissen, Verwalten von Domänen, Kontakten, Sendungen, Webhooks, API-Schlüsseln, Automatisierungen, Ereignissen, Anzeigen von API-Anforderungsprotokollen oder Einrichten des Resend SDK. Verwenden Sie diese Fähigkeit immer, wenn der Benutzer Resend erwähnt, selbst bei einfachen Aufgaben wie „Senden Sie eine E-Mail mit Resend“ – die Fähigkeit enthält kritische Fallstricke (Idempotenzschlüssel, Webhook-Überprüfung, Syntax von Vorlagenvariablen), die häufige Produktionsprobleme verhindern.
Idempotenzschlüssel
Verwenden Sie den Idempotency-Key-Header bei jedem Aufruf zum Senden von E-Mails.
POST https://api.resend.com/emails
Header: Idempotency-Key: <eindeutige_ID>
Body: {
"from": "[email protected]",
"to": "[email protected]",
"subject": "Hallo Welt",
"html": "<p>Es funktioniert!</p>"
}
Webhook-Überprüfung
Überprüfen Sie eingehende Webhook-Anfragen mit dem Resend-Signatur-Header.
// Beispiel mit Node.js
const crypto = require('crypto');
function verifyWebhookSignature(payload, signature, secret) {
const computedSignature = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return computedSignature === signature;
}
Syntax von Vorlagenvariablen
Verwenden Sie die doppelte geschweifte Klammer {{ variable }} in E-Mail-Vorlagen.
Betreff: Willkommen {{ name }}!
HTML: <p>Hallo {{ name }}, willkommen bei {{ product }}.</p>
Senden von E-Mails (einfach)
curl -X POST https://api.resend.com/emails \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json" \
-d '{
"from": "[email protected]",
"to": "[email protected]",
"subject": "Hallo Welt",
"html": "<p>Es funktioniert!</p>"
}'
Senden von Stapel-E-Mails
curl -X POST https://api.resend.com/emails/batch \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json" \
-d '[
{
"from": "[email protected]",
"to": "[email protected]",
"subject": "Hallo 1",
"html": "<p>Nachricht 1</p>"
},
{
"from": "[email protected]",
"to": "[email protected]",
"subject": "Hallo 2",
"html": "<p>Nachricht 2</p>"
}
]'
Verwalten von Domänen
# Domäne hinzufügen
curl -X POST https://api.resend.com/domains \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json" \
-d '{
"name": "example.com",
"region": "us-east-1"
}'
# Domänen auflisten
curl -X GET https://api.resend.com/domains \
-H "Authorization: Bearer re_<API-Schlüssel>"
Verwalten von Kontakten
# Kontakt erstellen
curl -X POST https://api.resend.com/contacts \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"first_name": "Max",
"last_name": "Mustermann",
"unsubscribed": false
}'
# Kontakte auflisten
curl -X GET https://api.resend.com/contacts \
-H "Authorization: Bearer re_<API-Schlüssel>"
Verwaltung von Sendungen
# Sendung erstellen
curl -X POST https://api.resend.com/broadcasts \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json" \
-d '{
"from": "[email protected]",
"subject": "Monatliches Update",
"html": "<p>Hier ist Ihr monatliches Update!</p>"
}'
# Sendung senden
curl -X POST https://api.resend.com/broadcasts/<id>/send \
-H "Authorization: Bearer re_<API-Schlüssel>"
Verwaltung von Webhooks
# Webhook erstellen
curl -X POST https://api.resend.com/webhooks \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/webhook",
"events": ["email.sent", "email.delivered", "email.bounced"]
}'
# Webhooks auflisten
curl -X GET https://api.resend.com/webhooks \
-H "Authorization: Bearer re_<API-Schlüssel>"
Verwaltung von API-Schlüsseln
# API-Schlüssel erstellen
curl -X POST https://api.resend.com/api-keys \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json" \
-d '{
"name": "Produktionsschlüssel",
"permission": "full_access"
}'
# API-Schlüssel auflisten
curl -X GET https://api.resend.com/api-keys \
-H "Authorization: Bearer re_<API-Schlüssel>"
Zustellungsereignisse verfolgen
# Zustellungsereignisse nach E-Mail-ID abrufen
curl -X GET https://api.resend.com/emails/<email_id> \
-H "Authorization: Bearer re_<API-Schlüssel>"
# Zustellungsereignisse auflisten
curl -X GET https://api.resend.com/emails?limit=10 \
-H "Authorization: Bearer re_<API-Schlüssel>"
Anforderungsprotokolle anzeigen
curl -X GET https://api.resend.com/audience-logs \
-H "Authorization: Bearer re_<API-Schlüssel>" \
-H "Content-Type: application/json"