Add an API to a Lovable App: 16 Prompts and What Breaks
Prompt builder · five steps · no account
Step 1 of 5
What are you building?
Building something else? Describe it to the AI generator
Adding an API to a Lovable app fails in a predictable place: the request works, the happy path renders, and then the key is in the client bundle, the rate limit is undiscovered, and nothing handles the third party being down. Lovable's docs close the first of those by design. These 16 prompts close the other two, and this page shows where the key lives, what the AI gateway costs, and what the first run will record.
By Marco Kohns · Prompts written and run by us
Short answers
Short answers
Where does the key go?
In project secrets, never in the chat and never in a VITE_ variable. Lovable's docs say secrets are encrypted, injected into edge functions and never reach the browser. Every prompt here assumes that path.
The three paths →What does a run cost?
? credits
Not measured for this category yet. The runs we have measured range from 1.8 to 10.4 credits; an integration that adds one edge function sits low in that range, and a model call is billed on top as a run credit.
See what we do know →Do I need an OpenAI or Gemini key?
Not for the AI prompts. Lovable's AI gateway adds model calls without a provider account or key and bills each call to workspace credits. A provider it does not offer is called from an edge function with your own key as a secret.
From the docs →My integration already exists
Then check three things: the key is not in the bundle, the same webhook event twice does nothing, and a timeout shows a state. The fix lines below cover each.
Fix lines for live apps →16
API & Integration prompts in this category
↳ Copy-paste, free
0of 16
Prompts from this category run in Lovable
↳ Next run: Payment Provider Webhook Integration
3runs
Measured so far across the library
↳ 1.8 to 10.4 credits each
24
Upvotes since Jan 2026
↳ One per visitor, self-reported
Data basis: no prompt run in this category yet; every card says so. Credit figures come from the three measured runs elsewhere in the library, the screenshots from the 26 September 2026 session, and every rule about secrets, connectors, edge functions and the AI gateway from Lovable's docs, checked 22 October 2026.
Find a prompt
Which service are you connecting?
Cards are sorted by build order. Each says whether we ran it in Lovable, and if not, shows a question mark instead of a guess.
Showing 16 prompts
- Step 1 · Understand▲ 7
API Request Explorer
A request explorer for your own API that sends through a server proxy with each user's encrypted key, so saved requests and history never store a credential.
Run it when: before committing to an API, to see the response shape instead of guessing it.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 2 · First integration▲ 1
Feature Flag Service Integration
A hosted feature-flag service behind one wrapper and a typed registry, where an unreachable provider falls back to declared defaults and overdue flags are highlighted.
Run it when: flags live in a service and the app must behave when it is unreachable.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 2 · First integration▲ 3
API-Driven Weather Dashboard
A weather dashboard where one server module owns the provider key, cache and call count, so cards fall back to stale cached data when the provider fails.
Run it when: you want a read-only integration to learn caching and failure states on.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 3 · Money▲ 1
Payment Provider Webhook Integration
Signature-verified payment webhooks as the only writer of subscriptions and entitlements, idempotent on event id and tested against duplicates and out-of-order delivery.
Run it when: a provider's events drive what a customer may do.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 3 · Money
Third-Party CRM Sync Integration
A two-way CRM sync where direction and conflict winner are declared per field, every change logs the rule that caused it, and mass changes pause for confirmation.
Run it when: two systems hold the same records and one of them must win.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 1
AI Chat Assistant Integration
An in-app chat assistant that answers from your help articles with source links, reads the user's plan, and hands off to support when retrieval finds nothing.
Run it when: conversation state and a cost cap matter as much as the answer.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 1
AI Text Classification API Integration
A text classifier against a versioned label set with a None of these option, where items below each label's threshold go to a human review queue.
Run it when: the output is a label from a fixed set and the app acts on it.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 2
AI Analytics Insights
A weekly AI narrative over your metrics where change detection runs before the model, and every number in the text must appear in the run's stored snapshot.
Run it when: numbers go in and a structured summary comes out.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 1
AI PDF Summarizer
A PDF summarizer that shows the summary beside the source, links each key point to its page, and names every scanned page it could not read.
Run it when: one document in, text out, with the size limit stated.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 1
AI Image Captioner
A batch captioner that writes alt text under 125 characters and a short description per image, then routes uncertain results to a reviewer who approves them.
Run it when: images in, captions out, failures handled per file.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 1
AI Multilingual Translator
A translation tool that sends the team glossary with every request, checks the output for each required term, and flags any translation that misses one.
Run it when: the output must preserve structure and the source must stay available.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 1
AI Driven Research Assistant
A research assistant that links every sentence to a verbatim supporting quote, labels unsupported sentences Inference, and quotes both sides when sources disagree.
Run it when: several calls chain and each needs a budget.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - AI▲ 1
AI Action History Logger
One wrapper around every model call writes a structured, redacted record that admins search by feature, user and trace, and every record opened is logged.
Run it when: a model takes actions and someone has to see what it did.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Your API▲ 1
Public API Explorer
A public API catalog with structured, filterable pages, a try-it console behind an allowlisted proxy, and a scheduled job that marks unverified entries Needs re-check.
Run it when: your app is the service and others need a catalogue and a try-it console.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Your API▲ 1
API Auto-Documentation Generator
An API docs site generated from an uploaded OpenAPI spec, with a page per endpoint and schema, a gap report, and publishing that swaps versions in one step.
Run it when: endpoints exist and the docs should come from the code.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock
Connecting more than one service? The bundle has all 16 as one kit in build order, with every Pro version unlocked, plus 136 more prompts.
See what is in the 152-prompt bundleDisclosure: if you create a Lovable account through links on this page, we may earn a commission. It costs you nothing and does not change what we recommend.
Measured run
No integration prompt has been run yet. This is what the first run will record.
▍Context
Add payment provider webhooks to an existing subscription app on the app's backend: signature-verified events are the only source of subscription and entitlement state. The one job: no customer pays without access and none keeps access after cancelling.
▍Core Features
1. Receiver: a server function verifies the signature on the raw body, stores the event, answers 200 at once and processes it afterwards
2. Handlers for checkout completed, payment failed, subscription updated and subscription canceled; with Stripe these are checkout.session.completed, invoice.payment_failed, customer.subscription.updated and customer.subscription.deleted, verified with the Stripe-Signature header and the endpoint's signing secret
3. Entitlements written only by processed events; the success page after checkout reads them and shows "Confirming your payment" until the event arrives
4. Failure alerts: a processing error emails admins with the event id and shows on the admin page
5. Reconciliation page: subscription states in your database against a pull from the provider's API, mismatches listed
▍Event Truth & Idempotency
▍Safe-Guard Instructions
- Never grant access from a redirect, query parameter or any browser signal
- Idempotency on the provider's event id; unknown event types are stored, acknowledged and ignored
▍Distribution hooks · Pro
Locked. The Pro version adds the growth-channel instructions for this screen.
- 01
A fresh project in Marco's own workspace
Balance read and screenshotted first. A test-mode Stripe key as the secret, added through More > Settings > Secrets, which Lovable's docs say is the place for it.
- 02
The prompt pasted unedited, in Build mode
Its Before Building line should make Lovable ask which provider and which events matter first. Every question goes on the record with the answer given.
- 03
Watch where the key ends up
Lovable detects a key pasted into chat and steers it to Secrets. The run checks the published bundle for the key anyway, because a prompt asking for a client-side fetch can still get one.
- 04
Send the same test event twice
The docs say the Stripe connector uses no webhooks by default, so the prompt has to make Lovable write the endpoint. Idempotency is proven by a replay, never by reading the code.
- 05
Rounds counted until the Core Features list is met, or 5
Each follow-up verbatim: a missing handler, an unverified signature, a redirect page that wrote state.
- 06
Balance read again, Security view scanned
Leaked secrets is one of the seven Deep scan areas and the scan is free. The credit figure goes on the card.




Credit math
What an integration costs, from the docs and the runs we have
Build credits pay for the message that writes the edge function; run credits pay for every model call through the AI gateway and for the backend while hosted. No run in this category yet, so the row uses the measured range.
| Plan | Daily build credits | A measured run (1.8 to 10.4) | Unused credits |
|---|---|---|---|
| Free | 5 a day, max 30 a month | A one-function integration fits in a day; a backend-provisioning build spans two. Plus 4 AI credits and 1 connector credit a month as grants. | Daily credits do not roll over; the grants do not either |
| Pro | 5 a day, plus 100 monthly plan credits from $25 | Daily credits first, then plan credits. Model calls through the gateway are billed per call on top. | Plan credits roll over, expire after 2 months |
| Business | 5 a day, plus 100 monthly plan credits from $50 | Same as Pro | Same as Pro |
Lovable's own examples, for scale
- “Add authentication”
- 1.20
- Build a landing page with images
- 2.00
- A Plan mode message
- 1.00 plus research
- Deep scan from the Security view
- 0.00
Source: Lovable docs, Credits and usage (illustrative), Plan mode and Security view. Checked 22 October 2026.
Three ways to spend less
- Use the gateway for AI before a provider key. No account, no key, no billing setup, per the docs; each call is metered as a run credit. Reach for your own key only for a provider the gateway does not offer.
- Explore the API in one prompt first. The request explorer shows the response shape before application code depends on it. A wrong guess at the shape is a rebuild round.
- Prefer a connector where one exists. The docs list connectors for Stripe, Resend, Perplexity, HubSpot, Slack, Twilio and more; the key stays out of code and chat and the connector adds it to requests.
Start here
Which integration prompt should you run first?
Pick the sentence that sounds like your project.
Learn the server-side pattern where a mistake is cheap
- 01API Request Explorer · see the response shape first
- 02API-Driven Weather Dashboard · read-only, with caching and failure states
- 03Simple Social Login Connector · the key pattern, low stakes
Build order
Four steps. Understand the API, call it safely, then handle it failing.
01
Understand
API request explorer
One prompt to see the response shape beats guessing at it in application code.
02
First integration
Social login · Flags · Weather
The secret in Secrets, the call in an edge function, the failure state on screen.
03
The ones that matter
Payment webhook · CRM sync
Signature verification, idempotency on the event id, reconciliation.
04
Make failure visible
API error tracker (backend page)
The piece most often missing when an integration silently stops.
Anatomy
What each section of an integration prompt does
| Section | What it tells Lovable | What you get without it |
|---|---|---|
| Context | Which service, which direction, and what the app does when it is down | A happy path and nothing else |
| Core features | Verified receipt and storage first, handlers second, the UI last | A redirect page that writes state before the event arrives |
| Rules section | Idempotency, ordering, the output contract, the cost cap | Double charges that look correct in testing |
| Build order | Secret, then the server-side call, then the screen | A key in a VITE_ variable, which the docs say is public |
| Safe-guards | Keys in Secrets; calls server-side; reject unsigned payloads; never trust the client | A fetch in the browser with the key in it |
| Before building | Ask questions first, save answers to project knowledge | A guess at which events matter |
A one-line prompt gets you
- The key in the client bundle
- One handler for the happy path
- A webhook that charges twice on retry
- A blank screen when the model returns prose
A prompt from this page gets you
- The secret in Secrets, read by an edge function
- Every event stored once by its id
- A confirming state until the webhook has written
- An output contract and a cost cap in the same message
Fixes
Where integration prompts go wrong, and the line that fixes it
Already shipped an integration that works on the happy path? Paste the fix line into your existing project.
Symptom
The API key is visible in the browser
Cause: the prompt asked for a fetch and the key went into frontend code or a VITE_ variable, which Lovable's docs say is bundled and public.
Fix line
Move the [service] key to project secrets. Move the call into an edge function that reads it from there. Remove every reference to the key from frontend code and confirm the published bundle does not contain it.
Symptom
A retried webhook event ran twice
Cause: nothing stored the provider's event id, so a replay looked like a new event.
Fix line
Store every incoming event by the provider's event id with a unique constraint. If the id exists, acknowledge and do nothing. Apply events against current state using the provider timestamp, so a cancel that arrives before its update still ends canceled.
Symptom
The model answered in prose and the screen went blank
Cause: the AI call was treated as deterministic and nothing handled a response that does not parse.
Fix line
Define the exact JSON shape the model must return. Validate the response; on a parse failure retry once with the error quoted, then show a visible failed state with the raw text available. Never render an unvalidated response.
Symptom
The third party was down and the app hung
Cause: no timeout, no error state, no retry policy were named.
Fix line
Add a 10-second timeout to every call to [service]. On timeout or a 5xx, show a retryable error state, log the attempt with the status code, and retry at most 3 times with backoff. Do not block the rest of the page.
Upvotes
Which API & Integration prompts do builders upvote?
Upvotes since January 2026, one per visitor. Small numbers: read them as a hint, never as a ranking.
- API Request Explorer7
- API-Driven Weather Dashboard3
- AI Analytics Insights2
- AI Text Classification API Integration1
- AI Image Captioner1
- API Auto-Documentation Generator1
The Complete Lovable Bundle
All 16 integration prompts in build order, plus every other prompt
Every prompt and kit, every Pro version unlocked. One payment, no subscription.
One payment. No subscription, no renewal, ever.
FAQ
Questions about API & Integration prompts
How do I add an API to a Lovable app?+×
Three ways per Lovable's docs, read on 22 October 2026: a connector from the catalogue, a custom connector an owner or admin creates, or a direct integration where you describe the endpoints, methods and auth and Lovable writes the server-side code. On older React and Vite projects that is an edge function; on newer TanStack Start projects a server function. The key goes in through the Add secret form, never the chat. Then handle the three cases the docs leave to you: the request failing, the response not parsing, the same event arriving twice.
Does Lovable have an API?+×
Three things get typed as lovable api. Your app can call any internet-reachable API, which is this page. Your published app can be exposed as an MCP server so ChatGPT or Claude can call its actions. And there is a Lovable API connector for Business and Enterprise plans. A public API for scripting Lovable projects themselves is not in the docs as of the check date.
Where does the API key live?+×
In project secrets, which the docs describe as encrypted, injected into edge functions and never reaching the browser; a value cannot be viewed again after saving, only replaced. Lovable rejects VITE_ names in Secrets because anything with that prefix is bundled into the client. Lovable also detects a key pasted into the chat and steers it to Secrets.
Which AI model do the AI prompts assume?+×
None in particular. Lovable's AI gateway adds model calls without a provider account, API key or billing setup; Lovable manages a per-project key and bills each call to workspace credits. For a provider the gateway does not offer, the docs say to call it from a backend edge function with your own key stored as a secret. The prompts specify the call shape and the output contract, so either path works.
Does the Stripe integration handle webhooks?+×
Not by default. Lovable's Stripe connector docs say the integration does not use webhooks and to ask Lovable to write a webhook function when you need one, for fulfilment or subscription state. That is what the payment webhook prompt does. Built-in payments on Pro and above are different: Lovable registers two endpoints per environment and the docs say not to delete either.
Where do webhooks belong, here or in Backend Logic?+×
Receiving and verifying one is an integration and lives here. Processing the event, retrying it and recovering from a bad batch is the Webhook Listener prompt on the backend page. The two are written to run in that order on one project.
Which of these prompts have been run?+×
None of the 16 yet, and the cards say so. The three measured runs in the library are a landing page, a UI states system and a SaaS foundation, 1.8 to 10.4 credits. The first integration run is the payment webhook prompt with a test-mode Stripe key, and the replay test is the part that matters.
What we have not tested yet
- All 16 prompts in this category. Their cards show a question mark until we run them.
- A published bundle searched for a key after a direct integration, to confirm the docs' claim on our own build.
- The same AI prompt through the gateway and through a provider key, with the run credits compared.
- Connectors other than Stripe. Named from the docs catalogue, never run by us.
Next run: Payment Provider Webhook Integration, with a test-mode Stripe key and the replay test. How we test prompts
Who wrote this
Marco Kohns wrote these prompts and ran the three measured ones elsewhere in the library. Lovable Prompts is independent and not affiliated with Lovable.
“Try in Lovable” links are affiliate links: we may earn a commission when you create an account through them. The Pro versions and the bundle are our own paid products. Neither decides which prompt we tell you to start with.
Related reading
- backend prompts for processing what a webhook delivers · Idempotent, replayable, visible.
- SaaS prompts with Lovable's payment rules · Built-in payments versus your own Stripe.
- Lovable pricing and credits · Plans read today and what one prompt costs in credits.
- project and file references in prompts · @Project and @file, with limits.
- Lovable vs Bolt · Tokens versus credits.
- the admin dashboard kit · Aggregate reads done safely.
- common integration mistakes · Keys in the browser, no idempotency.
- Lovable SEO · Public pages for what your API does.
- Lovable security · Leaked secrets is one of the seven Deep scan areas.
- Lovable and Stripe, in the SaaS guide · Why the webhook is the only writer, with Stripe's own words.
- AI app ideas for Lovable · The AI prompts as fifteen ideas, each with its safeguard line.
Other prompt categories
Sources
- Lovable docs: Integrate any API
- Lovable docs: Secrets
- Lovable docs: Edge functions
- Lovable docs: AI gateway
- Lovable docs: Stripe connector
- Lovable docs: Add payments to your app
- Lovable docs: Connectors introduction
- Lovable docs: Lovable API connector
- Lovable docs: Publish your app as an MCP server
- Lovable docs: Security best practices
All read on 22 Oct 2026.