Skip to content

Organization

The tenant is the taxpayer. Its configuration — profile, locations, activities, credentials, branding — is environment-independent (shared by sandbox and production); only transactional data is environment-scoped.

Ventana de terminal
GET /v1/tenants/me
PATCH /v1/tenants/:id

Identity fields (identification type/number) are immutable once set (IMMUTABLE_FIELD, params.field: "identification") — the tenant is that taxpayer. The legal name is not edited by hand either (params.field: "name"): it follows Hacienda’s registry, and POST /v1/tenants/:id/hacienda-sync updates it to the official value. Editable: commercial name, contact, default locale, enabled currencies, notification preferences.

Consecutivos are allocated per (branch, terminal, docType). Map each physical location to a branch and each register/POS device to a terminal so numbering never contends across devices.

Ventana de terminal
GET /v1/tenants/:tenantId/branches
POST /v1/tenants/:tenantId/branches
PATCH /v1/tenants/:tenantId/branches/:branchId
DELETE /v1/tenants/:tenantId/branches/:branchId
GET /v1/tenants/:tenantId/branches/:branchId/terminals
POST /v1/tenants/:tenantId/branches/:branchId/terminals
PATCH /v1/tenants/:tenantId/branches/:branchId/terminals/:terminalId
DELETE /v1/tenants/:tenantId/branches/:branchId/terminals/:terminalId

A branch/terminal code referenced by issued documents is immutable — create a new one instead of renumbering.

The company always has a default branch, and each branch a default terminal: it is the one a document that names no other uses. To change it, send isDefault: true to another one; sending isDefault: false to the default answers 409 (BRANCH_DEFAULT_REQUIRED, TERMINAL_DEFAULT_REQUIRED), and deleting it answers 422 (BRANCH_DEFAULT_CANNOT_BE_DELETED, TERMINAL_DEFAULT_CANNOT_BE_DELETED).

Your document must declare an economic activity registered to the taxpayer at Hacienda.

Ventana de terminal
GET /v1/tenants/:tenantId/economic-activities
POST /v1/tenants/:tenantId/economic-activities/sync # sync from Hacienda's registry
PATCH /v1/tenants/:tenantId/economic-activities/:activityId/default # set the default

Syncing pulls the current activities from Hacienda’s padrón. If the default activity is no longer registered, the sync applies nothing and answers 409 DEFAULT_ACTIVITY_DROPPED, with the activity that dropped in error.details.removed and the taxpayer’s current ones in error.details.suggested: call it again with newDefault, the code of one of them. An empty suggested means Hacienda has no activity registered for the company, which has to be registered before syncing. A newDefault that is not in the registry answers 409 INVALID_NEW_DEFAULT, with the same list.

The .p12 certificate + ATV credentials, per environment. Uploaded as multipart/form-data; only opaque, non-secret metadata (cert expiry, ATV username) is ever returned.

Ventana de terminal
GET /v1/tenants/:tenantId/credentials # status per env (no secrets)
PUT /v1/tenants/:tenantId/credentials/:environment # upload p12 + ATV
PATCH /v1/tenants/:tenantId/credentials/:environment # rotate individual fields
DELETE /v1/tenants/:tenantId/credentials/:environment
PATCH /v1/tenants/:tenantId/credentials/active-environment # switch active env
POST /v1/tenants/:tenantId/credentials/:environment/verify # one try of refused credentials

Deleting removes that env’s certificate, its PIN and its ATV credentials, even if it is the active one: until new ones are uploaded, that env cannot sign or send documents. Switching to an env with no credentials returns TARGET_ENVIRONMENT_NOT_CONFIGURED.

When Hacienda refuses the stored credentials

Section titled “When Hacienda refuses the stored credentials”

If Hacienda’s IdP refuses the stored ATV username and password (a password changed at Hacienda, an expired or locked account), EmiteCR stops presenting them: every refused login counts toward the account’s lockout at Hacienda, and the pipeline would otherwise keep trying around the clock. Nothing is lost meanwhile:

  • Documents keep their number and issue date and wait signed; none is marked error, and no 24-hour timeout runs while the credentials are refused.
  • GET …/credentials shows atvRejectedAt, the IdP’s own words (atvRejectionDetail) and how many documents wait (waitingDocuments).
  • The company’s owner and administrators get an email at once and a reminder every day; integrations subscribed to credentials.rejected get a webhook.
  • Saving the credentials again (PUT or PATCH), or a successful POST …/verify (one try with the stored ones, at most once a minute — for when they were fixed at Hacienda without changing them here), clears the mark and everything that waited goes out on its own, followed by credentials.restored. A daily probe does the same when Hacienda starts accepting them again without anyone touching them.
Ventana de terminal
PUT /v1/tenants/:id/logo # upload (multipart)
GET /v1/tenants/:id/logo/raw # the stored image
DELETE /v1/tenants/:id/logo
POST /v1/tenants/me/pdf-branding/preview # render a sample PDF; nothing is saved

The logo appears on generated invoice PDFs on every plan. The colours and the layout are saved with the rest of the settings: PATCH /v1/tenants/me/settings with pdfBranding, where only the fields sent change and null puts one back to its default. Changing them is gated by the pdf_branding feature. The preview renders a sample invoice with the branding sent in its body, without saving it.

Ventana de terminal
GET /v1/tenants/me/settings
PATCH /v1/tenants/me/settings

Preferences like enabled currencies and default currency live here. Disabling a currency that still has draft invoices returns CURRENCY_HAS_DRAFTS — use the disable-currency-impact preflight first.