1---2name: sendgrid-webhook-listener3description: Use when tasks require sendgrid webhook listener with credential-aware preflight, deterministic execution, validation gates, and handoff-ready artifacts.4---56# SendGrid Webhook Listener78## Quick Reference9| Field | Value |10| --- | --- |11| Skill ID | `385` |12| Provider | `SendGrid` |13| Operation | `Webhook Listener` |14| Domain | `Messaging and communications platforms` |15| Runtime archetype | `signed-event-ingestion-engine` |16| Core method | `signed event intake and routing` |17| Primary artifact | `sendgrid-event-intake-log` |18| Routing tag | `sendgrid:webhook-listener` |19| Mutating | `yes` |20| Release cycles | `3` |2122## Why This Skill Exists23We need this skill because SendGrid workflows degrade when unverified events can trigger unsafe downstream actions. This specific skill turns SendGrid Webhook Listener into a deterministic, auth-checked workflow for captures, verifies, and routes sendgrid webhook events..2425## Trigger Checklist26- [ ] The task explicitly requires `SendGrid Webhook Listener` rather than generic brainstorming.27- [ ] The provider tenant, workspace, or environment is known before execution begins.28- [ ] Credential reuse has been checked before asking for new secrets.29- [ ] Success criteria, side effects, and handoff owner are clear.30- [ ] If the run mutates provider state, the relevant approval gates are available.3132## Auth & Access Profile33| Field | Value |34| --- | --- |35| External auth required | `yes` |36| API key likely required | `yes` |37| Protocols | `HTTPS/REST`, `webhook callbacks` |38| Mutating | `yes` |39| Webhook capable | `yes` |4041| Auth Mode | Kind | Env Hints | Validation |42| --- | --- | --- | --- |43| OAuth client or delegated session | `oauth2` | `SENDGRID_CLIENT_ID`, `SENDGRID_CLIENT_SECRET` | Reuse an active delegated session or validate the client credentials with a lightweight identity call. |44| Access token or personal access token | `token` | `SENDGRID_TOKEN`, `SENDGRID_ACCESS_TOKEN` | Validate the token with the smallest read-only endpoint that proves scope and tenancy. |45| Webhook signing secret | `signing_secret` | `SENDGRID_WEBHOOK_SECRET`, `SENDGRID_SIGNING_SECRET` | Verify signature generation against a known sample payload before accepting live webhook traffic. |4647## Inputs (contract)48| Input | Type | Required | Source |49| --- | --- | --- | --- |50| signed event payload | signal | yes | operator or upstream tool |51| secret reference | signal | yes | operator or upstream tool |52| routing rules | signal | yes | operator or upstream tool |5354## Outputs (contract)55| Output | Type | Guaranteed | Consumer |56| --- | --- | --- | --- |57| sendgrid-event-intake-log | structured-artifact | yes | next workflow or operator |58| sendgrid-event-intake-log-scorecard | scorecard | yes | reviewer |59| sendgrid-event-intake-log-handoff | handoff-packet | yes | downstream owner |6061## Step-by-Step Implementation Guide621. Define the accepted event types, replay window, and downstream side effects for SendGrid Webhook Listener, then register the signing-secret policy for SendGrid.632. Validate credential reuse for the listener and verify that signature, timestamp, and dedupe stores are all healthy before accepting events.643. Implement captures, verifies, and routes sendgrid webhook events. so that every payload is verified, normalized, and either routed or quarantined deterministically.654. Preserve accepted event IDs, quarantine references, and downstream trigger artifacts for every dispatch decision.665. Run simulation and regression suites that cover invalid signatures, replay attacks, duplicate deliveries, and routing-policy violations.676. Publish an event-intake log with accepted IDs, quarantined deliveries, and any replay guidance needed for downstream operators.6869## Operational Runbook70### Preflight71- Validate the signing secret, replay window, and dedupe cache before accepting live events.72- Confirm the routing rules and downstream side effects that each event type may trigger.7374### Execution75- Verify signatures and timestamps before deserializing the payload.76- Route verified events through a dedupe check and quarantine anything that violates policy.7778### Recovery79- Pause live acceptance when signature verification or replay detection regresses.80- Replay only from the quarantine queue after the root cause is corrected.8182### Handoff83- Return accepted event IDs, quarantined deliveries, and downstream trigger references.84- Document the active replay window and any signature policy overrides used during recovery.8586## Validation Gates & Test Matrix87| Gate | Purpose | On Fail |88| --- | --- | --- |89| auth-preflight | Validate credential presence, scope, and environment before work begins. | block execution |90| schema-contract-check | Ensure required signals and payload shapes remain valid. | quarantine and request correction |91| policy-approval-check | Verify the declared approval gates before mutating or publishing state. | pause or route to human review |92| reliability-check | Confirm retries, rollback, and checkpoint readiness. | rollback or fail closed |9394- Required validation suites: `unit`, `integration`, `simulation`, `regression-baseline`9596## Failure Modes & Recovery Playbook97| Code | Trigger | Action |98| --- | --- | --- |99| `E_SIGNATURE_INVALID` | Incoming payload fails signature or timestamp verification. | Reject the event, quarantine the payload, and record the verification failure. |100| `E_DUPLICATE_DELIVERY` | The same event is observed outside the allowed replay policy. | Suppress the duplicate and keep the original trace as the authoritative record. |101| `E_HANDLER_POLICY` | Event shape or target route violates downstream policy. | Block dispatch and route the event to manual triage. |102103## Tool Call Implementation104- Reuse existing credentials first. Check environment variables, secure stores, and active sessions before prompting.105- Start with the smallest authenticated read or validation call that proves identity and scope.106- Preserve request, response, and approval traces in `sendgrid-event-intake-log` so downstream owners do not need to rediscover context.107- If any auth, contract, or approval gate fails, halt execution and attach remediation guidance instead of guessing.108109## Credential Reuse Policy110- Reuse valid provider credentials by default and prefer tenant-scoped sessions over newly created secrets.111- Prompt for credentials only when they are missing, invalid, expired, or point at the wrong environment.112- For webhook flows, validate the signing secret against a known sample before accepting live traffic.113114## Guardrails115- safety: Reject unsigned or replayed events before any downstream side effects are triggered. (`signature-check+replay-window`)116- reliability: Persist a quarantine queue for every event that cannot be safely dispatched. (`quarantine-queue`)117- compliance: Route policy-violating payloads to manual review instead of auto-retrying. (`handler-policy-review`)118- compliance: Validate provider key or secret mode (sandbox vs production) before any mutating execution. (`credential-mode-check`)119120## Acceptance Checklist121- [ ] Credential preflight and scope validation completed successfully.122- [ ] Required validation suites ran and all fail-closed gates passed.123- [ ] sendgrid-event-intake-log, scorecard, and handoff packet were produced.124- [ ] Any mutations, approvals, or rollbacks are reflected in the artifact bundle.125126## Anti-Patterns127- Do not ask for new credentials before checking reusable auth context.128- Do not skip the read-only or dry-run validation step for mutating work.129- Do not proceed when approval gates, signing secrets, or rollback checkpoints are missing.130- Do not hand off partial or ambiguous provider state as complete.131132## Handoff Contract133- **Produces:** `sendgrid-event-intake-log`, execution scorecard, approval trace, and next actions.134- **Consumes:** `signed event payload`, `secret reference`, `routing rules`.135- **Readiness rule:** release only after auth, contract, approval, and reliability gates all pass.136- **Downstream hint:** route to `sendgrid:webhook-listener` consumers with approval and credential context attached.137138## Observability & Continuous Improvement139- SLO: >=99.9% successful runs per 7-day window140- Error budget: <=0.1% critical failures per 7-day window141- Alert triggers:142- credential validation failures exceed baseline143- schema or contract regressions persist for two consecutive runs144- critical posture or rollback events exceed tolerance145- Primary outcome metric: `signature verification pass rate`146- Secondary metrics: `event processing latency`, `duplicate suppression accuracy`147- Review cadence: `daily`