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

CampoTipoRequeridoDescripción
customer.document_typestringTipo de documento (31=NIT, 13=CC, 22=CE)
customer.document_numberstringNúmero de documento (sin DV)
customer.namestringRazón social o nombre
customer.emailstringNoEmail para notificación
lines[].codestringCódigo del producto/servicio
lines[].namestringDescripción
lines[].quantitynumberCantidad
lines[].unit_pricenumberPrecio unitario
lines[].taxes[].codestringCódigo DIAN (01=IVA, 04=INC)
lines[].taxes[].ratenumberTarifa (ej: 19 para 19%)
payment.method_codestringMé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"
  }
}
CampoTipoDescripción
successbooleantrue si fue aceptado
cufestringCódigo Único de Factura Electrónica
xml_urlstringURL del XML firmado
pdf_urlstringURL de la representación gráfica
statusstringaccepted, rejected, pending

Errores

CódigoErrorSolución
400NIT_INVALIDVerifica el NIT con dígito de verificación
400TAX_RATE_INVALIDRevisa las tarifas de impuestos
409DUPLICATE_INVOICE_NUMBERNúmero de factura ya usado
422LINE_TOTAL_MISMATCHSuma 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