Skip to content

Bulk import parties from a parsed spreadsheet

POST
/v1/tenants/{tenantId}/parties/bulk
curl --request POST \
--url https://api.emite.cr/v1/tenants/example/parties/bulk \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "dryRun": false, "duplicateStrategy": "skip", "rows": [ { "identificationType": "01", "identificationNumber": "3101234567", "name": "Distribuidora La Nacional S.A.", "commercialName": "La Nacional", "email": "compras@lanacional.cr", "additionalEmails": [ "contabilidad@lanacional.cr" ], "phoneCountryCode": "506", "phoneNumber": "22223333", "location": { "provincia": "1", "canton": "01", "distrito": "01", "barrio": "Carmen", "otrasSenas": "50 metros norte de la iglesia, edificio azul" }, "otrasSenasExtranjero": "1234 Ocean Ave, Miami, FL 33101, USA", "isCustomer": true, "isSupplier": false, "notes": "Cliente preferencial — descuento 5%" } ] }'

Accepts up to 1000 CreatePartyDto rows. With dryRun:true it validates + detects duplicates WITHOUT writing (preview). duplicateStrategy (skip|update) decides what happens on a (type, number) match; a soft-deleted match is always reactivated. 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 contacts, 1 to 1000 per request (split a larger file). Every row must pass the same field validation as creating one contact, or the whole request is rejected (400); problems found while importing (an unknown location code, a row that is neither customer nor supplier…) are reported on that row and do not stop the others. A row repeating the identification of an earlier row is skipped with DUPLICATE_IN_FILE.

Array<object>
object
identificationType
required

Hacienda identification type (<Identificacion><Tipo>):

  • 01: cédula física (an individual).
  • 02: cédula jurídica (a company or other legal entity).
  • 03: DIMEX (migration identity document for foreigners).
  • 04: NITE (identification number assigned by the tax administration, DGT).
  • 05: foreigner not domiciled in Costa Rica.
  • 06: non-contributor (not registered as a taxpayer).

Immutable after creation. Whether a document accepts the type is checked when the document is created: a 06, for example, can only be the supplier of a purchase invoice (FEC).

string
Allowed values: 01 02 03 04 05 06
Example
02
identificationNumber
required

Identification number (<Identificacion><Numero>), with no spaces, normalized to upper case. Its format depends on identificationType: 01 9 digits; 02 10 positions, 4 digits and 6 that may include letters (cédulas jurídicas issued from 2026-11-01 under decree 44648-MJ are alphanumeric, e.g. 3101A1B2C3); 03 11–12 digits; 04 10 digits; 05 up to 20 letters, digits or dashes; 06 9–12 digits. Unique per type within the company, and immutable after creation.

string
Example
3101234567
name
required

Legal name of the person or company: <Nombre> of the <Receptor>, or of the <Emisor> when the contact is the supplier of a purchase invoice (FEC). Hacienda's schema asks for at least 3 characters (5 as an <Emisor>).

string
Example
Distribuidora La Nacional S.A.
commercialName

Trade name, when it differs from name (<NombreComercial>). Hacienda's schema asks for at least 3 characters.

string
nullable
Example
La Nacional
email

The contact's email address: <CorreoElectronico> of the documents that name them, and where EmiteCR emails each of those documents once Hacienda accepts it (unless the company turned that off).

string
nullable
Example
compras@lanacional.cr
additionalEmails

Up to 3 more email addresses, kept with the contact for reference. Documents carry email only, and EmiteCR sends nothing to these addresses.

Array<string>
nullable
Example
[
"contabilidad@lanacional.cr"
]
phoneCountryCode

Country calling code, 1–3 digits with no + (<Telefono><CodigoPais>). 506 (Costa Rica) is assumed when a phoneNumber comes without it.

string
nullable
Example
506
phoneNumber

Phone number, 5–20 digits with no spaces or symbols (<Telefono><NumTelefono>). Without it, documents carry no <Telefono>.

string
nullable
Example
22223333
location

Address in Costa Rica (<Ubicacion>): the provincia, cantón and distrito codes of GET /v1/catalogs/locations, all three or no location (400 otherwise, also for codes that do not exist), plus optional barrio and otrasSenas. Not written for a foreign (05) contact, nor on an export invoice (FEE) or a payment receipt (REP). Required when an inscribed (01–04) contact is the supplier of a purchase invoice (400 SUPPLIER_LOCATION_REQUIRED).

object
provincia
required

Provincia code of Hacienda's location codification, one digit: 1 San José, 2 Alajuela, 3 Cartago, 4 Heredia, 5 Guanacaste, 6 Puntarenas, 7 Limón. GET /v1/catalogs/locations lists every code.

string
Example
1
canton
required

Cantón code within that provincia, two digits (01, 02…).

string
Example
01
distrito
required

Distrito code within that cantón, two digits (01, 02…).

string
Example
01
barrio

Neighborhood (barrio), by name — <Barrio>, which Hacienda requires to be 5–50 characters when present.

string
Example
Carmen
otrasSenas

The rest of the address, free text — <OtrasSenas>, 5–250 characters in Hacienda's schema (cut to 250). Without it the XML says «Sin otras señas», since the element is mandatory.

string
Example
50 metros norte de la iglesia, edificio azul
otrasSenasExtranjero

Address abroad, free text (<OtrasSenasExtranjero>; the schema asks for 5–300 characters). Written only for a foreign (05) contact, and required when that contact is the supplier of a purchase invoice (400 SUPPLIER_FOREIGN_ADDRESS_REQUIRED).

string
nullable
Example
1234 Ocean Ave, Miami, FL 33101, USA
isCustomer

The contact can be the customer of the documents the company issues: a document whose receiverId names a contact that is not a customer is rejected (400 PARTY_NOT_CUSTOMER), except a purchase invoice (FEC) and its notes, which need a supplier. Defaults to true. A contact is a customer, a supplier or both (422 when neither).

boolean
Example
true
isSupplier

The contact is a supplier: the counterpart of a purchase invoice (FEC, docType 08) and of the notes on it, whose receiverId must name a supplier (400 PARTY_NOT_SUPPLIER). Defaults to false.

boolean
Example
false
notes

Internal notes about the contact. Never sent to Hacienda nor printed.

string
nullable
Example
Cliente preferencial — descuento 5%
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.