How to create an Invoice on a specific Sequence

Most of the times you will probably want to issue Invoices on the default Sequence. But you may need to specify the Sequence you want to create the Invoice on and that Sequence may not be the default one.

So how do you create an Invoice and specify the Sequence you want it to be created on?

First of all you will need to GET the ids of your Sequences. You can do that with this endpoint /sequences.json: https://developers.invoicexpress.com/docs/versions/2.0.0/resources/sequences/endpoints/list-sequences

The response will be something like this:

{
    "sequences": [
        {
            "serie": "A",
            "default_sequence": 1,
            "current_invoice_number": 0,
            "current_invoice_sequence_id": 101,
            "current_invoice_receipt_number": 0,
            "current_invoice_receipt_sequence_id": 102,
            ...
        },
        {
            "serie": "B",
            "default_sequence": 0,
            "current_invoice_number": 0,
            "current_invoice_sequence_id": 203,
            "current_invoice_receipt_number": 0,
            "current_invoice_receipt_sequence_id": 204,
            ...
        },
        ...
    ]
}

Note: Sequence ≡ Serie

When creating an Invoice, you should set the value of the sequence_id parameter depending on the type of document you want to create.

For example, if you want to create an Invoice on Sequence A, sequence_id should be 101.

If you want to create an InvoiceReceipt on Sequence B, sequence_id should be 204.

Note: default_sequence tells you which Sequence is set as default (1 means it's the default Sequence).