Skip to main content
POST
/
v1
/
coupons
Create coupon
curl --request POST \
  --url https://api.hyperline.co/v1/coupons \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Partner discount",
  "type": "amount",
  "discount_amount": 2000,
  "currency": "EUR",
  "description": null,
  "expiration_date": null,
  "redemption_limit": null,
  "product_ids": null,
  "repeat": "duration",
  "duration": {
    "count": 3,
    "period": "months"
  }
}
'
import requests

url = "https://api.hyperline.co/v1/coupons"

payload = {
"name": "Partner discount",
"type": "amount",
"discount_amount": 2000,
"currency": "EUR",
"description": None,
"expiration_date": None,
"redemption_limit": None,
"product_ids": None,
"repeat": "duration",
"duration": {
"count": 3,
"period": "months"
}
}
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({
name: 'Partner discount',
type: 'amount',
discount_amount: 2000,
currency: 'EUR',
description: null,
expiration_date: null,
redemption_limit: null,
product_ids: null,
repeat: 'duration',
duration: {count: 3, period: 'months'}
})
};

fetch('https://api.hyperline.co/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.hyperline.co/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' => 'Partner discount',
'type' => 'amount',
'discount_amount' => 2000,
'currency' => 'EUR',
'description' => null,
'expiration_date' => null,
'redemption_limit' => null,
'product_ids' => null,
'repeat' => 'duration',
'duration' => [
'count' => 3,
'period' => 'months'
]
]),
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.hyperline.co/v1/coupons"

payload := strings.NewReader("{\n \"name\": \"Partner discount\",\n \"type\": \"amount\",\n \"discount_amount\": 2000,\n \"currency\": \"EUR\",\n \"description\": null,\n \"expiration_date\": null,\n \"redemption_limit\": null,\n \"product_ids\": null,\n \"repeat\": \"duration\",\n \"duration\": {\n \"count\": 3,\n \"period\": \"months\"\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.hyperline.co/v1/coupons")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Partner discount\",\n \"type\": \"amount\",\n \"discount_amount\": 2000,\n \"currency\": \"EUR\",\n \"description\": null,\n \"expiration_date\": null,\n \"redemption_limit\": null,\n \"product_ids\": null,\n \"repeat\": \"duration\",\n \"duration\": {\n \"count\": 3,\n \"period\": \"months\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.hyperline.co/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 \"name\": \"Partner discount\",\n \"type\": \"amount\",\n \"discount_amount\": 2000,\n \"currency\": \"EUR\",\n \"description\": null,\n \"expiration_date\": null,\n \"redemption_limit\": null,\n \"product_ids\": null,\n \"repeat\": \"duration\",\n \"duration\": {\n \"count\": 3,\n \"period\": \"months\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "cou_DKL4Xcb5VSa8CQ",
  "name": "Partner discount",
  "description": null,
  "expiration_date": null,
  "redemption_limit": null,
  "product_ids": [
    "itm_DKL4Xcb5VSa8CQ",
    "itm_1234567890abcdef"
  ],
  "repeat": "duration",
  "duration": {
    "count": 3,
    "period": "months"
  },
  "created_at": "2024-12-20T16:04:11Z",
  "integrations": [
    {
      "entity_id": "123456789",
      "provider_name": "stripe",
      "provider_account_id": "acc_1234567890"
    }
  ],
  "type": "amount",
  "discount_amount": 2000,
  "currency": "EUR"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Create coupon payload

name
string
required

Coupon name.

Example:

"Partner discount"

type
enum<string>
required
Available options:
amount
discount_amount
number
required

Amount to apply as a discount on the total amount (excluding taxes) of a subscription. Expressed in the currency's smallest unit.

Example:

2000

currency
enum<string>
required

Currency code. See ISO 4217.

Available options:
EUR,
AED,
AFN,
XCD,
ALL,
AMD,
AOA,
ARS,
USD,
AUD,
AWG,
AZN,
BAM,
BBD,
BDT,
BGN,
BHD,
BIF,
XOF,
BMD,
BND,
BOB,
BRL,
BSD,
BTN,
NOK,
BWP,
BYR,
BZD,
CAD,
CDF,
XAF,
CHF,
NZD,
CLP,
CNY,
COP,
CRC,
CUP,
CVE,
ANG,
CZK,
DJF,
DKK,
DOP,
DZD,
EGP,
MAD,
ERN,
ETB,
FJD,
FKP,
GBP,
GEL,
GHS,
GIP,
GMD,
GNF,
GTQ,
GYD,
HKD,
HNL,
HRK,
HTG,
HUF,
IDR,
ILS,
INR,
IQD,
IRR,
ISK,
JMD,
JOD,
JPY,
KES,
KGS,
KHR,
KMF,
KPW,
KRW,
KWD,
KYD,
KZT,
LAK,
LBP,
LKR,
LRD,
LSL,
LYD,
MDL,
MGA,
MKD,
MMK,
MNT,
MOP,
MRO,
MUR,
MVR,
MWK,
MXN,
MYR,
MZN,
NAD,
XPF,
NGN,
NIO,
NPR,
OMR,
PAB,
PEN,
PGK,
PHP,
PKR,
PLN,
PYG,
QAR,
RON,
RSD,
RUB,
RWF,
SAR,
SBD,
SCR,
SDG,
SEK,
SGD,
SHP,
SLL,
SOS,
SRD,
SSP,
STD,
SYP,
SZL,
THB,
TJS,
TMT,
TND,
TOP,
TRY,
TTD,
TWD,
TZS,
UAH,
UGX,
UYU,
UZS,
VEF,
VND,
VUV,
WST,
YER,
ZAR,
ZMW,
ZWL
Example:

"EUR"

description
string | null

Coupon description.

Example:

null

expiration_date
string<date-time> | null

Date corresponding to the expiration of the coupon.

Example:

null

redemption_limit
number | null

Maximum number of subscriptions to which a single coupon can be applied.

Example:

null

product_ids
string[] | null

List of product IDs the coupon can be applied to. If empty, the coupon can be applied to any product.

Example:

null

repeat
enum<string> | null

Default repeat behaviour applied when the coupon is attached to a subscription. Valid values: once, forever, duration. Can be overridden at attach time.

Available options:
once,
forever,
duration
Example:

"duration"

duration
object | null

Default duration applied when repeat is duration. Required when repeat is duration, must be null otherwise.

Example:
{ "count": 3, "period": "months" }

Response

201 - application/json

The newly created coupon

id
string
required

Coupon ID.

Example:

"cou_DKL4Xcb5VSa8CQ"

name
string
required

Coupon name.

Example:

"Partner discount"

description
string | null
required

Coupon description.

Example:

null

expiration_date
string<date-time> | null
required

Date corresponding to the expiration of the coupon.

Example:

null

redemption_limit
number | null
required

Maximum number of subscriptions to which a single coupon can be applied.

Example:

null

product_ids
string[]
required

List of product IDs the coupon can be applied to. If empty, the coupon can be applied to any product.

Example:
[
"itm_DKL4Xcb5VSa8CQ",
"itm_1234567890abcdef"
]
repeat
enum<string> | null
required

Default repeat behaviour applied when the coupon is attached to a subscription. Valid values: once, forever, duration. Can be overridden at attach time.

Available options:
once,
forever,
custom,
duration
Example:

"duration"

duration
object | null
required

Default duration applied when repeat is duration. Required when repeat is duration, must be null otherwise.

Example:
{ "count": 3, "period": "months" }
created_at
string<date-time>
required

UTC date time string in the ISO 8601 format.

Example:

"2024-12-20T16:04:11Z"

integrations
object[]
required

References to this coupon in external providers (billing, etc).

type
enum<string>
required
Available options:
amount
discount_amount
number
required

Amount to apply as a discount on the total amount (excluding taxes) of a subscription. Expressed in the currency's smallest unit.

Example:

2000

currency
enum<string> | null
required

Currency code. See ISO 4217.

Available options:
EUR,
AED,
AFN,
XCD,
ALL,
AMD,
AOA,
ARS,
USD,
AUD,
AWG,
AZN,
BAM,
BBD,
BDT,
BGN,
BHD,
BIF,
XOF,
BMD,
BND,
BOB,
BRL,
BSD,
BTN,
NOK,
BWP,
BYR,
BZD,
CAD,
CDF,
XAF,
CHF,
NZD,
CLP,
CNY,
COP,
CRC,
CUP,
CVE,
ANG,
CZK,
DJF,
DKK,
DOP,
DZD,
EGP,
MAD,
ERN,
ETB,
FJD,
FKP,
GBP,
GEL,
GHS,
GIP,
GMD,
GNF,
GTQ,
GYD,
HKD,
HNL,
HRK,
HTG,
HUF,
IDR,
ILS,
INR,
IQD,
IRR,
ISK,
JMD,
JOD,
JPY,
KES,
KGS,
KHR,
KMF,
KPW,
KRW,
KWD,
KYD,
KZT,
LAK,
LBP,
LKR,
LRD,
LSL,
LYD,
MDL,
MGA,
MKD,
MMK,
MNT,
MOP,
MRO,
MUR,
MVR,
MWK,
MXN,
MYR,
MZN,
NAD,
XPF,
NGN,
NIO,
NPR,
OMR,
PAB,
PEN,
PGK,
PHP,
PKR,
PLN,
PYG,
QAR,
RON,
RSD,
RUB,
RWF,
SAR,
SBD,
SCR,
SDG,
SEK,
SGD,
SHP,
SLL,
SOS,
SRD,
SSP,
STD,
SYP,
SZL,
THB,
TJS,
TMT,
TND,
TOP,
TRY,
TTD,
TWD,
TZS,
UAH,
UGX,
UYU,
UZS,
VEF,
VND,
VUV,
WST,
YER,
ZAR,
ZMW,
ZWL
Example:

"EUR"