// Empezar
Numeración
Los rangos de numeración de cada establecimiento y de la cuenta, con su resolución, número actual, cuántos quedan y alertas.
/api/v1/company/{billing_account_id}/sequencesEn esta página
Cada documento toma su número de un rango: un prefijo y un intervalo de consecutivos. La factura, el documento soporte y sus notas usan rangos del establecimiento; la nómina y sus ajustes usan rangos de la cuenta (global_sequences).
Headers
| Header | Obligatorio | Valor |
|---|---|---|
nestfac-api-key |
Sí | Tu API key, con el permiso SEQUENCE_READ. |
Parámetros de ruta
Path
- billing_account_idstring (uuid)obligatorio
- La cuenta.
Ejemplo
Recortado a dos rangos del establecimiento y uno global:
curl "https://api-sandbox.nestfac.co/api/v1/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences" \
-H "nestfac-api-key: $NESTFAC_API_KEY"// Node.js 18+ (fetch nativo). Corre en TU servidor: la API key nunca va al navegador.
const res = await fetch("https://api-sandbox.nestfac.co/api/v1/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences", {
headers: {
"nestfac-api-key": process.env.NESTFAC_API_KEY,
},
});
const json = await res.json();
if (!res.ok) throw new Error(`${json.code ?? res.status}: ${json.message ?? JSON.stringify(json.errors)}`);
console.log(json.data);import os
import requests
res = requests.get(
"https://api-sandbox.nestfac.co/api/v1/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences",
headers={
"nestfac-api-key": os.environ["NESTFAC_API_KEY"],
},
timeout=30,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{data.get('code', res.status_code)}: {data.get('message') or data.get('errors')}")
print(data["data"])<?php
$ch = curl_init('https://api-sandbox.nestfac.co/api/v1/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'nestfac-api-key: ' . getenv('NESTFAC_API_KEY'),
],
]);
$response = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException(($response['code'] ?? $status) . ': ' . ($response['message'] ?? json_encode($response['errors'] ?? null)));
}
print_r($response['data']);// .NET 7+
using System.Net.Http;
using System.Text;
using var http = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://api-sandbox.nestfac.co/api/v1/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences");
request.Headers.Add("nestfac-api-key", Environment.GetEnvironmentVariable("NESTFAC_API_KEY"));
var response = await http.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) throw new Exception($"{(int)response.StatusCode}: {result}");
Console.WriteLine(result);// Java 15+ (java.net.http)
import java.net.URI;
import java.net.http.*;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api-sandbox.nestfac.co/api/v1/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences"))
.header("nestfac-api-key", System.getenv("NESTFAC_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) throw new RuntimeException(response.body());
System.out.println(response.body());package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api-sandbox.nestfac.co/api/v1/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences", nil)
req.Header.Set("nestfac-api-key", os.Getenv("NESTFAC_API_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))
}// La API key NUNCA va en el navegador. React llama a TU backend,
// y tu backend llama a NestFac con la key (pestaña Node.js).
import { useEffect, useState } from "react";
export function useNestfac(path = "/company/3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71/sequences") {
const [data, setData] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
const ctrl = new AbortController();
fetch(`/api/nestfac${path}`, { signal: ctrl.signal })
.then(async (res) => {
const json = await res.json();
if (!res.ok) throw new Error(json.message ?? json.code);
setData(json.data);
})
.catch((e) => e.name !== "AbortError" && setError(e));
return () => ctrl.abort();
}, [path]);
return { data, error, loading: !data && !error };
}{
"success": true,
"data": {
"establishments": [
{
"id": "a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10",
"code": "001",
"trade_name": "Ferretería El Tornillo",
"address": "Calle 10 # 5-20",
"phone": "6088712345",
"email": "facturacion@eltornillo.co",
"is_default": true,
"location": {
"municipality_id": "41001",
"municipality_name": "Neiva",
"department_id": "41",
"department_name": "Huila"
},
"sequences": [
{
"id": "039792d3-88cd-49a1-abc7-ea9d46b2b133",
"document_type": "INVOICE",
"prefix": "SETP",
"from_number": 990000000,
"to_number": 995000000,
"current_number": 990000095,
"remaining_numbers": 4999905,
"usage_percent": 0,
"resolution_number": "18760000001",
"resolution_date": "2019-01-19T00:00:00.000Z",
"valid_from": "2019-01-19T00:00:00.000Z",
"valid_to": "2030-01-19T00:00:00.000Z",
"days_to_expire": 1183,
"environment": "TEST",
"status": "ACTIVE",
"sequence_role": "PRIMARY",
"priority": 1,
"is_exhausted": false,
"is_global": false,
"last_used_at": "2026-10-19T14:31:56.820Z",
"has_own_test_set": false,
"alert": "ok",
"alert_reasons": []
},
{
"id": "8a1fde18-5817-41db-b1b4-b15954020d39",
"document_type": "CREDIT_NOTE",
"prefix": "NCP",
"from_number": 1,
"to_number": 1000,
"current_number": 14,
"remaining_numbers": 986,
"usage_percent": 1.4,
"resolution_number": null,
"resolution_date": null,
"valid_from": null,
"valid_to": null,
"days_to_expire": null,
"environment": "TEST",
"status": "ACTIVE",
"sequence_role": "PRIMARY",
"priority": 1,
"is_exhausted": false,
"is_global": false,
"last_used_at": "2026-10-23T01:17:19.594Z",
"has_own_test_set": false,
"alert": "ok",
"alert_reasons": []
}
]
}
],
"global_sequences": [
{
"id": "2c3e2bb4-a846-475e-8c89-1dd44ac8bccd",
"document_type": "PAYROLL",
"prefix": "NEP",
"from_number": 1,
"to_number": 1000,
"current_number": 2,
"remaining_numbers": 998,
"usage_percent": 0.2,
"resolution_number": null,
"valid_to": null,
"days_to_expire": null,
"environment": "TEST",
"status": "ACTIVE",
"is_exhausted": false,
"is_global": true,
"alert": "ok",
"alert_reasons": []
}
],
"summary": { "total": 8, "active": 8, "warning": 0, "critical": 0 }
}
}Campos de la respuesta
data
- establishments[]array
Cada establecimiento con su dirección, su
locationy sus rangos ensequences.- global_sequences[]array
- Rangos de la cuenta, que no dependen del establecimiento (nómina).
- summaryobject
- Cuántos rangos hay (
total), activos (active) y en alerta (warning,critical).
sequences[] · global_sequences[]
- document_typestring
Qué documento numera.
APPLICATION_RESPONSEson los eventos RADIAN.INVOICECREDIT_NOTEDEBIT_NOTEDOCUMENT_SUPPORTSUPPORT_DOCUMENT_ADJUSTMENT_NOTEAPPLICATION_RESPONSEPAYROLLPAYROLL_ADJUSTMENT- prefixstring
- Prefijo de los números (
SETP). - from_numbernumber
- Primer número del rango.
- to_numbernumber
- Último número del rango.
- current_numbernumber
- Último número usado.
- remaining_numbersnumber
- Cuántos números quedan.
- usage_percentnumber
- Porcentaje del rango ya usado.
- resolution_numberstring | null
Número de la resolución DIAN. Solo la factura y el documento soporte llevan resolución; las notas, la nómina y los eventos no.
- valid_fromstring | null
- Inicio de vigencia de la resolución.
- valid_tostring | null
- Fin de vigencia de la resolución.
- days_to_expirenumber | null
- Días que le quedan a la resolución.
- environmentstring
- Ambiente DIAN del rango.
TESTPRODUCTION - statusstring
- Estado del rango (
ACTIVE). - is_exhaustedboolean
truesi ya no quedan números.- is_globalboolean
trueen los rangos de la cuenta (global_sequences).- last_used_atstring | null
- Cuándo se usó por última vez.
- alertstring
Si el rango necesita atención: pocos números o resolución por vencer.
okwarningcritical- alert_reasonsstring[]
- Por qué está en alerta.
// Revisado contra la API el 24 de octubre de 2026.