Get a token

You need to obtain a token to integrate with the payment UI. An access token is a string that identifies game, user, and purchase parameters.

Xsolla API uses basic access authentication. Specify your merchant ID as the username and the API key as the password.

URL to retrieve the token:

Full screen
Small screen{merchant_id}/token

You can alter the HTTP POST request by including the parameters you want to pass on to the payment UI. Both the request and the response are in JSON format.

Below you can find sample code of how to get a token in PHP with the help of Xsolla PHP SDK. If you are using another programming language, take a look at the CURL example by clicking on the CURL tab.
API reference
See the full list of parameters.
Full screen
Small screen

  • php
  • curl


use Xsolla\SDK\API\XsollaClient;
use Xsolla\SDK\API\PaymentUI\TokenRequest;

$tokenRequest = new TokenRequest($projectId, $userId);
    ->setPurchase(9.99, 'USD');

$xsollaClient = XsollaClient::factory(array(
    'merchant_id' => MERCHANT_ID,
    'api_key' => API_KEY
$token = $xsollaClient->createPaymentUITokenFromRequest($tokenRequest);
curl -v{merchant_id}/token \
-u your_merchant_id:merchant_api_key \
-H 'Content-Type:application/json' \
-H 'Accept: application/json' \
-d '
    "user": {
        "id": {
            "value": "1234567"
        "email": {
            "value": ""
    "settings": {
        "project_id": 14004,
        "mode": "sandbox"
    "purchase": {
            "checkout": {
                "amount": 9.99,
                "currency": "USD"

Continue reading