curl --request POST \
--url https://api.cakto.com.br/public_api/subscriptions/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parent_order_id": "<string>"
}
'import requests
url = "https://api.cakto.com.br/public_api/subscriptions/"
payload = { "parent_order_id": "<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({parent_order_id: '<string>'})
};
fetch('https://api.cakto.com.br/public_api/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://api.cakto.com.br/public_api/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([
'parent_order_id' => '<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;
}require 'uri'
require 'net/http'
url = URI("https://api.cakto.com.br/public_api/subscriptions/")
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 \"parent_order_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyHttpResponse<String> response = Unirest.post("https://api.cakto.com.br/public_api/subscriptions/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parent_order_id\": \"<string>\"\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.cakto.com.br/public_api/subscriptions/");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"parent_order_id\": \"<string>\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"amount": "<string>",
"parent_order": "<string>",
"paymentMethod": "<string>",
"customer": "<string>",
"product": "<string>",
"offer": "<string>",
"orders": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"status": "active",
"current_period": -1,
"recurrence_period": -1,
"quantity_recurrences": -1,
"trial_days": -1,
"max_retries": -1,
"retry_interval": -1,
"paid_payments_quantity": -1,
"retention": "<string>",
"next_payment_date": "2023-11-07T05:31:56Z",
"canceledAt": "2023-11-07T05:31:56Z"
}{
"amount": "<string>",
"parent_order": "<string>",
"paymentMethod": "<string>",
"customer": "<string>",
"product": "<string>",
"offer": "<string>",
"orders": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"status": "active",
"current_period": -1,
"recurrence_period": -1,
"quantity_recurrences": -1,
"trial_days": -1,
"max_retries": -1,
"retry_interval": -1,
"paid_payments_quantity": -1,
"retention": "<string>",
"next_payment_date": "2023-11-07T05:31:56Z",
"canceledAt": "2023-11-07T05:31:56Z"
}{
"detail": "<string>"
}{
"detail": "As credenciais de autenticação não foram fornecidas."
}Criar Assinatura
Cria assinatura a partir de um pedido pai
curl --request POST \
--url https://api.cakto.com.br/public_api/subscriptions/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"parent_order_id": "<string>"
}
'import requests
url = "https://api.cakto.com.br/public_api/subscriptions/"
payload = { "parent_order_id": "<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({parent_order_id: '<string>'})
};
fetch('https://api.cakto.com.br/public_api/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://api.cakto.com.br/public_api/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([
'parent_order_id' => '<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;
}require 'uri'
require 'net/http'
url = URI("https://api.cakto.com.br/public_api/subscriptions/")
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 \"parent_order_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyHttpResponse<String> response = Unirest.post("https://api.cakto.com.br/public_api/subscriptions/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"parent_order_id\": \"<string>\"\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://api.cakto.com.br/public_api/subscriptions/");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"parent_order_id\": \"<string>\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"amount": "<string>",
"parent_order": "<string>",
"paymentMethod": "<string>",
"customer": "<string>",
"product": "<string>",
"offer": "<string>",
"orders": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"status": "active",
"current_period": -1,
"recurrence_period": -1,
"quantity_recurrences": -1,
"trial_days": -1,
"max_retries": -1,
"retry_interval": -1,
"paid_payments_quantity": -1,
"retention": "<string>",
"next_payment_date": "2023-11-07T05:31:56Z",
"canceledAt": "2023-11-07T05:31:56Z"
}{
"amount": "<string>",
"parent_order": "<string>",
"paymentMethod": "<string>",
"customer": "<string>",
"product": "<string>",
"offer": "<string>",
"orders": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"status": "active",
"current_period": -1,
"recurrence_period": -1,
"quantity_recurrences": -1,
"trial_days": -1,
"max_retries": -1,
"retry_interval": -1,
"paid_payments_quantity": -1,
"retention": "<string>",
"next_payment_date": "2023-11-07T05:31:56Z",
"canceledAt": "2023-11-07T05:31:56Z"
}{
"detail": "<string>"
}{
"detail": "As credenciais de autenticação não foram fornecidas."
}Escopo
write subscriptions
Request
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
parent_order_id | string | Sim | ID do pedido de origem da assinatura |
Response
201: Assinatura criada.200: Pedido já possui assinatura (retorna assinatura existente).
Pré-condições
- O pedido informado deve existir.
- O pedido deve ser do tipo
subscription. - O pedido precisa ter oferta de assinatura.
Erros
400:parent_order_idausente.400: pedido não é de assinatura.400: pedido sem oferta, cliente, produto ou método de pagamento associado.404: pedido não encontrado ou não pertence à sua conta.
Authorizations
Token de autenticação do tipo Bearer {access_token}, onde {access_token} é o token obtido no fluxo de autenticação.
Body
Identificador do pedido pai usado para criar a assinatura
Response
Valor da Assinatura
^-?\d{0,8}(?:\.\d{0,2})?$Pedido de Origem da Assinatura
Método de pagamento utilizado na Assinatura
Produto vendido na Assinatura
Oferta vendida na Assinatura
Identificador único do pedido no sistema
Data e hora de criação
Data e hora da última atualização
Identificador único da Assinatura no sistema
255Status da Assinatura
active- Ativainactive- Inativacanceled- Canceladaexpired- Expiradapaused- Pausadatrial- Em período de teste
active, inactive, canceled, expired, paused, trial Número da recorrência atual. (ex: 1 = primeiro pagamento)
-2147483648 <= x <= 2147483647Quantidade de dias entre cada pagamento da assinatura
-2147483648 <= x <= 2147483647Quantidade vezes que a assinatura será cobrada
-2147483648 <= x <= 2147483647Quantidade de dias de teste gratuito da assinatura
-2147483648 <= x <= 2147483647Quantidade máxima de retentativas de cobrança em caso de falha
-2147483648 <= x <= 2147483647Intervalo entre retentativas de cobrança (dias)
-2147483648 <= x <= 2147483647Quantidade de pagamentos pagos para esta assinatura
-2147483648 <= x <= 2147483647Quantidade de tempo que a assinatura permaneceu ativa
Data e hora estimada do próximo pagamento
Data e hora em que a assinatura foi cancelada
Was this page helpful?