curl --request POST \
--url https://api-sandbox.beinfi.com/billing/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lineItems": [
{
"description": "<string>",
"amount": "<string>",
"quantity": "<string>",
"unitPrice": "<string>"
}
],
"currency": "<string>",
"dueDate": "2023-11-07T05:31:56Z",
"send": true,
"successUrl": "<string>",
"cancelUrl": "<string>"
}
'import requests
url = "https://api-sandbox.beinfi.com/billing/invoices"
payload = {
"payerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lineItems": [
{
"description": "<string>",
"amount": "<string>",
"quantity": "<string>",
"unitPrice": "<string>"
}
],
"currency": "<string>",
"dueDate": "2023-11-07T05:31:56Z",
"send": True,
"successUrl": "<string>",
"cancelUrl": "<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({
payerId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
lineItems: [
{
description: '<string>',
amount: '<string>',
quantity: '<string>',
unitPrice: '<string>'
}
],
currency: '<string>',
dueDate: '2023-11-07T05:31:56Z',
send: true,
successUrl: '<string>',
cancelUrl: '<string>'
})
};
fetch('https://api-sandbox.beinfi.com/billing/invoices', 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-sandbox.beinfi.com/billing/invoices",
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([
'payerId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'lineItems' => [
[
'description' => '<string>',
'amount' => '<string>',
'quantity' => '<string>',
'unitPrice' => '<string>'
]
],
'currency' => '<string>',
'dueDate' => '2023-11-07T05:31:56Z',
'send' => true,
'successUrl' => '<string>',
'cancelUrl' => '<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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.beinfi.com/billing/invoices"
payload := strings.NewReader("{\n \"payerId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"lineItems\": [\n {\n \"description\": \"<string>\",\n \"amount\": \"<string>\",\n \"quantity\": \"<string>\",\n \"unitPrice\": \"<string>\"\n }\n ],\n \"currency\": \"<string>\",\n \"dueDate\": \"2023-11-07T05:31:56Z\",\n \"send\": true,\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\"\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-sandbox.beinfi.com/billing/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payerId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"lineItems\": [\n {\n \"description\": \"<string>\",\n \"amount\": \"<string>\",\n \"quantity\": \"<string>\",\n \"unitPrice\": \"<string>\"\n }\n ],\n \"currency\": \"<string>\",\n \"dueDate\": \"2023-11-07T05:31:56Z\",\n \"send\": true,\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/billing/invoices")
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 \"payerId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"lineItems\": [\n {\n \"description\": \"<string>\",\n \"amount\": \"<string>\",\n \"quantity\": \"<string>\",\n \"unitPrice\": \"<string>\"\n }\n ],\n \"currency\": \"<string>\",\n \"dueDate\": \"2023-11-07T05:31:56Z\",\n \"send\": true,\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subscriptionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoiceNumber": "<string>",
"status": "draft",
"currency": "<string>",
"subtotal": "<string>",
"tax": "<string>",
"total": "<string>",
"amountDue": "<string>",
"periodStart": "2023-11-07T05:31:56Z",
"periodEnd": "2023-11-07T05:31:56Z",
"dueDate": "2023-11-07T05:31:56Z",
"finalizedAt": "2023-11-07T05:31:56Z",
"paidAt": "2023-11-07T05:31:56Z",
"successUrl": "<string>",
"cancelUrl": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"lineItems": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "usage",
"meterId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"priceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"quantity": "<string>",
"unitPrice": "<string>",
"amount": "<string>",
"proration": true
}
]
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Create a one-off invoice
Creates an invoice with free-form line items for a customer, with no subscription or product. It comes back open, ready to be paid at checkout. Send send: true to email it to the payer.
payerId is the customer id (customerId from POST /metering/customers), not a product enrollment id.
curl --request POST \
--url https://api-sandbox.beinfi.com/billing/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"payerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lineItems": [
{
"description": "<string>",
"amount": "<string>",
"quantity": "<string>",
"unitPrice": "<string>"
}
],
"currency": "<string>",
"dueDate": "2023-11-07T05:31:56Z",
"send": true,
"successUrl": "<string>",
"cancelUrl": "<string>"
}
'import requests
url = "https://api-sandbox.beinfi.com/billing/invoices"
payload = {
"payerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"lineItems": [
{
"description": "<string>",
"amount": "<string>",
"quantity": "<string>",
"unitPrice": "<string>"
}
],
"currency": "<string>",
"dueDate": "2023-11-07T05:31:56Z",
"send": True,
"successUrl": "<string>",
"cancelUrl": "<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({
payerId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
lineItems: [
{
description: '<string>',
amount: '<string>',
quantity: '<string>',
unitPrice: '<string>'
}
],
currency: '<string>',
dueDate: '2023-11-07T05:31:56Z',
send: true,
successUrl: '<string>',
cancelUrl: '<string>'
})
};
fetch('https://api-sandbox.beinfi.com/billing/invoices', 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-sandbox.beinfi.com/billing/invoices",
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([
'payerId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'lineItems' => [
[
'description' => '<string>',
'amount' => '<string>',
'quantity' => '<string>',
'unitPrice' => '<string>'
]
],
'currency' => '<string>',
'dueDate' => '2023-11-07T05:31:56Z',
'send' => true,
'successUrl' => '<string>',
'cancelUrl' => '<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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.beinfi.com/billing/invoices"
payload := strings.NewReader("{\n \"payerId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"lineItems\": [\n {\n \"description\": \"<string>\",\n \"amount\": \"<string>\",\n \"quantity\": \"<string>\",\n \"unitPrice\": \"<string>\"\n }\n ],\n \"currency\": \"<string>\",\n \"dueDate\": \"2023-11-07T05:31:56Z\",\n \"send\": true,\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\"\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-sandbox.beinfi.com/billing/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"payerId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"lineItems\": [\n {\n \"description\": \"<string>\",\n \"amount\": \"<string>\",\n \"quantity\": \"<string>\",\n \"unitPrice\": \"<string>\"\n }\n ],\n \"currency\": \"<string>\",\n \"dueDate\": \"2023-11-07T05:31:56Z\",\n \"send\": true,\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.beinfi.com/billing/invoices")
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 \"payerId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"lineItems\": [\n {\n \"description\": \"<string>\",\n \"amount\": \"<string>\",\n \"quantity\": \"<string>\",\n \"unitPrice\": \"<string>\"\n }\n ],\n \"currency\": \"<string>\",\n \"dueDate\": \"2023-11-07T05:31:56Z\",\n \"send\": true,\n \"successUrl\": \"<string>\",\n \"cancelUrl\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"payerId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"subscriptionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"invoiceNumber": "<string>",
"status": "draft",
"currency": "<string>",
"subtotal": "<string>",
"tax": "<string>",
"total": "<string>",
"amountDue": "<string>",
"periodStart": "2023-11-07T05:31:56Z",
"periodEnd": "2023-11-07T05:31:56Z",
"dueDate": "2023-11-07T05:31:56Z",
"finalizedAt": "2023-11-07T05:31:56Z",
"paidAt": "2023-11-07T05:31:56Z",
"successUrl": "<string>",
"cancelUrl": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"lineItems": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"type": "usage",
"meterId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"priceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"description": "<string>",
"quantity": "<string>",
"unitPrice": "<string>",
"amount": "<string>",
"proration": true
}
]
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"resource": "<string>"
}{
"message": "<string>",
"error_code": "internal_error",
"tracer_id": "<string>",
"errors": [
{
"field": "<string>",
"value": "<string>",
"constraint": "<string>",
"description": "<string>"
}
]
}Authorizations
Your account's secret key: Authorization: Bearer sk_test_… or sk_live_…. Server-side only.
Body
The paying customer's id (customerId from POST /metering/customers).
At least one line. Each needs a description and an amount (line total, as a decimal string); quantity (default 1) and unitPrice are optional.
1Show child attributes
Show child attributes
Currency, as an ISO 4217 code. Defaults to BRL.
Due date.
true emails the invoice to the payer as soon as it is created.
Where checkout sends the buyer after payment.
Where checkout sends the buyer if they back out.
Response
Created.
What a customer owes: line items, totals and status. Status: draft → open → paid, or void / uncollectible.
The customer's product enrollment id. Set on product, usage and subscription invoices.
The paying customer's id. Set on one-off invoices.
The subscription that generated the invoice
Sequential invoice number
draft (being built), open (issued, awaiting payment), paid, void (canceled) or uncollectible (written off).
draft, open, paid, void, uncollectible Currency, as an ISO 4217 code (BRL).
Sum of line items before tax and discounts.
Tax on the invoice.
The invoice's final amount.
How much is still owed.
Start of the billed period
End of the billed period
Due date.
When the invoice was issued.
When the invoice was paid.
Where checkout sends the buyer after payment.
Where checkout sends the buyer if they back out.
Show child attributes
Show child attributes