Authentication and API keys
How to authenticate requests with API keys, which scopes exist, who can manage keys and how to rotate them without downtime.
The API is authenticated with API keys: secret keys that start with blr_, belong to one organization and carry a set of permissions (scopes).
Sending the key
Send the key in the Authorization header with the Bearer scheme. This is the recommended format:
GET /api/v1/invoices/ HTTP/1.1
Host: api.billora.app
Authorization: Bearer blr_8fK2…curl https://api.billora.app/api/v1/customers/ \
-H "Authorization: Bearer $BILLORA_API_KEY"const res = await fetch("https://api.billora.app/api/v1/customers/", {
headers: { Authorization: `Bearer ${process.env.BILLORA_API_KEY}` },
});import os, requests
res = requests.get(
"https://api.billora.app/api/v1/customers/",
headers={"Authorization": f"Bearer {os.environ['BILLORA_API_KEY']}"},
timeout=30,
)$ch = curl_init("https://api.billora.app/api/v1/customers/");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer " . getenv("BILLORA_API_KEY")]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$customers = json_decode(curl_exec($ch), true);For backwards compatibility these two forms are also accepted and behave the same:
| Header | Example | Use |
|---|---|---|
Authorization: Bearer | Authorization: Bearer blr_… | Recommended. Works with OpenAPI generators and most HTTP clients. |
Authorization: ApiKey | Authorization: ApiKey blr_… | Previous format; still supported. |
X-Api-Key | X-Api-Key: blr_… | For tools that can't set Authorization. |
A Bearer value starting with blr_ is always treated as an API key. The key identifies the organization: don't send X-Organization-Id (it is ignored).
Never in the browser or a mobile app
An API key gives access to your organization's invoicing data. Use it only from servers. Don't ship it in web JavaScript or a mobile app, don't commit it, and don't put it in URLs (query strings end up in logs).
Creating an API key
Keys are created in Settings → API in the app. You need:
- A plan with API access (Pro or Business).
- To be an owner (OWNER) or admin (ADMIN) of the organization. Only these roles can create, list, rename, rotate or revoke keys.
When creating it you choose a name, the scopes and, optionally, an expiry date. The full key is shown only once; Billora only stores a hash and its prefix (so you can recognize it in the list next to its last-used date).
Scopes
Each scope looks like resource:read or resource:write. write includes read for the same resource. Give each key only what it needs.
| Scope | Allows |
|---|---|
invoices:read | Read invoices, quotes, proformas, credit notes, third-party invoices, recurring invoices, income categories and payment methods; download PDF and Facturae. |
invoices:write | Create, edit and delete drafts; issue (number and record in VeriFactu), cancel, correct, convert, email and create payment links. Includes irreversible actions. |
contacts:read | Read customers, suppliers, contact people, addresses, tags and payment terms. |
contacts:write | Create, edit and delete all of the above. |
products:read | Read products, units and tax templates. |
products:write | Create, edit and delete products, units and tax templates. |
payments:read | Read invoice payments and expense payments. |
payments:write | Record, edit and delete invoice and expense payments. |
expenses:read | Read expenses, categories, expense payment methods and document scans. |
expenses:write | Create, edit, confirm and delete expenses and categories; upload documents for scanning. |
series:read | Read numbering series. |
taxes:read | Read tax rates (VAT, IGIC, IRPF, surcharge…), regimes, templates and the tax configuration. |
webhooks:read | Read webhook endpoints, events and deliveries. |
webhooks:write | Create, edit, test and delete endpoints, rotate secrets and redeliver. |
files:read | Download generated files (bulk PDF downloads as ZIP) and read scans. |
files:write | Upload documents for scanning (OCR). |
cases:read | Read cases, parties, actions, folders, files and linked documents. |
cases:write | Create, edit and delete cases and their content, including file uploads. |
crm:read / crm:write | Pipelines, stages, leads, opportunities, activities and notes. |
agenda:read / agenda:write | Event types, bookings and availability. |
accounting:read | Chart of accounts, fiscal years, journal entries, general ledger and accounting reports. |
accounting:write | Create and edit fiscal years (and close them), accounts and journal entries (and post them), the accounting settings, and initialize the PGC PYMES chart of accounts. |
treasury:read | Treasury: bank accounts, imported statements, bank transactions with their reconciliation suggestions, rules, bank vs. ledger summary and settings. Status, accounts, sync history and queries of the Revolut Business integration. |
treasury:write | Create and edit bank accounts and rules, import statements (Norma 43, CSV, XLSX), reconcile transactions (payments, transfers, taxes, payroll, fees), accept suggestions, ignore and undo reconciliations. Configure the Revolut Business connection, link accounts, sync, register the webhook and create payment drafts. |
reports:read | Tax and VAT reports, tax forms (303, 130, 111, 347…) and dashboard indicators. |
reports:write | Manually adjust editable boxes of tax forms. |
purchases:read / purchases:write | Purchase orders, vendor bills (approve, cancel, PDF, email) and vendor payments. |
settings:read / settings:write | Organization data (profile, tax details, logo), numbering series, tax configuration, invoice designs and email templates. |
templates:read / templates:write | Word templates for cases, clinic and consents, and generating documents from them. |
hr:read / hr:write | HR: employees, departments, positions, work centers, contracts, schedules, leave, holidays, time entries, payroll and documents. |
clinica:read / clinica:write | Clinic: patients, episodes, allergies, medical history, vitals, consents, diagnoses, treatments and clinical files. Health data: every access is audited. |
signatures:read / signatures:write | Digital signature requests: create, send, remind, cancel and download the signed PDF, evidence and certificate. |
imports:read / imports:write | Excel imports (upload, validate, process and check the per-row result). |
verifactu:read / verifactu:write | VeriFactu records and their submission status with the AEAT; retry submissions and register invoices (irreversible). |
audit:read | The organization's audit log (creations, changes, deletions and access to clinical data). |
sms:read / sms:send | SMS balance, bundles and history; sms:send sends SMS (uses credits). |
account:read | Account summary (plan, modules and usage), members, plans, features and integration status (no tokens). |
For SMS the write level is called send: sms:send includes sms:read.
Some operations require more than one scope (the key needs all of them):
- Generating documents from templates:
templates:readpluscases:read(cases) orclinica:read(patients and consents). - Imports: besides
imports:write, the write scope of the imported resource (contacts:writefor customers, suppliers and contacts;products:write;invoices:writefor invoices and third-party invoices;expenses:write).
The reference shows the scope each operation requires (x-scope). If the key lacks the required scope, the API answers 403 with "code": "insufficient_scope" and the missing scope in required_scope:
{
"detail": "Tu API key no tiene permisos para este recurso.",
"code": "insufficient_scope",
"required_scope": "invoices:write",
"request_id": "req_01JBQ7X9K2M4N6P8R0S2T4V6W8"
}Which endpoints accept API keys
An API key only works on the public API endpoints, the ones listed in the reference. The app's account and session endpoints (profile, password, 2FA, subscription, managing API keys themselves, Claude connections…) reject API keys with 403 api_key_not_allowed, even if the key has every scope.
When a key stops working
| Situation | Response |
|---|---|
| Unknown or revoked key | 401 authentication_failed |
| Expired key | 401 api_key_expired |
| No authentication header | 401 not_authenticated |
| The user who created it is no longer active or no longer an owner/admin | 403 api_key_creator_inactive |
| The organization's plan no longer includes API access | 403 plan_no_api_access |
| Endpoint not available with API keys | 403 api_key_not_allowed |
| Missing scope | 403 insufficient_scope |
Keys are tied to their creator
A key acts under the responsibility of whoever created it. If that person leaves the organization or loses the admin role, their keys stop working. For long-lived integrations, create keys with a stable admin user.
Rotation and revocation
Rotate keys periodically and whenever you suspect one has been exposed.
Zero-downtime rotation (recommended):
- Create a new key with the same scopes.
- Deploy your integration with the new key.
- Check in Settings → API that the new key shows usage (“last used”) and the old one no longer does.
- Revoke the old key.
From the same screen you can also:
- Rotate a key: Billora generates a new secret with the same name, scopes and expiry, and shows it once. The previous secret stops working right away (and the key becomes tied to whoever rotated it), so use it when you can update the integration immediately or when the key has leaked.
- Revoke a key: it is rejected immediately and cannot be reactivated.
Best practices
- One key per integration and environment, with a descriptive name, so you can revoke one without affecting the rest.
- Least privilege: if you only read invoices for your BI,
invoices:readis enough. - Keep the key in a secrets manager or environment variable, never in code.
- Set an expiry date on temporary keys (tests, external consultants).
- Log the
X-Request-Idof every response: support will ask for it. - If a key leaks, revoke it first and create a new one afterwards.
