Skip to main content
POST
/
v2
/
payments
/
{payment_id}
/
create-external-sdk-tokens
Payments - Session token
curl --request POST \
  --url https://sandbox.hyperswitch.io/v2/payments/{payment_id}/create-external-sdk-tokens \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '{}'
import requests

url = "https://sandbox.hyperswitch.io/v2/payments/{payment_id}/create-external-sdk-tokens"

payload = {}
headers = {
    "Authorization": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({})
};

fetch('https://sandbox.hyperswitch.io/v2/payments/{payment_id}/create-external-sdk-tokens', 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://sandbox.hyperswitch.io/v2/payments/{payment_id}/create-external-sdk-tokens",
  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: <api-key>",
    "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://sandbox.hyperswitch.io/v2/payments/{payment_id}/create-external-sdk-tokens"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "<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("https://sandbox.hyperswitch.io/v2/payments/{payment_id}/create-external-sdk-tokens")
  .header("Authorization", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://sandbox.hyperswitch.io/v2/payments/{payment_id}/create-external-sdk-tokens")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
{
  "payment_id": "<string>",
  "session_token": [
    {
      "delayed_session_token": true,
      "connector": "<string>",
      "sdk_next_action": {
        "next_action": "post_session_tokens",
        "should_block_confirm": true
      },
      "wallet_name": "google_pay"
    }
  ],
  "vault_details": {
    "internal_vault": {
      "sdk_authorization": "<string>"
    },
    "external_vault_details": {
      "vgs": {
        "external_vault_id": "<string>",
        "sdk_env": "<string>"
      }
    }
  }
}
{
  "error_type": "invalid_request",
  "message": "Missing required param: {param}",
  "code": "IR_04"
}

Authorizations

Authorization
string
header
required

Format: publishable-key=<publishable-key>,client-secret=<client-secret>

Publishable keys are a type of keys that can be public and have limited scope of usage. Client Secret provide temporary access to singular data, such as access to a single customer object for a short period of time. This authentication scheme is used by the SDK.

Path Parameters

payment_id
string
required

The identifier for payment

Body

application/json

The body is of type object.

Response

Payment session object created or session token was retrieved from wallets

payment_id
string
required

The identifier for the payment

session_token
object[]
required

The list of session token object

vault_details
object | null

Top-level vault details returned in the session-tokens response. For v1: contains both internal vault (SDK authorization) and external vault details. For v2: contains only external vault details.