Reopen a closed company
const url = 'https://api.emite.cr/v1/tenants/reopen';const form = new FormData();form.append('p12', 'file');form.append('identificationType', '01');form.append('identificationNumber', 'example');form.append('environment', 'sandbox');form.append('pin', 'example');form.append('atvUsername', 'example');form.append('atvPassword', 'example');form.append('atvClientId', 'example');form.append('atvClientSecret', 'example');form.append('shareContact', 'true');form.append('legal', 'example');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
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/reopen \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form p12=@file \ --form identificationType=01 \ --form identificationNumber=example \ --form environment=sandbox \ --form pin=example \ --form atvUsername=example \ --form atvPassword=example \ --form atvClientId=example \ --form atvClientSecret=example \ --form shareContact=true \ --form legal=exampleA company whose account was closed and that kept its identification (it has documents) comes back with its history, its consecutives, its branches and its terminals. The .p12 with its PIN and the ATV user and password are checked like an upload of credentials, against the identification, and KEPT for the environment given: they are needed to issue. The caller becomes the owner, accepts the legal documents in the company's name (method company-reopening), and gets the session re-issued for it, in the body and in the X-Session-Token header. The people who had access before do not get it back; the owner at the closing is told, when it is someone else, with the caller's name and email (shareContact). A person's session only. 409 TENANT_REOPEN_NOT_CLOSED when no closed company holds the identification; 400 TENANT_REOPEN_NOT_AVAILABLE_IN_DEMO; 429 TENANT_REOPEN_RATE_LIMITED past 5 attempts in an hour, counted together with the claims of an identification.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
JSON text with the shape of legal in POST /v1/tenants: the acceptances, authority: true and the capacity.
Responses
Section titled “Responses”object
The company just created, in the shape of GET /tenants/me.
object
Id of the company — the {id} / {tenantId} of the tenant routes.
Hacienda identification type of the company: 01 cédula física, 02 cédula jurídica, 03 DIMEX, 04 NITE (05 and 06 are accepted at creation but cannot issue documents). Fixed once created.
Its identification number, without separators — the <Emisor> identification of its documents, embedded in every clave. Fixed once created.
Legal name (razón social), <Nombre> of the <Emisor>. Changes only through POST /tenants/{id}/hacienda-sync, which takes it from Hacienda's registry.
Trade name, <NombreComercial> of its documents; null when it has none.
Deprecated: the same value as defaultEconomicActivityCode, kept for old clients.
Code of its default economic activity — the <CodigoActividadEmisor> a document declares when it names none. null when no activity is the default (a document that names none is then refused with 412 TENANT_NOT_CONFIGURED).
Address of the company, <Ubicacion> of the <Emisor>. provincia, canton and distrito are empty strings until the company sets it, and it cannot issue until then (422 TENANT_LOCATION_MISSING).
object
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.
Cantón code within that provincia, two digits (01, 02…).
Distrito code within that cantón, two digits (01, 02…).
Neighborhood (barrio), by name — <Barrio>, which Hacienda requires to be 5–50 characters when present.
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.
Dial code of its phone, without + (e.g. 506); null without a phone.
Its phone number, digits only — <Telefono> of its documents; null without one.
Main email address of the company — <CorreoElectronico> of the <Emisor>, and where its notices go when notificationEmail is null. An empty string for a company created without one.
A separate address for the system's notices to the company (rejections, errors, summaries…); null when its notices go to email.
Storage key of the company's logo (a PNG); null without a logo. The image itself is served by GET /tenants/{id}/logo/raw.
Its branches (deleted ones left out). A company starts with branch 001 «Casa Matriz».
object
Id of the branch — the {branchId} of the branch and terminal routes.
Branch number, 3 digits: the first three digits of every consecutivo issued from it, and the branchCode a document names to be issued from it. Fixed once created.
Name of the branch, for the app and the API; documents do not show it.
Whether it is the company's default branch — the one a document uses when it names no branchCode. At most one branch is the default; with none, creating a document that names no branch answers 412 TENANT_NOT_CONFIGURED.
Its terminals, of every branch (branchId says which; deleted ones left out). A company starts with terminal 00001 «Terminal Principal» in branch 001.
object
Id of the terminal — the {terminalId} of the terminal routes.
Id of the branch the terminal belongs to.
Terminal number, 5 digits: the five digits after the branch code in every consecutivo issued from it, and the terminalCode a document names to be issued from it. Unique within its branch; fixed once created.
Name of the terminal, for the app and the API; documents do not show it.
Whether it is its branch's default terminal — the one a document of that branch uses when it names no terminalCode. At most one per branch; with none, creating a document of that branch that names no terminal answers 412 TENANT_NOT_CONFIGURED.
Its economic activities registered with Hacienda; at most one is the default.
object
Id of the activity in the company; PATCH …/{activityId}/default takes it.
Hacienda's economic activity code, in the dotted form its registry returns. The default one is what documents declare as <CodigoActividadEmisor>.
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.
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.
The caller's session token re-issued for the new company (same sign-in time, so it lives no longer than the one sent). Also sent in the X-Session-Token header; use it from now on as Authorization: Bearer <token>.
Always Bearer.
Remaining life of this token, in seconds with an explicit unit ("28800s").
Instant at which this token expires.
Example
{ "tenant": { "identificationType": "01", "identificationNumber": "3101234567", "name": "Futurabyte CR S.A.", "commercialName": "Futurabyte", "economicActivityCode": "6201.0", "defaultEconomicActivityCode": "6201.0", "location": { "provincia": "1", "canton": "01", "distrito": "01", "barrio": "Carmen", "otrasSenas": "50 metros norte de la iglesia, edificio azul" }, "phoneCountryCode": "506", "phoneNumber": "22223333", "email": "ventas@emite.cr", "notificationEmail": "notificaciones@emite.cr", "branches": [ { "code": "001", "name": "Casa Matriz" } ], "terminals": [ { "code": "00001", "name": "Terminal Principal" } ], "economicActivities": [ { "code": "6201.0", "description": "Programación de computadoras" } ] }, "tokenType": "Bearer", "expiresIn": "28800s"}