{
  "slug": "sendgrid-frontend-proxy",
  "title": "How to Call SendGrid API from Frontend Without Exposing API Key",
  "metaTitle": "Call SendGrid API from Frontend Securely - RealComposer",
  "metaDescription": "Call SendGrid from client-side apps without leaking API keys. RealComposer proxies requests at the edge, injecting Bearer tokens and preventing spam.",
  "headline": "Secure SendGrid Transactional Email Proxy at the Edge",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 10,
  "clientPlatform": "React / Webflow",
  "upstreamServices": [
    "SendGrid"
  ],
  "searchIntentQuery": "call sendgrid api from frontend without exposing api key",
  "directAnswerSummary": "SendGrid API keys must never be exposed client-side. RealComposer acts as an edge gateway that validates the incoming message, injects your SendGrid Bearer token server-side, and prevents unauthorized outbound email spam.",
  "problem": {
    "title": "SendGrid Key Leaks Turn Sites into Spam Relays",
    "explanation": "Exposed SendGrid keys are immediately seized by spam bots to blast phishing emails, causing domain blacklisting.",
    "risks": [
      "Domain reputation destruction on Spamhaus",
      "Instant SendGrid account termination",
      "High overage billing"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Vault Your SendGrid Key",
      "description": "Store SENDGRID_API_KEY in RealComposer Secret Vault."
    },
    {
      "stepNumber": 2,
      "title": "Send from Contact Form",
      "description": "Post form submissions to RealComposer edge route."
    }
  ],
  "pipelineConfig": {
    "name": "SendGrid Edge Proxy",
    "method": "POST",
    "cacheTtlSeconds": 0,
    "steps": [
      {
        "stepKey": "sendgrid",
        "upstreamUrlTemplate": "https://api.sendgrid.com/v3/mail/send",
        "httpMethod": "POST",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.SENDGRID_API_KEY}}"
        },
        "timeoutMs": 4000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "status",
          "sourceStep": "sendgrid",
          "sourcePath": "statusCode"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "statusCode": 202,
    "headers": {}
  },
  "sampleSlimmedOutput": {
    "status": 202
  },
  "curlSnippet": "curl -X POST \"https://realcomposer.com/v1/acme/send-email\"",
  "faqs": [
    {
      "question": "Does RealComposer rate limit requests?",
      "answer": "Yes, per-client token rate limits protect against automated spam abuse."
    }
  ],
  "relatedRecipeSlugs": [
    "resend-email-api-static-site",
    "twilio-sms-frontend-proxy"
  ],
  "links": {
    "page": "https://realcomposer.com/recipes/sendgrid-frontend-proxy",
    "markdown": "https://realcomposer.com/recipes/sendgrid-frontend-proxy.md",
    "json": "https://realcomposer.com/recipes/sendgrid-frontend-proxy.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=sendgrid-frontend-proxy&via=agent"
  }
}