Settings and templates
Organization details, numbering series, tax configuration, invoice designs, email templates and Word templates to generate documents.
This guide covers the organization configuration that previously could only be changed in the app.
Scopes: settings:read / settings:write (organization, series, tax configuration, designs and emails) and templates:read / templates:write (Word templates and document generation).
Organization details
/api/v1/current-organizationsettings:write{
"name": "Talleres Martín S.L.",
"fiscal_street": "Calle Larios 12, 3.º B",
"fiscal_city": "Málaga",
"fiscal_province": "Málaga",
"fiscal_postal_code": "29005",
"fiscal_country": "ES",
"iban": "ES9121000418450200051332",
"regime": "general"
}GET /current-organization returns the profile and tax details (with setup_warnings if something required for invoicing is missing) and GET /current-organization/logo downloads the logo. regime: general, redeme or recargo_equivalencia.
The tax ID can't be changed with an API key once there are invoices
vat_id is validated just like in the app. If the organization has already issued invoices, it cannot be changed with an API key; do it in the app.
Numbering series
/api/v1/settings/series/settings:write{ "type": "INVOICE", "code": "W", "name": "Online store", "prefix": "W{YYYY}-", "pad_length": 5, "reset_policy": "yearly" }| Field | Description |
|---|---|
type | QUOTE, PROFORMA, INVOICE, CREDIT_NOTE, PURCHASE_ORDER, VENDOR_BILL. |
code, name | Short code and internal name. |
prefix, suffix | Support {YYYY}, {YY} and {MM}. |
pad_length, next_number | Number of digits and next number. |
reset_policy | never, yearly or monthly. |
Reading is also allowed with series:read. GET /settings/series/{id}/next-preview/ shows the next number without using it. A series with numbered documents cannot be deleted (409 conflict). Numbers are always assigned by Billora when issuing (VeriFactu sequence).
Tax configuration
/organization-tax-config/ defines the organization's enabled taxes. It is read with taxes:read or settings:read and changed with settings:write; POST /organization-tax-config/setup-defaults/ creates the default configuration and GET /organization-tax-config/enabled-taxes/ lists the active taxes.
Invoice designs and email templates
| Resource | Route |
|---|---|
| PDF designs (colors, header, footer, logo) | /invoice-templates/ · GET …/available-types/ |
| Activate a design (deactivates the others) | POST /invoice-templates/{id}/activate/ |
| Sample PDF | GET /invoice-templates/{id}/download-preview/ |
Email templates per document type (doc_type, subject, body_html, is_default) | /email-templates/ |
Document templates
Word templates (.docx with placeholders) generate documents with the data of a case, a patient or a consent.
| Module | Route |
|---|---|
| Cases | /expedientes/templates/ |
| Clinic | /clinica/templates/ |
| Consents | /clinica/consent-doc-templates/ |
They are created and edited with multipart/form-data (file, name, description, is_active). On each route, GET …/placeholders/ lists the available placeholders, GET …/instructions-pdf/ downloads the instructions and GET …/{id}/download/ returns the template's download URL.
Generating a document
/api/v1/expedientes/cases/{case_id}/generate-document/templates:read{ "template_id": 9, "output_format": "pdf" }Returns the file (pdf or docx) without storing it. It requires two scopes: templates:read and the one for the source data.
| Source | Endpoint | Scopes |
|---|---|---|
| Case | POST /expedientes/cases/{case_id}/generate-document/ | templates:read + cases:read |
Patient (optional episode_id) | POST /clinica/patients/{patient_id}/generate-document/ | templates:read + clinica:read |
| Consent | POST /clinica/patients/{patient_id}/consents/{consent_id}/generate-document/ | templates:read + clinica:read |
Patient documents are recorded in the clinic audit log.
