Get Available Coupons
Introduction
This endpoint retrieves a list of available coupons for a specific event and ticket.
Endpoint
https://api.paydexp.com/v1/coupons
Authorization
Users need to include basic authentication credentials in the request headers.
Below are code examples in different programming languages demonstrating how to get available coupons for a ticket sales.
- curl
- Go
- Nodejs
- Python
- PHP
curl --location --request POST 'https://api.paydexp.com/v1/coupons' \
--header 'Authorization: Basic {base64_encoded_username_password}' \
--header 'Content-Type: application/json' \
--data '{
"event_id": 123,
"ticket_id": 1759,
"slots": 2
}'
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.paydexp.com/v1/coupons"
payload := map[string]interface{}{
"event_id": 123,
"ticket_id": 1759,
"slots": 2,
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Add("Authorization", "Basic {base64_encoded_username_password}")
req.Header.Add("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}
const axios = require('axios');
const url = 'https://api.paydexp.com/v1/coupons';
const payload = {
event_id: 123,
ticket_id: 1759,
slots: 2
};
axios.post(url, payload, {
headers: {
'Authorization': 'Basic {base64_encoded_username_password}',
'Content-Type': 'application/json'
}
})
.then(response => console.log(response.data))
.catch(error => console.error(error.response?.data || error.message));
import requests
url = "https://api.paydexp.com/v1/coupons"
payload = {
"event_id": 123,
"ticket_id": 1759,
"slots": 2
}
headers = {
"Authorization": "Basic {base64_encoded_username_password}",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$url = "https://api.paydexp.com/v1/coupons";
$data = [
"event_id" => 123,
"ticket_id" => 1759,
"slots" => 2
];
$options = [
'http' => [
'header' => "Authorization: Basic {base64_encoded_username_password}\r\n" .
"Content-Type: application/json\r\n",
'method' => 'POST',
'content' => json_encode($data),
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
Example success Response
{
"success": true,
"data": [
{
"id": 1,
"code": "DISCOUNT20",
"discount_type": "percentage",
"discount_value": 20,
"valid_for_ticket": true,
"is_available": true,
"available_until": "2025-12-14",
"original_amount": 300,
"discounted_amount": 240,
"sale_period": "Nov 1, 2025 - Dec 14, 2025",
"applicable_tickets": "VIP Ticket, General Admission"
},
{
"id": 2,
"code": "VIPSPECIAL",
"discount_type": "fixed",
"discount_value": 50,
"valid_for_ticket": true,
"is_available": true,
"available_until": "2025-11-30",
"original_amount": 300,
"discounted_amount": 200,
"sale_period": "Nov 1, 2025 - Nov 30, 2025",
"applicable_tickets": "VIP Ticket"
}
],
"message": "Coupons retrieved successfully."
}
Conclusion
Easily get all available coupons for a specific event using this endpoint.```