Trim Sendgrid Activity API JSON Response
Field-level SendGrid projection at the edge
SendGrid responses include fields Frontend / Web never renders. Map id, status, and UI columns at the edge after calling https://api.sendgrid.com/v3/marketing/stats?start_date={{query.startDate}}.
Unmapped SendGrid fields waste bandwidth
SendGrid returns nested CRM, audit, and configuration objects. Frontend / Web parses them on the main thread even when the UI binds three fields.
- Large arrays kept in memory after navigation
- Analytics showing poor LCP on API-heavy screens
- Developers shipping defensive null checks for unused paths
How RealComposer Solves This at the Edge
Bind vault keys to the Worker
Add SENDGRID_API_KEY to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.
Target the real upstream URL
Point step sendgrid at https://api.sendgrid.com/v3/marketing/stats?start_date={{query.startDate}} with GET. Map only the UI fields in output mapping so clients never download audit or nested blobs. Leave cache TTL at 0 when each response is user-specific (include userId or record id in query params before enabling cache).
Call from Frontend / Web
Call https://realcomposer.com/v1/workspace/trim-sendgrid-activity-api with a restricted rc_live_ client token. Frontend / Web never sends upstream secrets.
const res = await fetch('https://realcomposer.com/v1/workspace/trim-sendgrid-activity-api', {
headers: { Authorization: 'Bearer rc_live_your_token' }
});
{
"requestId": "req_trim-sen",
"upstreamLatencyMs": 142,
"audit": {
"region": "edge",
"trace": "trim-sendgrid-activity-api"
},
"payload": {
"id": "sample_id",
"status": "active",
"nested": {
"tags": [
"demo"
],
"internal": true
},
"unused_blob": {
"foo": "bar",
"bar": "baz"
}
}
}
{
"delivered": "sample",
"opens": "sample"
}
Recipe Specs
- HTTP method
- GET
- Upstream calls
- 1
- Edge cache TTL
- No caching
- Client auth
- Restricted client token
- Mapped output fields
- 2
- Payload
- 245 B to 39 B (-84%)
curl -X GET "https://realcomposer.com/v1/workspace/trim-sendgrid-activity-api" \ -H "Authorization: Bearer rc_live_client_token"
Developer Questions & Troubleshooting
What should Frontend / Web store instead of SendGrid secrets?
Log request IDs for trim-sendgrid-activity-api, not raw SendGrid payloads, because upstream bodies may include PII.
How do I forward JSON bodies to POST upstreams?
trim-sendgrid-activity-api vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body.
Can I restrict which domains call this pipeline?
Rotate vault secrets for trim-sendgrid-activity-api anytime; clients keep the same rc_live_ token.
Sources & Definitions Used in This Answer
Deploy this Frontend / Web + SendGrid Recipe
Clone this pre-configured pipeline into your RealComposer workspace in one click. We pre-populate upstream URLs, headers, and mapping rules.