Create a tenant for the authenticated user
const url = 'https://api.emite.cr/v1/tenants';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"id":"01a00c73-5c09-7bb5-8b9e-d91c43bd61dc","identificationType":"01","identificationNumber":"3101234567","name":"Futurabyte CR S.A.","commercialName":"Futurabyte","economicActivityCode":"6201.0","location":{"provincia":"1","canton":"01","distrito":"01","barrio":"Carmen","otrasSenas":"50 metros norte de la iglesia, edificio azul"},"phoneCountryCode":"506","phoneNumber":"22223333","phone":"50622223333","email":"ventas@emite.cr","notificationEmail":"notificaciones@emite.cr","otrasSenasExtranjero":"1234 Ocean Ave, Miami, FL 33101, USA","legal":{"acceptances":[{"documentType":"terminos-y-condiciones","documentVersion":"3.0","documentHash":"sha256:abcdef0123456789..."}],"authority":true,"capacity":"holder"}}'};
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 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "id": "01a00c73-5c09-7bb5-8b9e-d91c43bd61dc", "identificationType": "01", "identificationNumber": "3101234567", "name": "Futurabyte CR S.A.", "commercialName": "Futurabyte", "economicActivityCode": "6201.0", "location": { "provincia": "1", "canton": "01", "distrito": "01", "barrio": "Carmen", "otrasSenas": "50 metros norte de la iglesia, edificio azul" }, "phoneCountryCode": "506", "phoneNumber": "22223333", "phone": "50622223333", "email": "ventas@emite.cr", "notificationEmail": "notificaciones@emite.cr", "otrasSenasExtranjero": "1234 Ocean Ave, Miami, FL 33101, USA", "legal": { "acceptances": [ { "documentType": "terminos-y-condiciones", "documentVersion": "3.0", "documentHash": "sha256:abcdef0123456789..." } ], "authority": true, "capacity": "holder" } }'Self-service flow: a signed-in person (from POST /v1/auth/signup, or one who already belongs to other companies) creates a company — with its default branch 001 and terminal 00001, and its default economic activity when economicActivityCode is sent — and becomes its owner. Returns the company and the session re-issued for it, in the body and in the X-Session-Token header (it keeps the original sign-in time). A person's session only: no scope is required, and an API key gets 401. The body carries, in legal, the acceptance of the legal documents by its creator, who declares the authority to bind it and in which capacity (docs/legal-acceptance-design.md §6.2): the texts are checked before the company exists and the acceptance is written right after it — no company without its acceptance.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Not used: ignored when a company is created, and kept as sent in the inline party of a document.
Example
01a00c73-5c09-7bb5-8b9e-d91c43bd61dcHacienda identification type: 01 cédula física, 02 cédula jurídica, 03 DIMEX, 04 NITE, 05 foreign (extranjero no domiciliado), 06 no contribuyente. Only 01–04 with an all-digit number can issue documents, because the clave embeds it.
Example
02Number of that identification, without separators, normalized to uppercase. Its format depends on identificationType: 01 9 digits; 02 10 positions — from 2026-11-01 the last six may be alphanumeric (decree 44648-MJ), e.g. 3101A1B2C3, which can receive documents but not issue them; 03 11–12 digits; 04 10 digits; 05 up to 20 letters, digits or hyphens; 06 9–12 digits.
Example
3101234567Legal name (razón social) — <Nombre> in the XML, cut to 100 characters. A company's name cannot change through PATCH /tenants/:id (400 IMMUTABLE_FIELD): POST /tenants/:id/hacienda-sync takes it from Hacienda's registry.
Example
Futurabyte CR S.A.Trade name — <NombreComercial> in the XML when present, cut to 80 characters.
Example
FuturabyteOnly when creating a company: becomes its default economic activity, in Hacienda's dotted form (e.g. 6201.0). Ignored afterwards — activities are managed in /tenants/:tenantId/economic-activities — and in a document's inline party, whose activity is the document's economicActivityCodeReceptor.
Example
6201.0Address in Costa Rica — <Ubicacion> in the XML. A company cannot issue without it (422 TENANT_LOCATION_MISSING). In a document it is never written for a 05 party; in a purchase invoice (FEC), a supplier of type 01–04 must carry it (400 SUPPLIER_LOCATION_REQUIRED).
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.
Example
1Cantón code within that provincia, two digits (01, 02…).
Example
01Distrito code within that cantón, two digits (01, 02…).
Example
01Neighborhood (barrio), by name — <Barrio>, which Hacienda requires to be 5–50 characters when present.
Example
CarmenThe 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.
Example
50 metros norte de la iglesia, edificio azulDial code without "+" (1-3 digits).
Example
506National number, digits only (5-20).
Example
22223333Deprecated: a legacy single-string phone (+506 22223333). Send phoneCountryCode + phoneNumber instead; this one is only parsed for the XML when those are absent.
Example
50622223333Email address — <CorreoElectronico> in the XML. For a company, its main address and where its notices go when notificationEmail is empty; for a document's customer, where the accepted document is emailed.
Example
ventas@emite.crCompany only: a separate address for the system's notices to it (rejections, errors, summaries…). Set it with PATCH /tenants/:id; "" or null clears it and the notices go back to email. Ignored on creation and in a document's party.
Example
notificaciones@emite.crAddress abroad, free text — <OtrasSenasExtranjero>, 5–300 characters in Hacienda's schema. Written only for a foreign (05) party, and required when that party is the supplier of a purchase invoice (400 SUPPLIER_FOREIGN_ADDRESS_REQUIRED).
Example
1234 Ocean Ave, Miami, FL 33101, USAThe company's acceptance of the served Terms and Privacy Policy (version + hash of each text), with the declaration of authority and in which capacity. Required: 400 LEGAL_COMPANY_ACCEPTANCE_REQUIRED without it, 400 LEGAL_ACCEPTANCE_INCOMPLETE when a required document is missing, 409 OUTDATED_VERSION / HASH_MISMATCH for a stale text.
object
One entry per document accepted, at most 10. When creating a company every document it must accept has to be present (400 LEGAL_ACCEPTANCE_INCOMPLETE). A version the company already accepted is left as it was and not counted again.
object
Slug of a document the company accepts: terminos-y-condiciones or politica-de-privacidad (the documents marked requiredForSignup). The Cookie Policy (politica-de-cookies) is only announced, never accepted (400 LEGAL_DOCUMENT_NOT_REQUIRED).
Example
terminos-y-condicionesThe version of the document served today (its version), up to 32 characters. Any other version is 409 OUTDATED_VERSION.
Example
3.0The SHA-256 of the exact Markdown text shown: sha256: followed by 64 hex digits, copied verbatim from the hash served with the document. It is the proof of which text was accepted; one that differs from the served text is 409 HASH_MISMATCH.
Example
sha256:abcdef0123456789...The person declares the authority to bind the company (Terms 1.3). Must be true (400 LEGAL_AUTHORITY_REQUIRED), the same declaration the emailed link asks for.
In which capacity the person declares it (Terms 1.3 and 3.2): holder (a natural person who is the taxpayer), legal_representative, or authorized by whoever represents the company. Recorded with the acceptance (400 LEGAL_CAPACITY_REQUIRED without it).
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"}Missing or invalid session.
The identification is already registered by another company, or a legal text is stale (OUTDATED_VERSION / HASH_MISMATCH).