---
id: sendgrid-api
name: SendGrid API
version: 1.0.0
summary: |
  External SMTP email delivery provider used by BookWorm to submit rendered
  order notification emails over authenticated SMTP.
externalSystem: true
badges:
  - content: External
    backgroundColor: purple
    textColor: purple
  - content: SMTP
    backgroundColor: teal
    textColor: teal
styles:
  icon: /icons/third-party/sendgrid.svg
owners:
  - platform-engineering-team
---

## Integration Purpose & Boundary

SendGrid is BookWorm's external email delivery provider in publish environments, offloading internet mail routing, sender reputation, and downstream delivery. At runtime, only [[service|notification-api]] integrates with SendGrid to transmit rendered order lifecycle emails.

:::note
Although SendGrid's platform exposes a REST v3 HTTP API, BookWorm does **not** invoke SendGrid HTTP endpoints at runtime—[[service|notification-api]] submits rendered MIME messages exclusively over **authenticated SMTP** (using a local test inbox during development).
:::

## Integration Profile

| Property                         | Value                                                                                                                                                                                    |
| :------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Provider / Sidecar**           | Twilio SendGrid (SMTP relay in publish environments; local test inbox in development)                                                                                                    |
| **BookWorm Consumers**           | [[service\|notification-api]] only                                                                                                                                                       |
| **Runtime Transport & Protocol** | SMTP over TLS (port 587)                                                                                                                                                                 |
| **Auth / Credential Boundary**   | API key injected via runtime secret configuration (`apikey` username); domain-authenticated sender identity recommended for production                                                   |
| **Data / PII Sensitivity**       | High — carries customer recipient email addresses and order notification content; redact recipient metadata in logs and never log rendered email bodies                                  |
| **Failure / Fallback Behavior**  | Bounded client retries followed by Kafka listener backoff and dead-letter routing on [[channel\|bookworm.&#123;env&#125;.notification.dead-letter-queue]]; no delivery webhooks ingested |

## Visualizations & Specifications

### Delivery Integration Context

<MermaidFileLoader file="mermaids/SendGridAPI-diagram-1.mmd" />

### Service Interactions

<NodeGraph />

<Accordion title="Credential Rotation & Operational Boundaries">
	- **Least-privilege API keys:** Provision SendGrid keys scoped strictly to mail-send permissions,
	store them in the deployment secret store, and rotate or revoke keys immediately if exposed. -
	**Submission vs. business truth:** SMTP acceptance confirms only provider handoff, not recipient
	inbox delivery or order status.
</Accordion>

## Related Documentation

- [[doc|platform/006-api-and-contracts]] — Consolidated service, HTTP, gRPC, and Kafka directory.
- [[service|notification-api]] — Consuming Kafka email worker.
- [[system|sendgrid]] — External SendGrid system boundary.
- [[doc|domains/bookworm/subdomains/platform/engineering/platform-integration-boundaries]] — Platform service and external provider boundaries.
