curl --request POST \
--url https://api-dashboard.payra.com/v1/checkout-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 12550,
"currency": "USD",
"success_url": "https://shop.example/thanks?order=1042",
"cancel_url": "https://shop.example/cart",
"reference": "1042",
"description": "Northwind order #1042",
"customer_email": "[email protected]",
"customer": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_method_types": [
"card",
"us_bank_account"
],
"metadata": {
"order_id": "1042",
"cart": "a1b2c3"
},
"expires_at": "2026-09-26T12:00:00.000Z"
}
'import requests
url = "https://api-dashboard.payra.com/v1/checkout-sessions"
payload = {
"amount": 12550,
"currency": "USD",
"success_url": "https://shop.example/thanks?order=1042",
"cancel_url": "https://shop.example/cart",
"reference": "1042",
"description": "Northwind order #1042",
"customer_email": "[email protected]",
"customer": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_method_types": ["card", "us_bank_account"],
"metadata": {
"order_id": "1042",
"cart": "a1b2c3"
},
"expires_at": "2026-09-26T12:00:00.000Z"
}
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({
amount: 12550,
currency: 'USD',
success_url: 'https://shop.example/thanks?order=1042',
cancel_url: 'https://shop.example/cart',
reference: '1042',
description: 'Northwind order #1042',
customer_email: '[email protected]',
customer: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
payment_method_types: ['card', 'us_bank_account'],
metadata: {order_id: '1042', cart: 'a1b2c3'},
expires_at: '2026-09-26T12:00:00.000Z'
})
};
fetch('https://api-dashboard.payra.com/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-dashboard.payra.com/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' => 12550,
'currency' => 'USD',
'success_url' => 'https://shop.example/thanks?order=1042',
'cancel_url' => 'https://shop.example/cart',
'reference' => '1042',
'description' => 'Northwind order #1042',
'customer_email' => '[email protected]',
'customer' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'payment_method_types' => [
'card',
'us_bank_account'
],
'metadata' => [
'order_id' => '1042',
'cart' => 'a1b2c3'
],
'expires_at' => '2026-09-26T12:00:00.000Z'
]),
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-dashboard.payra.com/v1/checkout-sessions"
payload := strings.NewReader("{\n \"amount\": 12550,\n \"currency\": \"USD\",\n \"success_url\": \"https://shop.example/thanks?order=1042\",\n \"cancel_url\": \"https://shop.example/cart\",\n \"reference\": \"1042\",\n \"description\": \"Northwind order #1042\",\n \"customer_email\": \"[email protected]\",\n \"customer\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_method_types\": [\n \"card\",\n \"us_bank_account\"\n ],\n \"metadata\": {\n \"order_id\": \"1042\",\n \"cart\": \"a1b2c3\"\n },\n \"expires_at\": \"2026-09-26T12:00:00.000Z\"\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-dashboard.payra.com/v1/checkout-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 12550,\n \"currency\": \"USD\",\n \"success_url\": \"https://shop.example/thanks?order=1042\",\n \"cancel_url\": \"https://shop.example/cart\",\n \"reference\": \"1042\",\n \"description\": \"Northwind order #1042\",\n \"customer_email\": \"[email protected]\",\n \"customer\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_method_types\": [\n \"card\",\n \"us_bank_account\"\n ],\n \"metadata\": {\n \"order_id\": \"1042\",\n \"cart\": \"a1b2c3\"\n },\n \"expires_at\": \"2026-09-26T12:00:00.000Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dashboard.payra.com/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 \"amount\": 12550,\n \"currency\": \"USD\",\n \"success_url\": \"https://shop.example/thanks?order=1042\",\n \"cancel_url\": \"https://shop.example/cart\",\n \"reference\": \"1042\",\n \"description\": \"Northwind order #1042\",\n \"customer_email\": \"[email protected]\",\n \"customer\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_method_types\": [\n \"card\",\n \"us_bank_account\"\n ],\n \"metadata\": {\n \"order_id\": \"1042\",\n \"cart\": \"a1b2c3\"\n },\n \"expires_at\": \"2026-09-26T12:00:00.000Z\"\n}"
response = http.request(request)
puts response.read_body{
"object": "checkout_session",
"id": "cs_test_7Hs2kQ9mL1pXv4cR8tWzAbCd",
"status": "open",
"amount": 12550,
"currency": "USD",
"reference": "1042",
"description": "Northwind order #1042",
"success_url": "https://shop.example/thanks?order=1042",
"cancel_url": "https://shop.example/cart",
"customer_email": "[email protected]",
"customer": null,
"payment_method_types": [
"card"
],
"metadata": {
"order_id": "1042",
"cart": "a1b2c3"
},
"payment": "pay_test_7Hs2kQ9mL1pXv4cR8tWzAbCdEf",
"livemode": false,
"expires_at": "2026-09-26T12:00:00.000Z",
"completed_at": null,
"created_at": "2026-09-25T12:00:00.000Z",
"url": "https://dashboard.payra.com/checkout/cs_test_7Hs2kQ9mL1pXv4cR8tWzAbCd?key=…"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}Create a checkout session
Creates a hosted payment page for one order and answers its url. Send the customer there: the page collects a card or a US bank account with Payra Elements, charges it in your name (the payment shows in RevOS like any other), and sends the customer back to success_url. The page pays once and expires after 24 hours unless expires_at says otherwise. Requires an Idempotency-Key. If your workspace has no active publishable key in this environment, one named “Hosted checkout” is created for the page.
curl --request POST \
--url https://api-dashboard.payra.com/v1/checkout-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"amount": 12550,
"currency": "USD",
"success_url": "https://shop.example/thanks?order=1042",
"cancel_url": "https://shop.example/cart",
"reference": "1042",
"description": "Northwind order #1042",
"customer_email": "[email protected]",
"customer": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_method_types": [
"card",
"us_bank_account"
],
"metadata": {
"order_id": "1042",
"cart": "a1b2c3"
},
"expires_at": "2026-09-26T12:00:00.000Z"
}
'import requests
url = "https://api-dashboard.payra.com/v1/checkout-sessions"
payload = {
"amount": 12550,
"currency": "USD",
"success_url": "https://shop.example/thanks?order=1042",
"cancel_url": "https://shop.example/cart",
"reference": "1042",
"description": "Northwind order #1042",
"customer_email": "[email protected]",
"customer": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payment_method_types": ["card", "us_bank_account"],
"metadata": {
"order_id": "1042",
"cart": "a1b2c3"
},
"expires_at": "2026-09-26T12:00:00.000Z"
}
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({
amount: 12550,
currency: 'USD',
success_url: 'https://shop.example/thanks?order=1042',
cancel_url: 'https://shop.example/cart',
reference: '1042',
description: 'Northwind order #1042',
customer_email: '[email protected]',
customer: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
payment_method_types: ['card', 'us_bank_account'],
metadata: {order_id: '1042', cart: 'a1b2c3'},
expires_at: '2026-09-26T12:00:00.000Z'
})
};
fetch('https://api-dashboard.payra.com/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-dashboard.payra.com/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' => 12550,
'currency' => 'USD',
'success_url' => 'https://shop.example/thanks?order=1042',
'cancel_url' => 'https://shop.example/cart',
'reference' => '1042',
'description' => 'Northwind order #1042',
'customer_email' => '[email protected]',
'customer' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'payment_method_types' => [
'card',
'us_bank_account'
],
'metadata' => [
'order_id' => '1042',
'cart' => 'a1b2c3'
],
'expires_at' => '2026-09-26T12:00:00.000Z'
]),
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-dashboard.payra.com/v1/checkout-sessions"
payload := strings.NewReader("{\n \"amount\": 12550,\n \"currency\": \"USD\",\n \"success_url\": \"https://shop.example/thanks?order=1042\",\n \"cancel_url\": \"https://shop.example/cart\",\n \"reference\": \"1042\",\n \"description\": \"Northwind order #1042\",\n \"customer_email\": \"[email protected]\",\n \"customer\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_method_types\": [\n \"card\",\n \"us_bank_account\"\n ],\n \"metadata\": {\n \"order_id\": \"1042\",\n \"cart\": \"a1b2c3\"\n },\n \"expires_at\": \"2026-09-26T12:00:00.000Z\"\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-dashboard.payra.com/v1/checkout-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 12550,\n \"currency\": \"USD\",\n \"success_url\": \"https://shop.example/thanks?order=1042\",\n \"cancel_url\": \"https://shop.example/cart\",\n \"reference\": \"1042\",\n \"description\": \"Northwind order #1042\",\n \"customer_email\": \"[email protected]\",\n \"customer\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_method_types\": [\n \"card\",\n \"us_bank_account\"\n ],\n \"metadata\": {\n \"order_id\": \"1042\",\n \"cart\": \"a1b2c3\"\n },\n \"expires_at\": \"2026-09-26T12:00:00.000Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-dashboard.payra.com/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 \"amount\": 12550,\n \"currency\": \"USD\",\n \"success_url\": \"https://shop.example/thanks?order=1042\",\n \"cancel_url\": \"https://shop.example/cart\",\n \"reference\": \"1042\",\n \"description\": \"Northwind order #1042\",\n \"customer_email\": \"[email protected]\",\n \"customer\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"payment_method_types\": [\n \"card\",\n \"us_bank_account\"\n ],\n \"metadata\": {\n \"order_id\": \"1042\",\n \"cart\": \"a1b2c3\"\n },\n \"expires_at\": \"2026-09-26T12:00:00.000Z\"\n}"
response = http.request(request)
puts response.read_body{
"object": "checkout_session",
"id": "cs_test_7Hs2kQ9mL1pXv4cR8tWzAbCd",
"status": "open",
"amount": 12550,
"currency": "USD",
"reference": "1042",
"description": "Northwind order #1042",
"success_url": "https://shop.example/thanks?order=1042",
"cancel_url": "https://shop.example/cart",
"customer_email": "[email protected]",
"customer": null,
"payment_method_types": [
"card"
],
"metadata": {
"order_id": "1042",
"cart": "a1b2c3"
},
"payment": "pay_test_7Hs2kQ9mL1pXv4cR8tWzAbCdEf",
"livemode": false,
"expires_at": "2026-09-26T12:00:00.000Z",
"completed_at": null,
"created_at": "2026-09-25T12:00:00.000Z",
"url": "https://dashboard.payra.com/checkout/cs_test_7Hs2kQ9mL1pXv4cR8tWzAbCd?key=…"
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}{
"error": {
"type": "invalid_request_error",
"code": "<string>",
"message": "<string>",
"request_id": "<string>",
"param": "<string>"
}
}Authorizations
A secret key, sk_test_... or sk_live_...; a publishable key (pk_...) on the browser routes only
Body
In the smallest unit (cents).
12550
USD, CAD "USD"
Where the customer goes after paying; ?checkout_session=cs_… is appended. Must be https; a sandbox key may also use http://localhost while you test.
2048"https://shop.example/thanks?order=1042"
Where "Back to store" goes, and where an expired page sends the customer. Must be https; a sandbox key may also use http://localhost while you test.
2048"https://shop.example/cart"
Your order or invoice number; stored on the payment and shown in the dashboard.
1 - 100"1042"
Shown to the customer on the page, and stored on the payment.
1 - 500"Northwind order #1042"
Kept on the session and returned with it, for your records. The page does not show it.
254One of your customers: the payment is filed on them, and a card can be saved to them.
What the page offers. Omitted means a card only; us_bank_account needs USD.
1card, us_bank_account ["card", "us_bank_account"]
Up to 20 keys of your own (keys up to 40 characters, values up to 500); stored and returned, never interpreted.
Show child attributes
Show child attributes
{ "order_id": "1042", "cart": "a1b2c3" }
When the page stops accepting a payment. Default 24 hours from now; at most 7 days.
"2026-09-26T12:00:00.000Z"
Response
The session, with the URL to send the customer to
checkout_session "cs_test_7Hs2kQ9mL1pXv4cR8tWzAbCd"
open while the customer can pay; complete once one payment succeeded (or, for a bank debit, was accepted) on the page; expired after expires_at, or once you expired it. A session pays once.
open, complete, expired "open"
In the smallest unit of the currency (cents).
12550
USD, CAD "USD"
"1042"
"Northwind order #1042"
"https://shop.example/thanks?order=1042"
"https://shop.example/cart"
null
card, us_bank_account ["card"]
Up to 20 keys of your own (keys up to 40 characters, values up to 500); stored and returned, never interpreted.
Show child attributes
Show child attributes
{ "order_id": "1042", "cart": "a1b2c3" }
The payment made on the page, once the session is complete; read it at GET /payments/{id}.
"pay_test_7Hs2kQ9mL1pXv4cR8tWzAbCdEf"
false
"2026-09-26T12:00:00.000Z"
null
"2026-09-25T12:00:00.000Z"
Where to send the customer. Returned only here: it carries the key that opens the page.
"https://dashboard.payra.com/checkout/cs_test_7Hs2kQ9mL1pXv4cR8tWzAbCd?key=…"