Skip to content

Bulk import items from a parsed spreadsheet

POST
/v1/tenants/{tenantId}/items/bulk
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.

tenantId
required
string

Tenant UUID.

Idempotency-Key
string

UUID for safe retries.

Media typeapplication/json
object
dryRun

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.

boolean
duplicateStrategy

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 back skipped with code ALREADY_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 with MULTI_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).

string
default: skip
Allowed values: skip update
rows
required

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.

Array<object>
object
cabysCode
required

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.

string
Example
8399000000000
name
required

Name 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.

string
Example
Servicio de consultoría TI
description

Longer 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.

string
nullable
Example
Consultoría en arquitectura de software — bloque mensual de 40 horas
defaultTaxCode

Code 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 in defaultTaxRate).
  • 08: IVA under the used-goods regime, computed with defaultTaxFactor.

Omit the defaultTax* fields for no default tax. Excise taxes go in secondaryTaxes.

string
nullable
Example
01
defaultTaxRateCode

IVA 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.

string
nullable
Example
08
defaultTaxRate

Rate 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.

number
nullable
Example
13
defaultTaxFactor

Factor 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>.

number
nullable
Example
0.3
secondaryTaxes

Excise 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.

Array<object>
nullable
object
codigo
required

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).

string
Allowed values: 02 03 04 05 06 12 99
Example
02
codigoTarifa

Optional two-digit code, written as <CodigoTarifaIVA> of the tax when present. That element takes the IVA rate codes of GET /v1/catalogs/iva-tariffs.

string
Example
08
tarifa
required

Ad 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).

number
Example
10
datosEspecifico

Per-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
cantidadUnidadMedida
required

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.

number
Example
355
porcentaje

Alcohol 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.

number
Example
5
volumenUnidadConsumo

Code 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.

number
Example
355
impuestoUnidad
required

Tax per unit in colones, as the regulation of each specific tax sets it, up to 5 decimals (<ImpuestoUnidad>).

number
Example
18.5
esJabonTocador

Code 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.

boolean
Example
false
pharmacyRegistry

Ministry 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.

string
nullable
Example
CR-MED-2024-1234
pharmaceuticalForm

Pharmaceutical 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.

string
nullable
Example
01
notes

Internal notes, up to 2000 characters. Never sent to Hacienda nor printed.

string
nullable
Example
Producto estrella — promo Q4
variants
required

The 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.

Array<object>
object
code
required

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.

string
Example
IMP-350-UNI
variantName

Name of this format or presentation, 1–120 characters, shown next to the item name in catalog pickers; catalog searches match it.

string
nullable
Example
Cerveza Imperial 350ml — Unidad
unitOfMeasure
required

Unit 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.

string
Example
Unid
unitOfMeasureCommercial

Free-text commercial name of the package, up to 20 characters, kept with the catalog. Invoice lines do not carry it.

string
nullable
Example
Caja x12
prices
required

The 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.

Array<object>
object
currency
required

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).

string
Allowed values: AED AFN ALL AMD ANG AOA ARS AUD AWG AZN BAM BBD BDT BGN BHD BIF BMD BND BOB BOV BRL BSD BTN BWP BYR BZD CAD CDF CHE CHF CHW CLF CLP CNY COP COU CRC CUC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HRK HTG HUF IDR ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRO MUR MVR MWK MXN MXV MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLL SOS SRD SSP STD SVC SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD USN UYI UYU UZS VEF VND VUV WST XAF XCD XDR XOF XPF XSU XUA YER ZAR ZMW ZWL
Example
CRC
unitPrice
required

Price 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.

number
Example
950
packSize

How 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.

number
nullable
Example
12
innerUnitOfMeasure

Unit of the inner units packSize counts (e.g. Unid, L), a symbol of the same Hacienda catalog as unitOfMeasure. Both or neither with packSize.

string
nullable
Example
Unid
commercialCodes

Up 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.

Array<object>
nullable
object
tipo
required

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.
string
Allowed values: 01 02 03 04 99
Example
01
codigo
required

The code itself, 1–20 characters (<CodigoComercial><Codigo>).

string
Example
SKU-IMP-350
barcode

Barcode (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.

string
nullable
Example
7441001234567
isDefault

Marks 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.

boolean
Example
true
isActive

false pauses the variant without deleting it: the EmiteCR invoice picker and the WhatsApp agent stop offering it. Defaults to true.

boolean
Example
true
sortOrder

Position 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.

number
Example
0
isSurtido

Marks 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.

boolean
Example
false
surtidoComponents

Components 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.

Array<object>
object
sourceItemId

Id of the catalog item this component was taken from, kept as a link to it; absent for a component written inline.

string format: uuid
cabysCode
required

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).

string
Example
2310100000000
name
required

Name of the component. EmiteCR's invoice form writes it as the component's <DetalleSurtido>, which Hacienda accepts with 3–200 characters.

string
Example
Arroz 1kg
description

Optional longer description of the component, kept with the definition.

string
Example
Arroz blanco grano largo
unitOfMeasure
required

Unit 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.

string
Example
Unid
unitOfMeasureCommercial

The business's own unit for the component (e.g. a box), not a standard measure.

string
Example
Caja
prices
required

Price 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.

Array<object>
object
currency
required

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).

string
Allowed values: AED AFN ALL AMD ANG AOA ARS AUD AWG AZN BAM BBD BDT BGN BHD BIF BMD BND BOB BOV BRL BSD BTN BWP BYR BZD CAD CDF CHE CHF CHW CLF CLP CNY COP COU CRC CUC CUP CVE CZK DJF DKK DOP DZD EGP ERN ETB EUR FJD FKP GBP GEL GHS GIP GMD GNF GTQ GYD HKD HNL HRK HTG HUF IDR ILS INR IQD IRR ISK JMD JOD JPY KES KGS KHR KMF KPW KRW KWD KYD KZT LAK LBP LKR LRD LSL LYD MAD MDL MGA MKD MMK MNT MOP MRO MUR MVR MWK MXN MXV MYR MZN NAD NGN NIO NOK NPR NZD OMR PAB PEN PGK PHP PKR PLN PYG QAR RON RSD RUB RWF SAR SBD SCR SDG SEK SGD SHP SLL SOS SRD SSP STD SVC SYP SZL THB TJS TMT TND TOP TRY TTD TWD TZS UAH UGX USD USN UYI UYU UZS VEF VND VUV WST XAF XCD XDR XOF XPF XSU XUA YER ZAR ZMW ZWL
Example
CRC
unitPrice
required

Price 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.

number
Example
950
quantity
required

Quantity 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.

number
Example
1
ivaCodigoTarifa

IVA 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.

string
Example
08
ivaTarifa

IVA rate of the component as a percentage (13 for 13%), the rate of ivaCodigoTarifa.

number
Example
13
Media typeapplication/json
object
dryRun
required

true when the request was a dry run: the statuses and counts say what WOULD happen, and nothing was written.

boolean
summary
required

How many rows ended in each status; they add up to the number of rows sent.

object
created
required

Rows with status created.

number
updated
required

Rows with status updated.

number
skipped
required

Rows with status skipped.

number
errored
required

Rows with status error.

number
results
required

One result per row sent, in the same order as rows.

Array<object>
object
index
required

Position of the row in the rows array that was sent, starting at 0.

number
status
required

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.

string
Allowed values: created updated skipped error
code

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.

string
nullable
messageKey

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.

string
nullable
message

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.

string
nullable
id

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.

string format: uuid
nullable
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.