curl --request POST \
--url https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"name": "<string>",
"startsAt": "2023-11-07T05:31:56Z",
"endsAt": "2023-11-07T05:31:56Z",
"rules": {
"value": 123,
"minimumOrderValue": 123,
"usageLimit": 123
},
"options": []
}
'import requests
url = "https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts"
payload = {
"code": "<string>",
"name": "<string>",
"startsAt": "2023-11-07T05:31:56Z",
"endsAt": "2023-11-07T05:31:56Z",
"rules": {
"value": 123,
"minimumOrderValue": 123,
"usageLimit": 123
},
"options": []
}
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({
code: '<string>',
name: '<string>',
startsAt: '2023-11-07T05:31:56Z',
endsAt: '2023-11-07T05:31:56Z',
rules: {value: 123, minimumOrderValue: 123, usageLimit: 123},
options: []
})
};
fetch('https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts', 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.deliveryvip.com.br/merchant/v3/{merchantId}/discounts",
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([
'code' => '<string>',
'name' => '<string>',
'startsAt' => '2023-11-07T05:31:56Z',
'endsAt' => '2023-11-07T05:31:56Z',
'rules' => [
'value' => 123,
'minimumOrderValue' => 123,
'usageLimit' => 123
],
'options' => [
]
]),
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.deliveryvip.com.br/merchant/v3/{merchantId}/discounts"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"name\": \"<string>\",\n \"startsAt\": \"2023-11-07T05:31:56Z\",\n \"endsAt\": \"2023-11-07T05:31:56Z\",\n \"rules\": {\n \"value\": 123,\n \"minimumOrderValue\": 123,\n \"usageLimit\": 123\n },\n \"options\": []\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.deliveryvip.com.br/merchant/v3/{merchantId}/discounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"name\": \"<string>\",\n \"startsAt\": \"2023-11-07T05:31:56Z\",\n \"endsAt\": \"2023-11-07T05:31:56Z\",\n \"rules\": {\n \"value\": 123,\n \"minimumOrderValue\": 123,\n \"usageLimit\": 123\n },\n \"options\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts")
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 \"code\": \"<string>\",\n \"name\": \"<string>\",\n \"startsAt\": \"2023-11-07T05:31:56Z\",\n \"endsAt\": \"2023-11-07T05:31:56Z\",\n \"rules\": {\n \"value\": 123,\n \"minimumOrderValue\": 123,\n \"usageLimit\": 123\n },\n \"options\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z",
"startsAt": "2023-11-07T05:31:56Z",
"endsAt": "2023-11-07T05:31:56Z",
"type": "COUPON",
"code": "<string>",
"name": "<string>",
"status": "ACTIVE",
"rules": {
"valueType": "PERCENTAGE",
"value": 123,
"minimumOrderValue": 123,
"usageLimit": 123,
"usagePerCustomer": "ONCE",
"discountType": "TOTAL"
},
"options": [
"CUMULATIVE_WITH_SMART"
]
}{
"title": "Unauthorized",
"status": 401
}{
"status": "403",
"title": "growth_discount_not_hired"
}{
"status": "404",
"title": "Record not found"
}{
"status": "404",
"title": "Record not found"
}Criar desconto
Cria um cupom (COUPON, identificado por code) ou um desconto inteligente (SMART, identificado por name). O corpo pode ser enviado diretamente ou envolvido em {"discount": {...}}. Os valores de enum são aceitos em maiúsculas ou minúsculas.
curl --request POST \
--url https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"name": "<string>",
"startsAt": "2023-11-07T05:31:56Z",
"endsAt": "2023-11-07T05:31:56Z",
"rules": {
"value": 123,
"minimumOrderValue": 123,
"usageLimit": 123
},
"options": []
}
'import requests
url = "https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts"
payload = {
"code": "<string>",
"name": "<string>",
"startsAt": "2023-11-07T05:31:56Z",
"endsAt": "2023-11-07T05:31:56Z",
"rules": {
"value": 123,
"minimumOrderValue": 123,
"usageLimit": 123
},
"options": []
}
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({
code: '<string>',
name: '<string>',
startsAt: '2023-11-07T05:31:56Z',
endsAt: '2023-11-07T05:31:56Z',
rules: {value: 123, minimumOrderValue: 123, usageLimit: 123},
options: []
})
};
fetch('https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts', 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.deliveryvip.com.br/merchant/v3/{merchantId}/discounts",
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([
'code' => '<string>',
'name' => '<string>',
'startsAt' => '2023-11-07T05:31:56Z',
'endsAt' => '2023-11-07T05:31:56Z',
'rules' => [
'value' => 123,
'minimumOrderValue' => 123,
'usageLimit' => 123
],
'options' => [
]
]),
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.deliveryvip.com.br/merchant/v3/{merchantId}/discounts"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"name\": \"<string>\",\n \"startsAt\": \"2023-11-07T05:31:56Z\",\n \"endsAt\": \"2023-11-07T05:31:56Z\",\n \"rules\": {\n \"value\": 123,\n \"minimumOrderValue\": 123,\n \"usageLimit\": 123\n },\n \"options\": []\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.deliveryvip.com.br/merchant/v3/{merchantId}/discounts")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"name\": \"<string>\",\n \"startsAt\": \"2023-11-07T05:31:56Z\",\n \"endsAt\": \"2023-11-07T05:31:56Z\",\n \"rules\": {\n \"value\": 123,\n \"minimumOrderValue\": 123,\n \"usageLimit\": 123\n },\n \"options\": []\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.deliveryvip.com.br/merchant/v3/{merchantId}/discounts")
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 \"code\": \"<string>\",\n \"name\": \"<string>\",\n \"startsAt\": \"2023-11-07T05:31:56Z\",\n \"endsAt\": \"2023-11-07T05:31:56Z\",\n \"rules\": {\n \"value\": 123,\n \"minimumOrderValue\": 123,\n \"usageLimit\": 123\n },\n \"options\": []\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z",
"startsAt": "2023-11-07T05:31:56Z",
"endsAt": "2023-11-07T05:31:56Z",
"type": "COUPON",
"code": "<string>",
"name": "<string>",
"status": "ACTIVE",
"rules": {
"valueType": "PERCENTAGE",
"value": 123,
"minimumOrderValue": 123,
"usageLimit": 123,
"usagePerCustomer": "ONCE",
"discountType": "TOTAL"
},
"options": [
"CUMULATIVE_WITH_SMART"
]
}{
"title": "Unauthorized",
"status": 401
}{
"status": "403",
"title": "growth_discount_not_hired"
}{
"status": "404",
"title": "Record not found"
}{
"status": "404",
"title": "Record not found"
}Autorizações
Token de acesso opaco emitido pela API de autenticação (POST /authentication/v1/oauth/token).
Parâmetros de caminho
Id (UUID) da loja na plataforma. A loja precisa estar autorizada para o aplicativo.
Corpo
Tipo do desconto.
COUPON, SMART Código do cupom (COUPON).
Nome do desconto inteligente (SMART).
Início da vigência.
Fim da vigência (opcional).
Show child attributes
Show child attributes
Opções do desconto.
CUMULATIVE_WITH_SMART, NON_PROMOTION_PRODUCTS, SUBSCRIBER Resposta
Desconto criado.
Omitido quando o desconto não tem fim de vigência.
COUPON, SMART Código do cupom. Presente apenas em COUPON.
Nome do desconto. Presente apenas em SMART.
Situação da vigência.
ACTIVE, SCHEDULED, OVERDUE Show child attributes
Show child attributes
Omitido quando não há opções.
CUMULATIVE_WITH_SMART, NON_PROMOTION_PRODUCTS, SUBSCRIBER