Skip to content

SendGrid Integration

Email delivery via SendGrid.

Configuration

json
{
  "credentials": {
    "sendgrid": {
      "apiKey": "{{env.SENDGRID_API_KEY}}",
      "fromEmail": "noreply@example.com",
      "fromName": "My App"
    }
  }
}

Endpoints

MethodEndpointDescription
POST/integrations/sendgrid/sendSend email

Actions (for workflows)

sendEmail

json
{
  "integration": "sendgrid",
  "action": "sendEmail",
  "params": {
    "to": "user@example.com",
    "subject": "Welcome!",
    "html": "<h1>Welcome</h1><p>Thanks for signing up!</p>"
  }
}

sendTemplate

json
{
  "integration": "sendgrid",
  "action": "sendTemplate",
  "params": {
    "to": "user@example.com",
    "templateId": "d-abc123",
    "dynamicTemplateData": {
      "name": "&#123;&#123;input.name&#125;&#125;",
      "orderNumber": "&#123;&#123;input.orderId&#125;&#125;"
    }
  }
}

Examples

Send Simple Email

bash
curl -X POST http://localhost:3000/integrations/sendgrid/send \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Order Confirmation",
    "html": "<h1>Order Confirmed</h1><p>Your order has been placed.</p>"
  }'

Send with Template

bash
curl -X POST http://localhost:3000/integrations/sendgrid/send \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "templateId": "d-abc123",
    "dynamicTemplateData": {
      "name": "John",
      "orderNumber": "12345"
    }
  }'

In Routes

json
{
  "path": "/signup",
  "method": "post",
  "supabaseQueries": [{
    "table": "users",
    "operation": "insert",
    "data": {
      "email": "&#123;&#123;body.email&#125;&#125;",
      "name": "&#123;&#123;body.name&#125;&#125;"
    }
  }],
  "integrations": [{
    "type": "sendgrid",
    "action": "sendEmail",
    "params": {
      "to": "&#123;&#123;body.email&#125;&#125;",
      "subject": "Welcome to Our App",
      "html": "<h1>Welcome, &#123;&#123;body.name&#125;&#125;!</h1>"
    }
  }]
}

Workflow Example

json
{
  "id": "order-confirmation",
  "steps": [
    {
      "id": "send-email",
      "type": "integration",
      "integration": "sendgrid",
      "action": "sendTemplate",
      "params": {
        "to": "&#123;&#123;input.email&#125;&#125;",
        "templateId": "d-order-confirmation",
        "dynamicTemplateData": {
          "orderNumber": "&#123;&#123;input.orderId&#125;&#125;",
          "items": "&#123;&#123;input.items&#125;&#125;",
          "total": "&#123;&#123;input.total&#125;&#125;"
        }
      }
    }
  ]
}

Email Parameters

ParameterTypeRequiredDescription
tostringYesRecipient email
subjectstringYes*Email subject
htmlstringYes*HTML body
textstringNoPlain text body
templateIdstringYes*SendGrid template ID
dynamicTemplateDataobjectNoTemplate variables
fromstringNoOverride sender
replyTostringNoReply-to address

*Either subject+html or templateId required.

Released under the ISC License.