PMD Solutions
API & Webhooks13 min

Safe API integration patterns

Retries, rate limits, secrets, and logging — the boring essentials that keep integrations reliable in production.

Safe API integrations are production patterns for retries, rate limits, secrets, and logging — the boring essentials that keep CRM and finance syncs reliable. Ship these before clever business logic; most outages come from hanging requests and silent failures, not exotic edge cases.

1. Timeouts and retries with intent

  • Set explicit connect/read timeouts — never hang forever
  • Retry only idempotent or safely replayable operations
  • Exponential backoff + jitter; cap max attempts
  • Don’t retry 400s (bad request); do retry 429/502/503 with respect for Retry-After

2. Respect rate limits

  • Centralize HubSpot (or other API) calls through one client with a limiter
  • Batch reads/writes where the API allows
  • Prefer webhooks + targeted GETs over polling everything
  • Shed load gracefully — queue delayed work instead of melting the API

3. Secrets and access

  • Store tokens in a secret manager / env — never in git or HubSpot notes
  • Least-privilege scopes on private apps
  • Rotate credentials on a schedule and when people leave
  • Separate staging and production apps/tokens

4. Idempotency and data safety

  • Send an idempotency key on creates when the API supports it
  • Upsert by external ID instead of blind insert
  • Validate payloads before write; quarantine bad records
  • Avoid dual-writes without a clear system of record

5. Observability you can act on

  • Structured logs: correlation ID, object ID, endpoint, status, duration
  • Metrics: success rate, latency, retry count, queue depth
  • Alerts on error budget burn — not every single 404
  • Named owner on-call for the integration

Safe integrations look dull in a demo and calm in production. That’s the point.

Need an integration that won’t wake you at 2am?

We’ll design API patterns with retries, observability, and clear ownership before the first payload ships.