Get Metrics
curl --request GET \
--url https://api.example.com/api/metricsimport requests
url = "https://api.example.com/api/metrics"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/metrics', 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.example.com/api/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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://api.example.com/api/metrics"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/metrics")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"period": {
"id": "<string>",
"start": "<string>",
"end": "<string>"
},
"flujo": {
"ingresos_cobrados": 123,
"egresos_pagados": 123,
"flujo_neto": 123,
"ingresos_cobrados_sin_conciliar": 123,
"egresos_pagados_sin_conciliar": 123
},
"devengado": {
"ingresos_devengados": 123,
"egresos_devengados": 123,
"resultado_devengado": 123
},
"impuestos": {
"iva_trasladado": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
},
"iva_acreditable": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
},
"retenciones_iva": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
},
"retenciones_isr": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
}
},
"pendientes": {
"por_cobrar": 123,
"por_pagar": 123
}
}Invoices
Get Metrics
Retrieve financial metrics for a specific period
GET
/
api
/
metrics
Get Metrics
curl --request GET \
--url https://api.example.com/api/metricsimport requests
url = "https://api.example.com/api/metrics"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/metrics', 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.example.com/api/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$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://api.example.com/api/metrics"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/metrics")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"period": {
"id": "<string>",
"start": "<string>",
"end": "<string>"
},
"flujo": {
"ingresos_cobrados": 123,
"egresos_pagados": 123,
"flujo_neto": 123,
"ingresos_cobrados_sin_conciliar": 123,
"egresos_pagados_sin_conciliar": 123
},
"devengado": {
"ingresos_devengados": 123,
"egresos_devengados": 123,
"resultado_devengado": 123
},
"impuestos": {
"iva_trasladado": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
},
"iva_acreditable": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
},
"retenciones_iva": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
},
"retenciones_isr": {
"cobrado": 123,
"devengado": 123,
"pagado": 123
}
},
"pendientes": {
"por_cobrar": 123,
"por_pagar": 123
}
}Authentication
This endpoint requires authentication. Include your access token in the Authorization header.Authorization: Bearer YOUR_ACCESS_TOKEN
Query Parameters
string
Filter metrics by profile ID
number
Month to retrieve metrics for (1-12)
number
Year to retrieve metrics for
string
Filter by tax regime code
Response
object
object
Cash flow metrics (base de flujo - actual payments)
Show Flujo
Show Flujo
number
Income collected (actual cash received)
number
Expenses paid (actual cash paid out)
number
Net cash flow (ingresos_cobrados - egresos_pagados)
number
Part of collected income from payment complements without related PPD invoice
number
Part of paid expenses from payment complements without related PPD expense
object
object
Tax metrics
Show Impuestos
Show Impuestos
object
object
object
object
Example Request
curl -X GET "https://api.contafy.com/api/metrics?profile_id=prof_123&mes=3&año=2026" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Example Response
{
"period": {
"id": "period_2026_03",
"start": "2026-03-01T00:00:00Z",
"end": "2026-03-31T23:59:59Z"
},
"flujo": {
"ingresos_cobrados": 150000.00,
"egresos_pagados": 80000.00,
"flujo_neto": 70000.00,
"ingresos_cobrados_sin_conciliar": 0,
"egresos_pagados_sin_conciliar": 0
},
"devengado": {
"ingresos_devengados": 200000.00,
"egresos_devengados": 100000.00,
"resultado_devengado": 100000.00
},
"impuestos": {
"iva_trasladado": {
"cobrado": 24000.00,
"devengado": 32000.00
},
"iva_acreditable": {
"pagado": 12800.00,
"devengado": 16000.00
},
"retenciones_iva": {
"cobrado": 1500.00,
"devengado": 2000.00
},
"retenciones_isr": {
"cobrado": 1000.00,
"devengado": 1333.33
}
},
"pendientes": {
"por_cobrar": 50000.00,
"por_pagar": 20000.00
}
}
Error Responses
{
"error": "Unauthorized",
"message": "Invalid or missing access token"
}
When the user has no subscription or no data for the specified period, the endpoint returns default metrics with all values set to zero.
{
"period": { "id": "", "start": "", "end": "" },
"flujo": {
"ingresos_cobrados": 0,
"egresos_pagados": 0,
"flujo_neto": 0
},
"devengado": {
"ingresos_devengados": 0,
"egresos_devengados": 0,
"resultado_devengado": 0
},
"impuestos": {
"iva_trasladado": {},
"iva_acreditable": {},
"retenciones_iva": {},
"retenciones_isr": {}
},
"pendientes": {
"por_cobrar": 0,
"por_pagar": 0
}
}
{
"error": "Internal Server Error",
"message": "An unexpected error occurred"
}
Notes
- Metrics are calculated based on two accounting methods:
- Flujo (Cash basis): Based on actual payment dates from payment complements
- Devengado (Accrual basis): Based on invoice dates
- Tax metrics include both collected/paid amounts and accrued amounts
- If no period parameters are provided, metrics for the current month are returned
- The endpoint handles missing data gracefully by returning zero values
⌘I