Skip to content

Black Friday.Get 70% off your first two months70% off70% off your first 2 months

Get my 70%Get it
Ends 30 NovemberSales+34 608 911 052

Black Friday

Start with 70% off your first two months

Try Factuarea for 10 days with no card and, if you choose the monthly plan, pay only 30% of your first two months. On the annual plan, the discount equals two months at 70%.

Get my 70%See pricing

For new sign-ups until 30 November

Ends in

Esencial monthly: €2.97 a month for the first two months, instead of €9.90Annual: €83.74 for the first year, instead of €94.80Prices exclude VAT.

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

GET/me
curl "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" }]} }

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 key

Prepare 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.

New API key
Permissions for this walkthrough
account:readseries:readtaxes:readcontacts:writeinvoices:writeinvoices:sendpdfs:read
Key prefix
fact_test_8KqW3pXnR2VbY7TcA9eFmN5z
Copy it now: the secret is shown only once.

Start 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.

The same base URL in both environmentshttps://api.factuarea.com/v1
bash
export 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.

  1. 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:read

    GET/me
    curl "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" }]} }
  2. 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:read

    GET/companies/$COMPANY_ID/series?document_type=invoice
    curl "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}] }
  3. 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:write

    POST/companies/$COMPANY_ID/contacts
    curl -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" }JSON
    ResponseWaiting200 OK
    { "data": { "id": "01991e70-aaaa-7000-8000-000000000001", "name": "Estudio Ribera", "roles": [{ "role": "customer" }]} }
  4. 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:write

    POST/companies/$COMPANY_ID/invoices
    curl -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 }], … }JSON
    ResponseWaiting201 Created
    { "data": { "id": "01991e70-aaaa-7000-8000-000000000003", "status": "draft", "number": null, "total": 1500.4} }
  5. 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:read

    POST/companies/$COMPANY_ID/invoices/{invoice}/send
    curl -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" }JSON
    ResponseWaiting200 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 responses

The 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
curl "https://api.factuarea.com/v1/me" \ --header "Authorization: Bearer TU_CLAVE"
ResponseWaiting401 Unauthorized
{ "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" }}
How to fix it
export FACTUAREA_API_KEY="fact_test_TU_CLAVE"curl "https://api.factuarea.com/v1/me" \ --header "Authorization: Bearer $FACTUAREA_API_KEY"

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.

Message us on WhatsApp+34 608 911 052

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.

Try free for 10 daysGet my 70%

No card requiredA real person helps you

Questions before you get started?Developer portal