Software engineering

API integration prompt

A copy-and-paste prompt for ChatGPT, Claude or Gemini that gets a professional aPI integration on the first try, plus the cheapest model that does it well.

What most people type

how do I send an order confirmation email from my next.js app when a stripe payment succeeds

It works, but the AI has to guess your next.js version, app or Pages Router and email provider, so the first answer usually needs another round. The version below asks for exactly what a professional would deliver.

The better prompt

Show me how to send an order confirmation email from my Next.js app when a Stripe payment succeeds.

Context: Next.js version [version], router [App Router or Pages Router], email provider [Resend, SendGrid, Postmark, Nodemailer, or other], language [TypeScript or JavaScript], hosting [where it's deployed].

Before writing code, propose a short plan with milestones and acceptance criteria, and confirm it with me. Then provide:
1. The Stripe webhook route handler. Verify the signature using the raw request body and listen for the right event, such as checkout.session.completed or payment_intent.succeeded. Explain which one fits my flow: [Stripe Checkout, Payment Element, or Payment Links].
2. The email-sending function and a simple order confirmation template. Use the order details available from the Stripe event: [fields to include, e.g. items, total, order ID].
3. Idempotency, so retried webhook events don't send duplicate emails.
4. Error handling, including what to return to Stripe so it retries only when it should.
5. Environment variables needed, and how to test locally with the Stripe CLI.

Return complete code files with file paths, followed by a short checklist for going live. Don't invent API details. If something depends on my setup, say so.

Replace the [brackets] with your details before you send it: version, App Router or Pages Router, Resend, SendGrid, Postmark, Nodemailer, or other, TypeScript or JavaScript, where it's deployed, Stripe Checkout, Payment Element, or Payment Links, fields to include, e.g. items, total, order ID.

Why this version works

  • Added placeholders for stack details. Answer depends on router, provider, language and Stripe flow.
  • Specified webhook, email, idempotency, errors. Covers what a working production setup needs.
  • Asked for plan before code. Multi-step technical work should be confirmed first.
  • Requested files with paths and checklist. Gives a pasteable, complete result.

What a professional aPI integration prompt covers

  • Webhook-based approach with signature verification
  • Email provider placeholder
  • Asks for code with where it goes
  • Next.js version or router placeholder

Best AI model for this prompt

This is a everyday task: webhook security, idempotency and integration details; mistakes break payments or emails. You don't need the most expensive model. The cheapest model at each company that handles it well:

CompanyModelPer usePer 1,000 uses
AnthropicClaude Sonnet 5.5$0.015$14.53
OpenAIGPT-6.1 Terra$0.0073$7.27
GoogleGemini 3.8 Flashcheapest$0.0054$5.45

Pay-per-use list prices for this prompt and its expected answer (about 1,400 tokens). On a monthly chat plan, the same choice shows up as more messages before you hit your limit. See today's AI prices.

API integration prompt for ChatGPT, Claude and Gemini (Software engineering) · PromptSaver