curl --request POST \
--url https://api.lava.so/v1/checkout_sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_mode": "subscription",
"origin_url": "https://your-app.example.com/",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"plan_id": "sc_123",
"credit_bundle_id": "cb_abc123"
}
'import requests
url = "https://api.lava.so/v1/checkout_sessions"
payload = {
"checkout_mode": "subscription",
"origin_url": "https://your-app.example.com/",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"plan_id": "sc_123",
"credit_bundle_id": "cb_abc123"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
checkout_mode: 'subscription',
origin_url: 'https://your-app.example.com/',
customer_id: 'con_test_01EXAMPLE00000000000000001',
plan_id: 'sc_123',
credit_bundle_id: 'cb_abc123'
})
};
fetch('https://api.lava.so/v1/checkout_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.lava.so/v1/checkout_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([
'checkout_mode' => 'subscription',
'origin_url' => 'https://your-app.example.com/',
'customer_id' => 'con_test_01EXAMPLE00000000000000001',
'plan_id' => 'sc_123',
'credit_bundle_id' => 'cb_abc123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.lava.so/v1/checkout_sessions"
payload := strings.NewReader("{\n \"checkout_mode\": \"subscription\",\n \"origin_url\": \"https://your-app.example.com/\",\n \"customer_id\": \"con_test_01EXAMPLE00000000000000001\",\n \"plan_id\": \"sc_123\",\n \"credit_bundle_id\": \"cb_abc123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.lava.so/v1/checkout_sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_mode\": \"subscription\",\n \"origin_url\": \"https://your-app.example.com/\",\n \"customer_id\": \"con_test_01EXAMPLE00000000000000001\",\n \"plan_id\": \"sc_123\",\n \"credit_bundle_id\": \"cb_abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/checkout_sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"checkout_mode\": \"subscription\",\n \"origin_url\": \"https://your-app.example.com/\",\n \"customer_id\": \"con_test_01EXAMPLE00000000000000001\",\n \"plan_id\": \"sc_123\",\n \"credit_bundle_id\": \"cb_abc123\"\n}"
response = http.request(request)
puts response.read_body{
"checkout_session_id": "cs_test_01EXAMPLE00000000000000001",
"checkout_session_token": "eyJzZWNyZXQiOiJjc3NfdGVzdF9leGFtcGxlX3NlY3JldCIsImJhc2UiOiJodHRwczovL2NoZWNrb3V0LmV4YW1wbGUuY29tLyJ9",
"checkout_mode": "subscription",
"origin_url": "https://your-app.example.com/",
"created_at": "2023-05-15T08:30:00Z",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"plan_id": "sc_123",
"completed_at": "2023-05-15T08:35:42Z"
}Create checkout session
Create a new checkout session. Supports two modes: subscription (start a recurring plan) and credit_bundle (one-time credit pack purchase). Pass the returned checkout_session_token to the @lavapayments/checkout SDK to open the checkout flow.
curl --request POST \
--url https://api.lava.so/v1/checkout_sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_mode": "subscription",
"origin_url": "https://your-app.example.com/",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"plan_id": "sc_123",
"credit_bundle_id": "cb_abc123"
}
'import requests
url = "https://api.lava.so/v1/checkout_sessions"
payload = {
"checkout_mode": "subscription",
"origin_url": "https://your-app.example.com/",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"plan_id": "sc_123",
"credit_bundle_id": "cb_abc123"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
checkout_mode: 'subscription',
origin_url: 'https://your-app.example.com/',
customer_id: 'con_test_01EXAMPLE00000000000000001',
plan_id: 'sc_123',
credit_bundle_id: 'cb_abc123'
})
};
fetch('https://api.lava.so/v1/checkout_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.lava.so/v1/checkout_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([
'checkout_mode' => 'subscription',
'origin_url' => 'https://your-app.example.com/',
'customer_id' => 'con_test_01EXAMPLE00000000000000001',
'plan_id' => 'sc_123',
'credit_bundle_id' => 'cb_abc123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.lava.so/v1/checkout_sessions"
payload := strings.NewReader("{\n \"checkout_mode\": \"subscription\",\n \"origin_url\": \"https://your-app.example.com/\",\n \"customer_id\": \"con_test_01EXAMPLE00000000000000001\",\n \"plan_id\": \"sc_123\",\n \"credit_bundle_id\": \"cb_abc123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.lava.so/v1/checkout_sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_mode\": \"subscription\",\n \"origin_url\": \"https://your-app.example.com/\",\n \"customer_id\": \"con_test_01EXAMPLE00000000000000001\",\n \"plan_id\": \"sc_123\",\n \"credit_bundle_id\": \"cb_abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.lava.so/v1/checkout_sessions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"checkout_mode\": \"subscription\",\n \"origin_url\": \"https://your-app.example.com/\",\n \"customer_id\": \"con_test_01EXAMPLE00000000000000001\",\n \"plan_id\": \"sc_123\",\n \"credit_bundle_id\": \"cb_abc123\"\n}"
response = http.request(request)
puts response.read_body{
"checkout_session_id": "cs_test_01EXAMPLE00000000000000001",
"checkout_session_token": "eyJzZWNyZXQiOiJjc3NfdGVzdF9leGFtcGxlX3NlY3JldCIsImJhc2UiOiJodHRwczovL2NoZWNrb3V0LmV4YW1wbGUuY29tLyJ9",
"checkout_mode": "subscription",
"origin_url": "https://your-app.example.com/",
"created_at": "2023-05-15T08:30:00Z",
"customer_id": "con_test_01EXAMPLE00000000000000001",
"plan_id": "sc_123",
"completed_at": "2023-05-15T08:35:42Z"
}checkout_mode: "subscription", customer_id is optional:- Omit it for logged-out/new customers (checkout collects identity and creates a customer)
- Include it for logged-in/returning customers (checkout reuses the existing customer)
{
"checkout_mode": "subscription",
"origin_url": "https://yourapp.com",
"plan_id": "sub_plan_id"
}
{
"checkout_mode": "subscription",
"origin_url": "https://yourapp.com",
"plan_id": "sub_plan_id",
"customer_id": "conn_existing_customer_id"
}
Authorizations
Bearer token authentication used for standard API calls. Format: 'Bearer YOUR_API_KEY'
Body
Checkout mode: 'subscription' creates a recurring subscription checkout, 'credit_bundle' purchases a credit pack for an existing subscriber
subscription, credit_bundle "subscription"
Origin url where the checkout will be opened
"https://your-app.example.com/"
Required for credit_bundle mode. Optional for subscription mode — omit for new customers (checkout collects identity and creates a customer) or include for returning customers (reuses the existing customer).
"con_test_01EXAMPLE00000000000000001"
Required when checkout_mode is 'subscription' - identifies the plan to use
"sc_123"
Required when checkout_mode is 'credit_bundle' - identifies the credit bundle to purchase
"cb_abc123"
Response
Checkout session created
Unique identifier for the checkout session
"cs_test_01EXAMPLE00000000000000001"
Opaque token for the @lavapayments/checkout SDK. Pass this to open() to launch the checkout flow.
"eyJzZWNyZXQiOiJjc3NfdGVzdF9leGFtcGxlX3NlY3JldCIsImJhc2UiOiJodHRwczovL2NoZWNrb3V0LmV4YW1wbGUuY29tLyJ9"
Checkout mode: 'subscription' creates a recurring subscription checkout, 'credit_bundle' purchases a credit pack for an existing subscriber
subscription, credit_bundle "subscription"
Origin url where the checkout will be opened
"https://your-app.example.com/"
ISO 8601 timestamp when the checkout session was created
"2023-05-15T08:30:00Z"
Identifier for the customer (only available after checkout completion)
"con_test_01EXAMPLE00000000000000001"
Identifier for the plan (only available for subscription mode)
"sc_123"
If completed, ISO 8601 timestamp when the checkout was completed
"2023-05-15T08:35:42Z"