Create a client session
Creates a new client session for secure client-side payment processing. The session contains a temporary token that can be used by your frontend to interact with PayNext without exposing your API key.
curl --request POST \
--url https://sandbox-api.paynext.com/client-session \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-API-Version: <x-api-version>' \
--data '{}'const options = {
method: 'POST',
headers: {
'X-API-Version': '<x-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({})
};
fetch('https://sandbox-api.paynext.com/client-session', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.paynext.com/client-session"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Version", "<x-api-version>")
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://sandbox-api.paynext.com/client-session")
.header("X-API-Version", "<x-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();import requests
url = "https://sandbox-api.paynext.com/client-session"
payload = {}
headers = {
"X-API-Version": "<x-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.paynext.com/client-session",
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([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-API-Version: <x-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "d3b07384-d9a5-4d16-a5b1-3fa3d9b0b123",
"currency_details": {
"plan": {
"due_now": {
"local": {
"amount": 90,
"currency": "AED",
"currency_decimals": 2,
"currency_exchange_rate": 0.9,
"currency_position": "left",
"currency_symbol": "€",
"formatted_amount": "€0.90",
"formatted_amount_rounded": "€0.99"
},
"payment": {
"amount": 100,
"currency": "AED",
"currency_decimals": 2,
"currency_position": "left",
"currency_symbol": "$",
"formatted_amount": "$1.00"
}
},
"local": {
"amount": 90,
"currency": "AED",
"currency_decimals": 2,
"currency_exchange_rate": 0.9,
"currency_position": "left",
"currency_symbol": "€",
"formatted_amount": "€0.90",
"formatted_amount_rounded": "€0.99"
},
"payment": {
"amount": 100,
"currency": "AED",
"currency_decimals": 2,
"currency_position": "left",
"currency_symbol": "$",
"formatted_amount": "$1.00"
},
"trial": {
"local": {
"amount": 90,
"currency": "AED",
"currency_decimals": 2,
"currency_exchange_rate": 0.9,
"currency_position": "left",
"currency_symbol": "€",
"formatted_amount": "€0.90",
"formatted_amount_rounded": "€0.99"
},
"payment": {
"amount": 100,
"currency": "AED",
"currency_decimals": 2,
"currency_position": "left",
"currency_symbol": "$",
"formatted_amount": "$1.00"
}
}
}
},
"customer": {
"address": {
"country": "AD"
},
"email": "jane.doe@example.com",
"external_id": "cust_123456789",
"id": "cus_11dfa45f-23b1-40f4-9e9b-c9d485915528",
"metadata": {
"key": "value"
}
},
"expiry_date": "2021-08-12T16:14:08.578695",
"payment": {
"metadata": {
"key": "value"
}
},
"plan": {
"id": "price_1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"amount": 1999,
"currency": "AED",
"interval": "days",
"interval_count": 1,
"name": "Pro Plan",
"trial": {
"amount": 1999,
"currency": "AED",
"interval": "days",
"interval_count": 1
},
"type": "recurring",
"created_at": "2025-05-26T10:00:00Z",
"updated_at": "2025-05-27T10:00:00Z"
},
"subscription": {
"id": "sub_11dfa45f-23b1-40f4-9e9b-c9d485915528",
"metadata": {
"key": "value"
},
"proration_billing_mode": "prorated_immediately"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Missing required parameter: email",
"code": "parameter_missing",
"param": "email"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Missing required parameter: email",
"code": "parameter_missing",
"param": "email"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Missing required parameter: email",
"code": "parameter_missing",
"param": "email"
}
}Authorizations
Authentication header of the form api key, where api key is your organization api key.
Headers
Specifies the version of the API to use
2.0.0 Body
Create session data
Response
Returns the client session object with a temporary token for client-side use.
ClientSession is a unique session identifier generated for the client
"d3b07384-d9a5-4d16-a5b1-3fa3d9b0b123"
Currency-specific pricing and display information
Show child attributes
Show child attributes
Customer information associated with the client session
Show child attributes
Show child attributes
Expiration date and time of the client session
"2021-08-12T16:14:08.578695"
Payment information associated with the client session
Show child attributes
Show child attributes
Plan information associated with the client session
Show child attributes
Show child attributes
Subscription information associated with the client session
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://sandbox-api.paynext.com/client-session \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-API-Version: <x-api-version>' \
--data '{}'const options = {
method: 'POST',
headers: {
'X-API-Version': '<x-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({})
};
fetch('https://sandbox-api.paynext.com/client-session', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.paynext.com/client-session"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Version", "<x-api-version>")
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://sandbox-api.paynext.com/client-session")
.header("X-API-Version", "<x-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();import requests
url = "https://sandbox-api.paynext.com/client-session"
payload = {}
headers = {
"X-API-Version": "<x-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.paynext.com/client-session",
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([
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-API-Version: <x-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"id": "d3b07384-d9a5-4d16-a5b1-3fa3d9b0b123",
"currency_details": {
"plan": {
"due_now": {
"local": {
"amount": 90,
"currency": "AED",
"currency_decimals": 2,
"currency_exchange_rate": 0.9,
"currency_position": "left",
"currency_symbol": "€",
"formatted_amount": "€0.90",
"formatted_amount_rounded": "€0.99"
},
"payment": {
"amount": 100,
"currency": "AED",
"currency_decimals": 2,
"currency_position": "left",
"currency_symbol": "$",
"formatted_amount": "$1.00"
}
},
"local": {
"amount": 90,
"currency": "AED",
"currency_decimals": 2,
"currency_exchange_rate": 0.9,
"currency_position": "left",
"currency_symbol": "€",
"formatted_amount": "€0.90",
"formatted_amount_rounded": "€0.99"
},
"payment": {
"amount": 100,
"currency": "AED",
"currency_decimals": 2,
"currency_position": "left",
"currency_symbol": "$",
"formatted_amount": "$1.00"
},
"trial": {
"local": {
"amount": 90,
"currency": "AED",
"currency_decimals": 2,
"currency_exchange_rate": 0.9,
"currency_position": "left",
"currency_symbol": "€",
"formatted_amount": "€0.90",
"formatted_amount_rounded": "€0.99"
},
"payment": {
"amount": 100,
"currency": "AED",
"currency_decimals": 2,
"currency_position": "left",
"currency_symbol": "$",
"formatted_amount": "$1.00"
}
}
}
},
"customer": {
"address": {
"country": "AD"
},
"email": "jane.doe@example.com",
"external_id": "cust_123456789",
"id": "cus_11dfa45f-23b1-40f4-9e9b-c9d485915528",
"metadata": {
"key": "value"
}
},
"expiry_date": "2021-08-12T16:14:08.578695",
"payment": {
"metadata": {
"key": "value"
}
},
"plan": {
"id": "price_1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"amount": 1999,
"currency": "AED",
"interval": "days",
"interval_count": 1,
"name": "Pro Plan",
"trial": {
"amount": 1999,
"currency": "AED",
"interval": "days",
"interval_count": 1
},
"type": "recurring",
"created_at": "2025-05-26T10:00:00Z",
"updated_at": "2025-05-27T10:00:00Z"
},
"subscription": {
"id": "sub_11dfa45f-23b1-40f4-9e9b-c9d485915528",
"metadata": {
"key": "value"
},
"proration_billing_mode": "prorated_immediately"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Missing required parameter: email",
"code": "parameter_missing",
"param": "email"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Missing required parameter: email",
"code": "parameter_missing",
"param": "email"
}
}{
"error": {
"type": "invalid_request_error",
"message": "Missing required parameter: email",
"code": "parameter_missing",
"param": "email"
}
}