Skip to content

Inicio rápido

Signup → primera factura simulada en sandbox en menos de 10 minutos. Sin .p12 real, sin registro DIAN, sin cobro.

  • Cuenta Emitia con una clave sk_test_… (sandbox, sin costo)
  • curl, Postman, Insomnia u otro cliente HTTP

  1. Verifica tu autenticación

    El primer paso siempre es confirmar que tu clave funciona. GET /v1/account devuelve los datos de tu cuenta — úsalo para verificar la autenticación antes de seguir.

    Terminal window
    curl https://api.emitia.co/v1/account \
    -H "Authorization: Bearer sk_test_TU_CLAVE_AQUI"

    Respuesta esperada 200 OK:

    {
    "id": "ten_01HX…",
    "name": "Mi empresa SAS",
    "dian_environment": "habilitacion",
    "key_mode": "test"
    }

    Si recibes 401 con "code": "invalid_api_key", la clave está mal copiada o fue revocada. Consulta la página de error.

  2. Crea un cliente (adquirente)

    Terminal window
    curl -X POST https://api.emitia.co/v1/customers \
    -H "Authorization: Bearer sk_test_TU_CLAVE_AQUI" \
    -H "Content-Type: application/json" \
    -H "Emitia-Version: 2026-01-01" \
    -d '{
    "identification": {
    "type": "31",
    "number": "900000001",
    "check_digit": "1"
    },
    "legal_name": "Acme SAS",
    "organization_type": "1",
    "email": "facturacion@acme.co",
    "address": "Cra 7 # 71-21",
    "city_code": "11001",
    "department_code": "11",
    "country_code": "CO"
    }'

    Guarda el id del cliente (cust_01HX…): lo usarás en el siguiente paso.

  3. Emite la primera factura

    El NIT 900000001-1 es un NIT de prueba determinista: el sandbox siempre responde “aceptado”. Cada línea requiere line_extension_amount (el total de la línea antes de impuestos).

    Terminal window
    curl -X POST https://api.emitia.co/v1/invoices \
    -H "Authorization: Bearer sk_test_TU_CLAVE_AQUI" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Emitia-Version: 2026-01-01" \
    -d '{
    "customer_id": "cust_01HX_REEMPLAZA_CON_TU_ID",
    "currency": "COP",
    "operation_type": "10",
    "payment_means": { "code": "10", "type": "1" },
    "lines": [
    {
    "description": "Servicio de consultoría",
    "quantity": "1.00",
    "unit_code": "94",
    "unit_price": "100000.00",
    "line_extension_amount": "100000.00",
    "taxes": [
    { "code": "01", "rate": "19.00", "base": "100000.00", "value": "19000.00" }
    ]
    }
    ]
    }'

    Respuesta esperada 202 Accepted (el procesamiento es asincrónico). La factura se crea en draft y se encola; el worker asigna el consecutivo y el CUFE, por lo que full_number llega vacío y cufe en null en esta respuesta:

    {
    "id": "inv_01HX…",
    "object": "invoice",
    "status": "draft",
    "full_number": "",
    "cufe": null,
    "created_at": "2026-01-15T10:30:00-05:00"
    }
  4. Espera el resultado via webhook

    La factura pasa por la cola BullMQ → se firma → se envía a la DIAN (o al simulador en sandbox). El resultado llega como un evento webhook.

    Configura tu endpoint en el dashboard o vía API:

    Terminal window
    curl -X POST https://api.emitia.co/v1/webhook-endpoints \
    -H "Authorization: Bearer sk_test_TU_CLAVE_AQUI" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Emitia-Version: 2026-01-01" \
    -d '{
    "url": "https://tuapp.co/hooks/emitia",
    "subscribed_events": ["invoice.accepted_by_dian", "invoice.rejected_by_dian"]
    }'

    Cuando la factura sea aceptada recibirás:

    {
    "id": "evt_01HX…",
    "type": "invoice.accepted_by_dian",
    "data": {
    "object": {
    "id": "inv_01HX…",
    "status": "accepted_by_dian",
    "cufe": "fe9c3a1b…",
    "pdf_url": "https://files.emitia.co/…"
    }
    }
    }

    Aprende a verificar la firma HMAC del webhook en Conceptos: Webhooks.


TareaGuía
Mapear tu POS a EmitiaGuía de mapeo POS
Entender la idempotenciaConceptos: Idempotencia
Verificar firmas de webhooksConceptos: Webhooks
Pasar a habilitación DIANConceptos: Ambientes
Receta para tu stackRecetas
Explorar todos los endpointsReferencia API interactiva