Quickstart
Create an API key, make your first request and take an invoice from draft to issued and paid in ten minutes.
In this guide you will create a customer, prepare a draft invoice, issue it, download its PDF and record the payment. Every step has examples in cURL, JavaScript (Node.js 18+ with fetch), Python (requests) and PHP (cURL).
Use a test organization
Issuing an invoice is irreversible and, if the organization has VeriFactu enabled, it is submitted to the Spanish Tax Agency. While you develop, work in a test organization without VeriFactu. See Environments.
1. Create an API key
- Sign in to Billora as an owner or admin and go to Settings → API.
- Click Create API key, give it a name that identifies the integration (for example “ERP production”) and select these scopes:
contacts:write,invoices:write,payments:write,series:readandtaxes:read. - Copy the key. It starts with
blr_and is shown only once: Billora only stores a hash.
Store it in an environment variable; every example reads it from there:
export BILLORA_API_KEY="blr_…"2. Make your first request
List the organization's numbering series. It checks that the key works and tells you which series to use when invoicing.
curl https://api.billora.app/api/v1/settings/series/ \
-H "Authorization: Bearer $BILLORA_API_KEY"// billora.mjs — helper reused in the next steps
const API = "https://api.billora.app/api/v1";
export async function billora(method, path, body, extraHeaders = {}) {
const res = await fetch(`${API}${path}`, {
method,
headers: {
Authorization: `Bearer ${process.env.BILLORA_API_KEY}`,
"Content-Type": "application/json",
...extraHeaders,
},
body: body ? JSON.stringify(body) : undefined,
});
const data = res.status === 204 ? null : await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.detail} (${data.request_id})`);
return data;
}
const series = await billora("GET", "/settings/series/");
console.log(series.results.filter((s) => s.type === "INVOICE"));# billora.py — session reused in the next steps
import os
import requests
API = "https://api.billora.app/api/v1"
session = requests.Session()
session.headers.update({"Authorization": f"Bearer {os.environ['BILLORA_API_KEY']}"})
def billora(method, path, json=None, headers=None):
res = session.request(method, f"{API}{path}", json=json, headers=headers, timeout=30)
data = None if res.status_code == 204 else res.json()
if not res.ok:
raise RuntimeError(f"{data['code']}: {data['detail']} ({data['request_id']})")
return data
series = billora("GET", "/settings/series/")
print([s for s in series["results"] if s["type"] == "INVOICE"])<?php
// billora.php — function reused in the next steps
function billora(string $method, string $path, ?array $body = null, array $headers = []): ?array {
$ch = curl_init("https://api.billora.app/api/v1" . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array_merge([
"Authorization: Bearer " . getenv("BILLORA_API_KEY"),
"Content-Type: application/json",
], $headers),
CURLOPT_POSTFIELDS => $body !== null ? json_encode($body) : null,
]);
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$data = $status === 204 ? null : json_decode($raw, true);
if ($status >= 400) {
throw new RuntimeException("{$data['code']}: {$data['detail']} ({$data['request_id']})");
}
return $data;
}
$series = billora("GET", "/settings/series/");
print_r(array_filter($series["results"], fn ($s) => $s["type"] === "INVOICE"));The response is a paginated list. Note the id of the invoice series ("type": "INVOICE"):
{
"count": 3,
"next": null,
"previous": null,
"results": [
{ "id": 12, "type": "INVOICE", "code": "F", "name": "Facturas", "prefix": "F-", "next_number": 1 },
{ "id": 13, "type": "CREDIT_NOTE", "code": "R", "name": "Rectificativas", "prefix": "R-", "next_number": 1 },
{ "id": 14, "type": "QUOTE", "code": "P", "name": "Presupuestos", "prefix": "P-", "next_number": 1 }
]
}If you get a 401, check the Authorization header; if it is a 403, look at the error code (missing scope, plan without API…). Every code is listed in Errors.
3. Look up the tax to apply
Line taxes are given as ids from the Spanish tax catalog (VAT/IVA, IGIC, equivalence surcharge, IRPF withholding…). Look it up once and keep the id in your configuration:
curl "https://api.billora.app/api/v1/spanish-tax-rates/?page_size=200" \
-H "Authorization: Bearer $BILLORA_API_KEY"{
"results": [
{ "id": 1, "name": "IVA General 21%", "tax_type": "IVA", "category": "incremental", "rate": "21.00", "is_active": true },
{ "id": 9, "name": "IRPF Profesionales 15%", "tax_type": "IRPF_PROF", "category": "retencion", "rate": "15.00", "is_active": true }
]
}The examples use 1 (standard 21% VAT). More details in Spanish taxes.
4. Create a customer
curl https://api.billora.app/api/v1/customers/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"legal_name": "Talleres Martín S.L.",
"vat_id": "B12345674",
"party_type": "company",
"email": "administracion@talleresmartin.es",
"billing_address": {
"line1": "Calle Mayor 10",
"city": "Zaragoza",
"postal_code": "50001",
"province": "Zaragoza",
"country": "ES"
}
}'import { billora } from "./billora.mjs";
const customer = await billora("POST", "/customers/", {
legal_name: "Talleres Martín S.L.",
vat_id: "B12345674",
party_type: "company",
email: "administracion@talleresmartin.es",
billing_address: {
line1: "Calle Mayor 10",
city: "Zaragoza",
postal_code: "50001",
province: "Zaragoza",
country: "ES",
},
});
console.log(customer.id);from billora import billora
customer = billora("POST", "/customers/", json={
"legal_name": "Talleres Martín S.L.",
"vat_id": "B12345674",
"party_type": "company",
"email": "administracion@talleresmartin.es",
"billing_address": {
"line1": "Calle Mayor 10",
"city": "Zaragoza",
"postal_code": "50001",
"province": "Zaragoza",
"country": "ES",
},
})
print(customer["id"])require "billora.php";
$customer = billora("POST", "/customers/", [
"legal_name" => "Talleres Martín S.L.",
"vat_id" => "B12345674",
"party_type" => "company",
"email" => "administracion@talleresmartin.es",
"billing_address" => [
"line1" => "Calle Mayor 10",
"city" => "Zaragoza",
"postal_code" => "50001",
"province" => "Zaragoza",
"country" => "ES",
],
]);
echo $customer["id"];The API answers 201 Created with the full customer. Before creating customers from an integration, search by tax id first (GET /customers/?search=B12345674) to avoid duplicates.
5. Create the draft invoice
Prices are before tax and amounts are decimal strings ("85.00"). Billora computes the base, VAT, withholdings and total.
curl https://api.billora.app/api/v1/invoices/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: pedido-2026-1042" \
-d '{
"customer": 318,
"series": 12,
"due_date": "2026-12-01",
"notes": "Pedido 2026-1042",
"lines": [
{
"description": "Revisión anual de maquinaria",
"quantity": "10",
"unit_price": "85.00",
"spanish_taxes": [1]
}
]
}'const invoice = await billora(
"POST",
"/invoices/",
{
customer: customer.id,
series: 12,
due_date: "2026-12-01",
notes: "Pedido 2026-1042",
lines: [
{ description: "Revisión anual de maquinaria", quantity: "10", unit_price: "85.00", spanish_taxes: [1] },
],
},
{ "Idempotency-Key": "pedido-2026-1042" },
);
console.log(invoice.id, invoice.status, invoice.total); // 5120 draft 1028.50invoice = billora("POST", "/invoices/", json={
"customer": customer["id"],
"series": 12,
"due_date": "2026-12-01",
"notes": "Pedido 2026-1042",
"lines": [
{"description": "Revisión anual de maquinaria", "quantity": "10",
"unit_price": "85.00", "spanish_taxes": [1]},
],
}, headers={"Idempotency-Key": "pedido-2026-1042"})
print(invoice["id"], invoice["status"], invoice["total"]) # 5120 draft 1028.50$invoice = billora("POST", "/invoices/", [
"customer" => $customer["id"],
"series" => 12,
"due_date" => "2026-12-01",
"notes" => "Pedido 2026-1042",
"lines" => [[
"description" => "Revisión anual de maquinaria",
"quantity" => "10",
"unit_price" => "85.00",
"spanish_taxes" => [1],
]],
], ["Idempotency-Key: pedido-2026-1042"]);
echo "{$invoice['id']} {$invoice['status']} {$invoice['total']}"; // 5120 draft 1028.50{
"id": 5120,
"status": "draft",
"number": null,
"customer": { "id": 318, "legal_name": "Talleres Martín S.L.", "vat_id": "B12345674" },
"series": { "id": 12, "code": "F", "name": "Facturas", "type": "INVOICE" },
"subtotal": "850.00",
"tax_total": "178.50",
"withholding_total": "0.00",
"total": "1028.50",
"balance": "1028.50",
"lines": [
{ "id": 9001, "description": "Revisión anual de maquinaria", "quantity": "10.00", "unit_price": "85.00",
"discount_percent": "0.00", "spanish_taxes": [1], "line_subtotal": "850.00", "line_tax": "178.50", "line_total": "1028.50" }
]
}The Idempotency-Key header makes sure that, if you repeat the request after a timeout, no second invoice is created. See Idempotency.
6. Issue the invoice
Issuing assigns the series number and issue date (today) and records the invoice in VeriFactu. It cannot be undone.
curl -X POST https://api.billora.app/api/v1/invoices/5120/send/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-H "Idempotency-Key: emitir-5120"const issued = await billora("POST", `/invoices/${invoice.id}/send/`, null, {
"Idempotency-Key": `emitir-${invoice.id}`,
});
console.log(issued.number, issued.status); // F-2026-0001 sentissued = billora("POST", f"/invoices/{invoice['id']}/send/",
headers={"Idempotency-Key": f"emitir-{invoice['id']}"})
print(issued["number"], issued["status"]) # F-2026-0001 sent$issued = billora("POST", "/invoices/{$invoice['id']}/send/", null, ["Idempotency-Key: emitir-{$invoice['id']}"]);
echo "{$issued['number']} {$issued['status']}"; // F-2026-0001 sent{
"number": "F-2026-0001",
"status": "sent",
"message": "Factura enviada correctamente",
"verifactu_processed": true,
"sent_to_aeat": true
}If VeriFactu rejects the record, the API answers 400, the invoice stays as a draft and no number is consumed: fix the problem (for example the customer's tax id) and issue again.
7. Download the PDF
curl https://api.billora.app/api/v1/invoices/5120/download-pdf/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-o F-2026-0001.pdfThe response is application/pdf. You can also email it to the customer with POST /invoices/5120/email/ and {"to": ["administracion@talleresmartin.es"]}.
8. Record the payment
curl https://api.billora.app/api/v1/payments/ \
-H "Authorization: Bearer $BILLORA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: cobro-5120-1" \
-d '{ "invoice": 5120, "amount": "1028.50", "currency": "EUR", "date": "2026-11-15", "reference": "Transferencia 88231" }'await billora(
"POST",
"/payments/",
{ invoice: invoice.id, amount: "1028.50", currency: "EUR", date: "2026-11-15", reference: "Transferencia 88231" },
{ "Idempotency-Key": `cobro-${invoice.id}-1` },
);
const paid = await billora("GET", `/invoices/${invoice.id}/`);
console.log(paid.status, paid.remaining_amount); // paid 0.00billora("POST", "/payments/", json={
"invoice": invoice["id"], "amount": "1028.50", "currency": "EUR",
"date": "2026-11-15", "reference": "Transferencia 88231",
}, headers={"Idempotency-Key": f"cobro-{invoice['id']}-1"})
paid = billora("GET", f"/invoices/{invoice['id']}/")
print(paid["status"], paid["remaining_amount"]) # paid 0.00billora("POST", "/payments/", [
"invoice" => $invoice["id"], "amount" => "1028.50", "currency" => "EUR",
"date" => "2026-11-15", "reference" => "Transferencia 88231",
], ["Idempotency-Key: cobro-{$invoice['id']}-1"]);
$paid = billora("GET", "/invoices/{$invoice['id']}/");
echo "{$paid['status']} {$paid['remaining_amount']}"; // paid 0.00A partial payment leaves the invoice as partially_paid; once payments cover the total it becomes paid. To settle the whole outstanding amount at once there is POST /invoices/{id}/mark-paid/.
