Criar nova assinatura
curl --request POST \
--url https://besimplo.com/api/v1/subscriptions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"subscription": {
"customer_id": "cus_01h455vb4pex5vsknk084sn02p",
"price_id": "price_01h455vb4pex5vsknk084sn02q",
"external_code": "ACCOUNT-SUB-XYZ",
"quantity": 1,
"discounts": [
{
"type": "percentage",
"amount": 500,
"percentage": 10,
"cycles": 3
}
]
}
}
'import requests
url = "https://besimplo.com/api/v1/subscriptions"
payload = { "subscription": {
"customer_id": "cus_01h455vb4pex5vsknk084sn02p",
"price_id": "price_01h455vb4pex5vsknk084sn02q",
"external_code": "ACCOUNT-SUB-XYZ",
"quantity": 1,
"discounts": [
{
"type": "percentage",
"amount": 500,
"percentage": 10,
"cycles": 3
}
]
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscription: {
customer_id: 'cus_01h455vb4pex5vsknk084sn02p',
price_id: 'price_01h455vb4pex5vsknk084sn02q',
external_code: 'ACCOUNT-SUB-XYZ',
quantity: 1,
discounts: [{type: 'percentage', amount: 500, percentage: 10, cycles: 3}]
}
})
};
fetch('https://besimplo.com/api/v1/subscriptions', 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://besimplo.com/api/v1/subscriptions",
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([
'subscription' => [
'customer_id' => 'cus_01h455vb4pex5vsknk084sn02p',
'price_id' => 'price_01h455vb4pex5vsknk084sn02q',
'external_code' => 'ACCOUNT-SUB-XYZ',
'quantity' => 1,
'discounts' => [
[
'type' => 'percentage',
'amount' => 500,
'percentage' => 10,
'cycles' => 3
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://besimplo.com/api/v1/subscriptions"
payload := strings.NewReader("{\n \"subscription\": {\n \"customer_id\": \"cus_01h455vb4pex5vsknk084sn02p\",\n \"price_id\": \"price_01h455vb4pex5vsknk084sn02q\",\n \"external_code\": \"ACCOUNT-SUB-XYZ\",\n \"quantity\": 1,\n \"discounts\": [\n {\n \"type\": \"percentage\",\n \"amount\": 500,\n \"percentage\": 10,\n \"cycles\": 3\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://besimplo.com/api/v1/subscriptions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscription\": {\n \"customer_id\": \"cus_01h455vb4pex5vsknk084sn02p\",\n \"price_id\": \"price_01h455vb4pex5vsknk084sn02q\",\n \"external_code\": \"ACCOUNT-SUB-XYZ\",\n \"quantity\": 1,\n \"discounts\": [\n {\n \"type\": \"percentage\",\n \"amount\": 500,\n \"percentage\": 10,\n \"cycles\": 3\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://besimplo.com/api/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscription\": {\n \"customer_id\": \"cus_01h455vb4pex5vsknk084sn02p\",\n \"price_id\": \"price_01h455vb4pex5vsknk084sn02q\",\n \"external_code\": \"ACCOUNT-SUB-XYZ\",\n \"quantity\": 1,\n \"discounts\": [\n {\n \"type\": \"percentage\",\n \"amount\": 500,\n \"percentage\": 10,\n \"cycles\": 3\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "sub_01h455vb4pex5vsknk084sn02s",
"object": "subscription",
"external_code": "ACCOUNT-SUB-XYZ",
"billing_cycle_anchor": 1764039600,
"created": 1764040287,
"customer": "cus_01h455vb4pex5vsknk084sn02p",
"payment_method_type": null,
"installments": 1,
"current_period_start": 1764039600,
"latest_invoice": "in_01h455vb4pex5vsknk084sn02q",
"discounts": {
"object": "list",
"data": [
{
"coupon": "sdi_01h455vb4pex5vsknk084sn02d"
}
]
},
"ended": null,
"item": {
"id": "si_01h455vb4pex5vsknk084sn02i",
"object": "subscription_item",
"created": 1764040287,
"current_period_end": 1766631600,
"current_period_start": 1764039600,
"price": {
"id": "price_01h455vb4pex5vsknk084sn02q",
"object": "price",
"active": true,
"created": 1764040287,
"currency": "brl",
"product": "prod_01h455vb4pex5vsknk084sn02q",
"type": "recurring",
"interval": "month",
"interval_count": 1,
"unit_amount": 50000,
"unit_amount_decimal": "50000",
"nickname": "Preço mensal básico"
},
"quantity": 1,
"subscription": "sub_01h455vb4pex5vsknk084sn02s"
},
"start_date": 1764039600,
"status": "pending"
}
Assinaturas
Criar nova assinatura
Criar nova assinatura na sua conta conectando um Cliente e um Preço existentes
POST
/
api
/
v1
/
subscriptions
Criar nova assinatura
curl --request POST \
--url https://besimplo.com/api/v1/subscriptions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"subscription": {
"customer_id": "cus_01h455vb4pex5vsknk084sn02p",
"price_id": "price_01h455vb4pex5vsknk084sn02q",
"external_code": "ACCOUNT-SUB-XYZ",
"quantity": 1,
"discounts": [
{
"type": "percentage",
"amount": 500,
"percentage": 10,
"cycles": 3
}
]
}
}
'import requests
url = "https://besimplo.com/api/v1/subscriptions"
payload = { "subscription": {
"customer_id": "cus_01h455vb4pex5vsknk084sn02p",
"price_id": "price_01h455vb4pex5vsknk084sn02q",
"external_code": "ACCOUNT-SUB-XYZ",
"quantity": 1,
"discounts": [
{
"type": "percentage",
"amount": 500,
"percentage": 10,
"cycles": 3
}
]
} }
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscription: {
customer_id: 'cus_01h455vb4pex5vsknk084sn02p',
price_id: 'price_01h455vb4pex5vsknk084sn02q',
external_code: 'ACCOUNT-SUB-XYZ',
quantity: 1,
discounts: [{type: 'percentage', amount: 500, percentage: 10, cycles: 3}]
}
})
};
fetch('https://besimplo.com/api/v1/subscriptions', 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://besimplo.com/api/v1/subscriptions",
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([
'subscription' => [
'customer_id' => 'cus_01h455vb4pex5vsknk084sn02p',
'price_id' => 'price_01h455vb4pex5vsknk084sn02q',
'external_code' => 'ACCOUNT-SUB-XYZ',
'quantity' => 1,
'discounts' => [
[
'type' => 'percentage',
'amount' => 500,
'percentage' => 10,
'cycles' => 3
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://besimplo.com/api/v1/subscriptions"
payload := strings.NewReader("{\n \"subscription\": {\n \"customer_id\": \"cus_01h455vb4pex5vsknk084sn02p\",\n \"price_id\": \"price_01h455vb4pex5vsknk084sn02q\",\n \"external_code\": \"ACCOUNT-SUB-XYZ\",\n \"quantity\": 1,\n \"discounts\": [\n {\n \"type\": \"percentage\",\n \"amount\": 500,\n \"percentage\": 10,\n \"cycles\": 3\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://besimplo.com/api/v1/subscriptions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscription\": {\n \"customer_id\": \"cus_01h455vb4pex5vsknk084sn02p\",\n \"price_id\": \"price_01h455vb4pex5vsknk084sn02q\",\n \"external_code\": \"ACCOUNT-SUB-XYZ\",\n \"quantity\": 1,\n \"discounts\": [\n {\n \"type\": \"percentage\",\n \"amount\": 500,\n \"percentage\": 10,\n \"cycles\": 3\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://besimplo.com/api/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscription\": {\n \"customer_id\": \"cus_01h455vb4pex5vsknk084sn02p\",\n \"price_id\": \"price_01h455vb4pex5vsknk084sn02q\",\n \"external_code\": \"ACCOUNT-SUB-XYZ\",\n \"quantity\": 1,\n \"discounts\": [\n {\n \"type\": \"percentage\",\n \"amount\": 500,\n \"percentage\": 10,\n \"cycles\": 3\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "sub_01h455vb4pex5vsknk084sn02s",
"object": "subscription",
"external_code": "ACCOUNT-SUB-XYZ",
"billing_cycle_anchor": 1764039600,
"created": 1764040287,
"customer": "cus_01h455vb4pex5vsknk084sn02p",
"payment_method_type": null,
"installments": 1,
"current_period_start": 1764039600,
"latest_invoice": "in_01h455vb4pex5vsknk084sn02q",
"discounts": {
"object": "list",
"data": [
{
"coupon": "sdi_01h455vb4pex5vsknk084sn02d"
}
]
},
"ended": null,
"item": {
"id": "si_01h455vb4pex5vsknk084sn02i",
"object": "subscription_item",
"created": 1764040287,
"current_period_end": 1766631600,
"current_period_start": 1764039600,
"price": {
"id": "price_01h455vb4pex5vsknk084sn02q",
"object": "price",
"active": true,
"created": 1764040287,
"currency": "brl",
"product": "prod_01h455vb4pex5vsknk084sn02q",
"type": "recurring",
"interval": "month",
"interval_count": 1,
"unit_amount": 50000,
"unit_amount_decimal": "50000",
"nickname": "Preço mensal básico"
},
"quantity": 1,
"subscription": "sub_01h455vb4pex5vsknk084sn02s"
},
"start_date": 1764039600,
"status": "pending"
}
Authorizations
Body
application/json
Dados da assinatura que será criada
Response
Operação realizada com sucesso
Status da assinatura:
- pending: Assinatura criada, aguardando primeiro pagamento.
- active: Primeiro pagamento confirmado. Assinatura ativa.
- inactive: Assinatura cancelada.
- suspended: Assinatura suspensa por falha de pagamento.
Available options:
pending, active, inactive, suspended Example:
"active"

