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_bodyCriar nova assinatura
Criar nova assinatura na sua conta conectando um Cliente e um Preço existentes
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_bodyAuthorizations
A chave de API usada para autenticar a requisição e identificar a sua conta.
Exemplo: Authorization: ApiKey my-secure-key
Body
Dados da assinatura que será criada
Show child attributes
Show child attributes
Response
Operação realizada com sucesso
ID único da assinatura, no formato TypeID com prefixo sub_.
^sub_[0-9a-z]{26}$"sub_01h455vb4pex5vsknk084sn02s"
Indica ambiente de produção (true) ou sandbox (false). Dados de sandbox são limpos periodicamente.
true
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.
pending, active, inactive, suspended "active"
Data de início da assinatura (timestamp Unix).
1764039600
Método de pagamento da assinatura:
- card: Cartão de crédito.
- pix: Pagamento instantâneo via PIX.
- null: Ainda não definido até a confirmação do primeiro pagamento.
card, pix null
Quantidade de parcelas para cobrança no cartão de crédito. Valor 1 indica pagamento à vista.
1 <= x <= 121
ID do cliente associado, no formato TypeID com prefixo cus_.
^cus_[0-9a-z]{26}$"cus_01h455vb4pex5vsknk084sn02p"
Show child attributes
Show child attributes
Tipo do objeto. Sempre 'subscription'.
subscription "subscription"
Código externo para integração com outros sistemas.
"ACCOUNT-SUB-XYZ"
Data de término da assinatura (timestamp Unix). Null se ainda ativa.
1795575600
Data de referência para o ciclo de cobrança (timestamp Unix).
1764039600
Início do período atual (timestamp Unix). null se a assinatura ainda não iniciou seu primeiro ciclo.
1764039600
ID da última fatura gerada, no formato TypeID com prefixo in_.
"in_01h455vb4pex5vsknk084sn02q"
Data de criação da assinatura (timestamp Unix).
1764040287
Show child attributes
Show child attributes

