curl --request POST \
--url https://api.abacatepay.com/v1/billing/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"frequency": "ONE_TIME",
"methods": [
"PIX",
"CARD"
],
"products": [
{
"externalId": "prod-1234",
"name": "Assinatura de Programa Fitness",
"description": "Acesso ao programa fitness premium por 1 mês.",
"quantity": 2,
"price": 2000
}
],
"returnUrl": "https://example.com/billing",
"completionUrl": "https://example.com/completion",
"customerId": "cust_abcdefghij",
"allowCoupons": false,
"coupons": [
"ABKT10",
"ABKT5",
"PROMO10"
],
"externalId": "seu_id_123",
"metadata": {
"externalId": "123"
}
}
'import requests
url = "https://api.abacatepay.com/v1/billing/create"
payload = {
"frequency": "ONE_TIME",
"methods": ["PIX", "CARD"],
"products": [
{
"externalId": "prod-1234",
"name": "Assinatura de Programa Fitness",
"description": "Acesso ao programa fitness premium por 1 mês.",
"quantity": 2,
"price": 2000
}
],
"returnUrl": "https://example.com/billing",
"completionUrl": "https://example.com/completion",
"customerId": "cust_abcdefghij",
"allowCoupons": False,
"coupons": ["ABKT10", "ABKT5", "PROMO10"],
"externalId": "seu_id_123",
"metadata": { "externalId": "123" }
}
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({
frequency: 'ONE_TIME',
methods: ['PIX', 'CARD'],
products: [
{
externalId: 'prod-1234',
name: 'Assinatura de Programa Fitness',
description: 'Acesso ao programa fitness premium por 1 mês.',
quantity: 2,
price: 2000
}
],
returnUrl: 'https://example.com/billing',
completionUrl: 'https://example.com/completion',
customerId: 'cust_abcdefghij',
allowCoupons: false,
coupons: ['ABKT10', 'ABKT5', 'PROMO10'],
externalId: 'seu_id_123',
metadata: {externalId: '123'}
})
};
fetch('https://api.abacatepay.com/v1/billing/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/v1/billing/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([
'frequency' => 'ONE_TIME',
'methods' => [
'PIX',
'CARD'
],
'products' => [
[
'externalId' => 'prod-1234',
'name' => 'Assinatura de Programa Fitness',
'description' => 'Acesso ao programa fitness premium por 1 mês.',
'quantity' => 2,
'price' => 2000
]
],
'returnUrl' => 'https://example.com/billing',
'completionUrl' => 'https://example.com/completion',
'customerId' => 'cust_abcdefghij',
'allowCoupons' => false,
'coupons' => [
'ABKT10',
'ABKT5',
'PROMO10'
],
'externalId' => 'seu_id_123',
'metadata' => [
'externalId' => '123'
]
]),
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/v1/billing/create"
payload := strings.NewReader("{\n \"frequency\": \"ONE_TIME\",\n \"methods\": [\n \"PIX\",\n \"CARD\"\n ],\n \"products\": [\n {\n \"externalId\": \"prod-1234\",\n \"name\": \"Assinatura de Programa Fitness\",\n \"description\": \"Acesso ao programa fitness premium por 1 mês.\",\n \"quantity\": 2,\n \"price\": 2000\n }\n ],\n \"returnUrl\": \"https://example.com/billing\",\n \"completionUrl\": \"https://example.com/completion\",\n \"customerId\": \"cust_abcdefghij\",\n \"allowCoupons\": false,\n \"coupons\": [\n \"ABKT10\",\n \"ABKT5\",\n \"PROMO10\"\n ],\n \"externalId\": \"seu_id_123\",\n \"metadata\": {\n \"externalId\": \"123\"\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/v1/billing/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"frequency\": \"ONE_TIME\",\n \"methods\": [\n \"PIX\",\n \"CARD\"\n ],\n \"products\": [\n {\n \"externalId\": \"prod-1234\",\n \"name\": \"Assinatura de Programa Fitness\",\n \"description\": \"Acesso ao programa fitness premium por 1 mês.\",\n \"quantity\": 2,\n \"price\": 2000\n }\n ],\n \"returnUrl\": \"https://example.com/billing\",\n \"completionUrl\": \"https://example.com/completion\",\n \"customerId\": \"cust_abcdefghij\",\n \"allowCoupons\": false,\n \"coupons\": [\n \"ABKT10\",\n \"ABKT5\",\n \"PROMO10\"\n ],\n \"externalId\": \"seu_id_123\",\n \"metadata\": {\n \"externalId\": \"123\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.abacatepay.com/v1/billing/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 \"frequency\": \"ONE_TIME\",\n \"methods\": [\n \"PIX\",\n \"CARD\"\n ],\n \"products\": [\n {\n \"externalId\": \"prod-1234\",\n \"name\": \"Assinatura de Programa Fitness\",\n \"description\": \"Acesso ao programa fitness premium por 1 mês.\",\n \"quantity\": 2,\n \"price\": 2000\n }\n ],\n \"returnUrl\": \"https://example.com/billing\",\n \"completionUrl\": \"https://example.com/completion\",\n \"customerId\": \"cust_abcdefghij\",\n \"allowCoupons\": false,\n \"coupons\": [\n \"ABKT10\",\n \"ABKT5\",\n \"PROMO10\"\n ],\n \"externalId\": \"seu_id_123\",\n \"metadata\": {\n \"externalId\": \"123\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "bill_123456",
"url": "https://pay.abacatepay.com/bill-5678",
"status": "PENDING",
"devMode": true,
"methods": [
"PIX",
"CARD"
],
"products": [
{
"id": "prod_123456",
"externalId": "prod-1234",
"quantity": 2
}
],
"frequency": "ONE_TIME",
"amount": 4000,
"nextBilling": "null",
"customer": {
"id": "bill_123456",
"metadata": {
"name": "Daniel Lima",
"cellphone": "(11) 4002-8922",
"email": "daniel_lima@abacatepay.com",
"taxId": "123.456.789-01"
}
},
"allowCoupons": false,
"coupons": []
},
"error": null
}{
"error": "Token de autenticação inválido ou ausente."
}Criar uma nova cobrança
Permite que você crie um link de cobrança pro seu cliente pagar você.
curl --request POST \
--url https://api.abacatepay.com/v1/billing/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"frequency": "ONE_TIME",
"methods": [
"PIX",
"CARD"
],
"products": [
{
"externalId": "prod-1234",
"name": "Assinatura de Programa Fitness",
"description": "Acesso ao programa fitness premium por 1 mês.",
"quantity": 2,
"price": 2000
}
],
"returnUrl": "https://example.com/billing",
"completionUrl": "https://example.com/completion",
"customerId": "cust_abcdefghij",
"allowCoupons": false,
"coupons": [
"ABKT10",
"ABKT5",
"PROMO10"
],
"externalId": "seu_id_123",
"metadata": {
"externalId": "123"
}
}
'import requests
url = "https://api.abacatepay.com/v1/billing/create"
payload = {
"frequency": "ONE_TIME",
"methods": ["PIX", "CARD"],
"products": [
{
"externalId": "prod-1234",
"name": "Assinatura de Programa Fitness",
"description": "Acesso ao programa fitness premium por 1 mês.",
"quantity": 2,
"price": 2000
}
],
"returnUrl": "https://example.com/billing",
"completionUrl": "https://example.com/completion",
"customerId": "cust_abcdefghij",
"allowCoupons": False,
"coupons": ["ABKT10", "ABKT5", "PROMO10"],
"externalId": "seu_id_123",
"metadata": { "externalId": "123" }
}
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({
frequency: 'ONE_TIME',
methods: ['PIX', 'CARD'],
products: [
{
externalId: 'prod-1234',
name: 'Assinatura de Programa Fitness',
description: 'Acesso ao programa fitness premium por 1 mês.',
quantity: 2,
price: 2000
}
],
returnUrl: 'https://example.com/billing',
completionUrl: 'https://example.com/completion',
customerId: 'cust_abcdefghij',
allowCoupons: false,
coupons: ['ABKT10', 'ABKT5', 'PROMO10'],
externalId: 'seu_id_123',
metadata: {externalId: '123'}
})
};
fetch('https://api.abacatepay.com/v1/billing/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/v1/billing/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([
'frequency' => 'ONE_TIME',
'methods' => [
'PIX',
'CARD'
],
'products' => [
[
'externalId' => 'prod-1234',
'name' => 'Assinatura de Programa Fitness',
'description' => 'Acesso ao programa fitness premium por 1 mês.',
'quantity' => 2,
'price' => 2000
]
],
'returnUrl' => 'https://example.com/billing',
'completionUrl' => 'https://example.com/completion',
'customerId' => 'cust_abcdefghij',
'allowCoupons' => false,
'coupons' => [
'ABKT10',
'ABKT5',
'PROMO10'
],
'externalId' => 'seu_id_123',
'metadata' => [
'externalId' => '123'
]
]),
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/v1/billing/create"
payload := strings.NewReader("{\n \"frequency\": \"ONE_TIME\",\n \"methods\": [\n \"PIX\",\n \"CARD\"\n ],\n \"products\": [\n {\n \"externalId\": \"prod-1234\",\n \"name\": \"Assinatura de Programa Fitness\",\n \"description\": \"Acesso ao programa fitness premium por 1 mês.\",\n \"quantity\": 2,\n \"price\": 2000\n }\n ],\n \"returnUrl\": \"https://example.com/billing\",\n \"completionUrl\": \"https://example.com/completion\",\n \"customerId\": \"cust_abcdefghij\",\n \"allowCoupons\": false,\n \"coupons\": [\n \"ABKT10\",\n \"ABKT5\",\n \"PROMO10\"\n ],\n \"externalId\": \"seu_id_123\",\n \"metadata\": {\n \"externalId\": \"123\"\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/v1/billing/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"frequency\": \"ONE_TIME\",\n \"methods\": [\n \"PIX\",\n \"CARD\"\n ],\n \"products\": [\n {\n \"externalId\": \"prod-1234\",\n \"name\": \"Assinatura de Programa Fitness\",\n \"description\": \"Acesso ao programa fitness premium por 1 mês.\",\n \"quantity\": 2,\n \"price\": 2000\n }\n ],\n \"returnUrl\": \"https://example.com/billing\",\n \"completionUrl\": \"https://example.com/completion\",\n \"customerId\": \"cust_abcdefghij\",\n \"allowCoupons\": false,\n \"coupons\": [\n \"ABKT10\",\n \"ABKT5\",\n \"PROMO10\"\n ],\n \"externalId\": \"seu_id_123\",\n \"metadata\": {\n \"externalId\": \"123\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.abacatepay.com/v1/billing/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 \"frequency\": \"ONE_TIME\",\n \"methods\": [\n \"PIX\",\n \"CARD\"\n ],\n \"products\": [\n {\n \"externalId\": \"prod-1234\",\n \"name\": \"Assinatura de Programa Fitness\",\n \"description\": \"Acesso ao programa fitness premium por 1 mês.\",\n \"quantity\": 2,\n \"price\": 2000\n }\n ],\n \"returnUrl\": \"https://example.com/billing\",\n \"completionUrl\": \"https://example.com/completion\",\n \"customerId\": \"cust_abcdefghij\",\n \"allowCoupons\": false,\n \"coupons\": [\n \"ABKT10\",\n \"ABKT5\",\n \"PROMO10\"\n ],\n \"externalId\": \"seu_id_123\",\n \"metadata\": {\n \"externalId\": \"123\"\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "bill_123456",
"url": "https://pay.abacatepay.com/bill-5678",
"status": "PENDING",
"devMode": true,
"methods": [
"PIX",
"CARD"
],
"products": [
{
"id": "prod_123456",
"externalId": "prod-1234",
"quantity": 2
}
],
"frequency": "ONE_TIME",
"amount": 4000,
"nextBilling": "null",
"customer": {
"id": "bill_123456",
"metadata": {
"name": "Daniel Lima",
"cellphone": "(11) 4002-8922",
"email": "daniel_lima@abacatepay.com",
"taxId": "123.456.789-01"
}
},
"allowCoupons": false,
"coupons": []
},
"error": null
}{
"error": "Token de autenticação inválido ou ausente."
}Authorizations
Cabeçalho de autenticação Bearer no formato Bearer <abacatepay-api-key> onde <abacatepay-api-key> é a sua chave de API.
Body
Define o tipo de frequência da cobrança. Para cobranças únicas, use ONE_TIME. Para cobranças que podem ser pagas mais de uma vez, use MULTIPLE_PAYMENTS.
ONE_TIME, MULTIPLE_PAYMENTS "ONE_TIME"
Métodos de pagamento que serão utilizados. Aceita um ou mais: PIX e CARD
1 - 2 elementsPIX, CARD ["PIX", "CARD"]Lista de produtos que seu cliente está pagando.
1Show child attributes
Show child attributes
[
{
"externalId": "prod-1234",
"name": "Assinatura de Programa Fitness",
"description": "Acesso ao programa fitness premium por 1 mês.",
"quantity": 2,
"price": 2000
}
]URL para redirecionar o cliente caso o mesmo clique na opção "Voltar".
"https://example.com/billing"
URL para redirecionar o cliente quando o pagamento for concluído.
"https://example.com/completion"
O id de um cliente já cadastrado em sua loja.
"cust_abcdefghij"
Dados do seu cliente. Caso o cliente não exista ele será criado.
Show child attributes
Show child attributes
Se verdadeiro cupons podem ser usados na billing
false
Lista de cupons disponíveis para resem usados com a billing
50["ABKT10", "ABKT5", "PROMO10"]Caso você tenha um identificador único da sua aplicação para cobranças, completamente opcional.
"seu_id_123"
Metadados opcionais para a cobrança
Was this page helpful?