Skip to main content
POST
/
connectors
/
consumers
/
{consumer_id}
/
offers
/
{offer_id}
/
voucher
Reserves a voucher on a given brand.
curl --request POST \
  --url https://api.sandbox.paylead.tech/connectors/consumers/{consumer_id}/offers/{offer_id}/voucher \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "value": 123
}'
import requests

url = "https://api.sandbox.paylead.tech/connectors/consumers/{consumer_id}/offers/{offer_id}/voucher"

payload = { "value": 123 }
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({value: 123})
};

fetch('https://api.sandbox.paylead.tech/connectors/consumers/{consumer_id}/offers/{offer_id}/voucher', 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://api.sandbox.paylead.tech/connectors/consumers/{consumer_id}/offers/{offer_id}/voucher",
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([
'value' => 123
]),
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;
}
package main

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

func main() {

url := "https://api.sandbox.paylead.tech/connectors/consumers/{consumer_id}/offers/{offer_id}/voucher"

payload := strings.NewReader("{\n \"value\": 123\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(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.sandbox.paylead.tech/connectors/consumers/{consumer_id}/offers/{offer_id}/voucher")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"value\": 123\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.sandbox.paylead.tech/connectors/consumers/{consumer_id}/offers/{offer_id}/voucher")

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 \"value\": 123\n}"

response = http.request(request)
puts response.read_body
{
  "offer_id": "94b36765-a06c-4baf-a33c-40e43686a96a",
  "price": 123,
  "value": 123,
  "brand": {
    "name": "<string>",
    "id": "e2c32b4b-de61-459b-accf-a75f76247946",
    "logo": "<unknown>",
    "reference": "MYBRAND-20180220-001"
  },
  "codes": [
    {
      "value": 123,
      "activation_code": "<string>",
      "code": "<string>",
      "validity_date": "2023-12-25"
    }
  ],
  "id": "e2c32b4b-de61-459b-accf-a75f76247946",
  "reservation_date": "2023-12-25",
  "reservation_expired_date": "2023-12-25",
  "validity_date": "2023-12-25"
}

Authorizations

Authorization
string
header
required

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

Path Parameters

consumer_id
string
required

The id you used to create the given consumer

offer_id
string<uuid>
required

Unique ID of the offer on PayLead system.

Body

application/json

Voucher Reservation Schema

mode
enum<string>
required

Reservation mode used, passing by the voucher value or price

Available options:
VALUE,
PRICE
value
number
required

The value associated to the reservation mode, price of voucher if mode is PRICE, otherwise the value

Response

Created

offer_id
string<uuid>
required
read-only

Unique UUID of the offer

Example:

"94b36765-a06c-4baf-a33c-40e43686a96a"

price
number
required
read-only

Price paid by the consumer

status
enum<string>
required
read-only

Current status of the voucher.

Available options:
RESERVED,
CANCELLED,
CONFIRMED,
READY,
REFUNDING,
REFUNDED,
REFUND_REJECTED
Maximum string length: 15
value
number
required
read-only

nominal value of the voucher

brand
object
codes
object[]
read-only

List of codes to be used.

id
string<uuid>
read-only

Unique ID of the object.

Example:

"e2c32b4b-de61-459b-accf-a75f76247946"

reservation_date
string<date>
read-only

Date when the voucher has been reserved.

reservation_expired_date
string<date>
read-only

Date when the reservation expired. If this date is passed, the voucher is automatically cancelled.

validity_date
string<date>
read-only

voucher validity date, after this date the voucher is not valid anymore and can't be used.