Document Types
Document types define the structure, behavior, and fiscal rules of each document category in Moloni ON (invoices, receipts, credit notes, etc.). They are system-defined and fixed, meaning you cannot create or delete them. Your code refers to them by their documentTypeId or, more commonly, by their apiCode.
Fetching document types
Use the documentTypes query to retrieve the full list with all their properties. Pass defaultLanguageId in options to populate the title and titlePlural shorthand fields (see Translated Fields for details).
query {
documentTypes(options: { defaultLanguageId: 2 }) {
data {
documentTypeId
apiCode
apiCodePlural
saftDocCode
group
entityType
title # populated because defaultLanguageId was passed
titlePlural
canConvertTo {
documentTypeId
apiCode
}
}
}
}
To fetch a single type by ID:
query {
documentType(documentTypeId: 1) {
data {
documentTypeId
apiCode
apiCodePlural
saftDocCode
title
}
}
}
Key fields
| Field | Description |
|---|---|
documentTypeId | Numeric ID used when creating documents or filtering document sets |
apiCode | camelCase identifier used as the prefix for all API operations on this type |
apiCodePlural | Plural form of apiCode, used for list queries and some API operations |
saftDocCode | Portuguese SAF-T fiscal code (e.g. FT for Invoice, RE for Receipt) |
group | Logical grouping: Sales, Settlements, Transport, Suppliers, etc. |
entityType | The counterparty type: Customer, Supplier, or Salesperson |
title / titlePlural | Human-readable name, only populated when defaultLanguageId is passed in options (see Translated Fields) |
canConvertTo | Document types this one can be converted into |
canBeConvertedFrom | Document types that can originate this one |
How apiCode drives the API
The apiCode is the building block for all type-specific API operations. By convention:
| Operation | Naming pattern | Example (Invoice) |
|---|---|---|
| Create a document | {apiCode}Create | invoiceCreate |
| Get a single document | {apiCode} | invoice |
| List documents | {apiCodePlural} | invoices |
| Generate PDF | {apiCode}GetPDF | invoiceGetPDF |
| Get PDF download token | {apiCode}GetPDFToken | invoiceGetPDFToken |
| Update a document | {apiCode}Update | invoiceUpdate |
| Delete a document | {apiCode}Delete | invoiceDelete |
| Count documents | {apiCode}Count | invoiceCount |
Sales (Customer)
| Document type | documentTypeId | apiCode | apiCodePlural | SAF-T |
|---|---|---|---|---|
| Invoice | 1 | invoice | invoices | FT |
| Simplified Invoice | 20 | simplifiedInvoice | simplifiedInvoices | FS |
| Invoice Receipt | 27 | invoiceReceipt | invoiceReceipts | FR |
| Debit Note | 4 | debitNote | debitNotes | ND |
| Settlement Note | 19 | settlementNote | settlementNotes | NDL |
| Pro Forma Invoice | 13 | proFormaInvoice | proFormaInvoices | PF |
| Purchase Order | 28 | purchaseOrder | purchaseOrders | NE |
| Recurring Agreement | 12 | recurringAgreement | recurringAgreements | AV |
Settlements (Customer)
| Document type | documentTypeId | apiCode | apiCodePlural | SAF-T |
|---|---|---|---|---|
| Receipt | 2 | receipt | receipts | RE |
| Credit Note | 3 | creditNote | creditNotes | NC |
| Payment Return | 35 | paymentReturn | paymentReturns | DP |
Transport (Customer)
| Document type | documentTypeId | apiCode | apiCodePlural | SAF-T |
|---|---|---|---|---|
| Delivery Note | 6 | deliveryNote | deliveryNotes | GR |
| Bills of Lading | 15 | billsOfLading | billsOfLadings | GT |
| Customer Return Note | 32 | customerReturnNote | customerReturnNotes | GD |
Other Documents (Customer)
| Document type | documentTypeId | apiCode | apiCodePlural | SAF-T |
|---|---|---|---|---|
| Estimate | 14 | estimate | estimates | OR |
| Table Consult | 47 | tableConsult | tableConsults | CM |
Suppliers
| Document type | documentTypeId | apiCode | apiCodePlural | SAF-T |
|---|---|---|---|---|
| Supplier Invoice | 8 | supplierInvoice | supplierInvoices | FF |
| Supplier Receipt | 10 | supplierReceipt | supplierReceipts | REF |
| Supplier Credit Note | 21 | supplierCreditNote | supplierCreditNotes | NCF |
| Supplier Purchase Order | 7 | supplierPurchaseOrder | supplierPurchaseOrders | NEF |
| Supplier Bills of Lading | 78 | supplierBillsOfLading | supplierBillsOfLadings | GTF |
| Purchase Recurring Agreement | 80 | purchaseRecurringAgreement | purchaseRecurringAgreements | AVF |
Salespersons
| Document type | documentTypeId | apiCode | apiCodePlural | SAF-T |
|---|---|---|---|---|
| Salesperson Payment | 33 | salespersonPayment | salespersonPayments | PV |
Migrated Documents
| Document type | documentTypeId | apiCode | apiCodePlural | SAF-T |
|---|---|---|---|---|
| Migrated Invoice | 11 | migratedInvoice | migratedInvoices | SMFT |
| Migrated Simplified Invoice | 25 | migratedSimplifiedInvoice | migratedSimplifiedInvoices | SMFS |
| Migrated Invoice Receipt | 66 | migratedInvoiceReceipt | migratedInvoiceReceipts | SMFR |
| Migrated Receipt | 79 | migratedReceipt | migratedReceipts | SMRE |
| Migrated Credit Note | 18 | migratedCreditNote | migratedCreditNotes | SMNC |
| Migrated Debit Note | 24 | migratedDebitNote | migratedDebitNotes | SMND |
| Migrated Estimate | 73 | migratedEstimate | migratedEstimates | SMOR |
| Migrated Purchase Order | 81 | migratedPurchaseOrder | migratedPurchaseOrders | SMNE |
Next steps
- Creating an Invoice: Create your first document using the invoice type
- Querying Documents: List and retrieve documents by type
- Downloading a Document PDF: Export documents as PDF
- Translated Fields: Fetch document type names in other languages