// Documentos electrónicos
Crear nota crédito
Corrige una factura a favor del cliente (devoluciones, anulaciones, descuentos y ajustes de precio) sin tocar la factura original.
/api/v1/credit-notesCuándo se usa
Una factura aceptada por la DIAN no se modifica ni se borra. Si hay que devolver dinero, quitar productos o anular la venta, se emite una nota crédito que referencia esa factura. La nota sigue el mismo ciclo de vida que la factura: 202, luego ACCEPTED o REJECTED.
| Código | Concepto (tabla DIAN) | Cuándo |
|---|---|---|
1 |
Devolución parcial de bienes / no aceptación parcial del servicio | El cliente devolvió algunos productos. |
2 |
Anulación de la factura | La venta completa queda sin efecto. |
3 |
Rebaja o descuento parcial o total | Descuento posterior a la venta. |
4 |
Ajuste de precio | Se facturó un precio mayor al pactado. |
5 |
Descuento comercial por pronto pago | El cliente pagó antes del plazo. |
6 |
Descuento comercial por volumen de ventas | Descuento por cantidades acumuladas. |
Reglas
- No supera el saldo de la factura. El total de la nota no puede ser mayor a lo que queda por acreditar: el total de la factura menos las notas crédito aceptadas y las que están en proceso. Consúltalo en Saldo de la factura.
- La anulación (
2) es por el total. Lleva los mismos ítems y cantidades de la factura, y no aplica si la factura ya tiene otras notas crédito. Una factura anulada no admite más notas. - Mismo cliente. El
customerdebe ser el de la factura. - No sobre facturas aceptadas en RADIAN. Si el comprador aceptó la factura (evento 033) o quedó aceptada tácitamente (034), la DIAN ya no admite notas y la API responde
422. - Lo demás lo hereda. Si la factura es de mandatos (11) o AIU (09), la nota conserva el mandante y los componentes; si fue a crédito, toma su plazo.
{
"success": false,
"code": "INVOICE_ACCEPTED_NO_ADJUSTMENTS",
"message": "No se puede emitir una nota crédito: la factura fue aceptada expresamente por el comprador (evento 033). Después de la aceptación la factura no admite ajustes."
}Headers
| Header | Obligatorio | Valor |
|---|---|---|
nestfac-api-key |
Sí | Tu API key. Ver Autenticación. |
nestfac-idempotency-key |
Sí | Un valor único por nota, por ejemplo el id de la devolución en tu sistema. Ver Idempotencia. |
Content-Type |
Sí | application/json |
Ejemplo: devolución parcial
La factura SETP990000093 vendió 2 gaseosas de $5.000 + IVA. El cliente devuelve 1.
curl -X POST "https://api-sandbox.nestfac.co/api/v1/credit-notes" \
-H "nestfac-api-key: $NESTFAC_API_KEY" \
-H "nestfac-idempotency-key: DEV-1042-1" \
-H "Content-Type: application/json" \
-d '{
"billing_account_id": "51f77d28-4862-46ac-8de6-aa7268fc4a9e",
"establishment_id": "d60a21af-1659-4039-80fa-978928b11f38",
"CreditNoteTypeCode": "20",
"currency_code": "COP",
"note": "",
"rounding_amount": 0,
"reference": {
"invoice_id": "3ec85cbf-28d6-456e-be88-03a06a0c000c",
"referenced_invoice_number": "SETP990000093",
"referenced_invoice_cufe": "271b025d54c4b974c294fb5c62a65fd6be888e4865e0d61969b145867351d9f926e46c42fb85e1ae103771a28d8a8477",
"reference_issue_date": "2026-10-22"
},
"reason": {
"reason_code": "1",
"reason_description": "El cliente devolvió 1 unidad, por defecto de fabrica"
},
"customer": {
"document_identity_type_code": "31",
"document_identity_type_name": "NIT",
"customer_type_name": "COMPANY",
"document_identification_number": "902100650",
"legal_name": "nestfac sas",
"email": "nesterlon.dev@gmail.com",
"phone": "3134318776",
"legal_organization_type_code": "1",
"tax_regime_code": "49",
"tax_level_code": "PN",
"responsibilities": [
"R-99-PN"
],
"address": {
"country_code": "CO",
"line_1": "Calle 100 # 10-20",
"municipality_code": "11001"
},
"dv": "9"
},
"payments": [
{
"payment_form_code": "1",
"payment_method_code": "42",
"amount": 5950
}
],
"items": [
{
"sku": "ITEM-001",
"name": "Gaseosa de Uva",
"quantity": 1,
"unit_measure_code": "94",
"unit_price": 5000,
"discount_percent": 0,
"taxes": [
{
"tax_code": "01",
"percent": 19
}
],
"withholding_taxes": [],
"code_reference": "ITEM-001"
}
]
}'// Node.js 18+ (fetch nativo). Corre en TU servidor: la API key nunca va al navegador.
const body = {
"billing_account_id": "51f77d28-4862-46ac-8de6-aa7268fc4a9e",
"establishment_id": "d60a21af-1659-4039-80fa-978928b11f38",
"CreditNoteTypeCode": "20",
"currency_code": "COP",
"note": "",
"rounding_amount": 0,
"reference": {
"invoice_id": "3ec85cbf-28d6-456e-be88-03a06a0c000c",
"referenced_invoice_number": "SETP990000093",
"referenced_invoice_cufe": "271b025d54c4b974c294fb5c62a65fd6be888e4865e0d61969b145867351d9f926e46c42fb85e1ae103771a28d8a8477",
"reference_issue_date": "2026-10-22"
},
"reason": {
"reason_code": "1",
"reason_description": "El cliente devolvió 1 unidad, por defecto de fabrica"
},
"customer": {
"document_identity_type_code": "31",
"document_identity_type_name": "NIT",
"customer_type_name": "COMPANY",
"document_identification_number": "902100650",
"legal_name": "nestfac sas",
"email": "nesterlon.dev@gmail.com",
"phone": "3134318776",
"legal_organization_type_code": "1",
"tax_regime_code": "49",
"tax_level_code": "PN",
"responsibilities": [
"R-99-PN"
],
"address": {
"country_code": "CO",
"line_1": "Calle 100 # 10-20",
"municipality_code": "11001"
},
"dv": "9"
},
"payments": [
{
"payment_form_code": "1",
"payment_method_code": "42",
"amount": 5950
}
],
"items": [
{
"sku": "ITEM-001",
"name": "Gaseosa de Uva",
"quantity": 1,
"unit_measure_code": "94",
"unit_price": 5000,
"discount_percent": 0,
"taxes": [
{
"tax_code": "01",
"percent": 19
}
],
"withholding_taxes": [],
"code_reference": "ITEM-001"
}
]
};
const res = await fetch("https://api-sandbox.nestfac.co/api/v1/credit-notes", {
method: "POST",
headers: {
"nestfac-api-key": process.env.NESTFAC_API_KEY,
"nestfac-idempotency-key": "DEV-1042-1",
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
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
payload = {
"billing_account_id": "51f77d28-4862-46ac-8de6-aa7268fc4a9e",
"establishment_id": "d60a21af-1659-4039-80fa-978928b11f38",
"CreditNoteTypeCode": "20",
"currency_code": "COP",
"note": "",
"rounding_amount": 0,
"reference": {
"invoice_id": "3ec85cbf-28d6-456e-be88-03a06a0c000c",
"referenced_invoice_number": "SETP990000093",
"referenced_invoice_cufe": "271b025d54c4b974c294fb5c62a65fd6be888e4865e0d61969b145867351d9f926e46c42fb85e1ae103771a28d8a8477",
"reference_issue_date": "2026-10-22",
},
"reason": {
"reason_code": "1",
"reason_description": "El cliente devolvió 1 unidad, por defecto de fabrica",
},
"customer": {
"document_identity_type_code": "31",
"document_identity_type_name": "NIT",
"customer_type_name": "COMPANY",
"document_identification_number": "902100650",
"legal_name": "nestfac sas",
"email": "nesterlon.dev@gmail.com",
"phone": "3134318776",
"legal_organization_type_code": "1",
"tax_regime_code": "49",
"tax_level_code": "PN",
"responsibilities": ["R-99-PN"],
"address": {
"country_code": "CO",
"line_1": "Calle 100 # 10-20",
"municipality_code": "11001",
},
"dv": "9",
},
"payments": [
{
"payment_form_code": "1",
"payment_method_code": "42",
"amount": 5950,
},
],
"items": [
{
"sku": "ITEM-001",
"name": "Gaseosa de Uva",
"quantity": 1,
"unit_measure_code": "94",
"unit_price": 5000,
"discount_percent": 0,
"taxes": [
{
"tax_code": "01",
"percent": 19,
},
],
"withholding_taxes": [],
"code_reference": "ITEM-001",
},
],
}
res = requests.post(
"https://api-sandbox.nestfac.co/api/v1/credit-notes",
headers={
"nestfac-api-key": os.environ["NESTFAC_API_KEY"],
"nestfac-idempotency-key": "DEV-1042-1",
},
json=payload,
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
$payload = [
'billing_account_id' => '51f77d28-4862-46ac-8de6-aa7268fc4a9e',
'establishment_id' => 'd60a21af-1659-4039-80fa-978928b11f38',
'CreditNoteTypeCode' => '20',
'currency_code' => 'COP',
'note' => '',
'rounding_amount' => 0,
'reference' => [
'invoice_id' => '3ec85cbf-28d6-456e-be88-03a06a0c000c',
'referenced_invoice_number' => 'SETP990000093',
'referenced_invoice_cufe' => '271b025d54c4b974c294fb5c62a65fd6be888e4865e0d61969b145867351d9f926e46c42fb85e1ae103771a28d8a8477',
'reference_issue_date' => '2026-10-22',
],
'reason' => [
'reason_code' => '1',
'reason_description' => 'El cliente devolvió 1 unidad, por defecto de fabrica',
],
'customer' => [
'document_identity_type_code' => '31',
'document_identity_type_name' => 'NIT',
'customer_type_name' => 'COMPANY',
'document_identification_number' => '902100650',
'legal_name' => 'nestfac sas',
'email' => 'nesterlon.dev@gmail.com',
'phone' => '3134318776',
'legal_organization_type_code' => '1',
'tax_regime_code' => '49',
'tax_level_code' => 'PN',
'responsibilities' => ['R-99-PN'],
'address' => [
'country_code' => 'CO',
'line_1' => 'Calle 100 # 10-20',
'municipality_code' => '11001',
],
'dv' => '9',
],
'payments' => [
[
'payment_form_code' => '1',
'payment_method_code' => '42',
'amount' => 5950,
],
],
'items' => [
[
'sku' => 'ITEM-001',
'name' => 'Gaseosa de Uva',
'quantity' => 1,
'unit_measure_code' => '94',
'unit_price' => 5000,
'discount_percent' => 0,
'taxes' => [
[
'tax_code' => '01',
'percent' => 19,
],
],
'withholding_taxes' => [],
'code_reference' => 'ITEM-001',
],
],
];
$ch = curl_init('https://api-sandbox.nestfac.co/api/v1/credit-notes');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'nestfac-api-key: ' . getenv('NESTFAC_API_KEY'),
'nestfac-idempotency-key: DEV-1042-1',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE),
]);
$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.Post, "https://api-sandbox.nestfac.co/api/v1/credit-notes");
request.Headers.Add("nestfac-api-key", Environment.GetEnvironmentVariable("NESTFAC_API_KEY"));
request.Headers.Add("nestfac-idempotency-key", "DEV-1042-1");
var json = """
{
"billing_account_id": "51f77d28-4862-46ac-8de6-aa7268fc4a9e",
"establishment_id": "d60a21af-1659-4039-80fa-978928b11f38",
"CreditNoteTypeCode": "20",
"currency_code": "COP",
"note": "",
"rounding_amount": 0,
"reference": {
"invoice_id": "3ec85cbf-28d6-456e-be88-03a06a0c000c",
"referenced_invoice_number": "SETP990000093",
"referenced_invoice_cufe": "271b025d54c4b974c294fb5c62a65fd6be888e4865e0d61969b145867351d9f926e46c42fb85e1ae103771a28d8a8477",
"reference_issue_date": "2026-10-22"
},
"reason": {
"reason_code": "1",
"reason_description": "El cliente devolvió 1 unidad, por defecto de fabrica"
},
"customer": {
"document_identity_type_code": "31",
"document_identity_type_name": "NIT",
"customer_type_name": "COMPANY",
"document_identification_number": "902100650",
"legal_name": "nestfac sas",
"email": "nesterlon.dev@gmail.com",
"phone": "3134318776",
"legal_organization_type_code": "1",
"tax_regime_code": "49",
"tax_level_code": "PN",
"responsibilities": [
"R-99-PN"
],
"address": {
"country_code": "CO",
"line_1": "Calle 100 # 10-20",
"municipality_code": "11001"
},
"dv": "9"
},
"payments": [
{
"payment_form_code": "1",
"payment_method_code": "42",
"amount": 5950
}
],
"items": [
{
"sku": "ITEM-001",
"name": "Gaseosa de Uva",
"quantity": 1,
"unit_measure_code": "94",
"unit_price": 5000,
"discount_percent": 0,
"taxes": [
{
"tax_code": "01",
"percent": 19
}
],
"withholding_taxes": [],
"code_reference": "ITEM-001"
}
]
}
""";
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
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.*;
String json = """
{
"billing_account_id": "51f77d28-4862-46ac-8de6-aa7268fc4a9e",
"establishment_id": "d60a21af-1659-4039-80fa-978928b11f38",
"CreditNoteTypeCode": "20",
"currency_code": "COP",
"note": "",
"rounding_amount": 0,
"reference": {
"invoice_id": "3ec85cbf-28d6-456e-be88-03a06a0c000c",
"referenced_invoice_number": "SETP990000093",
"referenced_invoice_cufe": "271b025d54c4b974c294fb5c62a65fd6be888e4865e0d61969b145867351d9f926e46c42fb85e1ae103771a28d8a8477",
"reference_issue_date": "2026-10-22"
},
"reason": {
"reason_code": "1",
"reason_description": "El cliente devolvió 1 unidad, por defecto de fabrica"
},
"customer": {
"document_identity_type_code": "31",
"document_identity_type_name": "NIT",
"customer_type_name": "COMPANY",
"document_identification_number": "902100650",
"legal_name": "nestfac sas",
"email": "nesterlon.dev@gmail.com",
"phone": "3134318776",
"legal_organization_type_code": "1",
"tax_regime_code": "49",
"tax_level_code": "PN",
"responsibilities": [
"R-99-PN"
],
"address": {
"country_code": "CO",
"line_1": "Calle 100 # 10-20",
"municipality_code": "11001"
},
"dv": "9"
},
"payments": [
{
"payment_form_code": "1",
"payment_method_code": "42",
"amount": 5950
}
],
"items": [
{
"sku": "ITEM-001",
"name": "Gaseosa de Uva",
"quantity": 1,
"unit_measure_code": "94",
"unit_price": 5000,
"discount_percent": 0,
"taxes": [
{
"tax_code": "01",
"percent": 19
}
],
"withholding_taxes": [],
"code_reference": "ITEM-001"
}
]
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api-sandbox.nestfac.co/api/v1/credit-notes"))
.header("nestfac-api-key", System.getenv("NESTFAC_API_KEY"))
.header("nestfac-idempotency-key", "DEV-1042-1")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString(json))
.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"
"strings"
)
func main() {
body := `{
"billing_account_id": "51f77d28-4862-46ac-8de6-aa7268fc4a9e",
"establishment_id": "d60a21af-1659-4039-80fa-978928b11f38",
"CreditNoteTypeCode": "20",
"currency_code": "COP",
"note": "",
"rounding_amount": 0,
"reference": {
"invoice_id": "3ec85cbf-28d6-456e-be88-03a06a0c000c",
"referenced_invoice_number": "SETP990000093",
"referenced_invoice_cufe": "271b025d54c4b974c294fb5c62a65fd6be888e4865e0d61969b145867351d9f926e46c42fb85e1ae103771a28d8a8477",
"reference_issue_date": "2026-10-22"
},
"reason": {
"reason_code": "1",
"reason_description": "El cliente devolvió 1 unidad, por defecto de fabrica"
},
"customer": {
"document_identity_type_code": "31",
"document_identity_type_name": "NIT",
"customer_type_name": "COMPANY",
"document_identification_number": "902100650",
"legal_name": "nestfac sas",
"email": "nesterlon.dev@gmail.com",
"phone": "3134318776",
"legal_organization_type_code": "1",
"tax_regime_code": "49",
"tax_level_code": "PN",
"responsibilities": [
"R-99-PN"
],
"address": {
"country_code": "CO",
"line_1": "Calle 100 # 10-20",
"municipality_code": "11001"
},
"dv": "9"
},
"payments": [
{
"payment_form_code": "1",
"payment_method_code": "42",
"amount": 5950
}
],
"items": [
{
"sku": "ITEM-001",
"name": "Gaseosa de Uva",
"quantity": 1,
"unit_measure_code": "94",
"unit_price": 5000,
"discount_percent": 0,
"taxes": [
{
"tax_code": "01",
"percent": 19
}
],
"withholding_taxes": [],
"code_reference": "ITEM-001"
}
]
}`
req, _ := http.NewRequest("POST", "https://api-sandbox.nestfac.co/api/v1/credit-notes", strings.NewReader(body))
req.Header.Set("nestfac-api-key", os.Getenv("NESTFAC_API_KEY"))
req.Header.Set("nestfac-idempotency-key", "DEV-1042-1")
req.Header.Set("Content-Type", "application/json")
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,
// que agrega la key y la llave de idempotencia (pestaña Node.js).
async function enviar(datos) {
const res = await fetch("/api/nestfac/credit-notes", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(datos),
});
const json = await res.json();
if (!res.ok) throw new Error(json.message ?? json.code);
return json.data;
}
// const resultado = await enviar(datosDeLaVenta);{
"success": true,
"message": "Credit note received",
"data": {
"credit_note_id": "0611bbcf-bc99-458b-ade4-ad15fe8f1eb8",
"status": "PENDING"
}
}Guarda el credit_note_id y consulta la nota hasta que la DIAN responda.
Campos
La nota usa los mismos campos de la factura para customer, payments, items y los opcionales: ver Crear factura. Estos son los propios de la nota:
Body
- billing_account_idstring (uuid)obligatorio
La cuenta que emitió la factura.
- establishment_idstring (uuid)obligatorio si no envías numbering_range_id
Establecimiento que emite la nota. La numeración de notas crédito es propia (no la de facturas).
- credit_note_type_codestringpor defecto
20 Tipo de nota. Solo se admite
20(con referencia a una factura).- reference_codestring
Tu referencia de la nota (número de devolución en tu sistema). Sirve para buscarla.
- referenceobjectobligatorio
La factura que se corrige.
- invoice_idstring (uuid)obligatorio si la factura se emitió con NestFac
ID de la factura en NestFac. Con él la API valida el saldo y hereda mandante, AIU y plazo.
- referenced_invoice_numberstringobligatorio
Número completo de la factura (
SETP990000093).- referenced_invoice_cufestringobligatorio96 caracteres hexadecimales
CUFE de la factura.
- reference_issue_datestringobligatorioAAAA-MM-DD
Fecha de emisión de la factura.
- reasonobjectobligatorio
El motivo.
- reason_codestringobligatorio
Concepto de la tabla de arriba.
123456- reason_descriptionstringobligatoriomáx. 500
Explicación para el cliente; aparece en la nota.
- operation_typestringobligatorio si la factura no es de NestFac
Tipo de operación de la factura (
10,09,11…). Si la factura es de NestFac, la API lo lee de ella: no lo envíes.
Factura emitida fuera de NestFac
Si la factura la emitiste con otro proveedor, omite invoice_id y envía el tipo de operación. En ese caso la API no puede validar el saldo: es tu responsabilidad no acreditar más de lo facturado.
"operation_type": "10",
"reference": {
"referenced_invoice_number": "FE4521",
"referenced_invoice_cufe": "9a3c…(96 caracteres hexadecimales)",
"reference_issue_date": "2026-03-02"
}// Revisado contra la API el 24 de octubre de 2026.