Create checkout session
Creates a payment session for the authenticated application.
curl -X POST "https://api.example.com/api/v1/sessions" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: example_string" \
-H "Authorization: Bearer YOUR_API_TOKEN (JWT)" \
-d '{
"orderReference": "ORD-2024-001",
"paymentMethod": "card",
"currency": "AUD",
"locale": "en_AU",
"amount": {
"total": 140.76,
"shipping": 9.95,
"tax": 11.81
},
"orderItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
],
"customer": {
"firstName": "Jane",
"lastName": "Smith",
"email": "jane.smith@example.com",
"phone": "+61412345678",
"billingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
},
"shippingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
}
},
"shipping": {
"type": "express",
"method": "aus_post"
},
"additionalInformation": {
"campaignId": "summer-sale-2024",
"referralCode": "REF-ABC"
},
"redirectUrls": {
"success": "https://merchant.example.com/checkout/success",
"failure": "https://merchant.example.com/checkout/failure"
}
}'
import requests
import json
url = "https://api.example.com/api/v1/sessions"
headers = {
"Content-Type": "application/json",
"Idempotency-Key": "example_string",
"Authorization": "Bearer YOUR_API_TOKEN (JWT)"
}
data = {
"orderReference": "ORD-2024-001",
"paymentMethod": "card",
"currency": "AUD",
"locale": "en_AU",
"amount": {
"total": 140.76,
"shipping": 9.95,
"tax": 11.81
},
"orderItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
],
"customer": {
"firstName": "Jane",
"lastName": "Smith",
"email": "jane.smith@example.com",
"phone": "+61412345678",
"billingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
},
"shippingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
}
},
"shipping": {
"type": "express",
"method": "aus_post"
},
"additionalInformation": {
"campaignId": "summer-sale-2024",
"referralCode": "REF-ABC"
},
"redirectUrls": {
"success": "https://merchant.example.com/checkout/success",
"failure": "https://merchant.example.com/checkout/failure"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.example.com/api/v1/sessions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Idempotency-Key": "example_string",
"Authorization": "Bearer YOUR_API_TOKEN (JWT)"
},
body: JSON.stringify({
"orderReference": "ORD-2024-001",
"paymentMethod": "card",
"currency": "AUD",
"locale": "en_AU",
"amount": {
"total": 140.76,
"shipping": 9.95,
"tax": 11.81
},
"orderItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
],
"customer": {
"firstName": "Jane",
"lastName": "Smith",
"email": "jane.smith@example.com",
"phone": "+61412345678",
"billingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
},
"shippingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
}
},
"shipping": {
"type": "express",
"method": "aus_post"
},
"additionalInformation": {
"campaignId": "summer-sale-2024",
"referralCode": "REF-ABC"
},
"redirectUrls": {
"success": "https://merchant.example.com/checkout/success",
"failure": "https://merchant.example.com/checkout/failure"
}
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"orderReference": "ORD-2024-001",
"paymentMethod": "card",
"currency": "AUD",
"locale": "en_AU",
"amount": {
"total": 140.76,
"shipping": 9.95,
"tax": 11.81
},
"orderItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
],
"customer": {
"firstName": "Jane",
"lastName": "Smith",
"email": "jane.smith@example.com",
"phone": "+61412345678",
"billingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
},
"shippingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
}
},
"shipping": {
"type": "express",
"method": "aus_post"
},
"additionalInformation": {
"campaignId": "summer-sale-2024",
"referralCode": "REF-ABC"
},
"redirectUrls": {
"success": "https://merchant.example.com/checkout/success",
"failure": "https://merchant.example.com/checkout/failure"
}
}`)
req, err := http.NewRequest("POST", "https://api.example.com/api/v1/sessions", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Idempotency-Key", "example_string")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN (JWT)")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.example.com/api/v1/sessions')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = 'example_string'
request['Authorization'] = 'Bearer YOUR_API_TOKEN (JWT)'
request.body = '{
"orderReference": "ORD-2024-001",
"paymentMethod": "card",
"currency": "AUD",
"locale": "en_AU",
"amount": {
"total": 140.76,
"shipping": 9.95,
"tax": 11.81
},
"orderItems": [
{
"name": "Wireless Headphones",
"sku": "WH-100",
"quantity": 1,
"unitPrice": 119
}
],
"customer": {
"firstName": "Jane",
"lastName": "Smith",
"email": "jane.smith@example.com",
"phone": "+61412345678",
"billingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
},
"shippingAddress": {
"line1": "123 Collins Street",
"line2": "Level 5",
"city": "Melbourne",
"state": "VIC",
"postalCode": "3000",
"country": "AU"
}
},
"shipping": {
"type": "express",
"method": "aus_post"
},
"additionalInformation": {
"campaignId": "summer-sale-2024",
"referralCode": "REF-ABC"
},
"redirectUrls": {
"success": "https://merchant.example.com/checkout/success",
"failure": "https://merchant.example.com/checkout/failure"
}
}'
response = http.request(request)
puts response.body
{
"sessionId": "e4b8c1a2-b088-4e79-99ad-2c3e0fa3f1b9",
"checkoutUrl": "https://checkout.stripe.com/pay/cs_test_123",
"status": "PENDING",
"routing": {
"selectedProvider": "stripe",
"score": 92.5
},
"expiresAt": "2024-01-15T12:00:00Z",
"createdAt": "2024-01-15T11:00:00Z"
}
{
"error": "Bad Request",
"message": "Missing required header: Idempotency-Key",
"statusCode": 400
}
{
"error": "Bad Request",
"message": [
"amount.total does not match the sum of line items, shipping, and tax"
],
"statusCode": 400
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Conflict",
"message": "The request conflicts with the current state of the resource",
"code": 409,
"details": "Resource already exists"
}
{
"message": "This idempotency key was already used with different request parameters",
"statusCode": 422,
"code": "IDEMPOTENCY_KEY_MISMATCH"
}
{
"message": "No eligible providers found for the given request parameters",
"statusCode": 422,
"code": "NO_AVAILABLE_PROVIDER"
}
{
"message": "Internal server error",
"statusCode": 500
}
{
"error": "Error",
"message": "Service temporarily unavailable.",
"code": 502
}
{
"error": "Service Unavailable",
"message": "The service is temporarily unavailable. Please try again later",
"code": 503
}
{
"error": "Error",
"message": "Request timed out.",
"code": 504
}
POST
/api/v1/sessions
POST
Base URLstring
Target server for requests. Edit to use your own host.
Bearer Token (JWT)
Bearer Tokenstring
RequiredBearer token (JWT) - just enter the token, "Bearer" prefix will be added automatically
Content-Typestring
RequiredThe media type of the request body
Options: application/json
header
Idempotency-Keystring
RequiredClient-generated unique key used to safely retry session creation. Can be any opaque string up to 255 characters.
paymentMethodstring
RequiredOptions: card
currencystring
RequiredISO 4217 alphabetic currency code.
Min length: 3 • Max length: 3 • Pattern: ^[A-Z]{3}$
localestring
Locale code, for example en_AU.
Request Preview
Response
Response will appear here after sending the request
Authentication
header
Authorizationstring
RequiredBearer token (JWT). Authentication token required.
Headers
Idempotency-Keystring
RequiredClient-generated unique key used to safely retry session creation. Can be any opaque string up to 255 characters.
Body
application/json
orderReferencestring
RequiredExample:
ORD-2024-001paymentMethodstring
RequiredAllowed values:
cardResponses
Was this page helpful?