Create
curl --request POST \
--url https://{defaultHost}/v1/promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"promotion": {
"code": "TESTCODE",
"coupon_id": "ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba"
}
}
'import requests
url = "https://{defaultHost}/v1/promotions"
payload = { "promotion": {
"code": "TESTCODE",
"coupon_id": "ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba"
} }
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({
promotion: {code: 'TESTCODE', coupon_id: 'ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba'}
})
};
fetch('https://{defaultHost}/v1/promotions', 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://{defaultHost}/v1/promotions",
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([
'promotion' => [
'code' => 'TESTCODE',
'coupon_id' => 'ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba'
]
]),
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://{defaultHost}/v1/promotions"
payload := strings.NewReader("{\n \"promotion\": {\n \"code\": \"TESTCODE\",\n \"coupon_id\": \"ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba\"\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://{defaultHost}/v1/promotions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"promotion\": {\n \"code\": \"TESTCODE\",\n \"coupon_id\": \"ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/promotions")
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 \"promotion\": {\n \"code\": \"TESTCODE\",\n \"coupon_id\": \"ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "8e96a7f6-3044-4d52-841f-d6eaebfebbaf",
"object": "promotion",
"archived": false,
"archived_at": null,
"code": "TESTCODE",
"expired": false,
"max_redemptions": null,
"metadata": {},
"redeem_by": null,
"times_redeemed": 0,
"affiliation": null,
"coupon": "ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba",
"customer": null,
"discarded_at": null,
"created_at": 1796063960,
"updated_at": 1796063960
}Promotions
Create
Creates a new promotion.
POST
/
v1
/
promotions
Create
curl --request POST \
--url https://{defaultHost}/v1/promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"promotion": {
"code": "TESTCODE",
"coupon_id": "ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba"
}
}
'import requests
url = "https://{defaultHost}/v1/promotions"
payload = { "promotion": {
"code": "TESTCODE",
"coupon_id": "ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba"
} }
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({
promotion: {code: 'TESTCODE', coupon_id: 'ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba'}
})
};
fetch('https://{defaultHost}/v1/promotions', 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://{defaultHost}/v1/promotions",
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([
'promotion' => [
'code' => 'TESTCODE',
'coupon_id' => 'ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba'
]
]),
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://{defaultHost}/v1/promotions"
payload := strings.NewReader("{\n \"promotion\": {\n \"code\": \"TESTCODE\",\n \"coupon_id\": \"ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba\"\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://{defaultHost}/v1/promotions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"promotion\": {\n \"code\": \"TESTCODE\",\n \"coupon_id\": \"ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/promotions")
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 \"promotion\": {\n \"code\": \"TESTCODE\",\n \"coupon_id\": \"ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "8e96a7f6-3044-4d52-841f-d6eaebfebbaf",
"object": "promotion",
"archived": false,
"archived_at": null,
"code": "TESTCODE",
"expired": false,
"max_redemptions": null,
"metadata": {},
"redeem_by": null,
"times_redeemed": 0,
"affiliation": null,
"coupon": "ed49cc94-72ab-4ea8-89fa-d53c0d2ac5ba",
"customer": null,
"discarded_at": null,
"created_at": 1796063960,
"updated_at": 1796063960
}Authorizations
Response
200 - application/json
Success
Expandable – The associated affiliation ID.
Expandable – The associated coupon ID.
Expandable – The associated customer ID.
Expandable – Property not returned unless expanded.
Was this page helpful?