Stripe

Stripe API

Take card payments with PaymentIntents, sell with Checkout and payment links, run subscriptions, refund and verify webhooks.

PaymentsGuided#payments#cards#checkout#subscriptions#billing#webhooks

Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.

Overview

The Stripe API runs online payments end to end: customers, one-off card and wallet payments with PaymentIntents, hosted checkout pages, products and prices, recurring subscriptions and invoices, refunds, payment links and webhooks that tell your server what happened. This guided collection walks through those building blocks with requests that work in a sandbox as they are.

Get your test key

  1. Create an account or sign in at the Stripe Dashboard.
  2. Open a sandbox from the account picker (sandboxes are isolated test environments; no real money moves).
  3. Go to Developers > API keys and reveal the Secret key. Test secret keys start with sk_test_; live ones start with sk_live_, and Stripe recommends restricted keys (rk_live_...) with only the permissions you need in production.
  4. Paste the key into secretKey (marked secret). Never put a secret key in browser or mobile code.

Authentication, format and versioning

  • Auth: HTTP Basic with the secret key as the user name and an empty password (this collection sets it). Authorization: Bearer sk_test_... also works.
  • Base URL: https://api.stripe.com/v1.
  • Bodies are form-encoded (application/x-www-form-urlencoded), not JSON. Nested fields use brackets: line_items[0][price], metadata[order_id], expand[].
  • Stripe-Version: every request sends Stripe-Version: {{stripeVersion}}, set to 2026-10-28.endive, the newest stable version on 2026-11-17 (see the changelog). Without the header, your account's default version is used. Pinning it keeps responses stable when you upgrade.
  • Idempotency: create requests send Idempotency-Key: {{$guid}} (a fresh UUID per send). In your code, generate one key per operation and reuse it on retries: Stripe returns the saved result instead of charging twice. Keys up to 255 characters, kept at least 24 hours; reusing a key with different parameters is an error. Only POST requests use it.
  • expand[]: many fields hold an ID (customer, latest_charge). Add expand[]=latest_charge to get the full object inline, nested with dots up to four levels; on lists prefix with data. (e.g. expand[]=data.customer).
  • Pagination: list endpoints take limit (1-100, default 10) and starting_after / ending_before (an object ID); the response has data and has_more.

Using this collection

Run the folders in order. Test scripts store IDs (customerId, paymentIntentId, productId, priceId, recurringPriceId, subscriptionId...) for later requests. Payments use the test PaymentMethod pm_card_visa; other outcomes (declines, 3D Secure) have their own IDs on the testing page.

Common errors

Errors return {"error": {"type", "code", "message", "param", "doc_url"}}.

StatusMeaningWhat to do
400invalid_request_error: missing or invalid parameterRead error.param and message.
401Missing or wrong API keyCheck secretKey and sandbox vs live.
402card_error: the card was declinedShow error.message to the payer; see decline_code.
403Restricted key lacks permissionAdd the permission to the key.
404resource_missing: unknown ID, or an object from another sandbox/accountRe-run the request that creates it.
409Idempotency key reused with different parameters, or a conflicting concurrent requestUse a new key / retry.
429Too many requestsBack off and retry; see rate limits.

Pricing is per successful transaction and varies by country and method: see stripe.com/pricing. Docs: API reference, webhooks, Checkout, Billing.

Endpoints 22

1. Start here

  • GETRetrieve balance/balanceReturns the account's balance: funds available to pay out and funds still pending, per currency. When: first, to check the key works (any 200 proves it), and…

2. Customers

  • POSTCreate a customer/customersCreates a Customer. What comes back: the Customer (id starts with cus_). The test saves it to customerId. Tip: the Idempotency-Key header makes retries safe:…
  • GETRetrieve a customer/customers/{{customerId}}Fetches one Customer by ID ({{customerId}}). Key parameter: expand[] to inline related objects, e.g. invoice_settings.default_payment_method (requires one to…
  • GETList customers (pagination)/customersLists customers, newest first, and shows Stripe's cursor pagination. What comes back: {"object": "list", "data": [...], "has_more": true|false, "url":…

3. PaymentIntents (charge a card)

  • POSTCreate a PaymentIntent/payment_intentsStarts a payment for a fixed amount. What comes back: the PaymentIntent (pi_...) with status: requires_payment_method and a client_secret for the front end.…
  • POSTConfirm with a test card (pm_card_visa)/payment_intents/{{paymentIntentId}}/confirmAttaches a payment method and attempts the payment. What comes back: with manual capture, status: requires_capture and amount_capturable: 2000; with automatic…
  • POSTCapture the payment/payment_intents/{{paymentIntentId}}/captureCaptures funds that were authorised with capture_method=manual. When: when you ship the order or confirm the booking. Uncaptured PaymentIntents are canceled…
  • GETRetrieve a PaymentIntent (expand latest_charge)/payment_intents/{{paymentIntentId}}Fetches the PaymentIntent and, with expand[]=latest_charge, the full Charge inline instead of just its ID. When: checking a payment's state from your server…
  • POSTCancel a PaymentIntent/payment_intents/{{paymentIntentId}}/cancelCancels a PaymentIntent that has not succeeded yet, releasing any authorisation. When: the customer abandons checkout, or you decide not to capture. It only…

4. Refunds

  • POSTRefund a payment/refundsRefunds a captured PaymentIntent ({{paymentIntentId}} must be succeeded; re-run folder 3 if you canceled it). What comes back: a Refund (re_...) with status…

5. Products and prices

  • POSTCreate a product/productsCreates the thing you sell. What comes back: the Product (prod_...). The test saves productId.
  • POSTCreate a one-time price/pricesAdds a fixed, one-off price to the product. What comes back: the Price (price_...) with type: one_time. Prices cannot change amount after creation; create a…
  • POSTCreate a recurring price/pricesAdds a subscription price: billed every recurring[interval]. What comes back: a Price with type: recurring. The test saves recurringPriceId for subscriptions…

6. Checkout Sessions (hosted payment page)

  • POSTCreate a Checkout Session (one-time payment)/checkout/sessionsCreates a hosted page to pay for one-time items. What comes back: the Session (cs_test_...) with url (open it in a browser and pay with 4242 4242 4242 4242,…
  • POSTCreate a Checkout Session (subscription)/checkout/sessionsSame page, for a recurring price: Stripe collects the card, creates the Subscription and charges the first invoice. Differences from one-time mode:…

7. Subscriptions

  • POSTCreate a subscription/subscriptionsStarts a subscription and creates its first invoice. What comes back: the Subscription (sub_...) with status: incomplete (or trialing/active), items (each…
  • GETRetrieve a subscription/subscriptions/{{subscriptionId}}Fetches a subscription's current state ({{subscriptionId}}). Statuses: incomplete, incomplete_expired, trialing, active, past_due, unpaid, canceled, paused.…
  • DELETECancel a subscription/subscriptions/{{subscriptionId}}Cancels the subscription immediately (DELETE). To cancel at the end of the paid period instead, update it with cancel_at_period_end=true (POST…

8. Invoices and payment links

  • GETList invoices/invoicesLists invoices, newest first, optionally filtered. What comes back: a list of Invoices with number, status, amount_due, amount_paid, hosted_invoice_url (a…
  • POSTCreate a payment link/payment_linksCreates a permanent, shareable URL that opens a Stripe-hosted checkout for the given prices. No website needed: share it by email, chat or QR code. What comes…

9. Webhooks

  • POSTCreate a webhook endpoint/webhook_endpointsRegisters a URL to receive events. What comes back: the WebhookEndpoint (we_...) including secret (whsec_...). The secret is only returned on creation: the…
  • GETList webhook endpoints/webhook_endpointsLists your registered endpoints (paginated like other lists). What comes back: WebhookEndpoints with url, enabled_events, status (enabled/disabled) and…

API details

Base URL
https://api.stripe.com/v1
Authentication
HTTP Basic authentication (username and password)
A bearer token in the Authorization header
Operations
22 operations on 22 pathsPOST 14GET 7DELETE 1
Main resources
1. Start here 12. Customers 33. PaymentIntents (charge a card) 54. Refunds 15. Products and prices 36. Checkout Sessions (hosted payment page) 27. Subscriptions 38. Invoices and payment links 29. Webhooks 2
Description format
Swastik Codes guided collection, API version checked against the docs on 2026-11-17

How to test the Stripe API in Swastik Codes

  1. Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
  2. Fork it into your workspaceChoose a workspace. You get your own copy of the Stripe API collection, without the publisher's secrets.
  3. Add your credentialsThis API uses HTTP Basic authentication (username and password). Add yours in the collection's variables or an environment; the requests already reference it.
  4. Send a requestPick an endpoint, for example “Retrieve balance” (GET /balance), and press Send. Check the response, add tests and run the whole collection with the runner.

Frequently asked questions

What is the Stripe API?

Take card payments with PaymentIntents, sell with Checkout and payment links, run subscriptions, refund and verify webhooks. It is listed under Payments and has 22 endpoints.

Who publishes the Stripe API?

It is listed from Stripe's public API description (an OpenAPI document), not published by Stripe on Swastik Codes. Anyone who controls stripe.com can claim the profile by adding a DNS TXT record.

What is the base URL of the Stripe API?

Requests go to https://api.stripe.com/v1. Endpoint paths are added to this base URL.

How do I authenticate with the Stripe API?

It accepts 2 methods: HTTP Basic authentication (username and password); A bearer token in the Authorization header.

How many endpoints does the Stripe API have?

22 operations on 22 paths (14 POST, 7 GET, 1 DELETE). The largest groups are 1. Start here, 2. Customers, 3. PaymentIntents (charge a card), 4. Refunds.

Is forking the Stripe API free?

Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.

Suggest an API

Tell us which public API is missing. We check it, then add it here with its endpoints when it has an OpenAPI (Swagger) description.