curl --request POST \
--url https://api.abacatepay.com/v2/subscriptions/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": "prod-1234",
"quantity": 1
}
],
"customerId": "cust_abc123xyz",
"methods": [
"CARD"
]
}
'import requests
url = "https://api.abacatepay.com/v2/subscriptions/create"
payload = {
"items": [
{
"id": "prod-1234",
"quantity": 1
}
],
"customerId": "cust_abc123xyz",
"methods": ["CARD"]
}
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({
items: [{id: 'prod-1234', quantity: 1}],
customerId: 'cust_abc123xyz',
methods: ['CARD']
})
};
fetch('https://api.abacatepay.com/v2/subscriptions/create', 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.abacatepay.com/v2/subscriptions/create",
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([
'items' => [
[
'id' => 'prod-1234',
'quantity' => 1
]
],
'customerId' => 'cust_abc123xyz',
'methods' => [
'CARD'
]
]),
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.abacatepay.com/v2/subscriptions/create"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": \"prod-1234\",\n \"quantity\": 1\n }\n ],\n \"customerId\": \"cust_abc123xyz\",\n \"methods\": [\n \"CARD\"\n ]\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.abacatepay.com/v2/subscriptions/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": \"prod-1234\",\n \"quantity\": 1\n }\n ],\n \"customerId\": \"cust_abc123xyz\",\n \"methods\": [\n \"CARD\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.abacatepay.com/v2/subscriptions/create")
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 \"items\": [\n {\n \"id\": \"prod-1234\",\n \"quantity\": 1\n }\n ],\n \"customerId\": \"cust_abc123xyz\",\n \"methods\": [\n \"CARD\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "bill_abc123xyz",
"externalId": "pedido-123",
"url": "https://app.abacatepay.com/pay/bill_abc123xyz",
"amount": 10000,
"paidAmount": null,
"items": [
{
"id": "prod_456",
"quantity": 2
}
],
"status": "PENDING",
"coupons": [],
"devMode": false,
"customerId": null,
"returnUrl": null,
"completionUrl": null,
"receiptUrl": null,
"upSellProductId": "prod_bump456xyz",
"installmentsCount": 3,
"card": {
"maxInstallments": 12,
"passFeesToCustomer": false
},
"customerFee": null,
"dueDate": "2026-08-15",
"interest": {
"value": 100
},
"fine": {
"value": 200,
"type": "PERCENTAGE"
},
"metadata": {},
"createdAt": "2024-11-04T18:38:28.573Z",
"updatedAt": "2024-11-04T18:38:28.573Z"
},
"error": null,
"success": true
}{
"error": "Token de autenticação inválido ou ausente."
}Criar checkout de assinatura
Cria um Checkout de assinatura — uma página de pagamento igual ao Checkout comum, mas para cobrança recorrente.
Aceita os mesmos parâmetros do Checkout (returnUrl, completionUrl, customerId, externalId, metadata, coupons, methods). O Checkout de assinatura aceita apenas um produto; o ciclo (frequência) já deve estar definido no produto ao criá-lo na loja — não é enviado no checkout.
curl --request POST \
--url https://api.abacatepay.com/v2/subscriptions/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": "prod-1234",
"quantity": 1
}
],
"customerId": "cust_abc123xyz",
"methods": [
"CARD"
]
}
'import requests
url = "https://api.abacatepay.com/v2/subscriptions/create"
payload = {
"items": [
{
"id": "prod-1234",
"quantity": 1
}
],
"customerId": "cust_abc123xyz",
"methods": ["CARD"]
}
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({
items: [{id: 'prod-1234', quantity: 1}],
customerId: 'cust_abc123xyz',
methods: ['CARD']
})
};
fetch('https://api.abacatepay.com/v2/subscriptions/create', 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.abacatepay.com/v2/subscriptions/create",
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([
'items' => [
[
'id' => 'prod-1234',
'quantity' => 1
]
],
'customerId' => 'cust_abc123xyz',
'methods' => [
'CARD'
]
]),
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.abacatepay.com/v2/subscriptions/create"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": \"prod-1234\",\n \"quantity\": 1\n }\n ],\n \"customerId\": \"cust_abc123xyz\",\n \"methods\": [\n \"CARD\"\n ]\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.abacatepay.com/v2/subscriptions/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": \"prod-1234\",\n \"quantity\": 1\n }\n ],\n \"customerId\": \"cust_abc123xyz\",\n \"methods\": [\n \"CARD\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.abacatepay.com/v2/subscriptions/create")
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 \"items\": [\n {\n \"id\": \"prod-1234\",\n \"quantity\": 1\n }\n ],\n \"customerId\": \"cust_abc123xyz\",\n \"methods\": [\n \"CARD\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "bill_abc123xyz",
"externalId": "pedido-123",
"url": "https://app.abacatepay.com/pay/bill_abc123xyz",
"amount": 10000,
"paidAmount": null,
"items": [
{
"id": "prod_456",
"quantity": 2
}
],
"status": "PENDING",
"coupons": [],
"devMode": false,
"customerId": null,
"returnUrl": null,
"completionUrl": null,
"receiptUrl": null,
"upSellProductId": "prod_bump456xyz",
"installmentsCount": 3,
"card": {
"maxInstallments": 12,
"passFeesToCustomer": false
},
"customerFee": null,
"dueDate": "2026-08-15",
"interest": {
"value": 100
},
"fine": {
"value": 200,
"type": "PERCENTAGE"
},
"metadata": {},
"createdAt": "2024-11-04T18:38:28.573Z",
"updatedAt": "2024-11-04T18:38:28.573Z"
},
"error": null,
"success": true
}{
"error": "Token de autenticação inválido ou ausente."
}bill_...). Depois que o cliente paga na url da resposta, a assinatura (subs_...) passa a existir.
SUBSCRIPTION:CREATE.Entenda as assinaturas
{
"items": [
{ "id": "prod_abc123xyz", "quantity": 1 }
],
"customerId": "cust_abc123xyz",
"externalId": "assinatura-123",
"completionUrl": "https://seusite.com/sucesso",
"methods": ["CARD"],
"retryPolicy": {
"maxRetry": 3,
"retryEvery": 2
}
}
{
"items": [
{ "id": "prod_abc123xyz", "quantity": 1 }
],
"customerId": "cust_abc123xyz",
"methods": ["PIX"]
}
Erros
error | Causa |
|---|---|
No products found | Nenhum produto de items foi encontrado. |
No subscription product with cycle found for billing | Nenhum produto de items tem cycle. |
Subscription checkout: every item must have a billing cycle | Algum produto de items não tem cycle. |
All products in a subscription checkout must share the same billing cycle | Os produtos de items têm ciclos diferentes. |
Multiple products are not available for subscription checkouts on this store | Mais de um produto em items, sem a liberação na conta. |
PIX Automático is not available for this store | PIX em methods, sem o Pix Automático liberado. |
Subscription is not available for this store | A conta não tem assinaturas liberadas em produção. |
Subscription checkouts do not support card installments | card.maxInstallments maior que 1. |
card.passFeesToCustomer is not available for subscriptions | card.passFeesToCustomer: true. |
Authorizations
Todas as requisições devem incluir sua chave de API no header Authorization usando o formato Bearer <abacatepay-api-key>. Sem esse header a requisição será rejeitada.
Saiba mais sobre como criar e usar chaves de API na documentação de autenticação.
Body
Mesmos parâmetros do Checkout, com items contendo exatamente um item (id e quantity).
O produto referenciado deve ter sido criado com ciclo de assinatura (frequency) na loja.
Data de vencimento do boleto no formato YYYY-MM-DD (ex: "2026-08-15"). Opcional. Só é válido quando methods inclui BOLETO; ignorado nos demais métodos.
Se omitido, o vencimento padrão é de 3 dias úteis. Não pode ser data no passado. Máximo de 365 dias no futuro.
"2026-08-15"
Was this page helpful?