Create coupon
curl --request POST \
--url https://us.api.flexprice.io/v1/coupons \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "<string>",
"amount_off": "<string>",
"coupon_code": "<string>",
"currency": "<string>",
"duration_in_periods": 123,
"max_redemptions": 123,
"metadata": {},
"percentage_off": "<string>",
"redeem_after": "<string>",
"redeem_before": "<string>",
"rules": {}
}
'import requests
url = "https://us.api.flexprice.io/v1/coupons"
payload = {
"name": "<string>",
"amount_off": "<string>",
"coupon_code": "<string>",
"currency": "<string>",
"duration_in_periods": 123,
"max_redemptions": 123,
"metadata": {},
"percentage_off": "<string>",
"redeem_after": "<string>",
"redeem_before": "<string>",
"rules": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
amount_off: '<string>',
coupon_code: '<string>',
currency: '<string>',
duration_in_periods: 123,
max_redemptions: 123,
metadata: {},
percentage_off: '<string>',
redeem_after: '<string>',
redeem_before: '<string>',
rules: {}
})
};
fetch('https://us.api.flexprice.io/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://us.api.flexprice.io/v1/coupons",
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([
'name' => '<string>',
'amount_off' => '<string>',
'coupon_code' => '<string>',
'currency' => '<string>',
'duration_in_periods' => 123,
'max_redemptions' => 123,
'metadata' => [
],
'percentage_off' => '<string>',
'redeem_after' => '<string>',
'redeem_before' => '<string>',
'rules' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://us.api.flexprice.io/v1/coupons"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"amount_off\": \"<string>\",\n \"coupon_code\": \"<string>\",\n \"currency\": \"<string>\",\n \"duration_in_periods\": 123,\n \"max_redemptions\": 123,\n \"metadata\": {},\n \"percentage_off\": \"<string>\",\n \"redeem_after\": \"<string>\",\n \"redeem_before\": \"<string>\",\n \"rules\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://us.api.flexprice.io/v1/coupons")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"amount_off\": \"<string>\",\n \"coupon_code\": \"<string>\",\n \"currency\": \"<string>\",\n \"duration_in_periods\": 123,\n \"max_redemptions\": 123,\n \"metadata\": {},\n \"percentage_off\": \"<string>\",\n \"redeem_after\": \"<string>\",\n \"redeem_before\": \"<string>\",\n \"rules\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/coupons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"amount_off\": \"<string>\",\n \"coupon_code\": \"<string>\",\n \"currency\": \"<string>\",\n \"duration_in_periods\": 123,\n \"max_redemptions\": 123,\n \"metadata\": {},\n \"percentage_off\": \"<string>\",\n \"redeem_after\": \"<string>\",\n \"redeem_before\": \"<string>\",\n \"rules\": {}\n}"
response = http.request(request)
puts response.read_body{
"amount_off": "<string>",
"coupon_code": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"currency": "<string>",
"duration_in_periods": 123,
"environment_id": "<string>",
"id": "<string>",
"max_redemptions": 123,
"metadata": {},
"name": "<string>",
"percentage_off": "<string>",
"redeem_after": "<string>",
"redeem_before": "<string>",
"rules": {},
"tenant_id": "<string>",
"total_redemptions": 123,
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}Coupons
Create coupon
Use when creating a discount (e.g. promo code or referral). Ideal for percent or fixed value, with optional validity and usage limits.
POST
/
coupons
Create coupon
curl --request POST \
--url https://us.api.flexprice.io/v1/coupons \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"name": "<string>",
"amount_off": "<string>",
"coupon_code": "<string>",
"currency": "<string>",
"duration_in_periods": 123,
"max_redemptions": 123,
"metadata": {},
"percentage_off": "<string>",
"redeem_after": "<string>",
"redeem_before": "<string>",
"rules": {}
}
'import requests
url = "https://us.api.flexprice.io/v1/coupons"
payload = {
"name": "<string>",
"amount_off": "<string>",
"coupon_code": "<string>",
"currency": "<string>",
"duration_in_periods": 123,
"max_redemptions": 123,
"metadata": {},
"percentage_off": "<string>",
"redeem_after": "<string>",
"redeem_before": "<string>",
"rules": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
amount_off: '<string>',
coupon_code: '<string>',
currency: '<string>',
duration_in_periods: 123,
max_redemptions: 123,
metadata: {},
percentage_off: '<string>',
redeem_after: '<string>',
redeem_before: '<string>',
rules: {}
})
};
fetch('https://us.api.flexprice.io/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://us.api.flexprice.io/v1/coupons",
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([
'name' => '<string>',
'amount_off' => '<string>',
'coupon_code' => '<string>',
'currency' => '<string>',
'duration_in_periods' => 123,
'max_redemptions' => 123,
'metadata' => [
],
'percentage_off' => '<string>',
'redeem_after' => '<string>',
'redeem_before' => '<string>',
'rules' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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://us.api.flexprice.io/v1/coupons"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"amount_off\": \"<string>\",\n \"coupon_code\": \"<string>\",\n \"currency\": \"<string>\",\n \"duration_in_periods\": 123,\n \"max_redemptions\": 123,\n \"metadata\": {},\n \"percentage_off\": \"<string>\",\n \"redeem_after\": \"<string>\",\n \"redeem_before\": \"<string>\",\n \"rules\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://us.api.flexprice.io/v1/coupons")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"amount_off\": \"<string>\",\n \"coupon_code\": \"<string>\",\n \"currency\": \"<string>\",\n \"duration_in_periods\": 123,\n \"max_redemptions\": 123,\n \"metadata\": {},\n \"percentage_off\": \"<string>\",\n \"redeem_after\": \"<string>\",\n \"redeem_before\": \"<string>\",\n \"rules\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/coupons")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"amount_off\": \"<string>\",\n \"coupon_code\": \"<string>\",\n \"currency\": \"<string>\",\n \"duration_in_periods\": 123,\n \"max_redemptions\": 123,\n \"metadata\": {},\n \"percentage_off\": \"<string>\",\n \"redeem_after\": \"<string>\",\n \"redeem_before\": \"<string>\",\n \"rules\": {}\n}"
response = http.request(request)
puts response.read_body{
"amount_off": "<string>",
"coupon_code": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"created_by": "<string>",
"currency": "<string>",
"duration_in_periods": 123,
"environment_id": "<string>",
"id": "<string>",
"max_redemptions": 123,
"metadata": {},
"name": "<string>",
"percentage_off": "<string>",
"redeem_after": "<string>",
"redeem_before": "<string>",
"rules": {},
"tenant_id": "<string>",
"total_redemptions": 123,
"updated_at": "2023-11-07T05:31:56Z",
"updated_by": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}{
"http_status_code": 123,
"message": "<string>"
}Authorizations
ApiKeyAuthApiKeyAuth
Enter your API key in the format x-api-key <api-key>*
Body
application/json
Coupon request
Available options:
once, repeated, forever Available options:
fixed, percentage Show child attributes
Show child attributes
Response
Created
Available options:
once, repeated, forever Show child attributes
Show child attributes
Available options:
published, deleted, archived Available options:
fixed, percentage ⌘I

