Alternar status de um cupom
curl --request POST \
--url https://api.abacatepay.com/v2/coupons/toggle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "MY_COUPON"
}
'import requests
url = "https://api.abacatepay.com/v2/coupons/toggle"
payload = { "id": "MY_COUPON" }
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({id: 'MY_COUPON'})
};
fetch('https://api.abacatepay.com/v2/coupons/toggle', 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.abacatepay.com/v2/coupons/toggle",
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([
'id' => 'MY_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://api.abacatepay.com/v2/coupons/toggle"
payload := strings.NewReader("{\n \"id\": \"MY_COUPON\"\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.abacatepay.com/v2/coupons/toggle")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"MY_COUPON\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.abacatepay.com/v2/coupons/toggle")
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 \"id\": \"MY_COUPON\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "DEYVIN_20",
"discountKind": "PERCENTAGE",
"discount": 1000,
"status": "ACTIVE",
"createdAt": "2025-05-25T23:43:25.250Z",
"updatedAt": "2025-05-25T23:43:25.250Z",
"notes": "Cupom de desconto pro meu público",
"maxRedeems": -1,
"redeemsCount": 0,
"devMode": true,
"metadata": {}
},
"error": null,
"success": true
}{
"error": "Token de autenticação inválido ou ausente."
}{
"error": "Cupom não encontrado."
}Cupons
Alternar Status de um Cupom
Alterna o status de um cupom entre ativo e inativo.
Use essa rota para ativar ou desativar um cupom sem precisar deletá-lo.
Diferente de /coupons/delete, o id vai no corpo da requisição, não na query.
POST
/
coupons
/
toggle
Alternar status de um cupom
curl --request POST \
--url https://api.abacatepay.com/v2/coupons/toggle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"id": "MY_COUPON"
}
'import requests
url = "https://api.abacatepay.com/v2/coupons/toggle"
payload = { "id": "MY_COUPON" }
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({id: 'MY_COUPON'})
};
fetch('https://api.abacatepay.com/v2/coupons/toggle', 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.abacatepay.com/v2/coupons/toggle",
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([
'id' => 'MY_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://api.abacatepay.com/v2/coupons/toggle"
payload := strings.NewReader("{\n \"id\": \"MY_COUPON\"\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.abacatepay.com/v2/coupons/toggle")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"id\": \"MY_COUPON\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.abacatepay.com/v2/coupons/toggle")
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 \"id\": \"MY_COUPON\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "DEYVIN_20",
"discountKind": "PERCENTAGE",
"discount": 1000,
"status": "ACTIVE",
"createdAt": "2025-05-25T23:43:25.250Z",
"updatedAt": "2025-05-25T23:43:25.250Z",
"notes": "Cupom de desconto pro meu público",
"maxRedeems": -1,
"redeemsCount": 0,
"devMode": true,
"metadata": {}
},
"error": null,
"success": true
}{
"error": "Token de autenticação inválido ou ausente."
}{
"error": "Cupom não encontrado."
}Ativa ou desativa um cupom. Cupons inativos não podem ser aplicados em checkouts.
Chame este endpoint sempre que quiser pausar uma promoção temporariamente ou reativá-la sem precisar recriar o cupom.
Requer a permissão
COUPON:UPDATE.Authorizations
Todas as requisições devem incluir sua chave de API no header Authorization usando o formato Bearer <abacatepay-api-key>. Sem esse header a requisição será rejeitada.
Saiba mais sobre como criar e usar chaves de API na documentação de autenticação.
Body
application/json
Identificador único do cupom
Example:
"MY_COUPON"
Was this page helpful?