How to hit the Stripe API

The Stripe API lives at https://api.stripe.com/v1. Request bodies are form-encoded (-d key=value), not JSON; responses are JSON. Use a test-mode key and nothing touches real money.

Authentication

Copy your secret key from Dashboard → Developers → API keys. Use the sk_test_… key while trying things out. Send it as Authorization: Bearer <key>. In the examples it's written {{STRIPE_SECRET_KEY}}.

Full reference: https://docs.stripe.com/api

Retrieve your balance

Available and pending funds per currency — the simplest call to check a key.

curl https://api.stripe.com/v1/balance \
  -H "Authorization: Bearer {{STRIPE_SECRET_KEY}}"
Run in PostTaco

Create a customer

Each -d is one form field. Returns the customer with its cus_… id.

curl https://api.stripe.com/v1/customers \
  -H "Authorization: Bearer {{STRIPE_SECRET_KEY}}" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d name="Jenny Rosen" \
  -d email="[email protected]"
Run in PostTaco

List customers

Newest first. Page with starting_after=<last id> while has_more is true.

curl "https://api.stripe.com/v1/customers?limit=3" \
  -H "Authorization: Bearer {{STRIPE_SECRET_KEY}}"
Run in PostTaco

Create a payment intent

Amounts are in the smallest currency unit: 2000 = $20.00. Nested fields use brackets.

curl https://api.stripe.com/v1/payment_intents \
  -H "Authorization: Bearer {{STRIPE_SECRET_KEY}}" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d amount=2000 \
  -d currency=usd \
  -d "automatic_payment_methods[enabled]=true"
Run in PostTaco

Refund a payment

Refunds the full amount unless you pass amount.

curl https://api.stripe.com/v1/refunds \
  -H "Authorization: Bearer {{STRIPE_SECRET_KEY}}" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d payment_intent={{PAYMENT_INTENT_ID}}
Run in PostTaco