Skip to content

Sync economic activities from Hacienda's registry

POST
/v1/tenants/{tenantId}/economic-activities/sync
curl --request POST \
--url https://api.emite.cr/v1/tenants/example/economic-activities/sync \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "newDefault": "6201.0" }'

Reads Hacienda's registry for the company's identification and brings the company's activities in line with it: adds the new ones, removes the ones Hacienda no longer registers, and updates their names. If the current default is among the removed, nothing is applied and the API answers 409 DEFAULT_ACTIVITY_DROPPED, with error.details.removed ({ code, description } of the dropped default) and error.details.suggested ([{ code, description }], every activity Hacienda registers): call again with { "newDefault": "<code>" } to choose the replacement. An empty suggested means Hacienda registers no activity for the company, which must register one with Hacienda before it can sync. Hacienda's answer is cached for an hour; 404 when Hacienda's registry does not know the identification, 424 HACIENDA_LOOKUP_UNAVAILABLE or 429 when its registry fails or throttles. Answers 201 (a POST), also when nothing changed.

tenantId
required
string
Media typeapplication/json
object
newDefault

Code of the activity that becomes the default, one of those Hacienda registers for the company. Send it after a 409 DEFAULT_ACTIVITY_DROPPED, choosing from error.details.suggested; a code Hacienda does not register answers 409 INVALID_NEW_DEFAULT and nothing is applied.

string
Example
6201.0
Media typeapplication/json
object
added
required

Activities Hacienda registers that the company did not have, now added.

Array<object>
object
id
required

Id of the activity in the company; PATCH …/{activityId}/default takes it.

string format: uuid
code
required

Hacienda's economic activity code, in the dotted form its registry returns. The default one is what documents declare as <CodigoActividadEmisor>.

string
description
required

The activity's name, as Hacienda's registry returns it (in Spanish). null for an activity seeded from the company's economicActivityCode at its creation, until the first sync with Hacienda fills it.

string
nullable
isDefault
required

Whether documents declare this activity when the request names none. At most one activity of the company is the default; with none, creating a document that names no activity answers 412 TENANT_NOT_CONFIGURED.

boolean
removed
required

Activities the company had that Hacienda no longer registers, now removed (as they were before the sync).

Array<object>
object
id
required

Id of the activity in the company; PATCH …/{activityId}/default takes it.

string format: uuid
code
required

Hacienda's economic activity code, in the dotted form its registry returns. The default one is what documents declare as <CodigoActividadEmisor>.

string
description
required

The activity's name, as Hacienda's registry returns it (in Spanish). null for an activity seeded from the company's economicActivityCode at its creation, until the first sync with Hacienda fills it.

string
nullable
isDefault
required

Whether documents declare this activity when the request names none. At most one activity of the company is the default; with none, creating a document that names no activity answers 412 TENANT_NOT_CONFIGURED.

boolean
total
required

How many activities the company has after the sync.

number
defaultActivityId
required

The default activity after the sync: the newDefault you sent, the previous default if Hacienda still registers it, or Hacienda's primary activity when the company had none. null when Hacienda registers no activity.

string format: uuid
nullable
Example
{
"added": [
{
"code": "6201.0",
"description": "Programación de computadoras"
}
],
"removed": [
{
"code": "6201.0",
"description": "Programación de computadoras"
}
]
}

Missing or invalid JWT / API key

Tenant boundary violation or insufficient scope.

DEFAULT_ACTIVITY_DROPPED: the current default is no longer registered (see error.details). INVALID_NEW_DEFAULT: newDefault is not one of the activities Hacienda registers (error.details.suggested lists them).