Invoices

Preview invoice

POST
/v1/ec/invoices/preview

Checks the body of POST /v1/ec/invoices and computes the document as it would be issued today, without numbering, storing or sending anything. What is wrong with the body is refused with 422, as issuing would refuse it; what would stop issuing it right now (no plan, certificate or numbering, a business not live yet, the spending cap reached) comes back in warnings. Pass its preview_id to POST /v1/ec/invoices?preview_id=… to issue exactly this body.

Authorization

AuthorizationBearer <token>

Your API key, which acts for the one business it was created for: fb_sandbox_… issues in sandbox, fb_test_… in test, the tax authority's testing service, and fb_live_… in live.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

The issue date is always today in Ecuador: documents are transmitted when issued.

buyer*|||
lines*array<>
Items1 <= items
payments*array<>
Items1 <= items
plate?string

Vehicle plate (placa): of the commercial transport service (tabla 33) or the vehicle fuel was dispatched to (tabla 29). No spaces.

Match^[A-Z0-9-]{1,20}$
tip?string

Tip (propina), up to 10 % of the subtotal before taxes. It adds to the total.

Match^\d+(\.\d{1,2})?$
delivery_note_number?string

Number of the delivery note that accompanies the goods (guiaRemision).

Match^\d{3}-\d{3}-\d{9}$
export?

Export invoice (annex 4). The buyer needs an address.

reimbursement?

Expense reimbursement (annex 5): the documents being reimbursed. We compute their totals.

withholdings?array<>

Withholdings the invoice itself declares (retenciones, tablas 22 and 23): fuel marketers and press.

substitute_delivery_note?

Invoice that replaces a delivery note (annex 9): the transfer of the goods it sells.

third_party_charges?array<>

Other third-party items (annex 8): amounts you collect on behalf of third parties. They aren't part of the invoice's total.

negotiable?

Negotiable commercial document (annex 11): requires the counterparty's address and a term on each payment.

additional_discounts?array<>

Additional discount on the IVA base of a rate (descuentoAdicional), applied after the lines: the IVA of that rate is computed on the base minus the discount.

iva_refunds?array<>

IVA refunded to an older adult (valorDevolucionIva, annex 20), by rate, as the SRI's DIG service authorized it. It is subtracted from the total; the buyer must identify with a cedula.

fiscal_machine?

The fiscal machine the document is issued from (annex 13). Only when one issues it.

additional_info?array<>
Default[]
establishment?string

The establishment whose series numbers it, such as 001. Without it, the first active series of the document type.

Match^\d{3}$
emission_point?string

The emission point of that establishment, such as 001. Without it, the first active one.

Match^\d{3}$
metadata?

Up to 20 pairs of your own, such as your order id, returned as sent and never interpreted; lists filter by them (metadata[key]=value).

Default{}
simulate?

Only with a sandbox key (422 in test and live, where the SRI decides): the outcome the simulator gives this revision, to rehearse how your system handles each one. Without it, it is authorized.

Response Body

application/json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X POST "https://example.com/v1/ec/invoices/preview" \  -H "Content-Type: application/json" \  -d '{    "buyer": {      "identification_type": "consumidor_final"    },    "lines": [      {        "description": "string",        "quantity": "string",        "unit_price": "string",        "taxes": [          {            "type": "iva",            "rate": "iva_15"          }        ]      }    ],    "payments": [      {        "method": "sin_sistema_financiero"      }    ]  }'
{  "object": "document_preview",  "type": "invoice",  "preview_id": "stringstringstringstringstringstringstringstringstringstringstri",  "environment": "sandbox",  "entity_id": "8161163a-f227-466f-bc01-090a01e80165",  "issue_date": "2019-08-24",  "total": "string",  "tax_total": "string",  "warnings": [    {      "code": "string",      "message": "string",      "detail": "string"    }  ],  "document": {    "lines": [      {        "code": "string",        "auxiliary_code": "string",        "description": "string",        "unit": "string",        "quantity": "string",        "unit_price": "string",        "discount": "string",        "net": "string",        "taxes": [          {            "type": "iva",            "rate": "iva_15",            "base": "string",            "value": "string"          }        ],        "additional_info": [          {            "name": "string",            "value": "string"          }        ],        "unsubsidized_price": "string"      }    ],    "taxes": [      {        "type": "iva",        "rate": "iva_15",        "base": "string",        "value": "string",        "additional_discount": "string",        "refund": "string"      }    ],    "subtotal": "string",    "discount": "string",    "iva": "string",    "ice": "string",    "irbpnr": "string",    "total": "string",    "subsidy": "string",    "tip": "string",    "issue_date": "string",    "buyer": {      "identification_type": "ruc",      "identification": "string",      "name": "string",      "address": "string",      "email": "string"    },    "payments": [      {        "method": "sin_sistema_financiero",        "amount": "string",        "term": {          "length": 0,          "unit": "days"        }      }    ],    "plate": "string",    "delivery_note_number": "string",    "export": {      "incoterm": "string",      "incoterm_place": "string",      "origin_country": "string",      "loading_port": "string",      "destination_port": "string",      "destination_country": "string",      "acquisition_country": "string",      "subtotal_incoterm": "string",      "international_freight": "string",      "international_insurance": "string",      "customs_costs": "string",      "other_transport_costs": "string"    },    "reimbursement": {      "document_type": "factura",      "total": "string",      "base": "string",      "tax": "string",      "documents": [        {          "supplier": {            "identification_type": "ruc",            "identification": "string"          },          "supplier_type": "persona_natural",          "payment_country": "string",          "document_type": "factura",          "number": "string",          "issue_date": "string",          "authorization_number": "string",          "taxes": [            {              "type": "iva",              "rate": "iva_15",              "base": "string",              "value": "string"            }          ],          "compensations": [            {              "code": "string",              "rate": "string",              "value": "string"            }          ]        }      ]    },    "withholdings": [      {        "type": "iva_100",        "value": "string"      }    ],    "withheld_iva": "string",    "withheld_renta": "string",    "substitute_delivery_note": {      "origin_address": "string",      "destination_address": "string",      "transport_start": "string",      "transport_end": "string",      "carrier": {        "identification_type": "ruc",        "identification": "string",        "name": "string"      },      "plate": "string",      "destinations": [        {          "reason": "string",          "customs_document": "string",          "destination_establishment": "string",          "route": "string"        }      ]    },    "third_party_charges": [      {        "concept": "string",        "amount": "string"      }    ],    "negotiable": {      "notification_email": "string"    },    "compensations": [      {        "code": "string",        "rate": "string",        "value": "string"      }    ],    "fiscal_machine": {      "brand": "string",      "model": "string",      "serial": "string"    },    "additional_info": [      {        "name": "string",        "value": "string"      }    ]  }}