Skip to main content

Invoice drafts

Invoice drafts allow you to save a preliminary or incomplete invoice, so you can send it to your client for review before applying the stamp and sending it to the SAT.

Once saved, you can download the PDF, but not the XML of a draft.

info

To create invoice drafts, your issuing organization must have the Advanced or higher plan. More information on our pricing page.

Create a draft

To create an invoice draft, simply create an invoice using the createInvoice method, sending the data you want to save and specifying the status field as draft.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');

const invoice = await facturapi.invoices.create({
status: 'draft', // Save as draft
customer: null, // When saving a draft, all fields become optional
items: [{
quantity: 2,
product: {
description: 'Ukelele',
product_key: '60131324',
price: 345.60,
taxes: [
{
type: 'IVA',
rate: 0.16
}
]
}
}],
use: 'G01',
payment_form: "28"
});

Edit a draft

To edit a draft, you can use the updateDraftInvoice method and update the invoice with the data you want to change.

const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');

const invoice = await facturapi.invoices.updateDraft('[INVOICE_ID]', {
customer: {
legal_name: 'Dunder Mifflin',
email: 'email@example.com',
tax_id: 'ABC101010111',
tax_system: '601',
address: {
zip: '85900'
}
}
});

Check if a draft is ready to stamp

To check if a draft is ready to be stamped, you can use the getInvoice method and check the is_ready_to_stamp field, which will have the value true when all the required fields are completed.To check if a draft is ready to be stamped, you can use the getInvoice method and check the is_ready_to_stamp field, which will have the value true when all the required fields are completed.

Stamp a draft

Stamping a draft means that you are ready to send the invoice to the SAT, and sign it with the organization's digital signature.

To stamp a draft, use the method stampDraftInvoice and specify the invoice ID. If the invoice is not ready to be stamped, you will receive an error in response.