> 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.

# Create User Voucher

POST TBD/api/v2/gifts/purchase-voucher

This API endpoint allows you to create user-specific promotions such as discounts, special offers, or rewards. The endpoint takes in the details about the user and the type of promotion to be granted and returns the unique identifier of the newly created promotion.

### Request Body

- `user_id` (string): The unique identifier of the user to whom the promotion is granted.
    
- `promotion_id` (string): The unique identifier of the promotion being granted.
    
- `timestamp` (string): The timestamp indicating when the promotion was created.
    
- `timestampx` (string): The expiration time of the promotion.
    

### Response

- `user_promotion_id` (string): The unique identifier of the newly created promotion.
    
- `user_id` (string): Repetition of the user identifier to whom the promotion was granted.
    
- `promotion_id` (string): Repetition of the promotion identifier that was granted.
    
- `barcode_id` (string): If applicable, the identifier of the barcode associated with the promotion. Null if no barcode is associated.
    
- `expiry_date` (string): The date and time at which the promotion will expire.
    
- `updated_at` (string): The date and time when the promotion record was last updated.
    
- `created_at` (string): The date and time when the promotion record was first created.

Reference: https://docs.littglobal.com/litt-white-label/api-reference/gift-card-promotion/create-user-voucher

## Request

### Query parameters

- `api_token` (string, optional)

## Response

### 200

By Wallet

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

## Types

### ApiV2GiftsPurchaseVoucherPostResponsesContentApplicationJsonSchemaData

- `user_voucher_id` (string, optional)
- `user_buyer_id` (string, optional)
- `user_receiver_id` (string, optional)
- `message` (string, optional)
- `voucher_id` (string, optional)
- `delivery_date` (string, optional)
- `expiry_date` (string, optional)
- `original_balance` (string, optional)
- `available_balance` (integer, optional)
- `bonus_amount` (integer, optional)
- `bonus_percent` (integer, optional)
- `barcode_id` (string, optional)
- `updated_at` (string, optional)
- `created_at` (string, optional)
- `full_address` (string, optional)
- `address_1` (string, optional)
- `postcode` (string, optional)
- `city` (string, optional)

## Examples

**Response**

```json
{
  "message": "Successfully purchased your voucher.",
  "api": "purchaseVoucher",
  "status": "success",
  "data": {
    "user_voucher_id": "ca6fb965-ccb6-464b-849d-1ffd7662756e",
    "user_buyer_id": "2ef350a0-f8cd-4730-8e29-9b5fc5db0ada",
    "user_receiver_id": "2ef350a0-f8cd-4730-8e29-9b5fc5db0ada",
    "message": "",
    "voucher_id": "14773aaa-16e4-44bd-919c-1e31d7a21ca1",
    "delivery_date": "2024-04-29 08:30:01",
    "expiry_date": "2027-04-29 08:30:01",
    "original_balance": "10000.00",
    "available_balance": 10000,
    "bonus_amount": 0,
    "bonus_percent": 0,
    "barcode_id": "a371afd4-45fc-11ed-a968-068dfc70fdd8",
    "updated_at": "2024-04-29 08:30:01",
    "created_at": "2024-04-29 08:30:01",
    "full_address": "",
    "address_1": "",
    "postcode": "",
    "city": ""
  }
}
```

**SDK Code**

```python Gift Card & Promotion_createUserVoucher_example
import requests

url = "https://tbd/api/v2/gifts/purchase-voucher"

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

response = requests.post(url, params=querystring)

print(response.json())
```

```javascript Gift Card & Promotion_createUserVoucher_example
const url = 'https://tbd/api/v2/gifts/purchase-voucher?api_token=%7B%7Btoken%7D%7D';
const options = {method: 'POST'};

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

```go Gift Card & Promotion_createUserVoucher_example
package main

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

func main() {

	url := "https://tbd/api/v2/gifts/purchase-voucher?api_token=%7B%7Btoken%7D%7D"

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

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Gift Card & Promotion_createUserVoucher_example
require 'uri'
require 'net/http'

url = URI("https://tbd/api/v2/gifts/purchase-voucher?api_token=%7B%7Btoken%7D%7D")

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

request = Net::HTTP::Post.new(url)

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

```java Gift Card & Promotion_createUserVoucher_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://tbd/api/v2/gifts/purchase-voucher?api_token=%7B%7Btoken%7D%7D")
  .asString();
```

```php Gift Card & Promotion_createUserVoucher_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://tbd/api/v2/gifts/purchase-voucher?api_token=%7B%7Btoken%7D%7D');

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

```csharp Gift Card & Promotion_createUserVoucher_example
using RestSharp;

var client = new RestClient("https://tbd/api/v2/gifts/purchase-voucher?api_token=%7B%7Btoken%7D%7D");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
```

```swift Gift Card & Promotion_createUserVoucher_example
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://tbd/api/v2/gifts/purchase-voucher?api_token=%7B%7Btoken%7D%7D")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"

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()
```