Update coupon
curl --request PUT \
--url https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"discount_amount": 1.01,
"offer_ids": [
123
],
"active": true,
"duration_amount": 2,
"expired_at": "2023-11-07T05:31:56Z",
"usage_limit": 2
}
'import requests
url = "https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}"
payload = {
"code": "<string>",
"discount_amount": 1.01,
"offer_ids": [123],
"active": True,
"duration_amount": 2,
"expired_at": "2023-11-07T05:31:56Z",
"usage_limit": 2
}
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({
code: '<string>',
discount_amount: 1.01,
offer_ids: [123],
active: true,
duration_amount: 2,
expired_at: '2023-11-07T05:31:56Z',
usage_limit: 2
})
};
fetch('https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}', 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://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}",
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([
'code' => '<string>',
'discount_amount' => 1.01,
'offer_ids' => [
123
],
'active' => true,
'duration_amount' => 2,
'expired_at' => '2023-11-07T05:31:56Z',
'usage_limit' => 2
]),
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://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"discount_amount\": 1.01,\n \"offer_ids\": [\n 123\n ],\n \"active\": true,\n \"duration_amount\": 2,\n \"expired_at\": \"2023-11-07T05:31:56Z\",\n \"usage_limit\": 2\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))
}HttpResponse<String> response = Unirest.put("https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"discount_amount\": 1.01,\n \"offer_ids\": [\n 123\n ],\n \"active\": true,\n \"duration_amount\": 2,\n \"expired_at\": \"2023-11-07T05:31:56Z\",\n \"usage_limit\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}")
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 \"code\": \"<string>\",\n \"discount_amount\": 1.01,\n \"offer_ids\": [\n 123\n ],\n \"active\": true,\n \"duration_amount\": 2,\n \"expired_at\": \"2023-11-07T05:31:56Z\",\n \"usage_limit\": 2\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"code": "<string>",
"is_active": true,
"discount_type": "percent",
"discount_amount": 123,
"duration_type": "once",
"duration_amount": 123,
"expired_at": "2023-11-07T05:31:56Z",
"usage_limit": 123,
"usages_count": 123,
"offers": [
{
"id": 123,
"name": "<string>",
"link": "<string>",
"landing_link": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}Промокоды
Обновить промокод
Заменяет все поля промокода, частичное обновление не поддерживается
PUT
/
api
/
v1
/
bot
/
{bot}
/
coupons
/
{coupon}
Update coupon
curl --request PUT \
--url https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"discount_amount": 1.01,
"offer_ids": [
123
],
"active": true,
"duration_amount": 2,
"expired_at": "2023-11-07T05:31:56Z",
"usage_limit": 2
}
'import requests
url = "https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}"
payload = {
"code": "<string>",
"discount_amount": 1.01,
"offer_ids": [123],
"active": True,
"duration_amount": 2,
"expired_at": "2023-11-07T05:31:56Z",
"usage_limit": 2
}
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({
code: '<string>',
discount_amount: 1.01,
offer_ids: [123],
active: true,
duration_amount: 2,
expired_at: '2023-11-07T05:31:56Z',
usage_limit: 2
})
};
fetch('https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}', 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://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}",
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([
'code' => '<string>',
'discount_amount' => 1.01,
'offer_ids' => [
123
],
'active' => true,
'duration_amount' => 2,
'expired_at' => '2023-11-07T05:31:56Z',
'usage_limit' => 2
]),
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://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"discount_amount\": 1.01,\n \"offer_ids\": [\n 123\n ],\n \"active\": true,\n \"duration_amount\": 2,\n \"expired_at\": \"2023-11-07T05:31:56Z\",\n \"usage_limit\": 2\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))
}HttpResponse<String> response = Unirest.put("https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"discount_amount\": 1.01,\n \"offer_ids\": [\n 123\n ],\n \"active\": true,\n \"duration_amount\": 2,\n \"expired_at\": \"2023-11-07T05:31:56Z\",\n \"usage_limit\": 2\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.zenedu.io/api/v1/bot/{bot}/coupons/{coupon}")
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 \"code\": \"<string>\",\n \"discount_amount\": 1.01,\n \"offer_ids\": [\n 123\n ],\n \"active\": true,\n \"duration_amount\": 2,\n \"expired_at\": \"2023-11-07T05:31:56Z\",\n \"usage_limit\": 2\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"code": "<string>",
"is_active": true,
"discount_type": "percent",
"discount_amount": 123,
"duration_type": "once",
"duration_amount": 123,
"expired_at": "2023-11-07T05:31:56Z",
"usage_limit": 123,
"usages_count": 123,
"offers": [
{
"id": 123,
"name": "<string>",
"link": "<string>",
"landing_link": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z"
}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}Авторизации
API token from the Zenedu dashboard
Тело
application/json
Coupon code
Maximum string length:
250Доступные опции:
percent, amount Percent for percent type, amount in offer currency for amount type
Требуемый диапазон:
x >= 0.01How long the discount applies to a subscription
Доступные опции:
once, forever, repeating Offers the coupon applies to
Minimum array length:
1Whether the coupon is active
Number of billing periods; required when duration_type is repeating
Требуемый диапазон:
x >= 1Expiration date (UTC)
Maximum number of uses
Требуемый диапазон:
x >= 1Ответ
Coupon updated
Show child attributes
Show child attributes