Stripe API
api.stripe.com · Finance
Complete payment infrastructure — accept payments, manage subscriptions, handle refunds, split payments, and build marketplaces. Comprehensive sandbox with test card numbers. No monthly fee.
Authentication
Bearer Token
API keys from dashboard.stripe.com/apikeys. Test keys (sk_test_...) for sandbox, live keys for production. Pass as Authorization: Bearer YOUR_KEY.
Sample Requests
POST
Create a payment intent
Create a $20.00 USD payment intent (amount in cents).
https://api.stripe.com/v1/payment_intents
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Content-Type | application/x-www-form-urlencoded |
| Authorization | Bearer sk_test_YOUR_KEY |
Request Body — data you're sending
"amount=2000¤cy=usd&payment_method_types[]=card"
curl -X POST "https://api.stripe.com/v1/payment_intents" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '"amount=2000¤cy=usd&payment_method_types[]=card"'
import requests
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
data = "amount=2000¤cy=usd&payment_method_types[]=card"
response = requests.post(
"https://api.stripe.com/v1/payment_intents",
headers=headers,
json=data,
)
print(response.json())const url = 'https://api.stripe.com/v1/payment_intents';
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify("amount=2000¤cy=usd&payment_method_types[]=card"),
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"bytes"
"encoding/json"
)
func main() {
targetURL := "https://api.stripe.com/v1/payment_intents"
jsonData, _ := json.Marshal("amount=2000¤cy=usd&payment_method_types[]=card")
req, _ := http.NewRequest("POST", targetURL, bytes.NewBuffer(jsonData))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.stripe.com/v1/payment_intents")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Post.new(uri)
req["Content-Type"] = "application/x-www-form-urlencoded"
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
req["Content-Type"] = "application/json"
req.body = "\"amount=2000¤cy=usd&payment_method_types[]=card\""
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.stripe.com/v1/payment_intents";
$opts = ["http" => [
"method" => "POST",
"header" => implode("\r\n", [
"Content-Type: application/x-www-form-urlencoded",
"Authorization: Bearer YOUR_ACCESS_TOKEN",
"Content-Type: application/json"
]),
"content" => json_encode("amount=2000¤cy=usd&payment_method_types[]=card"),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
List customers
List your Stripe customers.
https://api.stripe.com/v1/customers?limit=5
Hover any highlighted part to learn what it does
Headers — extra info sent with the request
| Authorization | Bearer sk_test_YOUR_KEY |
curl -X GET "https://api.stripe.com/v1/customers?limit=5" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
params = {
"limit": "5"
}
headers = {
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
"https://api.stripe.com/v1/customers",
params=params,
headers=headers,
)
print(response.json())const url = new URL('https://api.stripe.com/v1/customers');
url.searchParams.set('limit', '5');
const response = await fetch(url, {
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
});
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.stripe.com/v1/customers")
q := baseURL.Query()
q.Set("limit", "5")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.stripe.com/v1/customers")
uri.query = URI.encode_www_form({
"limit" => "5"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.stripe.com/v1/customers?" . http_build_query([
"limit" => "5"
]);
$opts = ["http" => [
"method" => "GET",
"header" => implode("\r\n", [
"Authorization: Bearer YOUR_ACCESS_TOKEN"
]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Sign up at stripe.com — free test account
- Get test keys from dashboard.stripe.com/apikeys (sk_test_...)
- Set Authorization: Bearer sk_test_YOUR_KEY
- Test card: 4242424242424242, any future expiry, any CVC
- All POST requests use form-encoded body (not JSON) by default