Analytics
Get Collections Failure Breakdown
Currently-failing invoices grouped by their last failure code, ranked by money at risk.
GET
/
v1
/
analytics
/
collections
/
failures
Failure-reason breakdown by money at risk
curl --request GET \
--url https://billing.example.com/v1/analytics/collections/failures \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/analytics/collections/failures"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://billing.example.com/v1/analytics/collections/failures', 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://billing.example.com/v1/analytics/collections/failures",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/analytics/collections/failures"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://billing.example.com/v1/analytics/collections/failures")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/analytics/collections/failures")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"error_code": "<string>",
"count": 123,
"amount_at_risk": 123
}
]
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}Groups the invoices currently in collections by the failure code of their last payment attempt, ranked by the amount of billed revenue at risk. Amounts are FX-normalized to the reporting currency, in minor units. Responses are cached for up to 5 minutes.
Example Request
curl "https://api.recurso.dev/v1/analytics/collections/failures" \
-H "Authorization: Bearer $API_KEY"
Response
{
"data": [
{
"error_code": "insufficient_funds",
"count": 34,
"amount_at_risk": 412000
},
{
"error_code": "card_expired",
"count": 12,
"amount_at_risk": 168500
},
{
"error_code": "do_not_honor",
"count": 5,
"amount_at_risk": 74900
}
]
}
Response Fields
| Field | Type | Description |
|---|---|---|
error_code | string | The failure code from the invoice’s last payment attempt |
count | integer | Number of currently-failing invoices with this failure code |
amount_at_risk | integer | Billed revenue at risk, FX-normalized to the reporting currency, minor units |
Pair this with the collections funnel to see how much of the at-risk revenue is ultimately recovered.
⌘I
Failure-reason breakdown by money at risk
curl --request GET \
--url https://billing.example.com/v1/analytics/collections/failures \
--header 'Authorization: Bearer <token>'import requests
url = "https://billing.example.com/v1/analytics/collections/failures"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://billing.example.com/v1/analytics/collections/failures', 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://billing.example.com/v1/analytics/collections/failures",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/analytics/collections/failures"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://billing.example.com/v1/analytics/collections/failures")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/analytics/collections/failures")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{
"error_code": "<string>",
"count": 123,
"amount_at_risk": 123
}
]
}{
"error": {
"code": "validation_failed",
"message": "<string>"
}
}