Update
curl --request PATCH \
--url https://{defaultHost}/v1/coupons/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"coupon": {
"name": "Updated Coupon"
}
}
'import requests
url = "https://{defaultHost}/v1/coupons/{id}"
payload = { "coupon": { "name": "Updated Coupon" } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({coupon: {name: 'Updated Coupon'}})
};
fetch('https://{defaultHost}/v1/coupons/{id}', 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/coupons/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'coupon' => [
'name' => 'Updated Coupon'
]
]),
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/coupons/{id}"
payload := strings.NewReader("{\n \"coupon\": {\n \"name\": \"Updated Coupon\"\n }\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://{defaultHost}/v1/coupons/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"coupon\": {\n \"name\": \"Updated Coupon\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/coupons/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"coupon\": {\n \"name\": \"Updated Coupon\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "fd1c58c9-c9a9-4d9a-8f53-f90882410f7f",
"object": "coupon",
"archived": false,
"archived_at": null,
"amount_off": 500,
"currency": "usd",
"duration": "once",
"duration_in_months": null,
"expired": false,
"metadata": {},
"max_redemptions": null,
"max_redemptions_per_customer": null,
"max_subtotal_amount": null,
"min_subtotal_amount": null,
"name": "Updated Coupon",
"percent_off": null,
"product_ids": [],
"redeem_by": null,
"times_redeemed": 0,
"discarded_at": null,
"created_at": 1793796869,
"updated_at": 1793796869
}Coupons
Update
Updates a specific coupon.
PATCH
/
v1
/
coupons
/
{id}
Update
curl --request PATCH \
--url https://{defaultHost}/v1/coupons/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"coupon": {
"name": "Updated Coupon"
}
}
'import requests
url = "https://{defaultHost}/v1/coupons/{id}"
payload = { "coupon": { "name": "Updated Coupon" } }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({coupon: {name: 'Updated Coupon'}})
};
fetch('https://{defaultHost}/v1/coupons/{id}', 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/coupons/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'coupon' => [
'name' => 'Updated Coupon'
]
]),
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/coupons/{id}"
payload := strings.NewReader("{\n \"coupon\": {\n \"name\": \"Updated Coupon\"\n }\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://{defaultHost}/v1/coupons/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"coupon\": {\n \"name\": \"Updated Coupon\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/coupons/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"coupon\": {\n \"name\": \"Updated Coupon\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "fd1c58c9-c9a9-4d9a-8f53-f90882410f7f",
"object": "coupon",
"archived": false,
"archived_at": null,
"amount_off": 500,
"currency": "usd",
"duration": "once",
"duration_in_months": null,
"expired": false,
"metadata": {},
"max_redemptions": null,
"max_redemptions_per_customer": null,
"max_subtotal_amount": null,
"min_subtotal_amount": null,
"name": "Updated Coupon",
"percent_off": null,
"product_ids": [],
"redeem_by": null,
"times_redeemed": 0,
"discarded_at": null,
"created_at": 1793796869,
"updated_at": 1793796869
}Authorizations
Response
200 - application/json
Success
Expandable – Property not returned unless expanded.
Expandable – Property not returned unless expanded.
Was this page helpful?