Create a promotion code
curl --request POST \
--url https://api.paybridgenp.com/v1/billing/promotion-codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"couponId": "cpn_01j9x2k3m4n5p6q7r8s9t0u1v2",
"code": "LAUNCH50",
"maxRedemptions": 123,
"expiresAt": "2023-11-07T05:31:56Z",
"firstTimeTransaction": false,
"minimumAmount": 123,
"customerIds": [
"<string>"
],
"metadata": {}
}
'import requests
url = "https://api.paybridgenp.com/v1/billing/promotion-codes"
payload = {
"couponId": "cpn_01j9x2k3m4n5p6q7r8s9t0u1v2",
"code": "LAUNCH50",
"maxRedemptions": 123,
"expiresAt": "2023-11-07T05:31:56Z",
"firstTimeTransaction": False,
"minimumAmount": 123,
"customerIds": ["<string>"],
"metadata": {}
}
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({
couponId: 'cpn_01j9x2k3m4n5p6q7r8s9t0u1v2',
code: 'LAUNCH50',
maxRedemptions: 123,
expiresAt: '2023-11-07T05:31:56Z',
firstTimeTransaction: false,
minimumAmount: 123,
customerIds: ['<string>'],
metadata: {}
})
};
fetch('https://api.paybridgenp.com/v1/billing/promotion-codes', 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.paybridgenp.com/v1/billing/promotion-codes",
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([
'couponId' => 'cpn_01j9x2k3m4n5p6q7r8s9t0u1v2',
'code' => 'LAUNCH50',
'maxRedemptions' => 123,
'expiresAt' => '2023-11-07T05:31:56Z',
'firstTimeTransaction' => false,
'minimumAmount' => 123,
'customerIds' => [
'<string>'
],
'metadata' => [
]
]),
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.paybridgenp.com/v1/billing/promotion-codes"
payload := strings.NewReader("{\n \"couponId\": \"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2\",\n \"code\": \"LAUNCH50\",\n \"maxRedemptions\": 123,\n \"expiresAt\": \"2023-11-07T05:31:56Z\",\n \"firstTimeTransaction\": false,\n \"minimumAmount\": 123,\n \"customerIds\": [\n \"<string>\"\n ],\n \"metadata\": {}\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.paybridgenp.com/v1/billing/promotion-codes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"couponId\": \"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2\",\n \"code\": \"LAUNCH50\",\n \"maxRedemptions\": 123,\n \"expiresAt\": \"2023-11-07T05:31:56Z\",\n \"firstTimeTransaction\": false,\n \"minimumAmount\": 123,\n \"customerIds\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paybridgenp.com/v1/billing/promotion-codes")
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 \"couponId\": \"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2\",\n \"code\": \"LAUNCH50\",\n \"maxRedemptions\": 123,\n \"expiresAt\": \"2023-11-07T05:31:56Z\",\n \"firstTimeTransaction\": false,\n \"minimumAmount\": 123,\n \"customerIds\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "promo_01j9x2k3m4n5p6q7r8s9t0u1v2",
"object": "promotion_code",
"code": "LAUNCH50",
"coupon_id": "cpn_01j9x2k3m4n5p6q7r8s9t0u1v2",
"active": true,
"max_redemptions": 123,
"redeemed_count": 0,
"expires_at": "2023-11-07T05:31:56Z",
"first_time_transaction": true,
"minimum_amount": 123,
"customer_ids": [
"<string>"
],
"metadata": {},
"livemode": true
}{
"error": {
"message": "<string>",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}Promotion codes
Create a promotion code
Creates a customer-facing code that applies a coupon’s discount. Requires a Growth or Pro plan.
POST
/
v1
/
billing
/
promotion-codes
Create a promotion code
curl --request POST \
--url https://api.paybridgenp.com/v1/billing/promotion-codes \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"couponId": "cpn_01j9x2k3m4n5p6q7r8s9t0u1v2",
"code": "LAUNCH50",
"maxRedemptions": 123,
"expiresAt": "2023-11-07T05:31:56Z",
"firstTimeTransaction": false,
"minimumAmount": 123,
"customerIds": [
"<string>"
],
"metadata": {}
}
'import requests
url = "https://api.paybridgenp.com/v1/billing/promotion-codes"
payload = {
"couponId": "cpn_01j9x2k3m4n5p6q7r8s9t0u1v2",
"code": "LAUNCH50",
"maxRedemptions": 123,
"expiresAt": "2023-11-07T05:31:56Z",
"firstTimeTransaction": False,
"minimumAmount": 123,
"customerIds": ["<string>"],
"metadata": {}
}
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({
couponId: 'cpn_01j9x2k3m4n5p6q7r8s9t0u1v2',
code: 'LAUNCH50',
maxRedemptions: 123,
expiresAt: '2023-11-07T05:31:56Z',
firstTimeTransaction: false,
minimumAmount: 123,
customerIds: ['<string>'],
metadata: {}
})
};
fetch('https://api.paybridgenp.com/v1/billing/promotion-codes', 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.paybridgenp.com/v1/billing/promotion-codes",
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([
'couponId' => 'cpn_01j9x2k3m4n5p6q7r8s9t0u1v2',
'code' => 'LAUNCH50',
'maxRedemptions' => 123,
'expiresAt' => '2023-11-07T05:31:56Z',
'firstTimeTransaction' => false,
'minimumAmount' => 123,
'customerIds' => [
'<string>'
],
'metadata' => [
]
]),
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.paybridgenp.com/v1/billing/promotion-codes"
payload := strings.NewReader("{\n \"couponId\": \"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2\",\n \"code\": \"LAUNCH50\",\n \"maxRedemptions\": 123,\n \"expiresAt\": \"2023-11-07T05:31:56Z\",\n \"firstTimeTransaction\": false,\n \"minimumAmount\": 123,\n \"customerIds\": [\n \"<string>\"\n ],\n \"metadata\": {}\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.paybridgenp.com/v1/billing/promotion-codes")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"couponId\": \"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2\",\n \"code\": \"LAUNCH50\",\n \"maxRedemptions\": 123,\n \"expiresAt\": \"2023-11-07T05:31:56Z\",\n \"firstTimeTransaction\": false,\n \"minimumAmount\": 123,\n \"customerIds\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paybridgenp.com/v1/billing/promotion-codes")
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 \"couponId\": \"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2\",\n \"code\": \"LAUNCH50\",\n \"maxRedemptions\": 123,\n \"expiresAt\": \"2023-11-07T05:31:56Z\",\n \"firstTimeTransaction\": false,\n \"minimumAmount\": 123,\n \"customerIds\": [\n \"<string>\"\n ],\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "promo_01j9x2k3m4n5p6q7r8s9t0u1v2",
"object": "promotion_code",
"code": "LAUNCH50",
"coupon_id": "cpn_01j9x2k3m4n5p6q7r8s9t0u1v2",
"active": true,
"max_redemptions": 123,
"redeemed_count": 0,
"expires_at": "2023-11-07T05:31:56Z",
"first_time_transaction": true,
"minimum_amount": 123,
"customer_ids": [
"<string>"
],
"metadata": {},
"livemode": true
}{
"error": {
"message": "<string>",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}{
"error": {
"message": "<string>",
"code": "<string>",
"request_id": "req_2Je91NlWKuXkdXUJOK9gaHNW",
"suspension": {
"suspended_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
},
"pause": {
"paused_at": "2023-11-07T05:31:56Z",
"reason": "<string>"
}
}
}Authorizations
Your PayBridgeNP API key. Obtain one from the dashboard under Settings → API Keys. Prefix: sk_test_ for testing, sk_live_ for production.
Body
application/json
Example:
"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2"
Example:
"LAUNCH50"
Minimum order amount in paisa.
Response
Promotion code created.
Example:
"promo_01j9x2k3m4n5p6q7r8s9t0u1v2"
Available options:
promotion_code Example:
"LAUNCH50"
Example:
"cpn_01j9x2k3m4n5p6q7r8s9t0u1v2"
Example:
0
Restrict to a customer's first transaction.
Minimum order amount in paisa for the code to apply.
Restrict to specific customers, or null for any.
true when created with a live key, false for sandbox.
Was this page helpful?
⌘I