Developers · Quickstart
From your first API call to an invoice PDF.
Connect your test key, prepare your data and follow an invoice through its full lifecycle. Five steps, seven requests and the same contract you will use in production.
cURL or Node.js · REST API · Isolated sandbox
curl "https://api.factuarea.com/v1/me" \ -H "Authorization: Bearer $FACTUAREA_API_KEY"{ "data": { "object": "me", "account": { "name": "Estudio Ribera" }, "scope": [{ "id": "01991e70-aaaa-7000-8000-0000000000c0" }]} }Before your first request
One key. Your testing environment.
Create an account and open Settings → Developers → API keys. Choose a test key and keep its secret on your server.
Create my test keyPrepare your terminal
Bash, cURL and uuidgen. For the JavaScript alternative, Node.js 20 or later. Replace TU_CLAVE and run this setup once in the same terminal.
Keep each REQUEST_ID when retrying the same operation with the same body. Generate another for a new operation. Never expose your API key in the browser.
account:readseries:readtaxes:readcontacts:writeinvoices:writeinvoices:sendpdfs:readfact_test_8KqW3pXnR2VbY7TcA9eFmN5zStart in the sandbox
Your first test key provisions an isolated company. Issuing uses its own numbering; email and AEAT submissions do not leave the sandbox.
https://api.factuarea.com/v1export FACTUAREA_API_KEY="fact_test_TU_CLAVE"export COMPANY_ID="ID_DE_TU_EMPRESA"export CONTACT_REQUEST_ID="$(uuidgen)"export INVOICE_REQUEST_ID="$(uuidgen)"export SEND_REQUEST_ID="$(uuidgen)"The complete workflow
From connection to document.
Choose a step to inspect its request. Run the code in your terminal; you can explore this walkthrough here without sending requests.
- Step 1 · Connect
Check your key and account
Your first call confirms which company the key belongs to and which permissions it has. It does not create documents.
A 200 response confirms you can continue.
Check data.scope and data.api_key.scopes before continuing.
Required permission:
account:readcurl "https://api.factuarea.com/v1/me" \ -H "Authorization: Bearer $FACTUAREA_API_KEY"ResponseWaiting200 OK{ "data": { "object": "me", "account": { "name": "Estudio Ribera" }, "scope": [{ "id": "01991e70-aaaa-7000-8000-0000000000c0" }]} } - Step 2 · Prepare
Find the series and VAT
List your invoice series and available taxes. This walkthrough uses tax_rate: 21 on the line, without combining it with tax_rate_id.
export SERIES_ID="series_id"Copy the id of an active invoice series and store it as SERIES_ID.
Required permission:
series:readtaxes:readcurl "https://api.factuarea.com/v1/companies/$COMPANY_ID/series?document_type=invoice" \ -H "Authorization: Bearer $FACTUAREA_API_KEY"ResponseWaiting200 OK{ "data": [{ "id": "01991e70-aaaa-7000-8000-000000000002", "code": "F-2026", "is_default": true}] } - Step 3 · Customer
Create the contact to invoice
Customers are contacts with the customer role. Keep the id returned by the API to link the contact to your document.
export CLIENT_ID="contact_id"The .example email has no real recipient. Complete the tax and address details required for your transaction before invoicing in production.
Required permission:
contacts:writecurl -X POST "https://api.factuarea.com/v1/companies/$COMPANY_ID/contacts" \ -H "Authorization: Bearer $FACTUAREA_API_KEY" \ -H "Idempotency-Key: $CONTACT_REQUEST_ID" \ -H "Content-Type: application/json" \ -d @- <<JSON{ "name": "Estudio Ribera", "kind": "company", "roles": ["customer"], "tax_id": "B12345674" }JSONResponseWaiting200 OK{ "data": { "id": "01991e70-aaaa-7000-8000-000000000001", "name": "Estudio Ribera", "roles": [{ "role": "customer" }]} } - Step 4 · Draft
Prepare the invoice before numbering
One €1,240 line with 21% VAT. The API creates a draft: you can still review it, and it has not consumed a series number.
export INVOICE_ID="invoice_id"This example sets issue and due dates to the same day. Adjust the due date to your customer’s payment terms.
Required permission:
invoices:writecurl -X POST "https://api.factuarea.com/v1/companies/$COMPANY_ID/invoices" \ -H "Authorization: Bearer $FACTUAREA_API_KEY" \ -H "Idempotency-Key: $INVOICE_REQUEST_ID" \ -H "Content-Type: application/json" \ -d @- <<JSON{ "client_id": "$CLIENT_ID", "series_id": "$SERIES_ID", "lines": [{ "description": "Consultoría de diseño", "unit_price": 1240, "tax_rate": 21 }], … }JSONResponseWaiting201 Created{ "data": { "id": "01991e70-aaaa-7000-8000-000000000003", "status": "draft", "number": null, "total": 1500.4} } - Step 5 · PDF
Issue and retrieve the PDF
The send action issues the draft and assigns its number. Download the PDF afterwards. In test mode, email is not delivered to the recipient.
The PDF is saved as factura.pdf in your current folder.
A 200 response from send does not confirm AEAT acceptance. Check tax records and their statuses separately.
Required permission:
invoices:sendpdfs:readcurl -X POST "https://api.factuarea.com/v1/companies/$COMPANY_ID/invoices/$INVOICE_ID/send" \ -H "Authorization: Bearer $FACTUAREA_API_KEY" \ -H "Idempotency-Key: $SEND_REQUEST_ID" \ -H "Content-Type: application/json" \ -d @- <<JSON{ "to": "facturas@ribera.example" }JSONResponseWaiting200 OK{ "data": { "number": "F-2026-0001", "status": "issued", "verifactu_status": "pending"} }
When something needs attention
Read the error. Keep going.
The HTTP status gives context; the response code and message tell you what to check.
Read about errors and responsesThe key does not authenticate
Check the complete secret and the Authorization: Bearer header. If you lost the secret, create or rotate the key in your account.
What to check: Make sure FACTUAREA_API_KEY is exported in your terminal.
curl "https://api.factuarea.com/v1/me" \ --header "Authorization: Bearer TU_CLAVE"{ "error": { "type": "authentication_error", "code": "invalid_api_key", "message": "La API key no tiene el formato esperado (debe empezar por fact_live_ o fact_test_).", "param": null, "doc_url": "https://docs.factuarea.com/guides/errors#invalid_api_key", "request_id": "req_01HKQS5N9JTQM7HVTQP3FBN5XB" }}export FACTUAREA_API_KEY="fact_test_TU_CLAVE"curl "https://api.factuarea.com/v1/me" \ --header "Authorization: Bearer $FACTUAREA_API_KEY"Where your integration goes next
Your first invoice is the beginning.
Questions
Before connecting your application
Still have a question?
A person on the team answers, on any plan. Write to us the way you would to a colleague.
Monday to Friday, 9:00 to 18:00
No. The test key is created from a normal account, and the sandbox company is provisioned when that first key is created.
A more connected business
The test invoice is five steps away
Create the account, get a fact_test_ key and follow the flow. The invoice is numbered inside the sandbox and its external effects stay there.
No card requiredA real person helps you