Update a coupon
curl --request PUT \
--url https://core.nozle.app/api/v1/coupons/{code} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"coupon": {
"name": "Startup Deal",
"code": "startup_deal",
"description": "I am a coupon description",
"coupon_type": "fixed_amount",
"amount_cents": 5000,
"amount_currency": "USD",
"reusable": false,
"percentage_rate": null,
"frequency": "recurring",
"frequency_duration": 6,
"expiration": "time_limit",
"expiration_at": "2022-08-08T23:59:59Z",
"applies_to": {
"plan_codes": [
"startup_plan"
],
"feature_codes": []
}
}
}
'import requests
url = "https://core.nozle.app/api/v1/coupons/{code}"
payload = { "coupon": {
"name": "Startup Deal",
"code": "startup_deal",
"description": "I am a coupon description",
"coupon_type": "fixed_amount",
"amount_cents": 5000,
"amount_currency": "USD",
"reusable": False,
"percentage_rate": None,
"frequency": "recurring",
"frequency_duration": 6,
"expiration": "time_limit",
"expiration_at": "2022-08-08T23:59:59Z",
"applies_to": {
"plan_codes": ["startup_plan"],
"feature_codes": []
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
coupon: {
name: 'Startup Deal',
code: 'startup_deal',
description: 'I am a coupon description',
coupon_type: 'fixed_amount',
amount_cents: 5000,
amount_currency: 'USD',
reusable: false,
percentage_rate: null,
frequency: 'recurring',
frequency_duration: 6,
expiration: 'time_limit',
expiration_at: '2022-08-08T23:59:59Z',
applies_to: {plan_codes: ['startup_plan'], feature_codes: []}
}
})
};
fetch('https://core.nozle.app/api/v1/coupons/{code}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://core.nozle.app/api/v1/coupons/{code}"
payload := strings.NewReader("{\n \"coupon\": {\n \"name\": \"Startup Deal\",\n \"code\": \"startup_deal\",\n \"description\": \"I am a coupon description\",\n \"coupon_type\": \"fixed_amount\",\n \"amount_cents\": 5000,\n \"amount_currency\": \"USD\",\n \"reusable\": false,\n \"percentage_rate\": null,\n \"frequency\": \"recurring\",\n \"frequency_duration\": 6,\n \"expiration\": \"time_limit\",\n \"expiration_at\": \"2022-08-08T23:59:59Z\",\n \"applies_to\": {\n \"plan_codes\": [\n \"startup_plan\"\n ],\n \"feature_codes\": []\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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))
}require 'uri'
require 'net/http'
url = URI("https://core.nozle.app/api/v1/coupons/{code}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"coupon\": {\n \"name\": \"Startup Deal\",\n \"code\": \"startup_deal\",\n \"description\": \"I am a coupon description\",\n \"coupon_type\": \"fixed_amount\",\n \"amount_cents\": 5000,\n \"amount_currency\": \"USD\",\n \"reusable\": false,\n \"percentage_rate\": null,\n \"frequency\": \"recurring\",\n \"frequency_duration\": 6,\n \"expiration\": \"time_limit\",\n \"expiration_at\": \"2022-08-08T23:59:59Z\",\n \"applies_to\": {\n \"plan_codes\": [\n \"startup_plan\"\n ],\n \"feature_codes\": []\n }\n }\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://core.nozle.app/api/v1/coupons/{code}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'coupon' => [
'name' => 'Startup Deal',
'code' => 'startup_deal',
'description' => 'I am a coupon description',
'coupon_type' => 'fixed_amount',
'amount_cents' => 5000,
'amount_currency' => 'USD',
'reusable' => false,
'percentage_rate' => null,
'frequency' => 'recurring',
'frequency_duration' => 6,
'expiration' => 'time_limit',
'expiration_at' => '2022-08-08T23:59:59Z',
'applies_to' => [
'plan_codes' => [
'startup_plan'
],
'feature_codes' => [
]
]
]
]),
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;
}HttpResponse<String> response = Unirest.put("https://core.nozle.app/api/v1/coupons/{code}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"coupon\": {\n \"name\": \"Startup Deal\",\n \"code\": \"startup_deal\",\n \"description\": \"I am a coupon description\",\n \"coupon_type\": \"fixed_amount\",\n \"amount_cents\": 5000,\n \"amount_currency\": \"USD\",\n \"reusable\": false,\n \"percentage_rate\": null,\n \"frequency\": \"recurring\",\n \"frequency_duration\": 6,\n \"expiration\": \"time_limit\",\n \"expiration_at\": \"2022-08-08T23:59:59Z\",\n \"applies_to\": {\n \"plan_codes\": [\n \"startup_plan\"\n ],\n \"feature_codes\": []\n }\n }\n}")
.asString();{
"coupon": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Startup Deal",
"code": "startup_deal",
"coupon_type": "fixed_amount",
"reusable": true,
"limited_plans": true,
"limited_features": false,
"frequency": "recurring",
"expiration": "time_limit",
"created_at": "2022-04-29T08:59:51Z",
"description": "I am a coupon description",
"amount_cents": 5000,
"amount_currency": "USD",
"plan_codes": [
"startup_plan"
],
"feature_codes": [],
"percentage_rate": null,
"frequency_duration": 6,
"expiration_at": "2022-08-08T23:59:59Z",
"terminated_at": "2022-08-08T23:59:59Z"
}
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 404,
"error": "Not Found",
"code": "object_not_found"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}Coupons
Update a coupon
This endpoint is used to update a coupon that can be then attached to a customer to create a discount.
PUT
/
coupons
/
{code}
Update a coupon
curl --request PUT \
--url https://core.nozle.app/api/v1/coupons/{code} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"coupon": {
"name": "Startup Deal",
"code": "startup_deal",
"description": "I am a coupon description",
"coupon_type": "fixed_amount",
"amount_cents": 5000,
"amount_currency": "USD",
"reusable": false,
"percentage_rate": null,
"frequency": "recurring",
"frequency_duration": 6,
"expiration": "time_limit",
"expiration_at": "2022-08-08T23:59:59Z",
"applies_to": {
"plan_codes": [
"startup_plan"
],
"feature_codes": []
}
}
}
'import requests
url = "https://core.nozle.app/api/v1/coupons/{code}"
payload = { "coupon": {
"name": "Startup Deal",
"code": "startup_deal",
"description": "I am a coupon description",
"coupon_type": "fixed_amount",
"amount_cents": 5000,
"amount_currency": "USD",
"reusable": False,
"percentage_rate": None,
"frequency": "recurring",
"frequency_duration": 6,
"expiration": "time_limit",
"expiration_at": "2022-08-08T23:59:59Z",
"applies_to": {
"plan_codes": ["startup_plan"],
"feature_codes": []
}
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
coupon: {
name: 'Startup Deal',
code: 'startup_deal',
description: 'I am a coupon description',
coupon_type: 'fixed_amount',
amount_cents: 5000,
amount_currency: 'USD',
reusable: false,
percentage_rate: null,
frequency: 'recurring',
frequency_duration: 6,
expiration: 'time_limit',
expiration_at: '2022-08-08T23:59:59Z',
applies_to: {plan_codes: ['startup_plan'], feature_codes: []}
}
})
};
fetch('https://core.nozle.app/api/v1/coupons/{code}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://core.nozle.app/api/v1/coupons/{code}"
payload := strings.NewReader("{\n \"coupon\": {\n \"name\": \"Startup Deal\",\n \"code\": \"startup_deal\",\n \"description\": \"I am a coupon description\",\n \"coupon_type\": \"fixed_amount\",\n \"amount_cents\": 5000,\n \"amount_currency\": \"USD\",\n \"reusable\": false,\n \"percentage_rate\": null,\n \"frequency\": \"recurring\",\n \"frequency_duration\": 6,\n \"expiration\": \"time_limit\",\n \"expiration_at\": \"2022-08-08T23:59:59Z\",\n \"applies_to\": {\n \"plan_codes\": [\n \"startup_plan\"\n ],\n \"feature_codes\": []\n }\n }\n}")
req, _ := http.NewRequest("PUT", 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))
}require 'uri'
require 'net/http'
url = URI("https://core.nozle.app/api/v1/coupons/{code}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"coupon\": {\n \"name\": \"Startup Deal\",\n \"code\": \"startup_deal\",\n \"description\": \"I am a coupon description\",\n \"coupon_type\": \"fixed_amount\",\n \"amount_cents\": 5000,\n \"amount_currency\": \"USD\",\n \"reusable\": false,\n \"percentage_rate\": null,\n \"frequency\": \"recurring\",\n \"frequency_duration\": 6,\n \"expiration\": \"time_limit\",\n \"expiration_at\": \"2022-08-08T23:59:59Z\",\n \"applies_to\": {\n \"plan_codes\": [\n \"startup_plan\"\n ],\n \"feature_codes\": []\n }\n }\n}"
response = http.request(request)
puts response.read_body<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://core.nozle.app/api/v1/coupons/{code}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'coupon' => [
'name' => 'Startup Deal',
'code' => 'startup_deal',
'description' => 'I am a coupon description',
'coupon_type' => 'fixed_amount',
'amount_cents' => 5000,
'amount_currency' => 'USD',
'reusable' => false,
'percentage_rate' => null,
'frequency' => 'recurring',
'frequency_duration' => 6,
'expiration' => 'time_limit',
'expiration_at' => '2022-08-08T23:59:59Z',
'applies_to' => [
'plan_codes' => [
'startup_plan'
],
'feature_codes' => [
]
]
]
]),
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;
}HttpResponse<String> response = Unirest.put("https://core.nozle.app/api/v1/coupons/{code}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"coupon\": {\n \"name\": \"Startup Deal\",\n \"code\": \"startup_deal\",\n \"description\": \"I am a coupon description\",\n \"coupon_type\": \"fixed_amount\",\n \"amount_cents\": 5000,\n \"amount_currency\": \"USD\",\n \"reusable\": false,\n \"percentage_rate\": null,\n \"frequency\": \"recurring\",\n \"frequency_duration\": 6,\n \"expiration\": \"time_limit\",\n \"expiration_at\": \"2022-08-08T23:59:59Z\",\n \"applies_to\": {\n \"plan_codes\": [\n \"startup_plan\"\n ],\n \"feature_codes\": []\n }\n }\n}")
.asString();{
"coupon": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Startup Deal",
"code": "startup_deal",
"coupon_type": "fixed_amount",
"reusable": true,
"limited_plans": true,
"limited_features": false,
"frequency": "recurring",
"expiration": "time_limit",
"created_at": "2022-04-29T08:59:51Z",
"description": "I am a coupon description",
"amount_cents": 5000,
"amount_currency": "USD",
"plan_codes": [
"startup_plan"
],
"feature_codes": [],
"percentage_rate": null,
"frequency_duration": 6,
"expiration_at": "2022-08-08T23:59:59Z",
"terminated_at": "2022-08-08T23:59:59Z"
}
}{
"status": 400,
"error": "Bad request"
}{
"status": 401,
"error": "Unauthorized"
}{
"status": 404,
"error": "Not Found",
"code": "object_not_found"
}{
"status": 422,
"error": "Unprocessable entity",
"code": "validation_errors",
"error_details": {}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Unique code used to identify the coupon.
Example:
"startup_deal"
Body
application/json
Coupon payload
Show child attributes
Show child attributes
Response
Coupon updated
Show child attributes
Show child attributes