PaybookDocsv1
Docs/Guías

Emitir y cancelar CFDI

Factura cada pago con CFDI 4.0, entrega el XML y el PDF, y corrige con cancelación, refacturación y notas de crédito.

Cómo factura HUB+#

HUB+ emite CFDI 4.0 a nombre de la razón social de cada campus, con sus certificados y sus series. La factura se liga al pago y a los avisos de cobro que cubre, y lleva el complemento de instituciones educativas cuando aplica.

El timbrado se balancea entre varios PAC (Proveedores Autorizados de Certificación) del SAT: si uno presenta intermitencia, HUB+ continúa timbrando con otro sin que el integrador tenga que hacer nada distinto.

ModalidadCómo funciona
AutomáticaSi el perfil fiscal del responsable tiene auto_invoice, cada pago exitoso genera su factura.
Bajo demandaTu sistema, o el responsable desde el portal, solicita la factura de un pago.
GlobalLos pagos sin factura nominativa se incluyen en la factura global del periodo: POST/v1/global_invoices
  1. Registra el perfil fiscal del receptor#

    El perfil fiscal guarda los datos con los que se factura a un responsable de pago: RFC, razón social, régimen, código postal y uso del CFDI.

    POST/v1/tax_profiles
    curl -X POST "https://api.sandbox.hubplus.example/v1/tax_profiles" \
      -H "Authorization: Bearer $HUB_ACCESS_TOKEN" \
      -H "X-Tenant-Id: $HUB_TENANT_ID" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "guardian": "4f507175-82d0-4c19-89c8-3c11fef92d83",
      "students": [
        "2f13d743-bed0-4fd7-8a0a-9a1f054a968c"
      ],
      "person_type": "individual",
      "rfc": "XAXX010101000",
      "legal_name": "MARIA FERNANDA LOPEZ GARCIA",
      "tax_regime": "605",
      "zip": "52786",
      "cfdi_use": "D10",
      "email": "responsable.pago@correo.example",
      "default": true,
      "auto_invoice": true,
      "metadata": {
        "sis_student_id": "30418822"
      }
    }'
    const res = await fetch("https://api.sandbox.hubplus.example/v1/tax_profiles", {
      method: "POST",
      headers: {
        "Authorization": "Bearer " + process.env.HUB_ACCESS_TOKEN,
        "X-Tenant-Id": process.env.HUB_TENANT_ID,
        "Idempotency-Key": crypto.randomUUID(),
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        "guardian": "4f507175-82d0-4c19-89c8-3c11fef92d83",
        "students": [
          "2f13d743-bed0-4fd7-8a0a-9a1f054a968c"
        ],
        "person_type": "individual",
        "rfc": "XAXX010101000",
        "legal_name": "MARIA FERNANDA LOPEZ GARCIA",
        "tax_regime": "605",
        "zip": "52786",
        "cfdi_use": "D10",
        "email": "responsable.pago@correo.example",
        "default": true,
        "auto_invoice": true,
        "metadata": {
          "sis_student_id": "30418822"
        }
      }),
    });
    
    if (!res.ok) throw new Error(`HUB+ respondió ${res.status}`);
    const data = await res.json();
    import os
    import uuid
    import requests
    
    res = requests.post(
        "https://api.sandbox.hubplus.example/v1/tax_profiles",
        headers={
            "Authorization": f"Bearer {os.environ['HUB_ACCESS_TOKEN']}",
            "X-Tenant-Id": os.environ["HUB_TENANT_ID"],
            "Idempotency-Key": str(uuid.uuid4()),
        },
        json={
            "guardian": "4f507175-82d0-4c19-89c8-3c11fef92d83",
            "students": ["2f13d743-bed0-4fd7-8a0a-9a1f054a968c"],
            "person_type": "individual",
            "rfc": "XAXX010101000",
            "legal_name": "MARIA FERNANDA LOPEZ GARCIA",
            "tax_regime": "605",
            "zip": "52786",
            "cfdi_use": "D10",
            "email": "responsable.pago@correo.example",
            "default": True,
            "auto_invoice": True,
            "metadata": {
                "sis_student_id": "30418822",
            },
        },
        timeout=30,
    )
    res.raise_for_status()
    data = res.json()
    <?php
    $ch = curl_init("https://api.sandbox.hubplus.example/v1/tax_profiles");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . getenv("HUB_ACCESS_TOKEN"),
            "X-Tenant-Id: " . getenv("HUB_TENANT_ID"),
            "Idempotency-Key: " . bin2hex(random_bytes(16)),
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "guardian" => "4f507175-82d0-4c19-89c8-3c11fef92d83",
            "students" => ["2f13d743-bed0-4fd7-8a0a-9a1f054a968c"],
            "person_type" => "individual",
            "rfc" => "XAXX010101000",
            "legal_name" => "MARIA FERNANDA LOPEZ GARCIA",
            "tax_regime" => "605",
            "zip" => "52786",
            "cfdi_use" => "D10",
            "email" => "responsable.pago@correo.example",
            "default" => true,
            "auto_invoice" => true,
            "metadata" => [
                "sis_student_id" => "30418822",
            ],
        ]),
    ]);
    $body = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($status >= 400) {
        throw new RuntimeException("HUB+ respondió $status");
    }
    $data = json_decode($body, true);
    HttpClient client = HttpClient.newHttpClient();
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.sandbox.hubplus.example/v1/tax_profiles"))
        .header("Authorization", "Bearer " + System.getenv("HUB_ACCESS_TOKEN"))
        .header("X-Tenant-Id", System.getenv("HUB_TENANT_ID"))
        .header("Idempotency-Key", UUID.randomUUID().toString())
        .header("Content-Type", "application/json")
        .method("POST", HttpRequest.BodyPublishers.ofString("""
            {
              "guardian": "4f507175-82d0-4c19-89c8-3c11fef92d83",
              "students": [
                "2f13d743-bed0-4fd7-8a0a-9a1f054a968c"
              ],
              "person_type": "individual",
              "rfc": "XAXX010101000",
              "legal_name": "MARIA FERNANDA LOPEZ GARCIA",
              "tax_regime": "605",
              "zip": "52786",
              "cfdi_use": "D10",
              "email": "responsable.pago@correo.example",
              "default": true,
              "auto_invoice": true,
              "metadata": {
                "sis_student_id": "30418822"
              }
            }
            """))
        .build();
    
    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());

    Antes de facturar, valida el perfil contra el SAT con POST/v1/tax_profiles/a402de42-eb99-4034-83d8-eb13e26f3911/validate. Un RFC, nombre o código postal que no coincide con la constancia de situación fiscal es la causa más común de rechazo al timbrar.

  2. Emite la factura de un pago#

    POST/v1/invoices
    curl -X POST "https://api.sandbox.hubplus.example/v1/invoices" \
      -H "Authorization: Bearer $HUB_ACCESS_TOKEN" \
      -H "X-Tenant-Id: $HUB_TENANT_ID" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "payment": "8920caef-a5bc-44b1-848e-97718177602b",
      "tax_profile": "a402de42-eb99-4034-83d8-eb13e26f3911",
      "cfdi_use": "D10",
      "send_email": true,
      "metadata": {
        "sap_billing_doc": "9000184502"
      }
    }'
    const res = await fetch("https://api.sandbox.hubplus.example/v1/invoices", {
      method: "POST",
      headers: {
        "Authorization": "Bearer " + process.env.HUB_ACCESS_TOKEN,
        "X-Tenant-Id": process.env.HUB_TENANT_ID,
        "Idempotency-Key": crypto.randomUUID(),
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        "payment": "8920caef-a5bc-44b1-848e-97718177602b",
        "tax_profile": "a402de42-eb99-4034-83d8-eb13e26f3911",
        "cfdi_use": "D10",
        "send_email": true,
        "metadata": {
          "sap_billing_doc": "9000184502"
        }
      }),
    });
    
    if (!res.ok) throw new Error(`HUB+ respondió ${res.status}`);
    const data = await res.json();
    import os
    import uuid
    import requests
    
    res = requests.post(
        "https://api.sandbox.hubplus.example/v1/invoices",
        headers={
            "Authorization": f"Bearer {os.environ['HUB_ACCESS_TOKEN']}",
            "X-Tenant-Id": os.environ["HUB_TENANT_ID"],
            "Idempotency-Key": str(uuid.uuid4()),
        },
        json={
            "payment": "8920caef-a5bc-44b1-848e-97718177602b",
            "tax_profile": "a402de42-eb99-4034-83d8-eb13e26f3911",
            "cfdi_use": "D10",
            "send_email": True,
            "metadata": {
                "sap_billing_doc": "9000184502",
            },
        },
        timeout=30,
    )
    res.raise_for_status()
    data = res.json()
    <?php
    $ch = curl_init("https://api.sandbox.hubplus.example/v1/invoices");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . getenv("HUB_ACCESS_TOKEN"),
            "X-Tenant-Id: " . getenv("HUB_TENANT_ID"),
            "Idempotency-Key: " . bin2hex(random_bytes(16)),
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "payment" => "8920caef-a5bc-44b1-848e-97718177602b",
            "tax_profile" => "a402de42-eb99-4034-83d8-eb13e26f3911",
            "cfdi_use" => "D10",
            "send_email" => true,
            "metadata" => [
                "sap_billing_doc" => "9000184502",
            ],
        ]),
    ]);
    $body = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($status >= 400) {
        throw new RuntimeException("HUB+ respondió $status");
    }
    $data = json_decode($body, true);
    HttpClient client = HttpClient.newHttpClient();
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.sandbox.hubplus.example/v1/invoices"))
        .header("Authorization", "Bearer " + System.getenv("HUB_ACCESS_TOKEN"))
        .header("X-Tenant-Id", System.getenv("HUB_TENANT_ID"))
        .header("Idempotency-Key", UUID.randomUUID().toString())
        .header("Content-Type", "application/json")
        .method("POST", HttpRequest.BodyPublishers.ofString("""
            {
              "payment": "8920caef-a5bc-44b1-848e-97718177602b",
              "tax_profile": "a402de42-eb99-4034-83d8-eb13e26f3911",
              "cfdi_use": "D10",
              "send_email": true,
              "metadata": {
                "sap_billing_doc": "9000184502"
              }
            }
            """))
        .build();
    
    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());
    Respuesta (abreviada)
    {
      "id": "70c1b837-c3de-4e53-80fd-7a4e6994689b",
      "object": "invoice",
      "status": "issued",
      "cfdi_type": "I",
      "uuid": "5b0e7c1a-93d4-4f6b-8a27-1c4e9d2f7a31",
      "series": "ANN",
      "folio": "184502",
      "issuer": {
        "rfc": "EKU9003173C9",
        "legal_name": "UNIVERSIDAD EJEMPLO DEL NORTE",
        "tax_regime": "603",
        "zip": "52786"
      },
      "receiver": {
        "rfc": "XAXX010101000",
        "legal_name": "MARIA FERNANDA LOPEZ GARCIA",
        "tax_regime": "605",
        "zip": "52786"
      },
      "cfdi_use": "D10",
      "payment_method": "PUE",
      "payment_form": "04",
      "currency": "mxn",
      "subtotal": 1845000,
      "discount": 553500,
      "tax": 0,
      "amount": 1291500,
      "issued_at": 1793895304,
      "student": "2f13d743-bed0-4fd7-8a0a-9a1f054a968c",
      "payments": [
        "8920caef-a5bc-44b1-848e-97718177602b"
      ],
      "collection_notices": [
        "7ad76df8-b625-4e83-8503-1503720b30f3"
      ]
    }

    El timbrado puede ser inmediato (issued) o quedar en pending unos segundos. Escucha invoice.issued o invoice.failed.

  3. Descarga el XML y el PDF#

    GET/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/xml
    curl "https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/xml" \
      -H "Authorization: Bearer $HUB_ACCESS_TOKEN" \
      -H "X-Tenant-Id: $HUB_TENANT_ID"
    const res = await fetch("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/xml", {
      headers: {
        "Authorization": "Bearer " + process.env.HUB_ACCESS_TOKEN,
        "X-Tenant-Id": process.env.HUB_TENANT_ID,
      },
    });
    
    if (!res.ok) throw new Error(`HUB+ respondió ${res.status}`);
    const data = await res.json();
    import os
    import requests
    
    res = requests.get(
        "https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/xml",
        headers={
            "Authorization": f"Bearer {os.environ['HUB_ACCESS_TOKEN']}",
            "X-Tenant-Id": os.environ["HUB_TENANT_ID"],
        },
        timeout=30,
    )
    res.raise_for_status()
    data = res.json()
    <?php
    $ch = curl_init("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/xml");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . getenv("HUB_ACCESS_TOKEN"),
            "X-Tenant-Id: " . getenv("HUB_TENANT_ID"),
        ],
    ]);
    $body = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($status >= 400) {
        throw new RuntimeException("HUB+ respondió $status");
    }
    $data = json_decode($body, true);
    HttpClient client = HttpClient.newHttpClient();
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/xml"))
        .header("Authorization", "Bearer " + System.getenv("HUB_ACCESS_TOKEN"))
        .header("X-Tenant-Id", System.getenv("HUB_TENANT_ID"))
        .GET()
        .build();
    
    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());

    El PDF se obtiene igual, con GET/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/pdf. El responsable de pago también los recibe por correo y los encuentra en el portal.

  4. Cancela una factura#

    Indica el motivo de cancelación del SAT. Según el caso, el SAT puede requerir la aceptación del receptor.

    POST/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/cancel
    curl -X POST "https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/cancel" \
      -H "Authorization: Bearer $HUB_ACCESS_TOKEN" \
      -H "X-Tenant-Id: $HUB_TENANT_ID" \
      -H "Content-Type: application/json" \
      -d '{
      "reason": "02",
      "note": "El responsable de pago solicitó factura a nombre de su empresa."
    }'
    const res = await fetch("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/cancel", {
      method: "POST",
      headers: {
        "Authorization": "Bearer " + process.env.HUB_ACCESS_TOKEN,
        "X-Tenant-Id": process.env.HUB_TENANT_ID,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        "reason": "02",
        "note": "El responsable de pago solicitó factura a nombre de su empresa."
      }),
    });
    
    if (!res.ok) throw new Error(`HUB+ respondió ${res.status}`);
    const data = await res.json();
    import os
    import requests
    
    res = requests.post(
        "https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/cancel",
        headers={
            "Authorization": f"Bearer {os.environ['HUB_ACCESS_TOKEN']}",
            "X-Tenant-Id": os.environ["HUB_TENANT_ID"],
        },
        json={
            "reason": "02",
            "note": "El responsable de pago solicitó factura a nombre de su empresa.",
        },
        timeout=30,
    )
    res.raise_for_status()
    data = res.json()
    <?php
    $ch = curl_init("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/cancel");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . getenv("HUB_ACCESS_TOKEN"),
            "X-Tenant-Id: " . getenv("HUB_TENANT_ID"),
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "reason" => "02",
            "note" => "El responsable de pago solicitó factura a nombre de su empresa.",
        ]),
    ]);
    $body = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($status >= 400) {
        throw new RuntimeException("HUB+ respondió $status");
    }
    $data = json_decode($body, true);
    HttpClient client = HttpClient.newHttpClient();
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/cancel"))
        .header("Authorization", "Bearer " + System.getenv("HUB_ACCESS_TOKEN"))
        .header("X-Tenant-Id", System.getenv("HUB_TENANT_ID"))
        .header("Content-Type", "application/json")
        .method("POST", HttpRequest.BodyPublishers.ofString("""
            {
              "reason": "02",
              "note": "El responsable de pago solicitó factura a nombre de su empresa."
            }
            """))
        .build();
    
    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());
    MotivoCuándo se usa
    01Comprobante emitido con errores con relación. Requiere la factura que lo sustituye: usa la refacturación del paso siguiente.
    02Comprobante emitido con errores sin relación.
    03No se llevó a cabo la operación.
    04Operación nominativa relacionada en una factura global.

    La factura pasa a cancellation_pending y después a cancelled (evento invoice.cancelled). Si el receptor rechaza la cancelación recibes invoice.cancellation_rejected y la factura vuelve a issued.

  5. Refactura#

    Para corregir el receptor o el uso del CFDI, la refacturación emite la factura nueva, la relaciona con la original y cancela la original, en una sola operación.

    POST/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/reissue
    curl -X POST "https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/reissue" \
      -H "Authorization: Bearer $HUB_ACCESS_TOKEN" \
      -H "X-Tenant-Id: $HUB_TENANT_ID" \
      -H "Idempotency-Key: $(uuidgen)" \
      -H "Content-Type: application/json" \
      -d '{
      "tax_profile": "99fe6094-625e-4fb4-8e7e-cb283ebb5973",
      "cfdi_use": "G03",
      "note": "Cambio de receptor a persona moral a solicitud del responsable de pago."
    }'
    const res = await fetch("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/reissue", {
      method: "POST",
      headers: {
        "Authorization": "Bearer " + process.env.HUB_ACCESS_TOKEN,
        "X-Tenant-Id": process.env.HUB_TENANT_ID,
        "Idempotency-Key": crypto.randomUUID(),
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        "tax_profile": "99fe6094-625e-4fb4-8e7e-cb283ebb5973",
        "cfdi_use": "G03",
        "note": "Cambio de receptor a persona moral a solicitud del responsable de pago."
      }),
    });
    
    if (!res.ok) throw new Error(`HUB+ respondió ${res.status}`);
    const data = await res.json();
    import os
    import uuid
    import requests
    
    res = requests.post(
        "https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/reissue",
        headers={
            "Authorization": f"Bearer {os.environ['HUB_ACCESS_TOKEN']}",
            "X-Tenant-Id": os.environ["HUB_TENANT_ID"],
            "Idempotency-Key": str(uuid.uuid4()),
        },
        json={
            "tax_profile": "99fe6094-625e-4fb4-8e7e-cb283ebb5973",
            "cfdi_use": "G03",
            "note": "Cambio de receptor a persona moral a solicitud del responsable de pago.",
        },
        timeout=30,
    )
    res.raise_for_status()
    data = res.json()
    <?php
    $ch = curl_init("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/reissue");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer " . getenv("HUB_ACCESS_TOKEN"),
            "X-Tenant-Id: " . getenv("HUB_TENANT_ID"),
            "Idempotency-Key: " . bin2hex(random_bytes(16)),
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "tax_profile" => "99fe6094-625e-4fb4-8e7e-cb283ebb5973",
            "cfdi_use" => "G03",
            "note" => "Cambio de receptor a persona moral a solicitud del responsable de pago.",
        ]),
    ]);
    $body = curl_exec($ch);
    $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    
    if ($status >= 400) {
        throw new RuntimeException("HUB+ respondió $status");
    }
    $data = json_decode($body, true);
    HttpClient client = HttpClient.newHttpClient();
    
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://api.sandbox.hubplus.example/v1/invoices/70c1b837-c3de-4e53-80fd-7a4e6994689b/reissue"))
        .header("Authorization", "Bearer " + System.getenv("HUB_ACCESS_TOKEN"))
        .header("X-Tenant-Id", System.getenv("HUB_TENANT_ID"))
        .header("Idempotency-Key", UUID.randomUUID().toString())
        .header("Content-Type", "application/json")
        .method("POST", HttpRequest.BodyPublishers.ofString("""
            {
              "tax_profile": "99fe6094-625e-4fb4-8e7e-cb283ebb5973",
              "cfdi_use": "G03",
              "note": "Cambio de receptor a persona moral a solicitud del responsable de pago."
            }
            """))
        .build();
    
    HttpResponse<String> response =
        client.send(request, HttpResponse.BodyHandlers.ofString());

Estados de una factura#

EstadoSignificado
pendingEn proceso de timbrado.
issuedTimbrada y vigente.
cancellation_pendingCancelación solicitada, en espera del SAT o de la aceptación del receptor.
cancelledCancelada ante el SAT.
failedEl timbrado fue rechazado. failure trae el código y el mensaje.

Notas de crédito#

Una nota de crédito es un CFDI de egreso relacionado con una factura. Se genera sola cuando se reembolsa un pago facturado, y puedes emitirla de forma explícita, por ejemplo por una beca retroactiva:

POST/v1/credit_notes
curl -X POST "https://api.sandbox.hubplus.example/v1/credit_notes" \
  -H "Authorization: Bearer $HUB_ACCESS_TOKEN" \
  -H "X-Tenant-Id: $HUB_TENANT_ID" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "invoice": "70c1b837-c3de-4e53-80fd-7a4e6994689b",
  "amount": 369000,
  "reason": "retroactive_scholarship",
  "refund": "27bab773-c10e-426c-833c-b86f3225506b",
  "description": "Ajuste por beca de excelencia del 50% autorizada el 15-nov-2026 (20 puntos adicionales sobre colegiatura).",
  "metadata": {
    "sap_credit_memo": "9100002214"
  }
}'
const res = await fetch("https://api.sandbox.hubplus.example/v1/credit_notes", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.HUB_ACCESS_TOKEN,
    "X-Tenant-Id": process.env.HUB_TENANT_ID,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "invoice": "70c1b837-c3de-4e53-80fd-7a4e6994689b",
    "amount": 369000,
    "reason": "retroactive_scholarship",
    "refund": "27bab773-c10e-426c-833c-b86f3225506b",
    "description": "Ajuste por beca de excelencia del 50% autorizada el 15-nov-2026 (20 puntos adicionales sobre colegiatura).",
    "metadata": {
      "sap_credit_memo": "9100002214"
    }
  }),
});

if (!res.ok) throw new Error(`HUB+ respondió ${res.status}`);
const data = await res.json();
import os
import uuid
import requests

res = requests.post(
    "https://api.sandbox.hubplus.example/v1/credit_notes",
    headers={
        "Authorization": f"Bearer {os.environ['HUB_ACCESS_TOKEN']}",
        "X-Tenant-Id": os.environ["HUB_TENANT_ID"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "invoice": "70c1b837-c3de-4e53-80fd-7a4e6994689b",
        "amount": 369000,
        "reason": "retroactive_scholarship",
        "refund": "27bab773-c10e-426c-833c-b86f3225506b",
        "description": "Ajuste por beca de excelencia del 50% autorizada el 15-nov-2026 (20 puntos adicionales sobre colegiatura).",
        "metadata": {
            "sap_credit_memo": "9100002214",
        },
    },
    timeout=30,
)
res.raise_for_status()
data = res.json()
<?php
$ch = curl_init("https://api.sandbox.hubplus.example/v1/credit_notes");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("HUB_ACCESS_TOKEN"),
        "X-Tenant-Id: " . getenv("HUB_TENANT_ID"),
        "Idempotency-Key: " . bin2hex(random_bytes(16)),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "invoice" => "70c1b837-c3de-4e53-80fd-7a4e6994689b",
        "amount" => 369000,
        "reason" => "retroactive_scholarship",
        "refund" => "27bab773-c10e-426c-833c-b86f3225506b",
        "description" => "Ajuste por beca de excelencia del 50% autorizada el 15-nov-2026 (20 puntos adicionales sobre colegiatura).",
        "metadata" => [
            "sap_credit_memo" => "9100002214",
        ],
    ]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($status >= 400) {
    throw new RuntimeException("HUB+ respondió $status");
}
$data = json_decode($body, true);
HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.sandbox.hubplus.example/v1/credit_notes"))
    .header("Authorization", "Bearer " + System.getenv("HUB_ACCESS_TOKEN"))
    .header("X-Tenant-Id", System.getenv("HUB_TENANT_ID"))
    .header("Idempotency-Key", UUID.randomUUID().toString())
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
        {
          "invoice": "70c1b837-c3de-4e53-80fd-7a4e6994689b",
          "amount": 369000,
          "reason": "retroactive_scholarship",
          "refund": "27bab773-c10e-426c-833c-b86f3225506b",
          "description": "Ajuste por beca de excelencia del 50% autorizada el 15-nov-2026 (20 puntos adicionales sobre colegiatura).",
          "metadata": {
            "sap_credit_memo": "9100002214"
          }
        }
        """))
    .build();

HttpResponse<String> response =
    client.send(request, HttpResponse.BodyHandlers.ofString());

CFDI en sandbox#

Los CFDI de sandbox no tienen validez fiscal. Usa siempre el RFC genérico XAXX010101000 y datos ficticios en tus pruebas.

HUB+ by Paybook · Documentación para desarrolladores · API v1
Los hosts, llaves e identificadores de los ejemplos son ficticios.