Atualizar Produto
curl --request PATCH \
--url https://garu.com.br/api/products/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"value": 123,
"pix": true,
"creditCard": true,
"boleto": true,
"pixAutomatic": true,
"installments": 123,
"image": "<string>",
"returnUrl": "<string>",
"returnUrlButtonText": "<string>"
}
'import requests
url = "https://garu.com.br/api/products/{id}"
payload = {
"name": "<string>",
"description": "<string>",
"value": 123,
"pix": True,
"creditCard": True,
"boleto": True,
"pixAutomatic": True,
"installments": 123,
"image": "<string>",
"returnUrl": "<string>",
"returnUrlButtonText": "<string>"
}
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({
name: '<string>',
description: '<string>',
value: 123,
pix: true,
creditCard: true,
boleto: true,
pixAutomatic: true,
installments: 123,
image: '<string>',
returnUrl: '<string>',
returnUrlButtonText: '<string>'
})
};
fetch('https://garu.com.br/api/products/{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://garu.com.br/api/products/{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([
'name' => '<string>',
'description' => '<string>',
'value' => 123,
'pix' => true,
'creditCard' => true,
'boleto' => true,
'pixAutomatic' => true,
'installments' => 123,
'image' => '<string>',
'returnUrl' => '<string>',
'returnUrlButtonText' => '<string>'
]),
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://garu.com.br/api/products/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"value\": 123,\n \"pix\": true,\n \"creditCard\": true,\n \"boleto\": true,\n \"pixAutomatic\": true,\n \"installments\": 123,\n \"image\": \"<string>\",\n \"returnUrl\": \"<string>\",\n \"returnUrlButtonText\": \"<string>\"\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://garu.com.br/api/products/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"value\": 123,\n \"pix\": true,\n \"creditCard\": true,\n \"boleto\": true,\n \"pixAutomatic\": true,\n \"installments\": 123,\n \"image\": \"<string>\",\n \"returnUrl\": \"<string>\",\n \"returnUrlButtonText\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/products/{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 \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"value\": 123,\n \"pix\": true,\n \"creditCard\": true,\n \"boleto\": true,\n \"pixAutomatic\": true,\n \"installments\": 123,\n \"image\": \"<string>\",\n \"returnUrl\": \"<string>\",\n \"returnUrlButtonText\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyProdutos
Atualizar Produto
Atualize os dados de um produto existente
PATCH
/
api
/
products
/
{id}
Atualizar Produto
curl --request PATCH \
--url https://garu.com.br/api/products/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"value": 123,
"pix": true,
"creditCard": true,
"boleto": true,
"pixAutomatic": true,
"installments": 123,
"image": "<string>",
"returnUrl": "<string>",
"returnUrlButtonText": "<string>"
}
'import requests
url = "https://garu.com.br/api/products/{id}"
payload = {
"name": "<string>",
"description": "<string>",
"value": 123,
"pix": True,
"creditCard": True,
"boleto": True,
"pixAutomatic": True,
"installments": 123,
"image": "<string>",
"returnUrl": "<string>",
"returnUrlButtonText": "<string>"
}
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({
name: '<string>',
description: '<string>',
value: 123,
pix: true,
creditCard: true,
boleto: true,
pixAutomatic: true,
installments: 123,
image: '<string>',
returnUrl: '<string>',
returnUrlButtonText: '<string>'
})
};
fetch('https://garu.com.br/api/products/{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://garu.com.br/api/products/{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([
'name' => '<string>',
'description' => '<string>',
'value' => 123,
'pix' => true,
'creditCard' => true,
'boleto' => true,
'pixAutomatic' => true,
'installments' => 123,
'image' => '<string>',
'returnUrl' => '<string>',
'returnUrlButtonText' => '<string>'
]),
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://garu.com.br/api/products/{id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"value\": 123,\n \"pix\": true,\n \"creditCard\": true,\n \"boleto\": true,\n \"pixAutomatic\": true,\n \"installments\": 123,\n \"image\": \"<string>\",\n \"returnUrl\": \"<string>\",\n \"returnUrlButtonText\": \"<string>\"\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://garu.com.br/api/products/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"value\": 123,\n \"pix\": true,\n \"creditCard\": true,\n \"boleto\": true,\n \"pixAutomatic\": true,\n \"installments\": 123,\n \"image\": \"<string>\",\n \"returnUrl\": \"<string>\",\n \"returnUrlButtonText\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/products/{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 \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"value\": 123,\n \"pix\": true,\n \"creditCard\": true,\n \"boleto\": true,\n \"pixAutomatic\": true,\n \"installments\": 123,\n \"image\": \"<string>\",\n \"returnUrl\": \"<string>\",\n \"returnUrlButtonText\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyVisão Geral
Use este endpoint para atualizar as informações de um produto existente. Apenas os campos enviados serão atualizados.Parâmetros de Path
ID do produto a ser atualizado.
Parâmetros do Body
Todos os campos são opcionais. Envie apenas os que deseja atualizar.Novo nome do produto.
Nova descrição do produto.
Novo preço do produto (mínimo R$ 5,00).
Habilitar/desabilitar pagamento via PIX.
Habilitar/desabilitar pagamento via cartão de crédito.
Habilitar/desabilitar pagamento via boleto.
Habilitar/desabilitar o Pix Automático (débito recorrente do Pix) no produto.
Novo número máximo de parcelas (1-12).
Nova URL da imagem do produto.
Nova URL de retorno após pagamento.
Novo texto do botão de retorno.
Exemplo de Requisição
curl -X PATCH https://garu.com.br/api/products/123 \
-H "Authorization: Bearer sk_test_sua_chave_api" \
-H "Content-Type: application/json" \
-d '{
"value": 347.00,
"installments": 6
}'
const response = await fetch('https://garu.com.br/api/products/123', {
method: 'PATCH',
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
value: 347.00,
installments: 6
})
});
const product = await response.json();
console.log(`Produto atualizado: ${product.name} - R$ ${product.value}`);
import requests
import os
url = "https://garu.com.br/api/products/123"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}",
"Content-Type": "application/json"
}
payload = {
"value": 347.00,
"installments": 6
}
response = requests.patch(url, json=payload, headers=headers)
product = response.json()
print(f"Produto atualizado: {product['name']} - R$ {product['value']}")
Resposta de Sucesso (200 OK)
{
"id": 123,
"name": "Curso de Marketing Digital",
"description": "Aprenda marketing digital do zero ao avançado",
"value": 347.00,
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"pix": true,
"creditCard": true,
"boleto": true,
"installments": [
{ "quantity": 1, "value": 347.00 },
{ "quantity": 2, "value": 179.32 },
{ "quantity": 3, "value": 122.61 },
{ "quantity": 4, "value": 94.28 },
{ "quantity": 5, "value": 77.30 },
{ "quantity": 6, "value": 66.05 }
],
"isActive": true,
"createdAt": "2024-12-24T10:30:00.000Z",
"updatedAt": "2024-12-24T14:45:00.000Z"
}
O
uuid do produto não muda ao atualizar. O link de pagamento permanece o mesmo.Erros Comuns
404 - Produto não encontrado
404 - Produto não encontrado
{
"statusCode": 404,
"message": "Product not found"
}
403 - Sem permissão
403 - Sem permissão
{
"statusCode": 403,
"message": "Insufficient permissions"
}
Próximos Passos
Excluir Produto
Desative um produto
Webhooks
Receba notificações de eventos
Was this page helpful?
⌘I