curl --request POST \
--url https://api.recoupable.dev/api/subscriptions/sessions \
--header 'Content-Type: application/json' \
--data '
{
"successUrl": "https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}",
"plan": "pro",
"cancelUrl": "https://recoupable.dev/pricing"
}
'import requests
url = "https://api.recoupable.dev/api/subscriptions/sessions"
payload = {
"successUrl": "https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}",
"plan": "pro",
"cancelUrl": "https://recoupable.dev/pricing"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
successUrl: 'https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}',
plan: 'pro',
cancelUrl: 'https://recoupable.dev/pricing'
})
};
fetch('https://api.recoupable.dev/api/subscriptions/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.recoupable.dev/api/subscriptions/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'successUrl' => 'https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}',
'plan' => 'pro',
'cancelUrl' => 'https://recoupable.dev/pricing'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.recoupable.dev/api/subscriptions/sessions"
payload := strings.NewReader("{\n \"successUrl\": \"https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}\",\n \"plan\": \"pro\",\n \"cancelUrl\": \"https://recoupable.dev/pricing\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.recoupable.dev/api/subscriptions/sessions")
.header("Content-Type", "application/json")
.body("{\n \"successUrl\": \"https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}\",\n \"plan\": \"pro\",\n \"cancelUrl\": \"https://recoupable.dev/pricing\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.recoupable.dev/api/subscriptions/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"successUrl\": \"https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}\",\n \"plan\": \"pro\",\n \"cancelUrl\": \"https://recoupable.dev/pricing\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cs_test_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/pay/cs_test_a1b2c3d4e5f6g7h8i9j0"
}{
"error": "starter_unavailable"
}{
"error": "successUrl is required"
}{
"error": "successUrl is required"
}Create Subscription Session
Create a checkout session to start a subscription for the authenticated account. Returns a hosted checkout URL that the client should redirect to. plan picks the price: pro (default) is pre-configured with a 30-day trial period; starter is charged at checkout with no trial.
curl --request POST \
--url https://api.recoupable.dev/api/subscriptions/sessions \
--header 'Content-Type: application/json' \
--data '
{
"successUrl": "https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}",
"plan": "pro",
"cancelUrl": "https://recoupable.dev/pricing"
}
'import requests
url = "https://api.recoupable.dev/api/subscriptions/sessions"
payload = {
"successUrl": "https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}",
"plan": "pro",
"cancelUrl": "https://recoupable.dev/pricing"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
successUrl: 'https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}',
plan: 'pro',
cancelUrl: 'https://recoupable.dev/pricing'
})
};
fetch('https://api.recoupable.dev/api/subscriptions/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.recoupable.dev/api/subscriptions/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'successUrl' => 'https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}',
'plan' => 'pro',
'cancelUrl' => 'https://recoupable.dev/pricing'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.recoupable.dev/api/subscriptions/sessions"
payload := strings.NewReader("{\n \"successUrl\": \"https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}\",\n \"plan\": \"pro\",\n \"cancelUrl\": \"https://recoupable.dev/pricing\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.recoupable.dev/api/subscriptions/sessions")
.header("Content-Type", "application/json")
.body("{\n \"successUrl\": \"https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}\",\n \"plan\": \"pro\",\n \"cancelUrl\": \"https://recoupable.dev/pricing\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.recoupable.dev/api/subscriptions/sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"successUrl\": \"https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}\",\n \"plan\": \"pro\",\n \"cancelUrl\": \"https://recoupable.dev/pricing\"\n}"
response = http.request(request)
puts response.read_body{
"id": "cs_test_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/pay/cs_test_a1b2c3d4e5f6g7h8i9j0"
}{
"error": "starter_unavailable"
}{
"error": "successUrl is required"
}{
"error": "successUrl is required"
}Body
Session creation parameters
Where Stripe sends the buyer after payment. For anonymous checkout include the literal {CHECKOUT_SESSION_ID} placeholder so the client can call Claim Subscription if the sign-in email differs.
"https://chat.recoupable.dev?checkout=success&session_id={CHECKOUT_SESSION_ID}"
The plan to buy. Defaults to pro when omitted (back-compat for authenticated callers). pro carries the 30-day trial; starter charges on completion.
starter, pro "pro"
Where Stripe sends the buyer if they leave Checkout without paying.
"https://recoupable.dev/pricing"
Was this page helpful?
