Create a checkout session
curl --request POST \
--url http://localhost:7701/api/v1/checkout/sessions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'x-client-id: <x-client-id>' \
--data '
{
"amount": 15000,
"currency": "BRL",
"merchant_order_id": "ORD-123",
"payment_method": "card",
"gateway_first_try": "pagarme",
"expires_in": 1800,
"metadata": {},
"success_url": "https://mystore.com/order/success",
"cancel_url": "https://mystore.com/order/failed",
"customer": {
"token": "cus_abc123",
"email": "customer@example.com",
"document": "12345678909"
}
}
'import requests
url = "http://localhost:7701/api/v1/checkout/sessions"
payload = {
"amount": 15000,
"currency": "BRL",
"merchant_order_id": "ORD-123",
"payment_method": "card",
"gateway_first_try": "pagarme",
"expires_in": 1800,
"metadata": {},
"success_url": "https://mystore.com/order/success",
"cancel_url": "https://mystore.com/order/failed",
"customer": {
"token": "cus_abc123",
"email": "customer@example.com",
"document": "12345678909"
}
}
headers = {
"x-client-id": "<x-client-id>",
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-id': '<x-client-id>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: 15000,
currency: 'BRL',
merchant_order_id: 'ORD-123',
payment_method: 'card',
gateway_first_try: 'pagarme',
expires_in: 1800,
metadata: {},
success_url: 'https://mystore.com/order/success',
cancel_url: 'https://mystore.com/order/failed',
customer: {token: 'cus_abc123', email: 'customer@example.com', document: '12345678909'}
})
};
fetch('http://localhost:7701/api/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_PORT => "7701",
CURLOPT_URL => "http://localhost:7701/api/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([
'amount' => 15000,
'currency' => 'BRL',
'merchant_order_id' => 'ORD-123',
'payment_method' => 'card',
'gateway_first_try' => 'pagarme',
'expires_in' => 1800,
'metadata' => [
],
'success_url' => 'https://mystore.com/order/success',
'cancel_url' => 'https://mystore.com/order/failed',
'customer' => [
'token' => 'cus_abc123',
'email' => 'customer@example.com',
'document' => '12345678909'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"x-client-id: <x-client-id>"
],
]);
$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 := "http://localhost:7701/api/v1/checkout/sessions"
payload := strings.NewReader("{\n \"amount\": 15000,\n \"currency\": \"BRL\",\n \"merchant_order_id\": \"ORD-123\",\n \"payment_method\": \"card\",\n \"gateway_first_try\": \"pagarme\",\n \"expires_in\": 1800,\n \"metadata\": {},\n \"success_url\": \"https://mystore.com/order/success\",\n \"cancel_url\": \"https://mystore.com/order/failed\",\n \"customer\": {\n \"token\": \"cus_abc123\",\n \"email\": \"customer@example.com\",\n \"document\": \"12345678909\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<x-client-id>")
req.Header.Add("X-API-Key", "<api-key>")
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("http://localhost:7701/api/v1/checkout/sessions")
.header("x-client-id", "<x-client-id>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 15000,\n \"currency\": \"BRL\",\n \"merchant_order_id\": \"ORD-123\",\n \"payment_method\": \"card\",\n \"gateway_first_try\": \"pagarme\",\n \"expires_in\": 1800,\n \"metadata\": {},\n \"success_url\": \"https://mystore.com/order/success\",\n \"cancel_url\": \"https://mystore.com/order/failed\",\n \"customer\": {\n \"token\": \"cus_abc123\",\n \"email\": \"customer@example.com\",\n \"document\": \"12345678909\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:7701/api/v1/checkout/sessions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-client-id"] = '<x-client-id>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 15000,\n \"currency\": \"BRL\",\n \"merchant_order_id\": \"ORD-123\",\n \"payment_method\": \"card\",\n \"gateway_first_try\": \"pagarme\",\n \"expires_in\": 1800,\n \"metadata\": {},\n \"success_url\": \"https://mystore.com/order/success\",\n \"cancel_url\": \"https://mystore.com/order/failed\",\n \"customer\": {\n \"token\": \"cus_abc123\",\n \"email\": \"customer@example.com\",\n \"document\": \"12345678909\"\n }\n}"
response = http.request(request)
puts response.read_body{
"token": "cs_live_a1b2c3d4e5f6...",
"amount": 15000,
"currency": "BRL",
"merchant_order_id": "ORD-123",
"payment_method": "card",
"gateway_first_try": "pagarme",
"metadata": {},
"success_url": "https://mystore.com/order/success",
"cancel_url": "https://mystore.com/order/failed",
"expires_at": "2026-06-23T14:30:00+00:00",
"saved_cards": [
{
"token": "card_abc123",
"holder_name": "John Doe",
"brand": "visa",
"first_6_digits": "411111",
"last_4_digits": "1111",
"expire_month": "12",
"expire_year": "2029",
"status": "active",
"created_at": "2026-06-26T10:00:00+00:00",
"updated_at": "2026-06-26T10:00:00+00:00"
}
]
}Checkout
Create a checkout session
Creates a short-lived, single-use checkout session. Pass the returned token to your frontend cart — it submits payments without ever seeing the API key.
POST
/
api
/
v1
/
checkout
/
sessions
Create a checkout session
curl --request POST \
--url http://localhost:7701/api/v1/checkout/sessions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'x-client-id: <x-client-id>' \
--data '
{
"amount": 15000,
"currency": "BRL",
"merchant_order_id": "ORD-123",
"payment_method": "card",
"gateway_first_try": "pagarme",
"expires_in": 1800,
"metadata": {},
"success_url": "https://mystore.com/order/success",
"cancel_url": "https://mystore.com/order/failed",
"customer": {
"token": "cus_abc123",
"email": "customer@example.com",
"document": "12345678909"
}
}
'import requests
url = "http://localhost:7701/api/v1/checkout/sessions"
payload = {
"amount": 15000,
"currency": "BRL",
"merchant_order_id": "ORD-123",
"payment_method": "card",
"gateway_first_try": "pagarme",
"expires_in": 1800,
"metadata": {},
"success_url": "https://mystore.com/order/success",
"cancel_url": "https://mystore.com/order/failed",
"customer": {
"token": "cus_abc123",
"email": "customer@example.com",
"document": "12345678909"
}
}
headers = {
"x-client-id": "<x-client-id>",
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-id': '<x-client-id>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
amount: 15000,
currency: 'BRL',
merchant_order_id: 'ORD-123',
payment_method: 'card',
gateway_first_try: 'pagarme',
expires_in: 1800,
metadata: {},
success_url: 'https://mystore.com/order/success',
cancel_url: 'https://mystore.com/order/failed',
customer: {token: 'cus_abc123', email: 'customer@example.com', document: '12345678909'}
})
};
fetch('http://localhost:7701/api/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_PORT => "7701",
CURLOPT_URL => "http://localhost:7701/api/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([
'amount' => 15000,
'currency' => 'BRL',
'merchant_order_id' => 'ORD-123',
'payment_method' => 'card',
'gateway_first_try' => 'pagarme',
'expires_in' => 1800,
'metadata' => [
],
'success_url' => 'https://mystore.com/order/success',
'cancel_url' => 'https://mystore.com/order/failed',
'customer' => [
'token' => 'cus_abc123',
'email' => 'customer@example.com',
'document' => '12345678909'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"x-client-id: <x-client-id>"
],
]);
$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 := "http://localhost:7701/api/v1/checkout/sessions"
payload := strings.NewReader("{\n \"amount\": 15000,\n \"currency\": \"BRL\",\n \"merchant_order_id\": \"ORD-123\",\n \"payment_method\": \"card\",\n \"gateway_first_try\": \"pagarme\",\n \"expires_in\": 1800,\n \"metadata\": {},\n \"success_url\": \"https://mystore.com/order/success\",\n \"cancel_url\": \"https://mystore.com/order/failed\",\n \"customer\": {\n \"token\": \"cus_abc123\",\n \"email\": \"customer@example.com\",\n \"document\": \"12345678909\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<x-client-id>")
req.Header.Add("X-API-Key", "<api-key>")
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("http://localhost:7701/api/v1/checkout/sessions")
.header("x-client-id", "<x-client-id>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 15000,\n \"currency\": \"BRL\",\n \"merchant_order_id\": \"ORD-123\",\n \"payment_method\": \"card\",\n \"gateway_first_try\": \"pagarme\",\n \"expires_in\": 1800,\n \"metadata\": {},\n \"success_url\": \"https://mystore.com/order/success\",\n \"cancel_url\": \"https://mystore.com/order/failed\",\n \"customer\": {\n \"token\": \"cus_abc123\",\n \"email\": \"customer@example.com\",\n \"document\": \"12345678909\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:7701/api/v1/checkout/sessions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-client-id"] = '<x-client-id>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 15000,\n \"currency\": \"BRL\",\n \"merchant_order_id\": \"ORD-123\",\n \"payment_method\": \"card\",\n \"gateway_first_try\": \"pagarme\",\n \"expires_in\": 1800,\n \"metadata\": {},\n \"success_url\": \"https://mystore.com/order/success\",\n \"cancel_url\": \"https://mystore.com/order/failed\",\n \"customer\": {\n \"token\": \"cus_abc123\",\n \"email\": \"customer@example.com\",\n \"document\": \"12345678909\"\n }\n}"
response = http.request(request)
puts response.read_body{
"token": "cs_live_a1b2c3d4e5f6...",
"amount": 15000,
"currency": "BRL",
"merchant_order_id": "ORD-123",
"payment_method": "card",
"gateway_first_try": "pagarme",
"metadata": {},
"success_url": "https://mystore.com/order/success",
"cancel_url": "https://mystore.com/order/failed",
"expires_at": "2026-06-23T14:30:00+00:00",
"saved_cards": [
{
"token": "card_abc123",
"holder_name": "John Doe",
"brand": "visa",
"first_6_digits": "411111",
"last_4_digits": "1111",
"expire_month": "12",
"expire_year": "2029",
"status": "active",
"created_at": "2026-06-26T10:00:00+00:00",
"updated_at": "2026-06-26T10:00:00+00:00"
}
]
}Headers
Body
application/json
Response
Checkout session created