SendGrid-integratie toevoegen
SendGrid is een cloudgebaseerde service voor het leveren van transactionele en marketing e-mails. Door deze integratie te verbinden kan uw applicatie programmatisch e-mails verzenden (bijv. welkomst-e-mails, wachtwoordresets of meldingen).
Configuratiestappen
Section titled “Configuratiestappen”Nadat u SendGrid uit de integratielijst hebt geselecteerd, verschijnt er een configuratiemodaal. U moet de volgende referenties opgeven om de verbinding tot stand te brengen:
1. API-sleutel
Section titled “1. API-sleutel”Dit is het authentication token gegenereerd binnen uw SendGrid-account.
- Invoer: Plak uw privé SendGrid API-sleutel in het tekstveld.
- Help: Als u er geen hebt, klik dan op de “Waar vind ik de API-sleutel?” link in het modaal voor instructies over het genereren ervan.
2. Omgeving
Section titled “2. Omgeving”Specificeer de omgevingscontext voor deze integratie.
- Invoer: Voer de omgevingsidentificatie in (bijv.
Production,Stagingof een specific configuratietag) in het veld Omgeving.
Voltooien van de verbinding
Section titled “Voltooien van de verbinding”Zodra de velden zijn ingevuld:
- Controleer de statusbalk (momenteel Not Connected).
- Klik op de zwarte Add-knop rechtsonder om de referenties op te slaan en de integratie te activeren.


SendGrid-integratie API-referentie
Section titled “SendGrid-integratie API-referentie”SendGrid-configuratie
Section titled “SendGrid-configuratie”SendGrid API-sleutel configureren
Section titled “SendGrid API-sleutel configureren”Configureert de SendGrid API-sleutel voor een specifiek project en omgeving.
Mutation:
mutation { sendgrid_configureSendGrid ( apiKey: "SG._api_key_here" )}E-mails verzenden
Section titled “E-mails verzenden”Eenvoudige e-mail verzenden
Section titled “Eenvoudige e-mail verzenden”Verzendt een e-mail naar één of meerdere ontvangers.
Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail ( email: { from: { email: "sender@archie.com", name: "Sender Name" }, subject: "Test Email", to: { email: "recipient@gmail.com", name: "Recipient Name" }, content: { type: "text/html", value: "<h1>Hello World</h1><p>This is a test email.</p>" } } ) { messageId success }}Response:
{ "data": { "sendgrid_sendEmail": { "messageId": "sent-1234567890", "success": true } }}E-mail verzenden met CC en BCC
Section titled “E-mail verzenden met CC en BCC”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail ( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] cc: [ { email: "cc@example.com" name: "CC Recipient" } ] bcc: [ { email: "bcc@example.com" } ] subject: "Email with CC and BCC" content: [ { type: "text/html" value: "<h1>Hello</h1><p>This email has CC and BCC recipients.</p>" } ] } ) { messageId success }}E-mail verzenden met bijlagen
Section titled “E-mail verzenden met bijlagen”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Email with Attachment" content: [ { type: "text/html" value: "<h1>Hello</h1><p>Please find attached file.</p>" } ] attachments: [ { content: "SGVsbG8gV29ybGQ=" type: "text/plain" filename: "document.txt" disposition: "attachment" } ] } ) { messageId success }}Opmerking: Het content-veld in bijlagen moet Base64-gecodeerd zijn.
E-mail verzenden met categorieën en tags
Section titled “E-mail verzenden met categorieën en tags”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Categorized Email" content: [ { type: "text/html" value: "<h1>Hello</h1>" } ] categories: ["transactional", "notification"] tags: ["important", "urgent"] } ) { messageId success }}Geplande e-mail verzenden
Section titled “Geplande e-mail verzenden”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Scheduled Email" content: [ { type: "text/html" value: "<h1>Hello</h1>" } ] sendAt: "2025-12-25T10:00:00Z" } ) { messageId success }}E-mail verzenden met aangepaste argumenten
Section titled “E-mail verzenden met aangepaste argumenten”Mutation:
mutation sendgrid_sendEmail { sendgrid_sendEmail( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] subject: "Email with Custom Args" content: [ { type: "text/html" value: "<h1>Hello</h1>" } ] customArgs: { orderId: "12345" userId: "67890" campaignId: "abc123" } } ) { messageId success }}Bulk-e-mails verzenden
Section titled “Bulk-e-mails verzenden”Meerdere e-mails verzenden
Section titled “Meerdere e-mails verzenden”Mutation:
mutation sendgrid_sendBulkEmail { sendgrid_sendBulkEmail( emails: { emails: [ { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient1@example.com" name: "Recipient 1" } ] subject: "Bulk Email 1" content: [ { type: "text/html" value: "<h1>Email 1</h1>" } ] } { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient2@example.com" name: "Recipient 2" } ] subject: "Bulk Email 2" content: [ { type: "text/html" value: "<h1>Email 2</h1>" } ] } ] } ) { messageIds success }}Response:
{ "data": { "sendgrid_sendBulkEmail": { "messageIds": ["sent-1234567890", "sent-1234567891"], "success": true } }}E-mails verzenden met sjablonen
Section titled “E-mails verzenden met sjablonen”E-mail verz
Section titled “E-mail verz”enden met dynamisch sjabloon
Mutation:
mutation sendgrid_sendTemplate { sendgrid_sendTemplate( email: { from: { email: "sender@example.com" name: "Sender Name" } to: [ { email: "recipient@example.com" name: "Recipient Name" } ] templateId: "d-1234567890abcdef" substitutions: { name: "John Doe" orderNumber: "12345" totalAmount: "$99.99" } } ) { messageId success }}Response:
{ "data": { "sendgrid_sendTemplate": { "messageId": "sent-1234567890", "success": true } }}Contactbeheer
Section titled “Contactbeheer”Contact toevoegen
Section titled “Contact toevoegen”Mutation:
mutation sendgrid_addContact { sendgrid_addContact( contact: { email: "newcontact@example.com" firstName: "John" lastName: "Doe" customFields: { company: "Acme Corp" phone: "+1234567890" position: "Developer" } listIds: ["list-id-1", "list-id-2"] } )}Response:
{ "data": { "sendgrid_addContact": true }}Contact bijwerken
Section titled “Contact bijwerken”Mutation:
mutation sendgrid_updateContact { sendgrid_updateContact( contact: { email: "existing@example.com" firstName: "Jane" lastName: "Smith" customFields: { company: "New Company" phone: "+0987654321" } } )}Response:
{ "data": { "sendgrid_updateContact": true }}Contact verwijderen
Section titled “Contact verwijderen”Mutation:
mutation sendgrid_deleteContact { sendgrid_deleteContact( email: "contact@example.com" )}Response:
{ "data": { "sendgrid_deleteContact": true }}Analytics en statistieken
Section titled “Analytics en statistieken”E-mailstatistieken ophalen
Section titled “E-mailstatistieken ophalen”Query:
query sendgrid_getEmailStats { sendgrid_getEmailStats ( startDate: "2025-01-01" endDate: "2025-01-31" ) { opens clicks bounces spamReports delivered startDate endDate }}Response:
{ "data": { "sendgrid_getEmailStats": { "opens": 150, "clicks": 75, "bounces": 5, "spamReports": 2, "delivered": 1000, "startDate": "2025-01-01T00:00:00Z", "endDate": "2025-01-31T00:00:00Z" } }}E-mail valideren
Section titled “E-mail valideren”Query:
query sendgrid_validateEmail { sendgrid_validateEmail ( email: "test@example.com" ) { valid score local domain reason suggestions }}Response (met SendGrid Premium):
{ "data": { "sendgrid_validateEmail": { "valid": true, "score": 0.95, "local": "test", "domain": "example.com", "reason": "", "suggestions": [] } }}Response (Basisvalidatie - wanneer SendGrid Premium niet beschikbaar is):
{ "data": { "sendgrid_validateEmail": { "valid": true, "score": 0.8, "local": "test", "domain": "example.com", "reason": "Basic validation (SendGrid premium validation not available)", "suggestions": [] } }}Opmerking: Het SendGrid e-mailvalidatie-endpoint (/v3/validations/email) vereist speciale machtigingen en is mogelijk niet beschikbaar in alle accounts. Als uw API-sleutel geen toegang heeft tot dit endpoint (fout 403), zal het systeem automatisch basisvalidatie op basis van regex gebruiken als fallback.
Volledige voorbeelden met variabelen
Section titled “Volledige voorbeelden met variabelen”Voorbeeld met GraphQL-variabelen
Section titled “Voorbeeld met GraphQL-variabelen”Request:
{ "query": "mutation SendEmail($email: EmailInput!) { sendgrid_sendEmail(email: $email) { messageId success } }", "variables": { "email": { "from": { "email": "sender@example.com", "name": "Sender Name" }, "to": [ { "email": "recipient@example.com", "name": "Recipient Name" } ], "subject": "Test Email", "content": [ { "type": "text/html", "value": "<h1>Hello World</h1>" } ] } }}Foutafhandeling
Section titled “Foutafhandeling”Foutvoorbeeld
Section titled “Foutvoorbeeld”Request:
{ "query": "mutation { sendgrid_sendEmail(email: { from: { email: \"invalid\" }, to: [], subject: \"Test\", content: [] }) { messageId success } }"}Response Error:
{ "errors": [ { "message": "validation error: at least one recipient is required", "path": ["sendgrid_sendEmail"] } ], "data": null}Veelvoorkomende fouten
Section titled “Veelvoorkomende fouten”-
Project-ID ontbreekt:
{"errors": [{"message": "project ID is required in context"}]} -
Configuratie niet gevonden:
{"errors": [{"message": "sendgrid configuration not found for project: xxx, environment: master"}]} -
API-sleutel ongeldig:
{"errors": [{"message": "sendgrid API error: status 401, body: ..."}]}
Webhooks
Section titled “Webhooks”Webhooks-endpoint
Section titled “Webhooks-endpoint”Het webhooks-endpoint is beschikbaar op:
- HTTP:
POST http://localhost:8080/webhooks/sendgrid - Lambda:
POST /webhooks/sendgrid
SendGrid-configuratie
Section titled “SendGrid-configuratie”- Ga naar SendGrid Dashboard > Settings > Mail Settings > Event Webhook
- Configureer de URL:
https://uw-domein.com/webhooks/sendgrid - Selecteer de gebeurtenissen die u wilt ontvangen
- Configureer de verificatiesleutel in de omgevingsvariabele
WEBHOOK_VERIFICATION_KEY
Ondersteunde gebeurtenissen
Section titled “Ondersteunde gebeurtenissen”processed: E-mail verwerktdelivered: E-mail afgeleverdopened: E-mail geopendclicked: Link aangekliktbounce: E-mail teruggestuurddropped: E-mail verworpenspamreport: Als spam gerapporteerdunsubscribe: Afgemeld