Skip to main content
POST
/
payment-services
/
{payment_service_id}
/
sessions
Create a session for a payment service by ID
using RestSharp;


var options = new RestClientOptions("https://api.sandbox.{id}.gr4vy.app/payment-services/{payment_service_id}/sessions");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.sandbox.{id}.gr4vy.app/payment-services/{payment_service_id}/sessions"

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

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.sandbox.{id}.gr4vy.app/payment-services/{payment_service_id}/sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{}")
.asString();
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sandbox.{id}.gr4vy.app/payment-services/{payment_service_id}/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([

]),
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;
}
import requests

url = "https://api.sandbox.{id}.gr4vy.app/payment-services/{payment_service_id}/sessions"

payload = {}
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({})
};

fetch('https://api.sandbox.{id}.gr4vy.app/payment-services/{payment_service_id}/sessions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
curl --request POST \
--url https://api.sandbox.{id}.gr4vy.app/payment-services/{payment_service_id}/sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'
{
  "type": "payment-service-session",
  "status": "succeeded",
  "code": "UNKNOWN_ERROR",
  "status_code": 200,
  "response_body": {
    "data": {
      "customerType": "EXISTING",
      "walletManagementUrl": "https://example.com/session"
    },
    "meta": {}
  }
}
{
"type": "error",
"code": "bad_request",
"status": 400,
"message": "Missing '****' field",
"details": [
{
"location": "body",
"type": "value_error.missing",
"pointer": "/payment_method/number",
"message": "field required"
}
]
}
{
"type": "error",
"code": "unauthorized",
"status": 401,
"message": "No valid API authentication found",
"details": []
}
{
"type": "error",
"code": "not_found",
"status": 404,
"message": "The resource could not be found",
"details": []
}
This endpoint requires the transactions.write scope.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

payment_service_id
string
required

The ID of the payment service.

Example:

"46973e9d-88a7-44a6-abfe-be4ff0134ff4"

Body

application/json

A request to generate a session for a payment session.

Response

Returns the response from the downstream service used to generate the session.

A session request for a payment session. This is an opaque object passed to the payment service.

type
enum<string>

The type of this resource.

Available options:
payment-service-session
Example:

"payment-service-session"

status
enum<string>

The status of the response.

  • succeeded - The session was successfully generated.
  • failed - The session could not be generated.
Available options:
succeeded,
failed
Example:

"succeeded"

code
string | null

A generic error code that may be returned when the session could not be generated.

Example:

"UNKNOWN_ERROR"

status_code
number | null

The HTTP status code received from the payment service.

Example:

200

response_body
object | null

The parsed JSON received from the payment service.

Example:
{
"data": {
"customerType": "EXISTING",
"walletManagementUrl": "https://example.com/session"
},
"meta": {}
}