> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.littglobal.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.littglobal.com/_mcp/server.

# Get Payment Token

POST TBD/api/v2/payment/token
Content-Type: application/json

This API endpoint is designed to generate a unique payment token. This token can be linked to a particular voucher in the user's account, although this is optional.

### Request Body

- `user_voucher_id` (string, nullable): The ID of the user's voucher, if applicable. If no voucher is to be used, this value should be set to `null`.
    

### Response

- `token` (string): The generated payment token.

Reference: https://docs.littglobal.com/litt-white-label/api-reference/digital-wallet/get-payment-token

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Query parameters

- `api_token` (string, optional)

### Body (application/json)

This endpoint expects an object.

- `api` (string, optional)
- `data` (ApiV2PaymentTokenPostRequestBodyContentApplicationJsonSchemaData, optional)

## Response

### 200

Get Payment Token

- `message` (string, optional)
- `api` (string, optional)
- `status` (string, optional)
- `data` (ApiV2PaymentTokenPostResponsesContentApplicationJsonSchemaData, optional)

## Types

### ApiV2PaymentTokenPostRequestBodyContentApplicationJsonSchemaData

- `user_voucher_id` (any, optional, nullable)

### ApiV2PaymentTokenPostResponsesContentApplicationJsonSchemaData

- `token` (string, optional)

## Examples

**Request**

```json
{
  "api": "payment-token",
  "data": {
    "user_voucher_id": null
  }
}
```

**Response**

```json
{
  "message": "Successfully generated a token",
  "api": "paymentToken",
  "status": "success",
  "data": {
    "token": "YOUR_TOKEN"
  }
}
```

**SDK Code**

```python Digital Wallet_getPaymentToken_example
import requests

url = "https://tbd/api/v2/payment/token"

querystring = {"api_token":"{{token}}"}

payload = {
    "api": "payment-token",
    "data": { "user_voucher_id": None }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Digital Wallet_getPaymentToken_example
const url = 'https://tbd/api/v2/payment/token?api_token=%7B%7Btoken%7D%7D';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"api":"payment-token","data":{"user_voucher_id":null}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Digital Wallet_getPaymentToken_example
package main

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

func main() {

	url := "https://tbd/api/v2/payment/token?api_token=%7B%7Btoken%7D%7D"

	payload := strings.NewReader("{\n  \"api\": \"payment-token\",\n  \"data\": {\n    \"user_voucher_id\": null\n  }\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(res)
	fmt.Println(string(body))

}
```

```ruby Digital Wallet_getPaymentToken_example
require 'uri'
require 'net/http'

url = URI("https://tbd/api/v2/payment/token?api_token=%7B%7Btoken%7D%7D")

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  \"api\": \"payment-token\",\n  \"data\": {\n    \"user_voucher_id\": null\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Digital Wallet_getPaymentToken_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://tbd/api/v2/payment/token?api_token=%7B%7Btoken%7D%7D")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"api\": \"payment-token\",\n  \"data\": {\n    \"user_voucher_id\": null\n  }\n}")
  .asString();
```

```php Digital Wallet_getPaymentToken_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://tbd/api/v2/payment/token?api_token=%7B%7Btoken%7D%7D', [
  'body' => '{
  "api": "payment-token",
  "data": {
    "user_voucher_id": null
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Digital Wallet_getPaymentToken_example
using RestSharp;

var client = new RestClient("https://tbd/api/v2/payment/token?api_token=%7B%7Btoken%7D%7D");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"api\": \"payment-token\",\n  \"data\": {\n    \"user_voucher_id\": null\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Digital Wallet_getPaymentToken_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "api": "payment-token",
  "data": ["user_voucher_id": ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://tbd/api/v2/payment/token?api_token=%7B%7Btoken%7D%7D")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```