kmaruthi2002/universal-llm-skills/api-integrations-and-webhooks

Claude Code and agent skill by kmaruthi2002/universal-llm-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Integrate with third-party APIs and receive webhooks reliably and securely: reading API docs critically, choosing and implementing auth (API keys, OAuth 2.0 flows, signed requests), rate limits, timeouts, retries with exponential backoff and jitter, pagination, idempotency keys, webhook signature verification, deduplication, replay and reconciliation, sandbox vs production, versioning, and secret storage. Use when asked to connect to, sync with, or call an external service's API, build a client or SDK wrapper, receive or debug webhooks, handle OAuth, or fix an integration that drops, duplicates, or gets rate-limited.

Install

npx vskill@latest install kmaruthi2002/universal-llm-skills/api-integrations-and-webhooks

SKILL.md

The same SKILL.md was published earlier as kmaruthi2002/universal-llm-skills/api-integrations-and-webhooks.

API Integrations and Webhooks

Integrating with someone else's API means depending on a system you do not control, over a network that fails, under limits you did not set, documented by people who may not have tested their examples. The work is less about making the first request succeed and more about what happens on the ten-thousandth: the timeout after the payment was taken, the webhook delivered twice, the token that expired at 2 a.m., the field that changed type in a minor version.

Scope

Covers: consuming REST, GraphQL and RPC-style third-party APIs; OAuth and other auth schemes from the client side; receiving and processing webhooks; keeping local state in sync with a remote system.

Related:

  • Designing your own API for others to consume: api-design.
  • Building your own login/authorization system: authentication-and-authorization.
  • Orchestrating multi-step business processes around integrations: workflow-automation.
  • Bulk extraction into a warehouse: etl-pipelines.
  • General error-handling design: error-handling.

Core principles

  1. The network will fail in every possible way. Requests time out, connections reset, responses arrive after you gave up, servers return 200 with an error body. Design each call assuming its outcome may be unknown, and decide in advance what "unknown" means for your data.
  1. Retries require idempotency. Retrying a non-idempotent call (create payment, send message) after an ambiguous failure can do it twice. Use the provider's idempotency key mechanism, or make the operation idempotent on your side by checking before acting.
  1. Webhooks are at-least-once, unordered, and forgeable. Every provider redelivers on failure; most do not guarantee order; anyone can POST to your endpoint. Verify signatures, deduplicate by event ID, and treat the webhook as a notification to reconcile rather than the source of truth when stakes are high.
  1. Respect limits proactively. Rate limits protect the provider and are part of your contract. Pace requests below the limit and back off on signals; do not treat 429s as a normal control mechanism.
  1. Secrets are the integration's crown jewels. API keys and OAuth tokens grant access to customer data or money. Store them in a secret manager, scope them minimally, never log them, and plan rotation.
  1. Isolate the integration behind your own interface. Wrap the third-party client in a thin module that speaks your domain. Why: provider changes, version upgrades, mocking in tests, and switching providers then touch one place.

Process

1. Read the docs like a sceptic

Gather before coding:

  • Auth model and scopes/permissions available.
  • Rate limits: per key, per user, per endpoint; burst vs sustained; how signalled (headers such as X-RateLimit-Remaining, Retry-After).
  • Pagination style and maximum page sizes.
  • Idempotency support (header name, key lifetime, which endpoints).
  • Error format and which errors are retryable.
  • Webhooks: event types, payload shape, signature scheme, retry schedule, ordering guarantees, how to replay missed events.
  • Versioning and deprecation policy; how the version is selected (URL, header, account setting).
  • Sandbox/test mode and how it differs from production (often: different keys, different base URL, some features missing, fake data).
  • Terms of use: caching limits, data retention, display requirements, prohibited uses.

Then verify the docs against reality with a few exploratory calls in the sandbox. Note discrepancies; docs are frequently out of date. Check the provider's official SDK: it may already handle retries, pagination and signatures correctly — or it may be unmaintained. Decide based on its quality, not on reflex.

2. Choose and implement auth
SchemeTypical useKey points
API key / bearer tokenServer-to-server, single accountStore as a secret; send in header, never in URLs (URLs are logged); restrict by scope/IP if supported
OAuth 2.0 Authorization Code (+ PKCE)Acting on behalf of users of another serviceValidate state against CSRF; PKCE for public clients; store refresh tokens encrypted; request minimal scopes
OAuth 2.0 Client CredentialsServer-to-server with a provider that uses OAuthCache the access token until near expiry; refresh proactively
Signed requests (HMAC, AWS SigV4-style)Providers requiring request signingUse the provider's or a well-tested library; clock skew breaks signatures
mTLSHigh-security B2BCertificate rotation and expiry monitoring
Basic authLegacyOnly over TLS; treat as a password

OAuth specifics that bite:

  • Refresh token rotation: some providers issue a new refresh token on each refresh and invalidate the old one. Concurrent workers refreshing at once can lock each other out. Serialise refreshes (a lock per account) and persist the new token atomically.
  • Expiry and revocation: users revoke access, admins remove apps, tokens expire after inactivity. Detect invalid_grant / 401, mark the connection as needing reauthorisation, and notify the user; do not retry forever.
  • Redirect URIs must match exactly; keep separate app registrations for sandbox and production.
  • Scopes: request the least needed. Broad scopes increase the blast radius of a leak and may trigger lengthy provider reviews.

Never ask users to give you their password for another service so you can call its API as them; use the provider's delegated auth.

3. Make calls robust

Timeouts. Set connect and read timeouts on every request. Library defaults are often infinite. Pick values from the provider's typical latency (e.g. connect 5 s, read 30 s), and longer only for known slow endpoints.

Classify responses.

ResponseRetry?Notes
Connection error, timeoutYes, if the operation is idempotent or has an idempotency keyOutcome unknown: the request may have succeeded
408, 429Yes, after Retry-After or backoff429 means slow down globally for that key
500, 502, 503, 504Yes, with backoffCap attempts
400, 422NoFix the request; log the error body
401Refresh token once, then noPersisting 401 means re-auth needed
403NoPermissions/scopes; alert
404Usually noUnless eventual consistency is documented
409DependsConflict, often "already exists" — may mean a previous attempt succeeded
200 with error in bodyInspectSome APIs (and GraphQL) report errors with 200

Exponential backoff with jitter. Wait base * 2^attempt, capped, with randomness, so many clients do not retry in lockstep:

python
import random, time
def backoff_delays(base=0.5, cap=30.0, attempts=6):
for n in range(attempts):
yield random.uniform(0, min(cap, base * 2 ** n)) # "full jitter"
def call_with_retries(do_request, is_retryable):
last_exc = None
for delay in backoff_delays():
try:
resp = do_request()
except (TimeoutError, ConnectionError) as exc:
last_exc = exc
else:
if not is_retryable(resp):
return resp
retry_after = resp.headers.get("Retry-After")
if retry_after:
delay = max(delay, float(retry_after)) # may also be an HTTP date
time.sleep(delay)
raise RuntimeError("retries exhausted") from last_exc

Bound the total time spent retrying, not just the attempt count, especially inside user-facing requests. For high-volume integrations, add a circuit breaker so a provider outage does not exhaust your workers.

Idempotency keys. For create/charge/send operations, generate a key per logical operation (not per attempt), persist it with your local record before calling, and send the same key on every retry. If the provider has no idempotency support, look up by a client reference (many APIs accept an external ID/metadata) before re-creating.

Rate limiting on your side. Use a token bucket or the provider's documented quota to pace requests; share the limiter across all workers using the same key (e.g. in a shared store). Read remaining-quota headers and slow down before hitting zero. Batch endpoints, where offered, reduce call counts dramatically.

4. Paginate correctly
StyleHow to iteratePitfalls
Cursor / next tokenFollow next until absentDo not construct cursors yourself; they may expire
Offset/limit or page numberIncrement until fewer than limit returnedItems shift if data changes during iteration → duplicates/skips
Link header (rel="next")Follow URLsPreserve auth; URLs may point to different hosts
Time-windowQuery by updated_since slicesBoundary items: use inclusive/exclusive consistently and dedupe

Always cap total pages as a guard against loops, dedupe by ID, and checkpoint progress for long syncs so they resume rather than restart.

5. Receive webhooks safely

An endpoint receiving webhooks should:

  1. Verify authenticity before anything else. Typically an HMAC signature over the raw request body (and often a timestamp) using a shared secret. Compute over the raw bytes — parsing and re-serialising JSON changes them. Compare with a constant-time function. Reject timestamps outside a tolerance window (e.g. 5 minutes) to block replays.
  2. Respond fast. Acknowledge with 2xx within the provider's timeout (often a few seconds), after durably storing the event. Do heavy processing asynchronously via a queue. Slow endpoints cause provider retries, duplicates, and eventually the provider disabling your endpoint.
  3. Deduplicate by the provider's event ID (store processed IDs with a retention longer than the provider's retry window). Make handlers idempotent as well, because dedup storage can fail.
  4. Handle disorder. Events can arrive out of order (updated before created). Use timestamps/versions in the payload, or treat the event as a trigger to fetch the current state of the object from the API.
  5. Ignore unknown event types gracefully (return 2xx, log) so new provider events do not cause retries.
  6. Return errors deliberately: non-2xx tells the provider to retry. Return 2xx for events you have stored even if processing later fails; handle that failure internally.

Illustrative HMAC verification (adapt to the provider's exact scheme — header names, encoding, and what is signed vary):

python
import hmac, hashlib, time
def verify(raw_body: bytes, header_sig: str, header_ts: str, secret: bytes) -> bool:
if abs(time.time() - int(header_ts)) > 300:
return False
signed = header_ts.encode() + b"." + raw_body
expected = hmac.new(secret, signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, header_sig)

Additional hardening: HTTPS only; a hard-to-guess path is not a substitute for signatures; restrict by provider IP ranges only as an extra layer (they change); limit body size; never execute or follow URLs from payloads blindly. If a provider offers no signatures, fetch the referenced object from the API using your credentials instead of trusting the payload.

6. Reconcile and replay

Webhooks get lost: your endpoint was down beyond the retry window, a deploy broke verification, the provider had an incident. Plan for it:

  • Periodic reconciliation: a scheduled job lists recently changed objects via the API and compares with local state. This is the safety net that makes webhook loss recoverable.
  • Replay: know how to request redelivery from the provider (dashboard or API), and keep your own stored raw events so you can reprocess after fixing a handler bug.
  • Event log: store raw payloads (with retention appropriate to their sensitivity) with receipt time, verification result, and processing status.
7. Sandbox, production and versioning

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/kmaruthi2002/universal-llm-skills/api-integrations-and-webhooks/badge)](https://verified-skill.com/skills/kmaruthi2002/universal-llm-skills/api-integrations-and-webhooks)

Something wrong with this skill or its page? Tell us.