Criar um produto
curl --request POST \
--url https://api.valorapayments.com.br/v1/products \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Mentoria individual",
"description": "Uma hora de mentoria por videochamada.",
"type": "service",
"price": "149.90",
"external_reference": "sku-mentoria-1h"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Mentoria individual',
description: 'Uma hora de mentoria por videochamada.',
type: 'service',
price: '149.90',
external_reference: 'sku-mentoria-1h'
})
};
fetch('https://api.valorapayments.com.br/v1/products', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.valorapayments.com.br/v1/products"
payload = {
"name": "Mentoria individual",
"description": "Uma hora de mentoria por videochamada.",
"type": "service",
"price": "149.90",
"external_reference": "sku-mentoria-1h"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valorapayments.com.br/v1/products",
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([
'name' => 'Mentoria individual',
'description' => 'Uma hora de mentoria por videochamada.',
'type' => 'service',
'price' => '149.90',
'external_reference' => 'sku-mentoria-1h'
]),
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;
}{
"id": "prod_Xk2v9QeR7tLmN3bA",
"object": "product",
"name": "<string>",
"description": "<string>",
"type": "physical",
"status": "draft",
"images": [
"<string>"
],
"price": {
"amount": 14990,
"currency": "BRL"
},
"external_reference": "<string>",
"statement_description": "<string>",
"metadata": {
"order_id": "1001"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"archived_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "invalid_api_key",
"message": "Chave de API inválida ou revogada."
}
}{
"error": {
"type": "missing_scope",
"message": "A chave não tem o escopo necessário."
}
}{
"error": {
"type": "external_reference_in_use",
"message": "external_reference já usado."
}
}{
"error": {
"type": "invalid_request",
"message": "Corpo inválido.",
"details": {
"amount": [
"Valor inválido."
]
}
}
}{
"error": {
"type": "rate_limited",
"message": "Muitas requisições. Tente novamente em instantes."
}
}{
"error": {
"type": "service_unavailable",
"message": "Serviço temporariamente indisponível."
}
}Produtos
Criar um produto
Cadastra um produto. O preço do produto é a base de checkouts e de cobranças com product_id.
Escopo: products:write.
POST
/
v1
/
products
Criar um produto
curl --request POST \
--url https://api.valorapayments.com.br/v1/products \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Mentoria individual",
"description": "Uma hora de mentoria por videochamada.",
"type": "service",
"price": "149.90",
"external_reference": "sku-mentoria-1h"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Mentoria individual',
description: 'Uma hora de mentoria por videochamada.',
type: 'service',
price: '149.90',
external_reference: 'sku-mentoria-1h'
})
};
fetch('https://api.valorapayments.com.br/v1/products', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.valorapayments.com.br/v1/products"
payload = {
"name": "Mentoria individual",
"description": "Uma hora de mentoria por videochamada.",
"type": "service",
"price": "149.90",
"external_reference": "sku-mentoria-1h"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.valorapayments.com.br/v1/products",
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([
'name' => 'Mentoria individual',
'description' => 'Uma hora de mentoria por videochamada.',
'type' => 'service',
'price' => '149.90',
'external_reference' => 'sku-mentoria-1h'
]),
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;
}{
"id": "prod_Xk2v9QeR7tLmN3bA",
"object": "product",
"name": "<string>",
"description": "<string>",
"type": "physical",
"status": "draft",
"images": [
"<string>"
],
"price": {
"amount": 14990,
"currency": "BRL"
},
"external_reference": "<string>",
"statement_description": "<string>",
"metadata": {
"order_id": "1001"
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"archived_at": "2023-11-07T05:31:56Z"
}{
"error": {
"type": "invalid_api_key",
"message": "Chave de API inválida ou revogada."
}
}{
"error": {
"type": "missing_scope",
"message": "A chave não tem o escopo necessário."
}
}{
"error": {
"type": "external_reference_in_use",
"message": "external_reference já usado."
}
}{
"error": {
"type": "invalid_request",
"message": "Corpo inválido.",
"details": {
"amount": [
"Valor inválido."
]
}
}
}{
"error": {
"type": "rate_limited",
"message": "Muitas requisições. Tente novamente em instantes."
}
}{
"error": {
"type": "service_unavailable",
"message": "Serviço temporariamente indisponível."
}
}Autorizações
Corpo
application/json
Resposta
Produto criado.