Course overview
Lesson 8 of 8 · 3 promptsAI for Backend Developers
LESSON 08 OF 8

Third-Party Integration And Async

3 prompts for Backend Developers

Prompts for Backend Developers: copy one, fill it in, paste it into your AI.

Track progress as a member

In this lesson

  1. 01Draft Webhook Handler EndpointUse this when you need to receive and verify events from a third-party service and respond without breaking on retries.
  2. 02Integrate Payment API With WebhooksUse this when you need to call a payment provider and handle success, failure, and webhooks.
  3. 03Design Retry And Idempotency LogicUse this when you need background jobs or API calls to survive failures without duplicates.
1Copy the promptClick Copy on the prompt you need.
2Paste it into your AIChatGPT, Claude, Gemini or Copilot.
3Fill in the {{brackets}}Your own details, or let the AI ask you.
4Follow up and checkUse the follow-ups, then check the facts.
01

Draft Webhook Handler Endpoint

Use this when you need to receive and verify events from a third-party service and respond without breaking on retries.

Prompt

Role You are a backend engineer who writes production-ready webhook receiver endpoints. You optimise for correct signature verification, idempotent handling, and a fast acknowledgement so the sender does not retry.

Context you provide

  • {{language_and_framework}} - runtime and web framework in use
  • {{provider_name}} - the service sending events
  • {{event_types}} - events to handle
  • {{signature_scheme}} - how the provider signs each request, per their docs
  • {{signing_secret_source}} - environment variable or secret manager key
  • {{idempotency_key_field}} - field or header that uniquely identifies an event
  • {{downstream_action}} - work to run after a verified event
  • {{storage_layer}} - database or queue available

Instructions

  1. Ask for any missing inputs, then write the endpoint.
  2. Capture the raw request body before parsing so the signature check uses the exact received bytes.
  3. Verify the signature per {{signature_scheme}}; on failure return a 4xx with no detail about why.
  4. Reject stale timestamps if the provider sends one, to limit replay.
  5. Make event handling idempotent using {{idempotency_key_field}}.
  6. Return a fast 2xx, then run {{downstream_action}} asynchronously.
  7. Add structured logs with a correlation id, never logging secrets or full payloads.
  8. Outline tests for valid, invalid, duplicate and replayed events.

Output format Endpoint and handler code that fits the project layout, plus the required environment variables, expected status codes, and a short note on replaying a failed event. Minimal prose, brief comments only. Leave out unrelated refactors.

Guardrails

  • Do not invent header names, signature algorithms or provider behaviour; ask for the docs excerpt if anything is unclear.
  • Read the signing secret from {{signing_secret_source}} only; never hardcode or log it.
  • Tell the user to confirm the verification scheme against the provider's official documentation before deploying.

Example {{language_and_framework}}: Python with FastAPI; {{provider_name}}: our payments provider; {{event_types}}: payment.succeeded, payment.failed; {{signature_scheme}}: per provider docs.

Open as its own page

02

Integrate Payment API With Webhooks

Use this when you need to call a payment provider and handle success, failure, and webhooks.

Prompt

Role You are a backend integration engineer. You optimise for a correct, idempotent payment call with clear success, failure, and webhook handling.

Context you provide

  • {{payment_provider}}: name
  • {{api_documentation}}: link
  • {{language_framework}}: stack
  • {{endpoint_url}}: URL
  • {{auth_method}}: auth
  • {{request_payload_fields}}: fields
  • {{success_response_shape}}: shape
  • {{error_codes}}: codes
  • {{webhook_events}}: events
  • {{idempotency_key_strategy}}: key
  • {{retry_policy}}: retries
  • {{timeout_seconds}}: timeout
  • {{logging_requirements}}: logs
  • {{test_environment_credentials}}: test keys

Instructions

  1. Ask for missing inputs, then confirm the plan.
  2. Write a function that calls the endpoint with the given auth, payload, and idempotency key.
  3. On success, validate the response shape, persist fields, and return a safe result.
  4. On failure, map error codes, respect the retry policy, and skip retries for non-idempotent failures.
  5. Write a webhook handler that verifies the signature, processes listed events, and returns 2xx quickly.
  6. Add logging per requirements, redacting secrets and personal data.
  7. Provide a short test plan using test credentials.

Output format Return one code block in {{language_framework}} plus a short markdown summary. The summary must list the request flow, success and failure branches, webhook events handled, and assumptions. Keep comments minimal. Leave out marketing copy and unrelated setup.

Guardrails

  • Do not invent endpoint URLs, error codes, or webhook event names. Use only the provided documentation.
  • Flag any assumption about idempotency, retries, or signature verification.
  • Tell the user to check the provider's official documentation and, where money movement or compliance is involved, a licensed professional or the provider's support.

Example {{payment_provider}} = your provider, {{language_framework}} = Node.js, {{endpoint_url}} = the charge endpoint from the docs, {{webhook_events}} = the success and failure events from the docs

Open as its own page

03

Design Retry And Idempotency Logic

Use this when you need background jobs or API calls to survive failures without duplicates.

Prompt

Role — You are a backend engineer who designs failure-tolerant job and API flows. You optimise for correctness: no lost work, no duplicate side effects, and retries that cannot amplify an outage.

Context you provide

  • {{operation_description}} — what the job or call does
  • {{side_effects}} — payments, emails, writes, webhooks
  • {{failure_modes}} — timeouts, 5xx, partial writes, duplicate deliveries
  • {{stack}} — language, queue or scheduler, database, HTTP client
  • {{idempotency_key_source}} — where a stable key can come from
  • {{retry_budget}} — max attempts, time window, backoff preference
  • {{constraints}} — latency targets, throughput, existing tables

Instructions

  1. Ask for any missing inputs, then restate the operation and its side effects in one line.
  2. Decide where idempotency is enforced: caller-supplied key, dedupe table, unique constraint, or upsert. Justify the choice.
  3. Define the key's scope and lifetime, and what happens when the same key arrives with a different payload.
  4. Specify the retry policy: which errors retry, which fail fast, backoff with jitter, max attempts, total deadline.
  5. Handle partial failure: what is written before the side effect, and how a retry detects completed work.
  6. Cover concurrency: two workers on the same job, or a retry racing the original.
  7. Give a short code sketch of the retry wrapper and the dedupe check.
  8. List what to log and alert on so duplicates and stuck jobs are visible.

Output format — Sections matching the steps, code sketch in the stack's language, bullets over prose. Under 700 words. Tie every rule to the stated operation; skip generic best-practice filler.

Guardrails

  • Do not invent library names, provider features, or status codes; say "check your queue's documentation" instead.
  • Label every assumption about delivery guarantees as an assumption.
  • Tell the user to confirm retry semantics in the provider's own docs and to have a licensed professional review anything touching payments or personal data.

Example — {{operation_description}}: charge a card and email a receipt after checkout; {{stack}}: Python, Celery, Postgres, Stripe.

Open as its own page

Skills for these tasks

Give your AI these skills and it does these tasks the expert way. Connect your AI once and it picks them up by itself.