List coupons
curl --request GET \
--url https://api.yuvexpay.com/v1/coupons \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.yuvexpay.com/v1/coupons"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.yuvexpay.com/v1/coupons', 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.yuvexpay.com/v1/coupons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.yuvexpay.com/v1/coupons"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.yuvexpay.com/v1/coupons")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yuvexpay.com/v1/coupons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"coupons": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "BLACK10",
"type": "PERCENT",
"percentBp": 5000,
"amount": 123,
"validFrom": "2023-11-07T05:31:56Z",
"validUntil": "2023-11-07T05:31:56Z",
"maxRedemptions": 2,
"maxRedemptionsPerBuyer": 2,
"productIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"active": true,
"redemptionCount": 1,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
],
"pagination": {
"page": 123,
"limit": 123,
"total": 123,
"totalPages": 123
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": {
"amount": "Must be greater than 0.01"
}
}
}{
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid or revoked API key"
}
}{
"error": {
"code": "INSUFFICIENT_SCOPE",
"message": "Required scope missing: balance:read"
}
}Coupons
List coupons
List the coupons of your account that are not deleted, newest first. Requires the coupons:read scope. Coupons belong to the environment of the key: a ypk_test_ key manages sandbox coupons and a ypk_live_ key production coupons, and a payment uses only coupons of its own environment.
GET
/
v1
/
coupons
List coupons
curl --request GET \
--url https://api.yuvexpay.com/v1/coupons \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.yuvexpay.com/v1/coupons"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.yuvexpay.com/v1/coupons', 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.yuvexpay.com/v1/coupons",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.yuvexpay.com/v1/coupons"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.yuvexpay.com/v1/coupons")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yuvexpay.com/v1/coupons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"coupons": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"code": "BLACK10",
"type": "PERCENT",
"percentBp": 5000,
"amount": 123,
"validFrom": "2023-11-07T05:31:56Z",
"validUntil": "2023-11-07T05:31:56Z",
"maxRedemptions": 2,
"maxRedemptionsPerBuyer": 2,
"productIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"active": true,
"redemptionCount": 1,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
}
],
"pagination": {
"page": 123,
"limit": 123,
"total": 123,
"totalPages": 123
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": {
"amount": "Must be greater than 0.01"
}
}
}{
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid or revoked API key"
}
}{
"error": {
"code": "INSUFFICIENT_SCOPE",
"message": "Required scope missing: balance:read"
}
}Authorizations
YuvexPay API key. Include as Authorization: Bearer ypk_<env>_<kid>_<secret> where <env> is test (sandbox) or live (production). Create and manage keys in the dashboard under Settings > API Keys.
Query Parameters
Return the coupons whose code contains this text, case-insensitive.
Maximum string length:
32Filter by active. Only true or false; any other value returns 400.
Available options:
true, false Page number for pagination.
Required range:
x >= 1Number of items per page (1-100).
Required range:
1 <= x <= 100
