Create Discount
curl --request POST \
--url https://production-api.puppetvendors.com/discounts \
--header 'Content-Type: application/json' \
--header 'x-access-token: <api-key>' \
--data '
{
"code": "<string>",
"title": "<string>",
"startsAt": "<string>",
"endsAt": "<string>",
"customerGets": {},
"usageLimit": 123,
"appliesOncePerCustomer": true,
"items": {}
}
'import requests
url = "https://production-api.puppetvendors.com/discounts"
payload = {
"code": "<string>",
"title": "<string>",
"startsAt": "<string>",
"endsAt": "<string>",
"customerGets": {},
"usageLimit": 123,
"appliesOncePerCustomer": True,
"items": {}
}
headers = {
"x-access-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
title: '<string>',
startsAt: '<string>',
endsAt: '<string>',
customerGets: {},
usageLimit: 123,
appliesOncePerCustomer: true,
items: {}
})
};
fetch('https://production-api.puppetvendors.com/discounts', 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://production-api.puppetvendors.com/discounts",
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([
'code' => '<string>',
'title' => '<string>',
'startsAt' => '<string>',
'endsAt' => '<string>',
'customerGets' => [
],
'usageLimit' => 123,
'appliesOncePerCustomer' => true,
'items' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-access-token: <api-key>"
],
]);
$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://production-api.puppetvendors.com/discounts"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"title\": \"<string>\",\n \"startsAt\": \"<string>\",\n \"endsAt\": \"<string>\",\n \"customerGets\": {},\n \"usageLimit\": 123,\n \"appliesOncePerCustomer\": true,\n \"items\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-access-token", "<api-key>")
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://production-api.puppetvendors.com/discounts")
.header("x-access-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"title\": \"<string>\",\n \"startsAt\": \"<string>\",\n \"endsAt\": \"<string>\",\n \"customerGets\": {},\n \"usageLimit\": 123,\n \"appliesOncePerCustomer\": true,\n \"items\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://production-api.puppetvendors.com/discounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-access-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"title\": \"<string>\",\n \"startsAt\": \"<string>\",\n \"endsAt\": \"<string>\",\n \"customerGets\": {},\n \"usageLimit\": 123,\n \"appliesOncePerCustomer\": true,\n \"items\": {}\n}"
response = http.request(request)
puts response.read_bodyDiscounts
Create Discount
Create a new discount code as a vendor
POST
/
discounts
Create Discount
curl --request POST \
--url https://production-api.puppetvendors.com/discounts \
--header 'Content-Type: application/json' \
--header 'x-access-token: <api-key>' \
--data '
{
"code": "<string>",
"title": "<string>",
"startsAt": "<string>",
"endsAt": "<string>",
"customerGets": {},
"usageLimit": 123,
"appliesOncePerCustomer": true,
"items": {}
}
'import requests
url = "https://production-api.puppetvendors.com/discounts"
payload = {
"code": "<string>",
"title": "<string>",
"startsAt": "<string>",
"endsAt": "<string>",
"customerGets": {},
"usageLimit": 123,
"appliesOncePerCustomer": True,
"items": {}
}
headers = {
"x-access-token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
code: '<string>',
title: '<string>',
startsAt: '<string>',
endsAt: '<string>',
customerGets: {},
usageLimit: 123,
appliesOncePerCustomer: true,
items: {}
})
};
fetch('https://production-api.puppetvendors.com/discounts', 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://production-api.puppetvendors.com/discounts",
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([
'code' => '<string>',
'title' => '<string>',
'startsAt' => '<string>',
'endsAt' => '<string>',
'customerGets' => [
],
'usageLimit' => 123,
'appliesOncePerCustomer' => true,
'items' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-access-token: <api-key>"
],
]);
$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://production-api.puppetvendors.com/discounts"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"title\": \"<string>\",\n \"startsAt\": \"<string>\",\n \"endsAt\": \"<string>\",\n \"customerGets\": {},\n \"usageLimit\": 123,\n \"appliesOncePerCustomer\": true,\n \"items\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-access-token", "<api-key>")
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://production-api.puppetvendors.com/discounts")
.header("x-access-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"title\": \"<string>\",\n \"startsAt\": \"<string>\",\n \"endsAt\": \"<string>\",\n \"customerGets\": {},\n \"usageLimit\": 123,\n \"appliesOncePerCustomer\": true,\n \"items\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://production-api.puppetvendors.com/discounts")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-access-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"title\": \"<string>\",\n \"startsAt\": \"<string>\",\n \"endsAt\": \"<string>\",\n \"customerGets\": {},\n \"usageLimit\": 123,\n \"appliesOncePerCustomer\": true,\n \"items\": {}\n}"
response = http.request(request)
puts response.read_bodyV2 Alpha — This endpoint is part of the V2 API preview. Breaking changes may occur.
Overview
Create a new discount code for the authenticated vendor’s products.Use Cases
- Launch vendor-specific promotions
- Automate discount creation from marketing campaigns
Request Body
string
required
Discount code for checkout.
string
required
Internal title/description.
string
Start date (ISO 8601).
string
End date (ISO 8601).
object
Discount value configuration.
integer
Maximum total uses.
boolean
Limit to one use per customer.
object
Item targeting configuration.
Response
201
{
"success": true,
"data": {
"discount": {
"_id": "507f1f77bcf86cd799439011",
"code": "VENDOR20",
"title": "Vendor Special 20% Off",
"status": "active",
"createdAt": "2024-06-15T10:00:00.000Z"
}
}
}
Example
curl -X POST https://production-api.puppetvendors.com/discounts \
-H "Content-Type: application/json" \
-H "x-access-token: YOUR_VENDOR_JWT_TOKEN" \
-d '{
"code": "VENDOR20",
"title": "Vendor Special 20% Off",
"usageLimit": 50,
"appliesOncePerCustomer": true
}'
More Examples
20% off discount with limitcurl -X POST "https://production-api.puppetvendors.com/discounts" \
-H "Content-Type: application/json" \
-H "x-access-token: YOUR_VENDOR_JWT_TOKEN" \
-d '{
"code": "SUMMER20",
"title": "Summer 20% Off",
"customerGets": {
"value": { "type": "percentage", "value": 20 }
},
"usageLimit": 100,
"appliesOncePerCustomer": true,
"startsAt": "2026-06-01T00:00:00Z",
"endsAt": "2026-08-31T23:59:59Z"
}'
curl -X POST "https://production-api.puppetvendors.com/discounts" \
-H "Content-Type: application/json" \
-H "x-access-token: YOUR_VENDOR_JWT_TOKEN" \
-d '{
"code": "SAVE10",
"title": "$10 Off Any Order",
"customerGets": {
"value": { "type": "fixed_amount", "value": 10 }
}
}'
Was this page helpful?
⌘I