Skip to content

HubfiscalGetDocuments

Queries the Hub Fiscal database to retrieve fiscal documents with powerful filtering capabilities. Supports filtering by country, status, type, provider, date range and free-text search. Returns paginated JSON results with configurable inclusion/exclusion of heavy binary fields (ticket HTML, ticket PDF, original payload).

Key features:

  • Multiple filters: Combine country, status, type, provider, date range and text search
  • Multi-value filters: Country and status accept comma-separated values (e.g. PT,ES)
  • Binary control: Include or exclude ticket_html, ticket_pdf and payload_json independently
  • Fiscal history: Optionally join with fiscal_status table to include attempt history
  • Pagination: limit + offset with total count for cursor-based navigation
  • Safe ordering: Whitelist-validated column names to prevent SQL injection
FieldTypeRequiredDescription
credentials_idcredentialsYesHub Fiscal SQL Server (MSSQL) credential
document_idtextNoDocument ID(s): single or comma-separated
entity_idtextNoExternal entity ID (Shopify order ID)
order_numbertextNoVisible order number
country_isotextNoCountry ISO: single (PT) or multiple (PT,ES)
statusselectNoFilter by status: pending, processing, completed, failed, voided
doc_typeselectNoFilter by type: FT, FR, NC, ORC
fiscal_providerselectNoFilter by provider: billpt, fiskaly, sage
date_fromtextNoIssue date from (YYYY-MM-DD)
date_totextNoIssue date to (YYYY-MM-DD)
searchtextNoFree-text search in order_number, contact_name, contact_email, fiscal_doc_number
include_htmlselectNoInclude ticket_html in response. Default: Yes
include_pdfselectNoInclude ticket_pdf (base64) in response. Default: No (heavy)
include_payloadselectNoInclude original order payload_json. Default: Yes
include_fiscal_statusselectNoInclude fiscal attempt history per document. Default: No
limittextNoMax documents to return (default: 100)
offsettextNoSkip N records for pagination (default: 0)
order_byselectNoSort by: created_at, issued_at, updated_at, total_gross, order_number, status, country_iso
order_dirselectNoSort direction: DESC (default) or ASC
timeouttextNoTimeout in milliseconds (default: 30000)

Uses the same credential type as HubfiscalCreateDocument (hubfiscalCreateDocument provider).

{
"documents": [
{
"id": 42,
"entity_id": "6702987051221",
"entity_source": "shopify",
"order_number": "PT14684",
"country_iso": "PT",
"type": "FT",
"status": "completed",
"fiscal_provider": "billpt",
"fiscal_doc_id": "789",
"fiscal_doc_number": "FT 2026/1",
"contact_name": "Andrea Bernardino",
"contact_nif": "999999990",
"contact_email": "andpaty19@gmail.com",
"total_net": 15.95,
"total_tax": 3.95,
"total_gross": 19.90,
"currency": "EUR",
"issued_at": "2026-04-05T00:00:00.000Z",
"ticket_html": "<html>...</html>",
"created_at": "2026-04-06T10:21:30.000Z",
"fiscal_history": [
{
"provider": "billpt",
"action": "create",
"status": "success",
"generated_ms": 1250,
"created_at": "2026-04-06T10:21:31.000Z"
}
]
}
],
"pagination": {
"total": 1523,
"limit": 100,
"offset": 0,
"has_more": true
}
}
{
"credentials_id": "10",
"country_iso": "PT",
"status": "failed",
"include_html": "false",
"include_payload": "false",
"order_by": "created_at",
"order_dir": "DESC"
}

Search by customer name with fiscal history

Section titled “Search by customer name with fiscal history”
{
"credentials_id": "10",
"search": "Bernardino",
"include_fiscal_status": "true",
"include_pdf": "false",
"limit": "10"
}

Get documents for a date range across multiple countries

Section titled “Get documents for a date range across multiple countries”
{
"credentials_id": "10",
"country_iso": "PT,ES",
"date_from": "2026-04-01",
"date_to": "2026-04-30",
"doc_type": "FT",
"include_html": "false",
"include_pdf": "false",
"limit": "500"
}

Lightweight query (no binaries) for dashboard

Section titled “Lightweight query (no binaries) for dashboard”
{
"credentials_id": "10",
"include_html": "false",
"include_pdf": "false",
"include_payload": "false",
"limit": "50",
"order_by": "created_at"
}
  • The include_pdf option is false by default because PDF base64 data is very large. Use HubfiscalExportPdf to download PDFs as files instead
  • When include_pdf is true, the binary VARBINARY(MAX) data is converted to base64 string in the response
  • The include_fiscal_status option performs an additional JOIN query with the fiscal_status table, adding a fiscal_history array to each document
  • The search filter performs a LIKE search across order_number, contact_name, contact_email and fiscal_doc_number
  • The order_by column is validated against a whitelist to prevent SQL injection
  • Pagination returns has_more: true when there are more results beyond the current page
  • All filter parameters use parameterized queries (no string concatenation) for security
ErrorCauseSolution
TimeoutQuery too slow with large result setsReduce limit, add filters, or increase timeout
No documents foundFilters too restrictiveRelax filters or verify data exists in Hub Fiscal
Large responseinclude_pdf: true with many documentsSet include_pdf: false and use HubfiscalExportPdf for PDFs