Bulk import items from a parsed spreadsheet
const url = 'https://api.emite.cr/v1/tenants/example/items/bulk';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"dryRun":false,"duplicateStrategy":"skip","rows":[{"cabysCode":"8399000000000","name":"Servicio de consultoría TI","description":"Consultoría en arquitectura de software — bloque mensual de 40 horas","defaultTaxCode":"01","defaultTaxRateCode":"08","defaultTaxRate":13,"defaultTaxFactor":0.3,"secondaryTaxes":[{"codigo":"02","codigoTarifa":"08","tarifa":10,"datosEspecifico":{"cantidadUnidadMedida":355,"porcentaje":5,"volumenUnidadConsumo":355,"impuestoUnidad":18.5,"esJabonTocador":false}}],"pharmacyRegistry":"CR-MED-2024-1234","pharmaceuticalForm":"01","notes":"Producto estrella — promo Q4","variants":[{"code":"IMP-350-UNI","variantName":"Cerveza Imperial 350ml — Unidad","unitOfMeasure":"Unid","unitOfMeasureCommercial":"Caja x12","prices":[{"currency":"AED","unitPrice":950}],"packSize":12,"innerUnitOfMeasure":"Unid","commercialCodes":[{"tipo":"01","codigo":"SKU-IMP-350"}],"barcode":"7441001234567","isDefault":true,"isActive":true,"sortOrder":0}],"isSurtido":false,"surtidoComponents":[{"sourceItemId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","cabysCode":"2310100000000","name":"Arroz 1kg","description":"Arroz blanco grano largo","unitOfMeasure":"Unid","unitOfMeasureCommercial":"Caja","prices":[{"currency":"AED","unitPrice":950}],"quantity":1,"ivaCodigoTarifa":"08","ivaTarifa":13}]}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.emite.cr/v1/tenants/example/items/bulk \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "dryRun": false, "duplicateStrategy": "skip", "rows": [ { "cabysCode": "8399000000000", "name": "Servicio de consultoría TI", "description": "Consultoría en arquitectura de software — bloque mensual de 40 horas", "defaultTaxCode": "01", "defaultTaxRateCode": "08", "defaultTaxRate": 13, "defaultTaxFactor": 0.3, "secondaryTaxes": [ { "codigo": "02", "codigoTarifa": "08", "tarifa": 10, "datosEspecifico": { "cantidadUnidadMedida": 355, "porcentaje": 5, "volumenUnidadConsumo": 355, "impuestoUnidad": 18.5, "esJabonTocador": false } } ], "pharmacyRegistry": "CR-MED-2024-1234", "pharmaceuticalForm": "01", "notes": "Producto estrella — promo Q4", "variants": [ { "code": "IMP-350-UNI", "variantName": "Cerveza Imperial 350ml — Unidad", "unitOfMeasure": "Unid", "unitOfMeasureCommercial": "Caja x12", "prices": [ { "currency": "AED", "unitPrice": 950 } ], "packSize": 12, "innerUnitOfMeasure": "Unid", "commercialCodes": [ { "tipo": "01", "codigo": "SKU-IMP-350" } ], "barcode": "7441001234567", "isDefault": true, "isActive": true, "sortOrder": 0 } ], "isSurtido": false, "surtidoComponents": [ { "sourceItemId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "cabysCode": "2310100000000", "name": "Arroz 1kg", "description": "Arroz blanco grano largo", "unitOfMeasure": "Unid", "unitOfMeasureCommercial": "Caja", "prices": [ { "currency": "AED", "unitPrice": 950 } ], "quantity": 1, "ivaCodigoTarifa": "08", "ivaTarifa": 13 } ] } ] }'Accepts up to 1000 CreateItemDto rows, matched to existing items by the SKU of their first variant. With dryRun:true it validates + detects duplicates WITHOUT writing (preview). duplicateStrategy (skip|update) decides what happens on a SKU match; update on a multi-variant item is reported as MULTI_VARIANT_UPDATE (not applied). Each row succeeds or fails on its own; the response has one result per row plus a summary (201, dry run included). Set Idempotency-Key for safe retries.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Tenant UUID.
Header Parameters
Section titled “Header Parameters”UUID for safe retries.
Request Bodyrequired
Section titled “Request Bodyrequired”object
Preview mode. When true, every row is processed exactly as in a real run inside a transaction that is then rolled back: the response reports what would happen, nothing is written and no id is returned.
What to do with a row that matches an existing, non-deleted record (items match on the SKU of the first variant, variants[0].code; contacts on identificationType + identificationNumber):
skip: leave the record untouched; the row comes backskippedwith codeALREADY_EXISTS.update: overwrite it with the row. For an item, the base fields and that variant's fields are rewritten (an optional field left out is cleared) and its prices replaced; a SKU of an item with several variants is not updated and comes back as an error withMULTI_VARIANT_UPDATE. For a contact, only the fields the row sends change and its roles are added to the existing ones.
A deleted contact that matches is always reactivated with the row, whatever this setting (it comes back updated with code REACTIVATED).
The items, 1 to 1000 per request (split a larger file). Every row must pass the same field validation as creating one item, or the whole request is rejected (400); problems found while importing (a currency the company has not enabled, two prices in one currency…) are reported on that row and do not stop the others. A row repeating the SKU of an earlier row is skipped with DUPLICATE_IN_FILE. Surtidos are not imported: surtidoComponents is ignored.
object
13-digit CABYS code (Costa Rica's catalog of goods and services) that classifies the item: the code (<CodigoCABYS>) of an invoice line that sells it. Find codes with GET /v1/cabys/search, and the IVA Hacienda publishes for one with GET /v1/cabys/:codigo/suggested-iva.
Example
8399000000000Name of the product or service, 1–120 characters. The EmiteCR app uses it as the description (<Detalle>) of the invoice lines it builds from the item; Hacienda's schema asks for at least 3 characters there.
Example
Servicio de consultoría TILonger description, up to 200 characters (the EmiteCR app pre-fills it with the CABYS description). Catalog searches match it; the invoice lines the app builds take name, not this field.
Example
Consultoría en arquitectura de software — bloque mensual de 40 horasCode of the item's main tax (CodigoImpuestoType, Anexo nota 8), the first tax of an invoice line that sells it (<Impuesto><Codigo>):
01: IVA.07: IVA with a special calculation (the rate goes indefaultTaxRate).08: IVA under the used-goods regime, computed withdefaultTaxFactor.
Omit the defaultTax* fields for no default tax. Excise taxes go in secondaryTaxes.
Example
01IVA rate code (CodigoTarifaIVAType, <CodigoTarifaIVA>) for defaultTaxCode 01: 08 general 13%, 04 reduced 4%, 03 reduced 2%, 02 reduced 1%, 09 reduced 0.5%, 10 exempt, 01 0% (RLIVA art. 32), 11 0% without credit right, and the transitional 05 0%, 06 4% and 07 8%, which Hacienda reserves for credit and debit notes. GET /v1/catalogs/iva-tariffs lists them with labels.
Example
08Rate of the main tax as a percentage (13 = 13%), 0–100 with up to 2 decimals (<Tarifa>). Required whenever defaultTaxCode is set, 08 included: the item stores its main tax whole, or not at all.
Example
13Factor for the used-goods IVA regime, only with defaultTaxCode 08: 0 to 1 with up to 4 decimals. The IVA of a line is then its taxable base × this factor, written as <FactorCalculoIVA> instead of <Tarifa>.
Example
0.3Excise and other non-IVA taxes of the item, up to 5, added after the main tax to an invoice line that sells it. The EmiteCR app does not use them on a surtido, whose taxes come from its components.
object
Tax code (<Impuesto><Codigo>, Anexo nota 8):
02: selective consumption tax (ad valorem).03: single tax on fuels (per unit).04: specific tax on alcoholic beverages (per unit).05: specific tax on packaged non-alcoholic beverages and toilet soaps (per unit).06: tax on tobacco products (per unit).12: specific tax on cement (ad valorem).99: another tax. Hacienda asks for its description (<CodigoImpuestoOTRO>), which the API does not send.
Except 99, these taxes are accepted only on invoices in CRC (422 EXCISE_NOT_SUPPORTED_FOR_CURRENCY).
Example
02Optional two-digit code, written as <CodigoTarifaIVA> of the tax when present. That element takes the IVA rate codes of GET /v1/catalogs/iva-tariffs.
Example
08Ad valorem rate as a percentage for 02, 12 and 99 (<Tarifa>); for 02 and 12 the tax is this percentage of the line's subtotal. The per-unit codes 03 to 06 take their amount from datosEspecifico, not from this rate (the EmiteCR app sends 0 for them).
Example
10Per-unit data for codes 03 to 06 (<DatosImpuestoEspecifico>), which an invoice line with those codes requires; leave it out for 02, 12 and 99. The tax of a line is computed from it (Anexo formulas): 03 cantidadUnidadMedida × impuestoUnidad; 04 quantity × millilitres of absolute alcohol × impuestoUnidad; 05 see esJabonTocador; 06 quantity × cantidadUnidadMedida × impuestoUnidad.
object
Quantity of the unit of measure the tax is set on, up to 2 decimals (<CantidadUnidadMedida>): litres of fuel for 03; millilitres of the container sold for 04 and 05; for 06, the quantity per unit sold that impuestoUnidad applies to. The 03 formula does not multiply by the line quantity, so a line with that code must carry the litres it sells.
Example
355Alcohol by volume as a percentage, code 04 only (<Porcentaje>); an invoice line with 04 requires it. With cantidadUnidadMedida it gives the millilitres of absolute alcohol (<Proporcion>) the 04 tax is computed on.
Example
5Code 05 only (<VolumenUnidadConsumo>): the reference volume in millilitres for a drink, or the grams of toilet soap sold. An invoice line with 05 requires it.
Example
355Tax per unit in colones, as the regulation of each specific tax sets it, up to 5 decimals (<ImpuestoUnidad>).
Example
18.5Code 05 only: true for a toilet soap, whose tax is quantity × volumenUnidadConsumo × impuestoUnidad; false or absent for a drink, quantity × cantidadUnidadMedida × impuestoUnidad ÷ volumenUnidadConsumo. Only selects the formula: it is not sent to Hacienda.
Example
falseMinistry of Health registration number of a medicine, up to 100 characters (<RegistroMedicamento> of an invoice line). Hacienda asks for it when the item is a medicine with a sanitary registration.
Example
CR-MED-2024-1234Pharmaceutical form of a medicine, as a code of Hacienda's «Código de forma farmacéutica» catalog (Anexo nota 19; for example 04 is cápsula), written as <FormaFarmaceutica> of an invoice line. Like pharmacyRegistry, for medicines with a sanitary registration.
Example
01Internal notes, up to 2000 characters. Never sent to Hacienda nor printed.
Example
Producto estrella — promo Q4The formats or presentations the item is sold in, at least one. Each has its own SKU (code), unit and per-currency prices; CABYS and taxes are the item's. With several variants exactly one must be isDefault: true (422 otherwise). Later changes go through the …/variants endpoints.
object
The variant's SKU, 1–50 characters, unique among the company's variants (409 when another one has it). Bulk imports match existing items by it, and for a surtido the EmiteCR app sends it as the type-03 commercial code the invoice line requires.
Example
IMP-350-UNIName of this format or presentation, 1–120 characters, shown next to the item name in catalog pickers; catalog searches match it.
Example
Cerveza Imperial 350ml — UnidadUnit the variant is sold in, as a symbol of Hacienda's unit catalog (UnidadMedidaType, standard RTC 443:2010; case-sensitive): for example Unid (unit), Kg (kilogram), L (litre), h (hour), Sp (professional services), Os (other service). The unitOfMeasure (<UnidadMedida>) of an invoice line that sells it.
Example
UnidFree-text commercial name of the package, up to 20 characters, kept with the catalog. Invoice lines do not carry it.
Example
Caja x12The variant's prices, one per currency (1 to 10). Prices are independent: a variant may have a price in some of the company's currencies only, and an invoice uses the price in its own currency. Ignored for a surtido, whose prices are derived from its components.
object
Currency of the price (ISO 4217). It must be one of the company's enabled currencies (400 CURRENCY_NOT_ENABLED), and appear only once per variant (400 VARIANT_PRICE_DUPLICATE_CURRENCY).
Example
CRCPrice of one unit in that currency, before discounts and taxes, up to 5 decimals: the unit price an invoice in that currency uses (<PrecioUnitario> of a line, <PrecioUnitarioSurtido> of a surtido component). A price is never derived from another currency with an exchange rate.
Example
950How many inner units this variant holds (e.g. 12 for a box of 12), greater than 0 with up to 3 decimals. Send it together with innerUnitOfMeasure: both or neither. Catalog information only.
Example
12Unit of the inner units packSize counts (e.g. Unid, L), a symbol of the same Hacienda catalog as unitOfMeasure. Both or neither with packSize.
Example
UnidUp to 5 codes that identify the variant elsewhere (the seller's SKU, the buyer's code, a GTIN…), in the shape of an invoice line's commercialCodes (<CodigoComercial>). Kept with the catalog: the API does not add them to invoices, so copy them into a line that should carry them.
object
Who assigned the code (<CodigoComercial><Tipo>, Anexo nota 12):
01: the seller's product code.02: the buyer's product code.03: code assigned by the manufacturer (industrial or importer), such as a GTIN.04: internal-use code.99: other.
Example
01The code itself, 1–20 characters (<CodigoComercial><Codigo>).
Example
SKU-IMP-350Barcode (GTIN, EAN or UPC), up to 50 characters; the format is not checked. The catalog search matches it by prefix, so a scanner can find the variant.
Example
7441001234567Marks the item's main variant, the one catalog lists show. An item with a single variant gets it automatically; with several variants in one request, exactly one must be true (422 otherwise). On POST …/variants, true makes the new variant the default and demotes the previous one.
Example
truefalse pauses the variant without deleting it: the EmiteCR invoice picker and the WhatsApp agent stop offering it. Defaults to true.
Example
truePosition among the item's variants, ascending. Defaults to the variant's position in the request when the item is created, and to 0 when a variant is added later.
Example
0Marks the item as a surtido: a combo, pack or assortment of products sold as one line, whose components the invoice lists (<DetalleSurtido>). It needs surtidoComponents, and its variants get their prices from them. The CABYS codes for surtidos (e.g. 2399999002200, assorted food products) require that breakdown on the invoice.
Example
falseComponents of ONE unit of the surtido, required when isSurtido is true: 2 to 20, with distinct CABYS codes that are not surtido codes themselves (400 SURTIDO_MIN_COMPONENTS, SURTIDO_DUPLICATE_CABYS, SURTIDO_NESTING_NOT_ALLOWED). All of them need prices in the same currencies (400 SURTIDO_COMPONENT_CURRENCY_MISMATCH): a variant's price in a currency is the sum of quantity × price of the components.
object
Id of the catalog item this component was taken from, kept as a link to it; absent for a component written inline.
13-digit CABYS code of the component. It cannot be a surtido code itself (SURTIDO_NESTING_NOT_ALLOWED) nor repeat another component's (SURTIDO_DUPLICATE_CABYS).
Example
2310100000000Name of the component. EmiteCR's invoice form writes it as the component's <DetalleSurtido>, which Hacienda accepts with 3–200 characters.
Example
Arroz 1kgOptional longer description of the component, kept with the definition.
Example
Arroz blanco grano largoUnit of measure of the component, a symbol from Hacienda's catalog (Anexo nota 15) such as Unid; EmiteCR's invoice form uses it as the component's unidadMedida.
Example
UnidThe business's own unit for the component (e.g. a box), not a standard measure.
Example
CajaPrice of one unit of the component in each currency it is sold in, one entry per currency, each enabled for the company (CURRENCY_NOT_ENABLED) and none repeated (VARIANT_PRICE_DUPLICATE_CURRENCY). Every component of the surtido must have prices in the same currencies (SURTIDO_COMPONENT_CURRENCY_MISMATCH): the price of the surtido in a currency is the sum of quantity × price of its components.
object
Currency of the price (ISO 4217). It must be one of the company's enabled currencies (400 CURRENCY_NOT_ENABLED), and appear only once per variant (400 VARIANT_PRICE_DUPLICATE_CURRENCY).
Example
CRCPrice of one unit in that currency, before discounts and taxes, up to 5 decimals: the unit price an invoice in that currency uses (<PrecioUnitario> of a line, <PrecioUnitarioSurtido> of a surtido component). A price is never derived from another currency with an exchange rate.
Example
950Quantity of this component in ONE unit of the surtido (up to 3 decimals). It multiplies the component's price in the surtido's price, and EmiteCR's invoice form uses it as the component's cantidad, which Hacienda wants greater than 0.
Example
1IVA tariff code of the component (Anexo nota 8.1; e.g. 08 general 13%, 10 exempt). The components of a combo may carry different rates; EmiteCR's invoice form gives the component an IVA tax with this code.
Example
08IVA rate of the component as a percentage (13 for 13%), the rate of ivaCodigoTarifa.
Example
13Responses
Section titled “Responses”object
true when the request was a dry run: the statuses and counts say what WOULD happen, and nothing was written.
How many rows ended in each status; they add up to the number of rows sent.
object
Rows with status created.
Rows with status updated.
Rows with status skipped.
Rows with status error.
One result per row sent, in the same order as rows.
object
Position of the row in the rows array that was sent, starting at 0.
created: a new record was inserted. updated: an existing record was overwritten (duplicateStrategy: update) or a deleted contact was reactivated. skipped: nothing was written (see code). error: the row failed and nothing of it was written; the other rows are not affected.
Why the row ended as it did. One of DUPLICATE_IN_FILE (skipped: repeats an earlier row), ALREADY_EXISTS (skipped: matches an existing record and the strategy is skip), REACTIVATED (updated: a deleted contact was brought back) or MULTI_VARIANT_UPDATE (error: the SKU belongs to an item with several variants); on any other error row, the API error code that stopped it (e.g. CURRENCY_NOT_ENABLED; IMPORT_ROW_FAILED when the error carried none). Absent on a plain created or updated row.
On an error row, the errors.* message key of the error, as in an API error response; null when the error carried none. Absent on the other rows.
On an error row, the error's own message, for debugging (not meant for display: it may be in Spanish or English); null when there is none. Absent on the other rows.
Id of the record the row created or updated (for items, the ITEM id, not the variant's). Absent on skipped and error rows; null on every row of a dry run.
Example
{ "summary": { "created": 120, "updated": 3, "skipped": 5, "errored": 1 }, "results": [ { "index": 0, "status": "created", "code": "ALREADY_EXISTS", "messageKey": "errors.CURRENCY_NOT_ENABLED" } ]}A row fails field validation (the whole request is rejected).
Missing or invalid JWT / API key
Tenant boundary violation or insufficient scope.