curl --request POST \
--url https://api-sandbox.beinfi.com/products \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"key": "<string>",
"description": "<string>",
"currency": "BRL",
"basePrice": "<string>"
}
'import requests
url = "https://api-sandbox.beinfi.com/products"
payload = {
"name": "<string>",
"key": "<string>",
"description": "<string>",
"currency": "BRL",
"basePrice": "<string>"
}
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({
name: '<string>',
key: '<string>',
description: '<string>',
currency: 'BRL',
basePrice: '<string>'
})
};
fetch('https://api-sandbox.beinfi.com/products', 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-sandbox.beinfi.com/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' => '<string>',
'key' => '<string>',
'description' => '<string>',
'currency' => 'BRL',
'basePrice' => '<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://api-sandbox.beinfi.com/products"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"key\": \"<string>\",\n \"description\": \"<string>\",\n \"currency\": \"BRL\",\n \"basePrice\": \"<string>\"\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-sandbox.beinfi.com/products")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"key\": \"<string>\",\n \"description\": \"<string>\",\n \"currency\": \"BRL\",\n \"basePrice\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/products")
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 \"name\": \"<string>\",\n \"key\": \"<string>\",\n \"description\": \"<string>\",\n \"currency\": \"BRL\",\n \"basePrice\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"product": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "<string>",
"name": "<string>",
"type": "agent",
"description": "<string>",
"pricingModel": "subscription",
"currency": "BRL",
"status": "active",
"imageUrl": "<string>",
"requiresShipping": true,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"version": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"productId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"billingCycle": "weekly",
"basePrice": "<string>",
"status": "draft",
"isDefault": true,
"publishedAt": "2023-11-07T05:31:56Z",
"commitmentAmount": "<string>",
"commitmentResets": true,
"consumptionFloor": "<string>",
"grants": [
{
"meter": "<string>",
"amount": "<string>",
"on": "cycle"
}
]
}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>",
"metadata": {}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Create a product
Creates the product together with version 1 in draft. To sell it, publish that version with POST /products/{productID}/versions/{versionID}/publish.
With a key, the call is idempotent: if the key already exists you get the product it identifies (with name and description updated to what you sent) instead of an error. Pricing is not part of that update: if basePrice or billingCycle differ from the current version, the response is 422 pricing_immutable. To change the price, create a new version with POST /products/{productID}/versions. A request that sends no pricing leaves pricing alone.
curl --request POST \
--url https://api-sandbox.beinfi.com/products \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"key": "<string>",
"description": "<string>",
"currency": "BRL",
"basePrice": "<string>"
}
'import requests
url = "https://api-sandbox.beinfi.com/products"
payload = {
"name": "<string>",
"key": "<string>",
"description": "<string>",
"currency": "BRL",
"basePrice": "<string>"
}
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({
name: '<string>',
key: '<string>',
description: '<string>',
currency: 'BRL',
basePrice: '<string>'
})
};
fetch('https://api-sandbox.beinfi.com/products', 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-sandbox.beinfi.com/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' => '<string>',
'key' => '<string>',
'description' => '<string>',
'currency' => 'BRL',
'basePrice' => '<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://api-sandbox.beinfi.com/products"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"key\": \"<string>\",\n \"description\": \"<string>\",\n \"currency\": \"BRL\",\n \"basePrice\": \"<string>\"\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-sandbox.beinfi.com/products")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"key\": \"<string>\",\n \"description\": \"<string>\",\n \"currency\": \"BRL\",\n \"basePrice\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/products")
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 \"name\": \"<string>\",\n \"key\": \"<string>\",\n \"description\": \"<string>\",\n \"currency\": \"BRL\",\n \"basePrice\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"product": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "<string>",
"name": "<string>",
"type": "agent",
"description": "<string>",
"pricingModel": "subscription",
"currency": "BRL",
"status": "active",
"imageUrl": "<string>",
"requiresShipping": true,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z"
},
"version": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"productId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"version": 123,
"billingCycle": "weekly",
"basePrice": "<string>",
"status": "draft",
"isDefault": true,
"publishedAt": "2023-11-07T05:31:56Z",
"commitmentAmount": "<string>",
"commitmentResets": true,
"consumptionFloor": "<string>",
"grants": [
{
"meter": "<string>",
"amount": "<string>",
"on": "cycle"
}
]
}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>",
"metadata": {}
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Authorizations
Your account's secret key: Authorization: Bearer sk_test_… or sk_live_…. Server-side only.
Headers
A unique key per operation (a UUID works). Retrying with the same key returns the original response.
Body
subscription, one_time, usage or prepaid.
subscription, one_time, usage, prepaid Stable product key, unique in your account. Creating twice with the same key returns the same product; pricing different from the current version is refused with 422 pricing_immutable.
item (default) or agent.
agent, item 3-letter ISO 4217 code. Default: BRL.
"BRL"
weekly, monthly or annual. Required for subscription and prepaid; omit it for other models.
weekly, monthly, annual, null Version 1's base price, as a decimal string ("49.90").
Response
Product created (or the existing product with the same key).