Subchapter 2.2
references/backend.mdMarkdown4 KBView on GitHub
You need a backend if your app needs to:
You don’t need a backend if:
Before writing backend code, read these pages using WebFetch:
| Topic | URL |
|---|---|
| Backend implementation + fetchStripeSignature | https://docs.stripe.com/stripe-apps/build-backend (opens in a new tab) |
| Authentication types (determines backend pattern) | https://docs.stripe.com/stripe-apps/api-authentication (opens in a new tab) |
| Events and webhooks | https://docs.stripe.com/stripe-apps/events (opens in a new tab) |
| Secret Store API | https://docs.stripe.com/stripe-apps/store-secrets (opens in a new tab) |
Your app’s stripe_api_access_type controls how the backend authenticates. See authentication.md for the full breakdown of auth types and when to use each one.
CORS (Access-Control-Allow-Origin: *) is needed ONLY on endpoints called by the UI extension. The UI runs in a sandboxed iframe with a null origin — specific origin allowlisting will not work.
Webhook endpoints do NOT need CORS — they receive requests from Stripe’s servers, not from the browser.
fetchStripeSignature is how the UI extension authenticates requests to your backend. The signed payload and verification method are documented at https://docs.stripe.com/stripe-apps/build-backend (opens in a new tab).
Key facts:
absec_...) is generated on first stripe apps uploaduser_id and account_id (field order matters)fetchStripeSignature(payload)stripe.webhooks.signature.verifyHeader()Webhook setup depends on your app’s distribution and auth type:
| App type | Webhook setup |
|---|---|
| Private (your account only) | ONE standard webhook endpoint |
| Public with platform keys | ONE webhook with “Listen to events on Connected accounts” enabled |
| Public with restricted API keys | Can’t use Connect webhook fanout — each merchant manages their own webhooks |
The event_read permission MUST be declared in your manifest, plus read permissions for each event type you want to receive.
Read https://docs.stripe.com/stripe-apps/events (opens in a new tab) for the full setup guide.
For firewall allowlisting of inbound webhook traffic, see https://docs.stripe.com/ips (opens in a new tab) for Stripe’s IP addresses.
Plain-language: “Stripe has a built-in secure place to store passwords, tokens, and API keys for your app — you don’t need to build your own database for secrets.”
| Scope | Use for | Example |
|---|---|---|
account | Shared across all users of an account | The business’s API key for an email service |
user | Per-user secrets | An individual user’s OAuth access token |
In stripe-app.yaml:
declarations:
stripe_api_access:
permissions:
- permission: secret_write
purpose: Store third-party credentials for the appFor the correct code patterns to read, write, and delete secrets, read: https://docs.stripe.com/stripe-apps/store-secrets (opens in a new tab)
Run your backend locally alongside stripe apps start:
# Terminal 1: start the app preview
stripe apps start
# Terminal 2: start your backend server
node server.jsFor webhook forwarding during local development, see references/webhooks.md.