Invoices¶
Endpoints for listing, printing and creating sales invoice documents.
Invoices cannot be changed or cancelled through the API; cancel an invoice in Gestix.
GET /invoices¶
List invoices with optional filtering, searching, and pagination.
Request¶
Parameters¶
| Name | In | Type | Required | Description |
|---|---|---|---|---|
nonce |
query | integer (int64) | No | Client-generated unique sequential number |
filterDate |
query | string | No | Filter by date or interval. Format: YYYY-MM-DD or YYYY-MM-DD:YYYY-MM-DD |
searchString |
query | string | No | Search by document number. Example: searchString=123456 |
searchColumn |
query | string | No | Column to search instead of document number. Example: searchColumn=document_set&searchString=ORD |
searchOperator |
query | string | No | Comparison operator: lt (<), lte (<=), gt (>), gte (>=), ne (<>); from 7.2.03 also contains |
skip |
query | integer | No | Number of records to skip (pagination) |
limit |
query | integer | No | Max records to return. Max: 1000, default: 50 |
id |
query | integer | No | Return the invoice with this internal ID |
print |
query | integer | No | With id, pass 1 to receive the invoice as a PDF |
Responses¶
200 — Success¶
Returns an array of customerDocument objects (empty array if none found).
[
{
"id": 1001,
"document_set": "FT",
"seq_number": "FT2024/1001",
"date": "2024-11-01",
"currency": "EUR",
"total_amount": 1230.00,
"customer": { "name": "Acme Corp", "vat_id": "PT123456789" },
"items": [ ... ]
}
]
400 — Invalid input parameters¶
Finding an invoice by your reference¶
The result contains the invoice's id and number (document_alias, for example "FAT 63").
GET /invoices/{id} — PDF¶
Download the PDF of an existing invoice by its internal ID:
GET /api/{account}/v4.0.0/invoices/{id}/?nonce={nonce}&print=1
GET /api/{account}/v4.0.0/invoices/?nonce={nonce}&id={id}&print=1
Authorization: Bearer <xa-token>
Both return 200 with Content-Type: application/pdf. print is ignored on a search (searchString), which returns JSON.
POST /invoices¶
Create a new invoice document.
Request¶
POST /api/{account}/v4.0.0/invoices?nonce={nonce}
Authorization: Bearer <xa-token>
Content-Type: application/json
Parameters¶
| Name | In | Type | Required | Description |
|---|---|---|---|---|
nonce |
query | integer (int64) | Yes | Client-generated unique sequential number |
print |
query | integer | No | Pass 1 to receive the created document as a PDF. Default: 0 |
Request Body¶
A customerDocument object. Required fields: document_set, seq_number, date, currency, total_amount.
{
"document_set": "FT",
"seq_number": "FT2024/1002",
"date": "2024-11-15",
"currency": "EUR",
"total_amount": 500.00,
"customer": {
"name": "Acme Corp",
"country_iso": "PT",
"vat_id": "PT123456789"
},
"items": [
{
"description": "Consulting Services",
"qty": 2,
"unit_price": 250.00,
"vat": 23.0
}
]
}
Lines: see Line types for item_type (P, A, S, T) and Numbers for the number format.
Customer address above EUR 1,000¶
An invoice above EUR 1,000 requires the customer's address and postal code (art. 36 CIVA), whatever the customer's country. Otherwise it is refused with 400 (Código Postal / Especifique por favor: Morada do Cliente (36.º do Código do IVA - CIVA) / Max. 1.000,00).
- Before 7.2.03, the check uses only the address in the request: send
customer.billing_addresswithpostal_address,cityandzip_code. - From 7.2.03, the check uses the address the invoice prints: the customer's stored billing address. A
customer.billing_addressin the request updates the customer's stored address first (only the fields sent with a value; empty fields never clear stored ones). The change is saved only when the invoice is saved: a refused invoice leaves the customer's address unchanged. Without abilling_address, the stored address is used as it is.
Responses¶
202 — Document accepted (without print)¶
The invoice is created. The response has no ID or number. Before 7.2.03 the body is empty; from 7.2.03 it is {"status":202,"error":false,"message":"Gestix document accepted"}.
To get the invoice's id and number, search by your reference.
200 — PDF (with print=1)¶
The body is the invoice PDF (Content-Type: application/pdf). The number is in the file name of the Content-Disposition header, for example attachment; filename=DOC-506819523-CI-FAT-63-7022.pdf (series FAT, number 63).
400 — Invalid input¶
Nothing is stored. See Error Handling for how to read the reason.
409 — Duplicate entry¶
Returned when a document with the same identifier already exists.
405 — Method not allowed¶
From 7.2.03, PUT, PATCH and DELETE on /invoices/ return 405. See Error Handling.