Create Coupon
curl --request POST \
--url https://api.withflex.com/v1/coupons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"coupon": {
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": {
"key": "value"
}
}
}
'import requests
url = "https://api.withflex.com/v1/coupons"
payload = { "coupon": {
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": { "key": "value" }
} }
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({
coupon: {
name: 'Coupon',
amount_off: 100,
duration: 'once',
percent_off: 10,
max_redemptions: 100,
metadata: {key: 'value'}
}
})
};
fetch('https://api.withflex.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.withflex.com/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([
'coupon' => [
'name' => 'Coupon',
'amount_off' => 100,
'duration' => 'once',
'percent_off' => 10,
'max_redemptions' => 100,
'metadata' => [
'key' => 'value'
]
]
]),
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.withflex.com/v1/coupons"
payload := strings.NewReader("{\n \"coupon\": {\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\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.withflex.com/v1/coupons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"coupon\": {\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/coupons")
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 \"coupon\": {\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"coupon": {
"coupon_id": "fcoup_1234567890",
"amount_off": 2500,
"duration": "once",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"name": "Example",
"valid": false,
"created_at": "2026-06-15T14:30:00Z",
"test_mode": false
}
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}{
"code": "string",
"detail": "string"
}Create Coupon
Creates a coupon. Exactly one of amount_off or percent_off must be provided; supplying
both, or neither, is rejected. When duration is repeating, duration_in_months is
required.
POST
/
v1
/
coupons
Create Coupon
curl --request POST \
--url https://api.withflex.com/v1/coupons \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"coupon": {
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": {
"key": "value"
}
}
}
'import requests
url = "https://api.withflex.com/v1/coupons"
payload = { "coupon": {
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": { "key": "value" }
} }
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({
coupon: {
name: 'Coupon',
amount_off: 100,
duration: 'once',
percent_off: 10,
max_redemptions: 100,
metadata: {key: 'value'}
}
})
};
fetch('https://api.withflex.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.withflex.com/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([
'coupon' => [
'name' => 'Coupon',
'amount_off' => 100,
'duration' => 'once',
'percent_off' => 10,
'max_redemptions' => 100,
'metadata' => [
'key' => 'value'
]
]
]),
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.withflex.com/v1/coupons"
payload := strings.NewReader("{\n \"coupon\": {\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\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.withflex.com/v1/coupons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"coupon\": {\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.withflex.com/v1/coupons")
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 \"coupon\": {\n \"name\": \"Coupon\",\n \"amount_off\": 100,\n \"duration\": \"once\",\n \"percent_off\": 10,\n \"max_redemptions\": 100,\n \"metadata\": {\n \"key\": \"value\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"coupon": {
"coupon_id": "fcoup_1234567890",
"amount_off": 2500,
"duration": "once",
"metadata": {
"order_id": "8842",
"channel": "shopify"
},
"name": "Example",
"valid": false,
"created_at": "2026-06-15T14:30:00Z",
"test_mode": false
}
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"code": "string",
"detail": "string"
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}{
"code": "string",
"detail": "string"
}Authorizations
Use a Bearer token to access this API.
Body
application/json
An envelope wrapping a single coupon object.
An envelope wrapping a single coupon object.
The coupon.
Show child attributes
Show child attributes
Example:
{
"applies_to": { "products": [] },
"name": "Coupon",
"amount_off": 100,
"duration": "once",
"percent_off": 10,
"max_redemptions": 100,
"metadata": { "key": "value" }
}
Response
An envelope wrapping a single coupon object.
An envelope wrapping a single coupon object.
The coupon.
Show child attributes
Show child attributes
Example:
{
"coupon_id": "fcoup_1234567890",
"amount_off": 2500,
"applies_to": { "products": [] },
"duration": "once",
"metadata": { "order_id": "8842", "channel": "shopify" },
"name": "Example",
"valid": false,
"created_at": "2026-06-15T14:30:00Z",
"test_mode": false
}
⌘I