// Documentos electrónicos
Anular documento soporte
Deja sin efecto un documento soporte completo con una nota de ajuste por el total. No se envían ítems.
POST
/api/v1/support-document-adjustment-notesEn esta página
Cuando la compra no se hizo o el documento soporte no debió emitirse, se anula con una nota de ajuste de concepto 2. No envías ítems: la API copia todas las líneas del documento original y la nota sale por el total.
Headers
| Header | Obligatorio | Valor |
|---|---|---|
nestfac-api-key |
Sí | Tu API key. Ver Autenticación. |
nestfac-idempotency-key |
Sí | Un valor único por nota. Ver Idempotencia. |
Content-Type |
Sí | application/json |
Ejemplo
curl -X POST "https://api-sandbox.nestfac.co/api/v1/support-document-adjustment-notes" \
-H "nestfac-api-key: $NESTFAC_API_KEY" \
-H "nestfac-idempotency-key: OC-2207-ANULA" \
-H "Content-Type: application/json" \
-d '{
"billing_account_id": "3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71",
"establishment_id": "a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10",
"support_document_id": "804e2c7b-d10c-4443-b830-e3b9e8162f2f",
"reference_code": "OC-2207-ANULA",
"currency_code": "COP",
"reason": {
"code": "2",
"description": "La compra no se realizó: el vendedor no prestó el servicio"
}
}'// Node.js 18+ (fetch nativo). Corre en TU servidor: la API key nunca va al navegador.
const body = {
"billing_account_id": "3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71",
"establishment_id": "a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10",
"support_document_id": "804e2c7b-d10c-4443-b830-e3b9e8162f2f",
"reference_code": "OC-2207-ANULA",
"currency_code": "COP",
"reason": {
"code": "2",
"description": "La compra no se realizó: el vendedor no prestó el servicio"
}
};
const res = await fetch("https://api-sandbox.nestfac.co/api/v1/support-document-adjustment-notes", {
method: "POST",
headers: {
"nestfac-api-key": process.env.NESTFAC_API_KEY,
"nestfac-idempotency-key": "OC-2207-ANULA",
"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": "3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71",
"establishment_id": "a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10",
"support_document_id": "804e2c7b-d10c-4443-b830-e3b9e8162f2f",
"reference_code": "OC-2207-ANULA",
"currency_code": "COP",
"reason": {
"code": "2",
"description": "La compra no se realizó: el vendedor no prestó el servicio",
},
}
res = requests.post(
"https://api-sandbox.nestfac.co/api/v1/support-document-adjustment-notes",
headers={
"nestfac-api-key": os.environ["NESTFAC_API_KEY"],
"nestfac-idempotency-key": "OC-2207-ANULA",
},
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' => '3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71',
'establishment_id' => 'a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10',
'support_document_id' => '804e2c7b-d10c-4443-b830-e3b9e8162f2f',
'reference_code' => 'OC-2207-ANULA',
'currency_code' => 'COP',
'reason' => [
'code' => '2',
'description' => 'La compra no se realizó: el vendedor no prestó el servicio',
],
];
$ch = curl_init('https://api-sandbox.nestfac.co/api/v1/support-document-adjustment-notes');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'nestfac-api-key: ' . getenv('NESTFAC_API_KEY'),
'nestfac-idempotency-key: OC-2207-ANULA',
'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/support-document-adjustment-notes");
request.Headers.Add("nestfac-api-key", Environment.GetEnvironmentVariable("NESTFAC_API_KEY"));
request.Headers.Add("nestfac-idempotency-key", "OC-2207-ANULA");
var json = """
{
"billing_account_id": "3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71",
"establishment_id": "a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10",
"support_document_id": "804e2c7b-d10c-4443-b830-e3b9e8162f2f",
"reference_code": "OC-2207-ANULA",
"currency_code": "COP",
"reason": {
"code": "2",
"description": "La compra no se realizó: el vendedor no prestó el servicio"
}
}
""";
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": "3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71",
"establishment_id": "a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10",
"support_document_id": "804e2c7b-d10c-4443-b830-e3b9e8162f2f",
"reference_code": "OC-2207-ANULA",
"currency_code": "COP",
"reason": {
"code": "2",
"description": "La compra no se realizó: el vendedor no prestó el servicio"
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api-sandbox.nestfac.co/api/v1/support-document-adjustment-notes"))
.header("nestfac-api-key", System.getenv("NESTFAC_API_KEY"))
.header("nestfac-idempotency-key", "OC-2207-ANULA")
.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": "3f6c2a9e-5b1d-4c7e-9a2f-8d1e0b4c6a71",
"establishment_id": "a2d4f6b8-1c3e-4a5b-9d7f-0e2c4b6a8d10",
"support_document_id": "804e2c7b-d10c-4443-b830-e3b9e8162f2f",
"reference_code": "OC-2207-ANULA",
"currency_code": "COP",
"reason": {
"code": "2",
"description": "La compra no se realizó: el vendedor no prestó el servicio"
}
}`
req, _ := http.NewRequest("POST", "https://api-sandbox.nestfac.co/api/v1/support-document-adjustment-notes", strings.NewReader(body))
req.Header.Set("nestfac-api-key", os.Getenv("NESTFAC_API_KEY"))
req.Header.Set("nestfac-idempotency-key", "OC-2207-ANULA")
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/support-document-adjustment-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);202 Accepted
{
"success": true,
"message": "Support document adjustment note received",
"data": {
"support_document_adjustment_note_id": "89a713c5-655f-4fbb-b025-5e735dfc7d46",
"status": "PENDING"
}
}Campos
Body
- billing_account_idstring (uuid)obligatorio
- La cuenta que emitió el documento soporte.
- support_document_idstring (uuid)obligatorio
- El documento soporte que se anula.
- establishment_idstring (uuid)
- Si no lo envías, se usa el del documento soporte.
- currency_codestringpor defecto
COP - La moneda del documento soporte.
- reference_codestring
- Tu referencia de la nota.
- reasonobjectobligatorio
code:"2"(anulación) ydescription: el motivo, mínimo 20 caracteres.
Después de anular
Cuando la DIAN acepta la nota, el saldo del documento queda en cero y marcado como anulado:
GET /support-documents/{id}/adjustments
{
"success": true,
"data": {
"support_document_id": "804e2c7b-d10c-4443-b830-e3b9e8162f2f",
"currency": "COP",
"document_total": "476000.00",
"adjusted_total": "476000.00",
"in_progress_total": "0.00",
"balance": "0.00",
"available_to_adjust": "0.00",
"commercial_status": "ANULADO",
"is_annulled": true,
"adjustment_notes": [
{
"id": "89a713c5-655f-4fbb-b025-5e735dfc7d46",
"full_number": "NADS9",
"issue_date": "2026-10-23T13:06:07.604Z",
"reason_code": "2",
"reason_description": "La compra no se realizó: el vendedor no prestó el servicio",
"total": "476000.00",
"status": "ACCEPTED",
"dian_status": "ACCEPTED",
"cuds": "bc1102c73162f15117e9a8e817f54c6d294b653d852752dea14beee646069933fc4fed9ffe6d83a51a6237156de97e38",
"state": "APPLIED"
}
]
}
}// Revisado contra la API el 24 de octubre de 2026.