Electronic Invoicing (FE)

Everything you need to know about Costa Rica's electronic invoicing system (Factura Electrónica). This guide covers setup, digital certificates, document types, CABYS codes, tax rates, and troubleshooting to ensure full compliance with Hacienda.

Electronic Invoicing Overview

Factura Electrónica (Electronic Invoicing, commonly abbreviated as FE) is Costa Rica's mandatory electronic invoicing system administered by the Dirección General de Tributación (General Directorate of Taxation), part of the Ministry of Finance (Hacienda).

Important

All businesses registered as taxpayers in Costa Rica are legally required to issue electronic documents through Hacienda's system. Non-compliance can result in penalties, fines, and the inability to deduct expenses for tax purposes.

How It Works

The electronic invoicing process in Astra follows these steps:

  1. You create the invoice in Astra (or a credit or debit note from a document Hacienda has already accepted).
  2. You open the submission with the Electronic Invoice button in the invoice header. There you confirm branch and terminal, sale condition and payment method, and click Send to Hacienda.
  3. Astra validates before sending: the receiver's ID against the Hacienda registry, CABYS codes, IVA rates, exonerations and totals. If anything fails, nothing is sent and no consecutive number is spent.
  4. Astra generates the XML following Hacienda's technical specification (version 4.4), including the unique 50-digit Clave Numérica, and the FE API signs it with your cryptographic key and transmits it to Hacienda.
  5. Hacienda validates and responds: the invoice moves from Processing to Accepted or Rejected.
  6. The customer receives the signed XML and the PDF by email, and by WhatsApp if you tick it, followed by Hacienda's response.

What Astra Handles for You

Astra automates the process so you can focus on your business:

  • XML generation in the exact format required by Hacienda
  • Digital signing of documents using your certificate
  • Submission and status tracking (the invoice refreshes itself while Hacienda responds)
  • Consecutive numbering per branch and terminal
  • 50-digit Clave Numérica generation
  • PDF for the customer, sent with the XMLs by email and, if you tick it, by WhatsApp
  • Storage of the signed and response XMLs (the invoice's Files tab; they are also included in the Export and backup export)
  • Reception of supplier documents and replies to Hacienda (see Document Reception)

Setting Up Electronic Invoicing

Before you can issue electronic documents, you need to connect your organization to Hacienda. This is a one-time setup.

Prerequisites

You will need the following before you begin:

  • Hacienda electronic-document credentials — The username and password Hacienda assigns for electronic documents. They are generated in TRIBU-CR, the Hacienda portal that replaced ATV in October 2025.
  • Cryptographic key (.p12) and its PIN — The digital certificate used to sign your documents. See the Digital Certificates section.
  • Correct company data — Identification type and number, name, email address and economic activity, exactly as registered with Hacienda.
Important

Your electronic-document credentials are not the same as your Astra login. They are managed in TRIBU-CR, a separate Hacienda portal at ovitribucr.hacienda.go.cr (formerly ATV). If you don't have them yet, generate them there or ask at a local tax office.

Configuration Steps

  1. Complete Profile and contact — Open Settings and go to Profile and contact. Enter the identification type and number and use the Buscar información en Hacienda (look up in Hacienda) button: Astra fills in the registered name and the economic activities. Make sure the organization has an email address and at least one economic activity; without them Astra will not let you submit documents.
  2. Upload the certificate and credentials — In the Electronic invoicing section, open the Digital Certificate sub-tab: select the .p12 or .pfx file, type the PIN and fill in Hacienda username and Hacienda password (your TRIBU-CR username and password). Click Save Changes.
  3. Verify the connection — On save, Astra checks with Hacienda, before saving anything, that the .p12 opens with the PIN and that the credentials authenticate. If something fails, nothing is saved and the error says what to fix; if Hacienda does not answer, try again in a few minutes. The result appears in the verification panel. You can repeat the test any time with Verify now (verify now).
  4. Review your branches — In the Branches sub-tab, Astra has already created branch 001 with terminal 00001. You only need to adjust the starting sequence if you are migrating from another system. See Branches & Terminals.
  5. Optional: Technical Configuration — In the Technical Configuration sub-tab you can set the reception consecutives, how to receive supplier documents, and the Correo para alertas de error (error-alert email: where Astra writes when an automatic electronic invoice cannot be issued; if left empty, the organization owner is notified).
Who sees this tab?

The Electronic invoicing section is visible to organization administrators and to members whose role has the electronic-invoice settings permission. If something is missing when you try to send, the submission dialog lists it and offers a shortcut to the right settings screen.

Digital Certificates (Llave Criptográfica)

The digital certificate (also called Llave Criptográfica, cryptographic key) is a .p12 file that acts as your electronic signature. Every document sent to Hacienda must be signed with this certificate to prove its authenticity.

Step-by-step guide

This section is the summary. For the full walkthrough — the four items and where each one comes from, the verification panel, renewal and the common errors — see Digital Certificate & Hacienda Credentials.

What Is a Digital Certificate?

A digital certificate is a cryptographic file (with the .p12 or .pfx extension) that contains:

  • Your identity information (name, ID number)
  • A private key used to sign documents
  • A public key that Hacienda uses to verify the signature

The certificate is protected by a PIN that you set when generating it: 4 digits on older keys; keys generated in TRIBU-CR since July 2026 have at least 14 characters, with an uppercase letter, a lowercase letter, a number and a symbol.

How to Obtain a Digital Certificate

The cryptographic key for electronic documents is generated by Hacienda from its own portal. The steps are the same ones Astra emails you when your certificate is about to expire:

  1. Log in to Hacienda's TRIBU-CR portal with your identification number and password.
  2. In the electronic-documents section, generate a new cryptographic key and assign its PIN.
  3. Download the new key's .p12 file and keep it together with the PIN.
  4. If you also changed your electronic-document username or password while there, note them down: you will need them in Astra.
Important

Keep your .p12 file and PIN safe. If someone obtains both, they can sign electronic documents on your behalf. Never share your PIN or certificate file via email or messaging apps.

Uploading Your Certificate to Astra

  1. Open Settings, the Electronic invoicing section, then the Digital Certificate sub-tab.
  2. In Cryptographic key (.p12), select the certificate file.
  3. Type the PIN. The Expiry date and Serial fill in by themselves on save: Astra reads them from the certificate through the FE API.
  4. Fill in Hacienda username and Hacienda password. If they were already saved, leave the fields empty to keep them.
  5. Click Save Changes. Before saving, Astra checks with Hacienda that the .p12 opens with the PIN and that the credentials authenticate. If Hacienda rejects something, nothing is saved and the error appears above the field; if Hacienda does not answer, nothing is saved and you can try again in a few minutes. The result appears in the verification panel. You can repeat it with Verify now.
The Digital Certificate sub-tab with the certificate and credentials loaded
The Digital Certificate sub-tab with everything in place. Expiry date and Key serial are greyed out because Astra fills them; the PIN and password stay masked with a Configurado badge.

Certificate Expiration

Digital certificates have an expiry date. Astra shows it in the Digital Certificate sub-tab (Valid until) and, as it approaches:

  • Sends a warning email 30, 15, 7 and 1 day before expiry to the organization's email address and to users with the accountant role, with the renewal instructions.
  • If the certificate has already expired, the submission dialog blocks the invoice with the message "The organization's digital certificate has expired. You must upload a valid one." and offers to resend the renewal instructions.
  • Once you have the new key, upload it on the same screen with its PIN to replace the old one. If the Hacienda credentials changed, update them there too.
Warning

With an expired certificate you cannot issue invoices, tickets, or credit or debit notes until a valid one is uploaded. Renew as soon as you get the first reminder.

Branches & Terminals

Hacienda requires every electronic document to be associated with a branch (sucursal) and a terminal (point of sale). These are part of the document's consecutive numbering system.

What Are Branches?

A branch represents a physical business location. Every organization has at least one branch, which Astra creates automatically with code 001.

  • Branch codes are 3 digits (001 to 999) and are generated automatically when you add one; you can edit them.
  • Each branch has a name and, optionally, phone, email and address (province, canton, district, neighborhood and directions).
  • You can activate or deactivate branches and mark one as the default.
  • Adding more than one branch requires the Multi-branch add-on; the first one is always included.

What Are Terminals?

A terminal (point of sale) represents an issuing point within a branch. Each branch has at least one terminal.

  • Terminal codes are 5 digits (00001 to 99999) and are also generated automatically.
  • Each new branch automatically gets its terminal 00001, named Terminal Principal (Main Terminal).
  • Each terminal keeps its own independent sequence for every document type (FE, ND, NC, TE, acceptance messages, FEC and FEE).

How Numbering Works

The consecutive number of every electronic document follows this 20-digit structure:

SSS-TTTTT-DD-NNNNNNNNNN

  • SSS — Branch code (3 digits, e.g., 001)
  • TTTTT — Terminal code (5 digits, e.g., 00001)
  • DD — Document type code (2 digits, e.g., 01 for Factura Electrónica)
  • NNNNNNNNNN — Sequential number (10 digits, auto-incrementing)

For example, 001-00001-01-0000000042 means: branch 001, first terminal, electronic invoice, number 42.

Tip

If you have a single-location business, the branch 001 and terminal 00001 Astra creates automatically are all you need. Each team member can have a Default branch and terminal (in the Team tab, when editing the member); they are preselected when the submission dialog opens.

Creating Branches and Terminals

  1. Open Settings, the Electronic invoicing section, then the Branches sub-tab.
  2. Click Agregar Nueva Sucursal (add new branch). In the Nueva Sucursal dialog fill in the name, review the Branch code (auto-generated) and the Starting sequence, and optionally the contact and address details.
  3. The Terminal Principal (00001) is created automatically with that starting sequence.
  4. To add more terminals, click Agregar Terminal (add terminal) inside the branch and fill in name, Terminal code and Starting sequence.
  5. When editing an existing terminal (the pencil on its row, under the branch) you see the Document sequences section with the Next sequence for each document type, which you can adjust. From Editar Sucursal ("edit branch") the Consecutivos de la terminal 00001 button takes you to the same place.
Migrating from another system

The Starting sequence applies to issued documents (FE, TE, NC, ND, FEC, FEE); acceptance messages always start at 1. If your company already issued documents with another system, adjust the branch code and starting sequence so numbers are not duplicated with Hacienda, or use a new branch. If the branch already exists, edit the terminal and set each Next sequence to the number after the last one you issued in the other system (if your last invoice was 245, enter 246). Lowering a Next sequence below numbers already issued can produce duplicates: Astra warns you but does not prevent it.

Document Types

Costa Rica's electronic invoicing system defines several document types, each identified by a two-digit code. Astra issues invoices, tickets, credit and debit notes, purchase invoices and export invoices, and replies with acceptance messages to the documents you receive.

Factura Electrónica (FE) — Code 01

The standard document for sales to an identified taxpayer. Astra uses it automatically when the invoice's contact has an identification type and number on file: cédula física (9 digits), cédula jurídica (10), DIMEX (11 or 12) or NITE (10). Before sending, Astra checks the Hacienda registry: if the number is registered under a different type it corrects it for you and warns you; if it does not exist, it blocks the submission so no consecutive number is wasted. A customer with a cédula jurídica must have an email address. The customer's address is optional: it goes out complete (province, canton, district and address details) or not at all. If the contact has a partial one, the submission dialog flags it with the Address quick fix so you can complete it or clear it.

Tiquete Electrónico (TE) — Code 04

The document for final consumers. Astra uses it automatically when the invoice has no customer, the customer has no ID number, or the ID is foreign (passport or other), and also when the customer asked not to appear before Hacienda (see below). The submission dialog tells you which type will be sent.

Tip

If a customer has a cédula and wants to deduct the expense, record the identification type and number on their contact card: with that, Astra issues a Factura Electrónica. A contact without an ID always gets a Tiquete Electrónico.

A customer who doesn't want to appear before Hacienda

Some people prefer that their name and cédula don't reach Hacienda, even though the business keeps them for history, birthdays or receivables. For a customer who is a persona física or has a DIMEX, the send dialog shows a Send as line at the top with the Not identified to Hacienda switch:

  • Off: Invoice in the name of the customer, as always.
  • On: Unidentified tiquete. Hacienda receives a Tiquete Electrónico with no receiver: no name, ID, email or economic activity. The sale stays on the customer's record and, if the customer has an email, Astra sends them the receipt.
Send as line: Invoice in the name of the customer, with the Not identified to Hacienda switch off
Off: the sale goes out as an Invoice in the customer's name.
Send as line: Unidentified tiquete, with the Not identified to Hacienda switch on
On: it goes out as an Unidentified tiquete; Hacienda receives no name, ID or email.

Astra remembers the choice on the customer once the submission goes through: their next sale opens with the switch as it was left. Closing the dialog without sending changes nothing. It can also be set on the contact card, with the Unidentified tiquete to Hacienda checkbox under the identification. Recurring invoices, which are sent without a dialog, follow the customer's setting, and on the phone the send summary has the same switch.

Important

Without an invoice, the customer can't deduct the purchase or use the IVA as a credit. That's why companies (cédula jurídica) and NITE always get an invoice, and a sale with an exemption always goes in the customer's name: Hacienda needs to know who holds the exemption (the switch shows as locked with that notice). A credit or debit note against an unidentified tiquete doesn't identify the customer either, and that sale's PDF and printed receipt don't show the cédula.

Nota de Crédito Electrónica (NC) — Code 03

Used to correct or reverse a document Hacienda has accepted. Common uses:

  • Returning a sale (full or partial)
  • Correcting an error on the original invoice (wrong amount, wrong product)
  • Applying a discount after the invoice was issued

In Astra the credit note is created from the accepted invoice with the Credit Note button in the header; it always references the original document (consecutive and clave numérica). See Credit Notes.

Nota de Débito Electrónica (ND) — Code 02

Used to charge additional amounts against an accepted document. Common uses:

  • Late payment interest
  • Additional charges not included in the original invoice
  • Upward price adjustments

It is created the same way, with the Debit Note button in the header, and also references the original document. See Debit Notes.

Important

You can only issue credit or debit notes against an accepted document. A rejected document is not corrected with a note: it is replaced (see Replacing a Rejected Invoice).

Other Document Types

  • Factura Electrónica de Compra (FEC) — Code 08 — Issued by you, from a purchase invoice, to document purchases from suppliers who cannot issue electronic documents. See Purchase Electronic Invoice.
  • Export Electronic Invoice (FEE) — Code 09 — For exports of goods, services or intangible assets from Costa Rica to abroad. See the FEE guide for requirements and issuing steps.
  • Acceptance messages (Codes 05, 06, 07) — Your replies to the documents you receive from suppliers. See Document Reception.

Customer with an overseas address

An overseas address does not prove an export. Astra helps you review a local sale, FEE for an export or incorrect contact details. See the Export Electronic Invoice (FEE) guide for examples, requirements, steps and common errors.

Sending Documents to Hacienda

In Astra, sending to Hacienda is an explicit action: you create the invoice, review it, and send it from its header. The consecutive number is assigned at that moment.

How to Send an Invoice

  1. Open the invoice and click the Electronic Invoice button in the header (the same button later shows the submission status).
  2. Review the dialog: Branch & Terminal (preselected from your defaults), Commercial Data (Sale condition, Credit term if on credit, Payment method) and Situation (Normal by default).
  3. Review the Activity Codes: the issuer's activity and, if the customer is registered, the receiver's (you can load them with Look up with Hacienda).
  4. Under Send to the customer, tick who gets the document, by email and by WhatsApp (see Send to the customer). Under Other emails you can add addresses separated by commas (up to 5): they get a copy of the same email, with the PDF and XML files, even when the customer has no email. If one is mistyped, Astra does not send until you fix it.
  5. Click Send to Hacienda (or press ⌘ + Enter on a Mac, Ctrl + Enter on Windows; it works the same for credit and debit notes). If Astra finds errors, it lists them in the same dialog with quick fixes for the customer's ID or email, the CABYS, the rate or the unit of measure, and the button reads Fix errors before sending.

After sending, the invoice is locked for editing and the header button goes through Sending… and Processing until Hacienda responds; the page refreshes itself every few seconds in the meantime. The consecutive number is consumed on send even if the submission fails afterwards: gaps in the numbering caused by failed attempts are normal.

Who can send

Sending to Hacienda, and sending again, requires the Create permission on Invoices, the same on desktop and on the phone; credit and debit notes too. Someone without it can open the dialog and see the status and the data, but instead of the Send to Hacienda button they see a note that this permission is missing. Changing the dialog's data (dates, notes, sale condition) still requires Edit, as does Dismiss Error.

Send to the customer: email and WhatsApp

The dialog's Send to the customer section shows who gets the document: the customer and each related person with an email or a mobile number, with an Email and a WhatsApp box per person.

  • Email — starts ticked as always: the customer, its billing contact and the related persons who receive invoices. The billing contact always gets the email, so its box cannot be unticked.
  • WhatsApp — starts unticked. Tick who should get it: they receive a message with the PDF and the XML files from your business's WhatsApp. The text is the Electronic comprobante - WhatsApp template, which you can change in the message templates. If your business has no WhatsApp connected, the column is greyed out with a Connect WhatsApp link.
  • Add person — adds someone new (name, email, mobile) as a related person of the customer, already ticked for this document.
  • Other emails — one-off addresses, separated by commas (up to 5).
Send to the customer section with one row per person and the Email and WhatsApp boxes
One row per person: the accountant gets the document by email and by WhatsApp; the manager does not get it.

What you change in this section is saved on the customer: the next document for that customer opens with the same boxes. You can also change it on the contact card, on each related person (Invoices and Invoices by WhatsApp).

WhatsApp goes out at the same moments as the email: the PDF and the signed XML when it is sent to Hacienda, and Hacienda's response as soon as it arrives (if it was already there, everything goes in one message). If Hacienda rejects the document before it goes out, nothing is sent. Each WhatsApp send is listed in the invoice's Activity tab with the person and the number, and when it could not be sent, with the reason (for example, WhatsApp is not connected), so you can send it by hand from the invoice's WhatsApp button.

Automatic Submission: Recurring Invoices

The only automatic issuing is for Recurring Invoices with Issue electronic invoice enabled: every cycle is signed and sent to Hacienda without intervention and the customer receives the document with its XMLs by email (recurring invoices do not go out by WhatsApp: a bulk send from your business's number can get it blocked by WhatsApp). If a cycle cannot be issued (for example, a customer detail is missing), Astra retries daily and emails the Correo para alertas de error address set in Technical Configuration (or the organization owner if it is empty).

From Mobile

In the mobile version, the invoice detail has a Send to Hacienda button. It opens a summary with the document type (Factura or Tiquete Electrónico), the receiver, branch and terminal, the sale condition and the total, and Send to the customer: a main switch and, under it, one per person for email and one for WhatsApp, as on desktop. If the submission fails, Retry Hacienda submission appears. Credit and debit notes, and replacing a rejected document, are handled from the desktop version.

The Clave Numérica (50-Digit Unique Key)

Every electronic document has a unique Clave Numérica: a 50-digit numeric code that serves as its universal identifier. Astra generates it automatically. The structure is:

Position Length Field
1-33Country code (506 = Costa Rica)
4-52Day (DD)
6-72Month (MM)
8-92Year (YY)
10-2112Issuer identification number (cédula, zero-padded)
22-4120Consecutive number (branch + terminal + type + sequence)
421Situation code (1=Normal, 2=Contingency, 3=No internet)
43-508Security code (random)

You don't need to understand or build this key manually: Astra handles it entirely. But it is useful to know that this is how Hacienda uniquely identifies every electronic document in the country, and it is what support will ask you for if you need help with a document.

XML Generation and Signing

When you send a document, it goes through these steps:

  1. Validation — Astra checks organization, customer, lines, taxes and exonerations before spending a consecutive number.
  2. Generation — Astra takes the consecutive number, builds the clave numérica and assembles the document with all lines, taxes, totals and economic activities.
  3. Signing and submission — The FE API signs the XML with your cryptographic key and transmits it to Hacienda with your credentials.
  4. Response — Hacienda replies and the invoice changes to Accepted or Rejected.
  5. Storage and email — The signed XML and the response XML are attached in the invoice's Files tab. The customer receives an email with the signed XML and the PDF and, when Hacienda's response arrives, a second email with that XML (if it was already available at send time, everything goes in a single email).

Hacienda Response Statuses

The Electronic Invoice button in the header shows the document's status:

Status Meaning
Sending…The document is being handed to the FE API.
ProcessingSigned and submitted; waiting for Hacienda's response. The page refreshes itself.
AcceptedHacienda accepted the document.
RejectedHacienda rejected it. The reason is shown in the header.
FE ErrorThe submission never reached Hacienda (for example, the FE API did not respond or the credentials failed). It is not a rejection.

Accepted

The document passed all validations and was officially accepted by Hacienda. This means:

  • The document is legally valid
  • It has been recorded in Hacienda's systems
  • The customer can use it for tax deductions
  • No further action is required from you; the response XML is kept in Files and the customer receives it by email

Rejected

The document failed one or more of Hacienda's validations. The rejection message is shown in the invoice header and in the Replace dialog. Reasons Hacienda does end up reporting (the ones Astra can detect are blocked before sending):

  • Receiver ID does not exist — The number is not in the Hacienda registry
  • Invalid CABYS code — The code does not exist in the catalog
  • Incomplete exoneration — The exoneration document's article or subsection is missing
  • Rate mismatch — The rate code does not match the percentage applied
  • Duplicate clave — A document with the same clave numérica already exists
  • Calculation or tax-breakdown errors — These are Astra's responsibility; see Case B

FE Error

If the submission fails before reaching Hacienda, the header shows FE Error and the error detail. You can retry from the same button once the problem is resolved. If you need to edit the invoice before resending, use Dismiss Error (only available while Hacienda has not received the document).

Warning

Rejected documents are not legally valid for Hacienda. Because the invoice "never existed" in their records, you cannot issue a credit note against it, and the rejected consecutive number cannot be reused. The only valid path is a new invoice with a new consecutive number, and for that Astra has the Replace button (see Replacing a Rejected Invoice).

Replacing a Rejected Invoice

If Hacienda rejects an invoice, Astra makes it easy: a single button creates the replacement invoice with a new consecutive number, automatically moves the customer's payments to the new one, and hides the rejected invoice from accounts receivable once the new one is accepted.

First — Astra prevents most rejections

Hacienda rejections are rare in Astra because every document goes through several layers of validation before it ever reaches Hacienda's servers:

  • Document validator — checks that the receiver's ID exists in the Hacienda registry, emails are well-formed, products have consistent CABYS codes and units of measure, and that the invoice lines add up correctly.
  • Math validator — verifies that the per-category totals (taxed services, exempt merchandise, etc.) match the sum of the individual lines. Catches errors Hacienda would report as codes -107, -109, -110, -111, -190, -290, -476, -487 and -488.
  • Tax-rate validator — confirms that each line's IVA rate code matches the percentage applied and what the CABYS requires (for example, an exempt CABYS must use the exempt rate).
  • CABYS & unit pre-flight — blocks submission if a product's CABYS or unit of measure changed and the invoice wasn't refreshed.
  • Receiver activity lookup — for Purchase Electronic Invoices (FEC), Astra confirms the receiver has the economic activity you're reporting.
  • Certificate health — Astra warns you well in advance if your cryptographic key is about to expire, and blocks submission once it has.

If any validation fails, the invoice is not sent to Hacienda. You see the error in the submission dialog and can fix it without spending a consecutive number. Only issues that none of these layers can catch end up as a true Hacienda rejection.

When Hacienda rejects anyway

A Replace rejected invoice button (circular-arrow icon on indigo) appears in the header of the rejected invoice. Clicking it opens a dialog that behaves in one of two ways depending on the cause of the rejection:

Case A: Your data needs a fix

Examples: wrong CABYS code, an extra digit in the receiver's ID, exoneration missing the article reference, a tax rate that doesn't match the CABYS code. The dialog shows the Hacienda rejection reason and previews what will happen when you confirm with Replace:

  1. Astra creates a new invoice (an editable copy of the rejected one) with a fresh consecutive number. The customer, line items, taxes, and exoneration are cloned; the exoneration refreshes to the contact's current state.
  2. The customer's payment is auto-migrated to the new invoice, including payment history and multi-invoice allocations if any existed. The rejected invoice now reads zero paid.
  3. The rejected invoice is flagged as "Being replaced by Fxx (awaiting Hacienda response)" with a blue banner — but it still counts toward accounts receivable until Hacienda confirms the new one.
  4. You're taken straight to the new invoice so you can fix the bad data (CABYS, ID, etc.) and submit it to Hacienda using the normal Electronic Invoice button. The replacement is sent with reference code 16 (replaces a rejected electronic document) pointing at the rejected document's clave; Astra adds it for you.
  5. When Hacienda accepts the new one, the rejected invoice is marked replaced with an amber banner, hidden from accounts receivable and sales reports, and kept only as a historical reference for auditors.
If the new one is also rejected

No problem — click Replace again on the new one, and the chain extends (F13 → F14 → F15). The original stays in the "awaiting response" banner as long as none of the replacements has been accepted. Once any one in the chain is accepted by Hacienda, the whole chain is marked replaced at once.

Case B: It's Astra's fault

There's a handful of Hacienda error codes (-107, -109, -110, -111, -190, -290, -475, -476, -487, -488) that indicate a problem in how Astra generated the XML — a calculation, a tax breakdown, or a summary field. Our pre-submission validators should have caught these; if they reach Hacienda, it's a system failure that's on us to fix.

In that case the Replace dialog behaves differently:

  • It shows System error detected with the codes, and the Replace button is blocked. If you replaced now, the replacement would be sent with the same flaw and Hacienda would reject it too, burning another consecutive needlessly.
  • Instead a Report to the Astra team button appears. The rejection was already logged automatically for the development team the moment Hacienda responded; clicking the button adds your report with all the details (codes, full message, organization and invoice).
  • Our team ships a fix to production as fast as possible.
  • Once the fix is released, the dialog shows Issue fixed, the Replace button is re-enabled and you can proceed normally as in Case A.
Why we block in this case

Hacienda doesn't allow reusing a rejected consecutive number, and it doesn't accept credit notes against an invoice it has itself rejected. Each failed attempt costs you a consecutive from your assigned range. Blocking the replacement when we know it will fail again protects you from burning consecutives on a problem only we can fix.

What happens to the rejected invoice

The rejected invoice is never deleted or voided — it stays visible as a historical reference (including the signed XML and Hacienda's response in Files, for auditing purposes). The only things that change are:

  • While the replacement is in flight: blue banner "Being replaced by Fxx (awaiting Hacienda response)".
  • After the replacement is accepted: amber banner "This invoice was replaced by Fxx on [date]" with the View replacement link.
  • Payment edit/delete buttons are hidden (the payments live on the new invoice now).
  • The invoice is automatically excluded from accounts receivable, sales charts, customer totals, and dashboard KPIs.

Seeing it in reports (auditor mode)

The contact's invoice tab has a Show replaced checkbox. Ticking it includes replaced invoices in the listing (with their respective banner) — useful for accountants who need the full history, not just what counts for taxes.

Contingency Mode

Two different situations are often confused: the document situation you declare when sending, and what happens when Hacienda does not respond at send time.

Document Situation

In the submission dialog, the Situation field has three options, recorded in position 42 of the clave numérica:

  • Normal — The document is generated and transmitted in the same act. This is the default.
  • Contingencia (contingency) — The document replaces a physical receipt issued while electronic invoicing was not possible.
  • Sin Internet (no internet) — The document was generated without a connection to transmit it immediately.

If you choose Contingencia or Sin Internet, Astra asks for the Voucher issue date (the date of the physical document). You decide the situation; Astra never changes it on its own.

An invoice sent on a later day

A document is issued when it is signed and sent. So if you send an invoice dated an earlier day as Normal, it goes out with today's date, and Astra re-dates the invoice when it sends it. An invoice dated September 28 and sent on October 9 becomes an October invoice for Hacienda, the IVA return, the reports and the books.

The send window warns you at the top, in the Warnings box, in yellow when the invoice changes month, and offers the Send with the original date button. That button sets the situation to Contingencia with the invoice's date, so the invoice stays in its month.

  • Hacienda asks for contingency documents within 2 business days after service is restored. Past that, Astra shows a warning with the business days of delay. Hacienda usually accepts the document with a late-issue note, but a late submission can bring fines. Astra warns; it does not block the submission.
  • If that month's IVA return is already due, the warning says so: if you already filed it, the invoice changes it and you need to amend it.
Warnings box of the send window: notice that, as Normal, the invoice goes out with today's date and changes month, and the Send with the original date button
A September invoice sent in October. As Normal it would go out with today's date and count in October; the button sends it with its own date.
Warnings box after Send with the original date: the invoice goes out in contingency with its own date and the notice counts the business days of delay
After the button: the situation is Contingencia with the invoice's date (below, under Commercial Data). The notice counts the business days of delay; you can still send it.

When Hacienda Is Down

If, at send time, Hacienda's servers do not respond or return an error:

  • The document is already signed and queued in the FE API, which retries automatically until Hacienda receives it.
  • Astra notifies you "Document queued — Hacienda unavailable" and the invoice stays in Processing.
  • The customer immediately receives the email with the signed XML and the PDF, and when Hacienda accepts, a second email (Hacienda Response — Invoice N) with the response XML.
  • You can keep creating and sending documents normally.

Automatic Recovery

There is nothing to do: when Hacienda comes back, the queued documents are processed and each invoice moves from Processing to Accepted or Rejected. If instead the invoice shows FE Error, the submission never made it into the queue; retry it from the same button once the service is restored.

Tip

If an invoice stays in Processing longer than usual, do not resend or replace it: it is already queued, and sending it again would spend another consecutive number. If the status has not changed after several hours, write to support with the clave numérica.

CABYS Codes

The CABYS (Catálogo de Bienes y Servicios — Catalog of Goods and Services) is a classification system maintained by Costa Rica's tax authority. Every product or service on an electronic document must have a valid CABYS code.

Important

CABYS codes are mandatory on all electronic documents. Astra will not send a line without a CABYS, and Hacienda rejects any invalid code. The code also determines the applicable IVA rate for that product or service.

What Is a CABYS Code?

A CABYS code is a 13-digit numeric code organized in a 9-level hierarchy. Each level adds more specificity:

  • Level 1: Broad category (e.g., "Products of agriculture")
  • Level 9: Specific product or service (e.g., "Organic coffee beans, roasted")

For example, code 8713000000000 is "Servicios de mantenimiento y reparación de computadores y equipo periférico" (computer and peripheral maintenance and repair services), with 13% IVA.

Searching the CABYS Catalog

When assigning a CABYS to a product or an invoice line, Astra opens a catalog search:

  • Search by name — Type a description like "reparación computadores" and Astra finds the matching codes (accents don't matter)
  • Search by code — If you know the CABYS code, type it directly
  • Results show the code, the description and the IVA rate that applies
  • Search the way you say it — the catalog says "alquiler de inmueble con fines comerciales" (commercial property rental), but alquiler de bodega, local comercial, oficina, galera or parqueo find it too
  • Products and services apart — Hacienda tells them apart by the CABYS's first digit: 0 to 4 are goods and 5 to 9 are services. The search shows codes of the item's type (Product or Service) first and the other type in a separate section. On a new product or a hand-typed line, choosing one of those switches the item to that type; on a product that can no longer change type, the search just tells you how many there are

CABYS Favorites

If your business frequently uses the same CABYS codes, save them as favorites for quick access:

  1. Open Settings, the Electronic invoicing section, then the CABYS Favorites sub-tab.
  2. Search for CABYS codes and click the star icon to add them to your favorites; you can reorder them.
  3. In the same sub-tab, under Predeterminados (defaults), you can set a default CABYS for products and another for services: the CABYS search proposes them first, and products created without a code (for example, from your online-store sync) receive them automatically.
  4. In the CABYS search, your favorites have their own tab for quick selection. If the item is a Product and your favorites are services (or the other way round), the tab shows them in the other type's section instead of coming up empty.
Tip

Assign the CABYS code directly to your products in the catalog. That way, every time you add that product to an invoice, the correct CABYS and IVA rate are applied automatically.

CABYS and Tax Rates

Each CABYS code has an associated IVA rate. When you select a CABYS on a product or a line, Astra adjusts the line's tax to that rate. See Tax Rates for the complete list.

Tax Rates (IVA)

Costa Rica's Value Added Tax (IVA) has several rates. The one that applies to each good or service is defined by the CABYS code, and on the document every line carries a rate code that Hacienda requires in version 4.4.

IVA Rate Table

Rate Code Description and examples
13% 08 General rate: most goods and services
8% 07 Transitional 8% rate
4% 04 Reduced rate: private health services, airline tickets, insurance
2% 03 Reduced rate: medicines, agricultural inputs, private education
1% 02 Reduced rate: basic tax basket (canasta básica)
0.5% 09 Reduced rate: certified organic agricultural products
0% (Exempt) 01 / 10 Exempt (Art. 32 RLIVA) or Tarifa Exenta. An exempt CABYS must use the exempt rate (10)
0% (Not subject) 11 Operations not subject to IVA
Important

The rate is determined by the CABYS code, not by personal choice. Before sending, Astra verifies that each line's rate code matches the percentage applied and what the CABYS requires; if they don't match, the invoice is not sent until you fix it.

Tax Exoneration (Exoneración)

Some buyers hold an authorization in their name that reduces or removes the IVA on their purchases: a Hacienda AL- number, a free-zone company, a diplomat. In Astra the exoneration is recorded once on the customer, not on each invoice:

  • On the customer, Professional tab, Exoneration Information: type the AL- number and click Look up in Hacienda. Astra brings the rest, with the expiry date and the products it covers.
  • When you add lines to that customer's invoice, Astra applies the exoneration by itself, but only to products the authorization covers and while it is valid.
  • Before sending, Astra checks the authorization again and stops, with a one-click fix, if it expired, isn't that customer's, or a line isn't covered.

An exempt sale, an exonerated one and one to a municipality or the CCSS (not subject) are different things. The guide Exonerated, exempt and non-taxable customers explains each case and how to set it up.

Document Reception and FEC

Two purchase-related features that are easy to confuse:

  • Document reception — Receiving the electronic invoices your suppliers issue to you and replying to Hacienda with an acceptance or rejection message.
  • Factura Electrónica de Compra (FEC) — A document you issue when the supplier cannot issue an electronic invoice. It is created from a purchase invoice and has its own guide: Purchase Electronic Invoice.

How Reception Works

Your suppliers' documents enter Astra in two ways:

  • By email — In Settings → Electronic invoicing → Technical Configuration, section Document reception, you'll find your Email para recibir comprobantes (reception email address). Share it with your suppliers so they send their XMLs there.
  • By uploading the XML — In Expenses → Document Reception, with Upload XML (you can select several files). Astra verifies that the document was issued to your ID.

Astra does not download documents from Hacienda: it only processes what arrives by email or what you upload.

Response Options

For each received document, you send Hacienda a receiver message stating your decision:

  • Accept (Code 05) — You agree with the document as issued. This is the usual response for valid purchase invoices.
  • Partial accept (Code 06) — You accept the document with reservations (for example, a quantity discrepancy or a quality issue).
  • Reject (Code 07) — You reject the document entirely (for example, you never made that purchase or it is for another company).

When replying you also set the Tax condition (whether the IVA is creditable or an applicable expense). The document status goes through Pending, Processing and Accepted, Partial or Rejected; if Hacienda is down you'll see Queued (Hacienda). The consecutives for these messages are set in Technical Configuration → Consecutivos de recepción.

Important

Respond to received documents promptly: accepted documents are what support the deduction of your purchases. Electronic tickets cannot be used as deductible expenses; ask the supplier for an electronic invoice.

Automatic Acceptance

In the same Document reception section of Technical Configuration you can enable Accept documents automatically: documents arriving by email are accepted and sent to Hacienda without intervention. With that option on you can also tick Email the confirmation to the issuer to let the supplier know their document was accepted. With the option off, documents wait in your inbox and you reply to each one.

Warning

Only enable automatic acceptance if you trust all your suppliers. An acceptance message sent to Hacienda cannot be undone. Review your reception inbox regularly even with the option enabled.

Creating Purchase Invoices from Received Documents

From a received document you can use Create Purchase Invoice (or create several at once with Create purchase invoices): Astra generates the purchase invoice with the supplier's data and its lines, with no manual entry. All the details of the inbox, filters and replies are in Document Reception.

Troubleshooting

This section covers the most common messages you may encounter with electronic invoicing and how to resolve them. Almost all of them appear in the submission dialog, before the document leaves for Hacienda.

Certificate and Credential Issues

Message Cause Solution
"The organization has no digital certificate (cryptographic key) configured." No .p12 has been uploaded Upload your .p12 or .pfx file and PIN in Settings → Electronic Invoice → Digital Certificate
"The organization's digital certificate has expired. You must upload a valid one." The certificate's expiry date has passed Generate a new key in TRIBU-CR and upload it; the dialog offers to resend the instructions
"The organization has no Hacienda (TRIBU-CR) credentials configured." The Hacienda username or password is missing Fill them in on the Digital Certificate sub-tab and save
Verification panel: "Certificate and PIN: the certificate could not be validated" The PIN does not match the .p12 file, or the file is damaged Re-enter the PIN and save. If you forgot it, generate a new key in TRIBU-CR
Verification panel: "Hacienda credentials (TRIBU-CR): authentication failed" Username or password wrong or expired Check them in TRIBU-CR and update them in Astra; click Verify now

Organization Data

Message Cause Solution
"The organization has no economic activity code configured." Economic activities were not loaded In Profile and contact, use the Hacienda lookup or add the activity manually
"The organization has no identification number" / "identification type" Identity data is missing Complete it in Profile and contact
"The organization has no email configured." Hacienda requires the issuer's email Add the email in Profile and contact
FE Error status in the header The FE API did not respond, or authentication with Hacienda failed Read the error detail, check certificate and credentials, and retry. Use Dismiss Error if you need to edit the invoice before resending

Customer and Line Data

Message Cause Solution
"The customer ID (…) does not exist in the Hacienda registry." The ID number is wrong or the customer is not registered Fix the number from the same dialog. If the customer is not registered, remove the ID to issue a Tiquete Electrónico
"The customer ID type for … was auto-corrected…" The number was registered under another type (for example, a jurídica saved as NITE) Just check that the name Hacienda reports is your customer; if not, the number is wrong
"The customer (company) has no email." Hacienda requires an email for company receivers Add the email from the dialog or on the contact card
"The customer has a foreign ID… it will be sent as Tiquete Electrónico." Just a notice Nothing to do, unless it is an export: then choose FEE
"Line N: No CAByS code assigned." The product or line has no CABYS Assign it from the dialog (it is saved on the product) or in the product catalog
"Line N: Hacienda does not accept the unit of measure '…'." The unit is an old code (from before version 4.4), such as Ozs, m or kg, that Hacienda no longer takes Click Unit on that error: Astra proposes the current code (Oz, M, Kg) and corrects it on the line and on the product
"CAByS … is a services code but unit of measure … is for goods" (or vice versa) CABYS and unit of measure disagree. A CABYS starting with 5 to 9 is a service and takes a service unit: Sp, St, Spe, Os, Al, Alc (commercial rent), Cm, I or a time unit (h, D, Min, S); 0 to 4 is goods Choose the right unit from the dialog; it is applied to the product. Products and lines saved now already take a unit of the CABYS's kind, so this error only shows up on older data
"Rate code … corresponds to X% but the tax has Y%" / "the CABYS is Exempt, so it must use rate 10" The line's rate does not match the rate code or the CABYS Click Classify IVA. If it is exempt, keep Exempt rate (10). If it carries IVA (13%, say), pick that rate and then a CABYS that carries it: it is saved on the line and on the product (a typed-in line becomes a product), so the next invoice goes out right. If the percentage changes, Astra recalculates the line's total
"The customer has an exoneration but this line does not have it applied." The line was created before the exoneration was recorded Edit the line and apply the contact's exoneration
"CABYS … carries 13 % IVA and the line goes out at 0 %" (or at 2 %) The line charges less IVA than its CABYS code says. Hacienda accepts the invoice anyway, but the IVA is owed Use one of the three buttons: Charge 13 % puts the CABYS rate on the line and on the product; CAByS changes the code if that is what is wrong; This customer has this rate is for a customer who pays another rate by law with no authorization involved (a public university at 2 %, a municipality or the CCSS) and saves it on the customer, so their next sales go out without asking. A customer with an authorization (AL- number, free zone, diplomat) doesn't go there: record their exoneration (see Exonerated, exempt and non-taxable customers). It can be changed on the contact, under Customer's special IVA rate
"Exoneration: the authorization is dated …, after today" The exoneration's date holds its expiry, not its issue date Click Fix date and type the date the authorization was issued: it is corrected on the customer and on this invoice

Hacienda Rejections

If the document reached Hacienda and was Rejected, the reason appears in the header and in the Replace rejected invoice dialog. Codes -99 (duplicate clave), -400 (invalid CABYS), -478 and -479 (exoneration missing article or subsection) and -505 (rate mismatch) are fixed on the replacement (Case A). Calculation codes (-107, -109, -110, -111, -190, -290, -475, -476, -487, -488) block the replacement and are reported to the Astra team (Case B).

Tip

If you run into a message not listed here, read the exact text Astra shows: it almost always names the field to fix. You can also write to app@astranexo.com with the document's clave numérica.

General Tips

  • Keep your certificate current — Act on the first expiry reminder (30 days out).
  • Record customer IDs correctly — Type and number on the contact card; Astra verifies them against Hacienda on send.
  • Assign CABYS to your products — Once, and it is reused on every invoice along with its rate.
  • Handle rejections promptly — Use Replace to keep clean records with Hacienda.
  • Back up your certificate — Keep a secure copy of your .p12 file and PIN.

Need more help?

Our team is ready to assist you.

EmailWhatsApp

Use Astra for your business

Astra · Astranexo

See plans and pricing