Factura Electrónica (FE)
POST /api/v1/service/invoice
Genera una Factura Electrónica de Venta según el Anexo Técnico DIAN v1.9.
Request
| Campo | Tipo | Requerido | Descripción |
|---|
customer.document_type | string | Sí | Tipo de documento (31=NIT, 13=CC, 22=CE) |
customer.document_number | string | Sí | Número de documento (sin DV) |
customer.name | string | Sí | Razón social o nombre |
customer.email | string | No | Email para notificación |
lines[].code | string | Sí | Código del producto/servicio |
lines[].name | string | Sí | Descripción |
lines[].quantity | number | Sí | Cantidad |
lines[].unit_price | number | Sí | Precio unitario |
lines[].taxes[].code | string | Sí | Código DIAN (01=IVA, 04=INC) |
lines[].taxes[].rate | number | Sí | Tarifa (ej: 19 para 19%) |
payment.method_code | string | Sí | Método de pago DIAN |
Ejemplo cURL
curl -X POST https://emision.smartapp.com.co/api/v1/service/invoice \
-H "Authorization: Bearer TU_API_KEY" \
-H "Content-Type: application/json" \
-d '{"customer":{"document_type":"31","document_number":"900123456","name":"Cliente SAS"},"lines":[{"code":"P001","name":"Servicio","quantity":1,"unit_price":100000,"taxes":[{"code":"01","name":"IVA","rate":19}]}],"payment":{"method_code":"10"}}'
Python
import requests
resp = requests.post(
"https://emision.smartapp.com.co/api/v1/service/invoice",
headers={"Authorization": "Bearer sk_..."},
json={
"customer": {"document_type": "31", "document_number": "900123456", "name": "Cliente SAS"},
"lines": [{"code": "P001", "name": "Servicio", "quantity": 1, "unit_price": 100000,
"taxes": [{"code": "01", "name": "IVA", "rate": 19}]}],
"payment": {"method_code": "10"}
}
)
print(resp.json())
PHP
$data = json_encode([
"customer" => ["document_type" => "31", "document_number" => "900123456", "name" => "Cliente SAS"],
"lines" => [["code" => "P001", "name" => "Servicio", "quantity" => 1, "unit_price" => 100000,
"taxes" => [["code" => "01", "name" => "IVA", "rate" => 19]]]],
"payment" => ["method_code" => "10"]
]);
$ch = curl_init("https://emision.smartapp.com.co/api/v1/service/invoice");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer sk_...", "Content-Type: application/json"],
CURLOPT_POSTFIELDS => $data,
CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);
Node.js
const resp = await fetch("https://emision.smartapp.com.co/api/v1/service/invoice", {
method: "POST",
headers: {
"Authorization": "Bearer sk_...",
"Content-Type": "application/json"
},
body: JSON.stringify({
customer: { document_type: "31", document_number: "900123456", name: "Cliente SAS" },
lines: [{ code: "P001", name: "Servicio", quantity: 1, unit_price: 100000,
taxes: [{ code: "01", name: "IVA", rate: 19 }] }],
payment: { method_code: "10" }
})
});
console.log(await resp.json());
Response
{
"success": true,
"cufe": "abc123def456...",
"xml_url": "https://minio.smartapp.com.co/xml-signed/FE-001.xml",
"pdf_url": "https://minio.smartapp.com.co/pdf/FE-001.pdf",
"status": "accepted",
"dian_response": {
"track_id": "xyz789",
"status": "accepted",
"status_message": "Documento validado correctamente"
}
}
| Campo | Tipo | Descripción |
|---|
success | boolean | true si fue aceptado |
cufe | string | Código Único de Factura Electrónica |
xml_url | string | URL del XML firmado |
pdf_url | string | URL de la representación gráfica |
status | string | accepted, rejected, pending |
Errores
| Código | Error | Solución |
|---|
400 | NIT_INVALID | Verifica el NIT con dígito de verificación |
400 | TAX_RATE_INVALID | Revisa las tarifas de impuestos |
409 | DUPLICATE_INVOICE_NUMBER | Número de factura ya usado |
422 | LINE_TOTAL_MISMATCH | Suma de líneas ≠ total declarado |
C#
using System.Net.Http.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "sk_...");
var body = new
{
customer = new { document_type = "31", document_number = "900123456", name = "Cliente SAS" },
lines = new[] {
new { code = "P001", name = "Servicio", quantity = 1, unit_price = 100000,
taxes = new[] { new { code = "01", name = "IVA", rate = 19 } } }
},
payment = new { method_code = "10" }
};
var response = await client.PostAsJsonAsync(
"https://emision.smartapp.com.co/api/v1/service/invoice", body);
Console.WriteLine(await response.Content.ReadAsStringAsync());
Java
HttpClient client = HttpClient.newHttpClient();
String body = """
{
"customer": {"document_type": "31", "document_number": "900123456", "name": "Cliente SAS"},
"lines": [{"code": "P001", "name": "Servicio", "quantity": 1, "unit_price": 100000,
"taxes": [{"code": "01", "name": "IVA", "rate": 19}]}],
"payment": {"method_code": "10"}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://emision.smartapp.com.co/api/v1/service/invoice"))
.header("Authorization", "Bearer sk_...")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
System.out.println(response.body());
Notas DIAN
- Anexo Técnico v1.9: Factura Electrónica de Venta
- Códigos de tipo de documento: Resolución 000042 de 2020
- Métodos de pago: Anexo Técnico Sección 9
- Tarifas de IVA: 0%, 5%, 19% (nacional)