To call the service, the access key must be provided in the x-api-key header of the HTTP request. If you are using the GraphQL console, you can view the service’s documentation and schema only after entering an access key. Make sure that the scope of the key allows access to the queries and mutations that you require. For example, to grant the key access to all queries and mutations, the keys’s scope must be set to ro-efactura-api:query:* ro-efactura-api:mutation:*.
Usage
The RO e-Factura Service enables calling applications to submit e-Factura invoices to the Romanian National Agency of Fiscal Administration (ANAF). The service also provides the ability to receive e-Factura invoices from ANAF, as well as retrieve information messages as provided by ANAF in real time.
In Romania, e-Factura reporting is mandatory for Business to Government (B2G) transactions, Business to Business (B2B) transactions, as well as for certain Business to Customer (B2C) transactions. For details, see https://mfinante.gov.ro/web/efactura/acasa.
As is the case of other SBS services, the RO e-Factura Service interacts with ANAF on your behalf and provides an abstraction layer to simplify ANAF reporting. More specifically, it enables you to perform the following tasks:
manage authentication and secure access to ANAF
receive e-Factura invoices from ANAF (inbound invoices)
create e-Factura invoices and upload them to ANAF (outbound invoices)
filter inbound or outbound invoices according to various criteria
store invoices and view invoice-related messages received from ANAF beyond their 60 days expiry period
send notification messages to the invoice sender, after receiving an invoice.
send and receive invoices with attachments
Prerequisites
Before using this service, note the following prerequisites:
The organization(s) for which e-Factura reporting takes place done must exist in the SBS system. You can add new organizations programmatically through the Organizations Service, or from the SBS Portal.
Any application that communicates with ANAF, including your application, requires authorization with ANAF. Therefore your app must be configured to handle OAuth 2.0 authorization with ANAF, as described in Configure ANAF Oauth 2.0 secrets.
Once the OAuth 2.0 secrets are configured for your app (see previous bullet), you must authorize with ANAF the organization(s) for which e-Factura reporting takes place. You can perform the authorization either programmatically or from the SBS Portal. To authorize an organization programmatically, run the generateAuthorizationRequest mutation of the RO ANAF OAuth Service. For instructions about performing the authorization process from the SBS Portal, see Managing ANAF Authorizations.
Conventions
There are two syntaxes accepted by ANAF for XML invoices: (i) the Universal Business Language (UBL) syntax and (ii) the Cross Industry Invoice (CII) syntax. On the SBS side, both the createInvoice mutation and the previewInvoice query generate invoices according to the UBL 2.1 syntax.
The “Queries” and “Mutations” sections on this page describe the GraphQL queries and mutations applicable to the e-Factura Service, in a similar way as this is done for all other SBS services. Note that, if a column “Code” is present for any field, it correlates the field with the respective business term (BT) or business group (BG) in the SR EN 16931-1+A1 standard, on which e-Factura reporting is based. The SR EN 16931-1+A1 standard can be acquired from the Romanian National Standardization Body (https://www.asro.ro).
Creating invoices
To create an invoice, run either the createInvoice or createInvoiceFromXml mutation. If you use createInvoiceFromXml, you can obtain the XML input for the mutation by running the previewInvoice query.
Before creating the invoice, SBS validates it against the ANAF e-Factura validation service (https://www.anaf.ro/uploadxmi/). If there are any validation errors at this stage, they will be reported in the response accordingly.
When you create or preview an invoice, the input must be valid; otherwise, the response contains the list of validation errors. To construct a valid invoice, do not rely solely on whether a field is represented as optional or mandatory in this documentation. The complete ANAF validation logic is too complex to be expressed by means of GraphQL optional/mandatory fields. Since the validation rules are subject to routine modifications by ANAF, the ultimate validation tool is the public ANAF e-Factura validation service (https://www.anaf.ro/uploadxmi/).
During development, it might be helpful to use the following online tool provided by ANAF: https://www.anaf.ro/CompletareFactura/faces/factura/informatiigenerale.xhtml. You could use it, for example, to find out what inputs are expected when creating an invoice. More specifically, you will notice that the “Code” column in the CreateInvoiceInput table correlates with the BT (business term) or BG (business group) codes displayed on the online form.
The following code listing illustrates creating an invoice through the createInvoice mutation:
For the input variables, the code listing below illustrates creating a simple invoice where the company Alpha SRL invoices the company Beta SRL for the amount of 100 RON for the provided services. Your invoice data will, of course, be different. Note the following:
YOUR_SUPPLIER_TIN and YOUR_CUSTOMER_TIN must be real tax identifier numbers (TIN) of Romanian companies. The TIN must be prefixed by the country code, for example, “RO1234567”.
You can upload invoices either to the ANAF test API or to the production API. To configure which API should be used, modify your application settings from the SBS Console, as described in Configure ANAF Environment.
To upload an invoice to ANAF:
Create the invoice using either the createInvoice or createInvoiceFromXml mutations. In either case, the result is of Invoice type. Among other fields, the response contains the ID of the generated invoice, which you must remember in order to work with this invoice subsequently. The status of the invoice at this stage is CREATED.
Upload the invoice by running the uploadInvoice mutation. The status of the invoice is now UPLOADED and it awaits resolution by ANAF.
The following code listing illustrates uploading an invoice:
To view the outcome of the ANAF resolution, wait at least 5 minutes from the moment the invoice has been uploaded, and then run either the invoice or invoices query. The code listing below illustrates running the invoice query.
At this stage, the invoice may have one of the following statuses:
SIGNED. This signifies that the invoice has been accepted by ANAF. The signed XML of the invoice is available for you to download from the download URL in the response.
REJECTED. This status signifies that the invoice has not been accepted by ANAF because an error has occurred. You can view the error details in the messages field of the response, as well as in the ZIP file returned by ANAF. You can also view all the errors for all requests of a given organization by running the messages query.
There may also be instances when the invoice is in rejected status without including any errors. According to the latest ANAF documentation (as of 15 Jan. 2024) this indicates that the file processing has not been completed.
Creating and uploading invoices in one call
To send an invoice to ANAF, you typically run createInvoice followed by uploadInvoice. As an alternative, you can create and upload invoices in a single API call. To do this, run the sendInvoice mutation. This mutation creates the invoice from the provided input data and also uploads it to ANAF in the same call.
If the input invoice data is an XML file, run sendInvoiceFromXml. This mutation creates the invoice from the provided XML input and also uploads it to ANAF in the same call.
Receiving invoices
If your organization has a Romanian tax identification number and is registered with ANAF, all the invoices sent by suppliers to your organization (the so-called “inbound” invoices) are by default available in ANAF’s Private Virtual Space (“Spațiul privat virtual” in Romanian).
You can view and manage all such incoming invoices (including the accompanying XML, PDF, and ZIP files) in SBS, without logging in to ANAF’s Private Virtual Space. The only requirement is that you authorize your SBS organization with ANAF once, see Prerequisites. Once authorization is complete, you can list all inbound invoices by running the inboundInvoices query.
Note that SBS fetches inbound invoices from ANAF at roughly 20 minute intervals.
Sending and receiving invoice notifications
For any incoming invoice, your organization may send an official text notification to the issuer (sender) of the invoice, tracked through the ANAF infrastructure. To perform such action, your SBS organization must go through a one-time ANAF authorization process (see Prerequisites).
Once authorization is complete, run the notifyInvoiceSender mutation to send a notification. Any sent notification is listed in the notifications field of the respective InboundInvoice.
If your organization has received any notifications from the invoice recipients (customers), such notifications appear in the notifications field of the respective outbound Invoice.
In addition, the messages query (or the messages field of an outbound or inbound invoices) provides information about incoming or outgoing notifications. The message text is generated by ANAF and is merely an information that a notification was sent or received; it does not include the text of the notification. To get the text of the notification, run the notification query.
Invoice attachments
You can create invoices with attachments in the following formats supported by ANAF: PDF, PNG, JPG, CSV, XLSX, ODS (Open Document Spreadsheet).
To create an invoice with attachments:
Create the attachment file(s) in File Management Service, using the standard steps for creating files. Take notice of the created file ID; you will need it in a subsequent step.
During the upload, make sure to send the correct Content Type (MIME) header in the HTTP PUT request. The following MIME types are accepted by ANAF:
Run the createInvoice mutation to create the invoice. In the input parameters, supply an additionalDocumentReference object with the details of the attachment to be created, for example:
{"additionalDocumentReference":[{"id":"AB23456","documentDescription":"This is an optional description of the attachment.","attachment":{"embeddedDocumentBinaryObject":{"fileId":"YOUR_FILE_ID"}}}]}
Note the following:
id is mandatory; it is an identifier of the supporting document as supplied by the invoice issuer
documentDescription is optional
Replace YOUR_FILE_ID with the file ID of the file created earlier in File Management Service.
Since additionalDocumentReference is an array, you can add multiple attachments if necessary.
For inbound invoices, you can view attachments data by running the inboundInvoice or inboundInvoices query and requesting the attachments response field, for example:
If the invoice has attachments, the attachments field in the response includes an id and a downloadUrl for each attachment, where id is the ID of the file from File Management Service.
Self-billing invoices (Autofactura)
From a general accounting perspective, a self-billing invoice is an invoice issued by an organization where it bills itself for goods or services provided to it by some other registered entity. This is typically the case when the customer (not the supplier) organization determines the final value of delivered goods or services. For example, a big online marketplace business may issue self-invoices through which it pays various smaller retailers that earn commissions through affiliation with that respective online marketplace. In this relationship, the organization that issues the invoice (that is the online marketplace) is the invoice customer, while the affiliated smaller retailers are the suppliers.
Consequently, in SBS, autofactura is an invoice with type code 389 (self-invoice) where the customer (NOT the supplier) organization is the ANAF-authorized organization that issues the invoice. Note that this is different from all other invoice types where the details of the invoice-issuing organization (such as TIN, registration and company name) appear in the supplier details.
Therefore, to create an autofactura for a given organization in SBS, make sure that:
The invoice type is 389 (self-invoice)
The customer details that appear on the invoice are those of the organization that issues the invoice.
The issuing organization is ANAF-authorized, as described in Prerequisites.
Queries
inboundInvoice
Fetches an invoice received from ANAF, by invoice ID.
Arguments
Argument
Type
Description
organizationId
ID!
Mandatory. The ID of the organization for which the invoice should be retrieved.
id
ID!
Mandatory. The ID of the inbound invoice that should be be retrieved.
Lists invoices received from ANAF for the organization ID supplied as argument.
Arguments
Argument
Type
Description
organizationId
ID!
Mandatory. Set this to the ID of the organization for which invoices must be retrieved.
filter
InboundInvoicesFilter!
Mandatory. Provides options to filter incoming data by invoice creation date and invoice status. See InboundInvoicesFilter.
nextToken
String
Optional argument used to fetch the next set of query results. This value can be obtained from the nextToken attribute of the InboundInvoicesResult type.
InboundInvoicesFilter input
Attribute
Type
Description
status
InboundInvoiceStatus
Optional. An enumeration with the following valid values: RECEIVED, REJECTED. NOTE: The status REJECTED is for future use.
Optional. Lets you filter inbound invoices uploaded within a specific date interval. The invoice upload date is provided by ANAF; therefore, use the Romanian time zone when applying this filter.
Optional. Lets you filter inbound invoices issued within a specific date interval. Use the GMT time zone when applying this filter.
invoiceTypeCode
String
Optional. Lets you filter invoices by type. Valid values: 380 - Invoice, 389 - Self-invoice, 384 - Corrected invoice, 381 - Credit note, 751 - Invoice information for accounting purposes.
supplierTin
Int
Optional. Lets you filter invoices by the supplier’s tax identification number.
customerTin
Int
Optional. Lets you filter invoices by the customer’s tax identification number.
invoiceNumberLike
String
Optional. Lets you filter invoices by the full or partial number of the invoice.
supplierNameLike
String
Optional. Lets you filter invoices by the full or partial supplier company name. Filtering by this criterion is case-insensitive (for example, “son” will match both “Sonar” and “Thomson”).
customerNameLike
String
Optional. Lets you filter invoices by the full or partial customer company name. Filtering by this criterion is case-insensitive.
DateFilter input
Attribute
Type
Description
from
Date
Provides the starting date of the date range.
to
Date
Provides the end date of the date range. NOTE: If to is supplied, the result will include all invoices created up to and including the to date. Therefore, if you would like to retrieve invoices from a particular date, use the same date as from and to date.
Result
InboundInvoicesResult type
Attribute
Type
Description
items
[InboundInvoice]
Returns the list of received invoices, as an array of InboundInvoice objects.
nextToken
String
If null, then the query has reached the end of the list of messages that match the query criteria. If not null, then use this value in the nextToken input argument to obtain the next page.
InboundInvoice type
Attribute
Type
Description
id
ID
The unique identifier of the invoice.
organizationId
ID
The ID of the organization to which this invoice belongs.
invoiceNumber
String
The invoice number.
issueDate
Date
The invoice issue date.
invoiceTypeCode
String
The type of the invoice. Valid values: 380 - Invoice, 389 - Self-invoice, 384 - Corrected invoice, 381 - Credit note, 751 - Invoice information for accounting purposes.
status
InboundInvoiceStatus
The invoice status.
requestId
ID
The identifier of the request as generated by ANAF.
downloadId
ID
The identifier of the download as generated by ANAF.
details
String
Stores a text description pertaining to the invoice.
uploadDate
String
The date and time when the invoice was uploaded to ANAF, in YYYYMMDDHHmm format. This time value is provided by ANAF and is expressed as local time (Romanian time zone).
The invoice in PDF format, as a File object. NOTE: The pdfFile is null in the first few seconds after the inbound invoice is created in SBS. Please allow at least 5 seconds for this attribute to be populated. This may take longer, depending on the size of the invoice.
zipFile
File
The compressed (zipped) archive of the invoice, as a File object. The archive includes the original XML invoice and the same XML invoice signed by ANAF.
Provides details about the customer party that appears on the invoice.
supplierTin
Int
The tax identification number of the supplier organization. SBS populates this value from the XML invoice according to the following logic: if <AccountingSupplierParty><PartyTaxScheme><CompanyID> exists, extract the value from there; otherwise, extract the value from <AccountingSupplierParty><PartyLegalEntity><CompanyID>. Finally, strip the alphabetic part and populate supplierTin with the numeric part only.
customerTin
Int
The tax identification number of the customer organization. SBS populates this value from the XML invoice according to the following logic: if <AccountingCustomerParty><PartyTaxScheme><CompanyID> exists, extract the value from there; otherwise, extract the value from <AccountingCustomerParty><PartyLegalEntity><CompanyID>. Finally, strip the alphabetic part and populate customerTin with the numeric part only.
supplierBankAccount
IBAN
The IBAN of the supplier. To populate this value, SBS reads from the invoice’s XML file the first PaymentMeans/PayeeFinancialAccount/ID where FinancialInstitutionBranch/ID is not TREZROBU.
Provides information about the total monetary amount on the invoice, as a LegalMonetaryTotal object.
createdAt
DateTime
The date and time the invoice was created in SBS.
standard
InvoiceStandard
Specifies the syntax upon which the XML invoice is based. This is an enumeration with the following valid values: UBL - Universal Business Language 2.1, CII - Cross-Industry Invoice.
An array of file attachments present on the inbound invoice. Each attachment is of type File and can be queried through the File Management Service.
invoice
Retrieves a previously created invoice, which may or may not have been uploaded to ANAF yet.
Argument
Type
Description
organizationId
ID!
Mandatory. The organization for which the invoice retrieval is requested.
id
ID!
Mandatory. The ID of the invoice to be retrieved.
Result
Invoice type
Attribute
Type
Description
id
ID
The ID of the invoice.
organizationId
ID
The organization ID to which this invoice belongs.
invoiceNumber
String
The invoice number.
issueDate
Date
The invoice issue date.
invoiceTypeCode
String
The type of the invoice. Valid values: 380 - Invoice, 389 - Self-invoice, 384 - Corrected invoice, 381 - Credit note, 751 - Invoice information for accounting purposes.
status
InvoiceStatus
The invoice status. Valid values: CREATED - the invoice has been created but not uploaded yet, UPLOADED - the invoice has been uploaded and is pending resolution with ANAF, SIGNED - the invoice has been signed and accepted by ANAF, REJECTED - the invoice has been rejected by ANAF.
uploadDate
String
If the invoice has been uploaded to ANAF, this field contains the invoice upload date, in YYYYMMDDHHmm format. This time value is provided by ANAF and is in the Romanian time zone.
requestId
ID
The identifier of the request as generated by ANAF.
downloadId
ID
The identifier of the download as generated by ANAF, in case of successful outcome.
This field stores ANAF-generated messages pertaining to this invoice, if any. For example, if an invoice has been rejected by ANAF, this field contains the rejection reason provided by ANAF. Note that messages of type “FACTURA TRIMISA” are not included.
notifications
[Notification]
The list of incoming notifications associated with the invoice, as a Notification type. These are notifications sent by the invoice recipient organization.
The PDF file generated by ANAF, as a File object. NOTE: The pdfFile is null in the first few seconds after the invoice is created in SBS. Please allow at least 5 seconds for this attribute to be populated. This may take longer, depending on the size of the invoice.
The invoice attachments, as an array of File objects.
uploadedToTestEnvironment
Boolean
This field indicates whether the invoice has been uploaded to the ANAF test or production API, based on a flag defined in application settings. A true value means the invoice was uploaded to ANAF test API. If the invoice hasn’t been uploaded yet, uploadedToTestEnvironment is null.
Provides information about the total monetary amount on the invoice, as a LegalMonetaryTotal object.
external
Boolean
If true, the invoice will be uploaded to ANAF with an indication that the customer on the invoice is located outside Romania. This happens when the customer TIN of the invoice is not a Romanian TIN and the customer’s country is other than “RO”. If both the customer and supplier have a Romanian address, then this flag is false.
createdAt
DateTime
The date and time the invoice was created in SBS.
standard
InvoiceStandard
Specifies the syntax upon which the XML invoice is based. This is an enumeration with the following valid values: UBL - Universal Business Language 2.1, CII - Cross-Industry Invoice.
Message type
Attribute
Type
Description
id
String
The unique identifier of the message.
creationDate
String
The date when the message was created.
tin
String
The tax identification number (TIN) of the organization to which this message applies.
requestId
String
The identifier of the ANAF request. This field is provided by ANAF; it identifies either an invoice or an invoice notification submitted to ANAF. If message type is “FACTURA TRIMISA” or “FACTURA PRIMITA”, the requestId correlates with the requestId of the Invoice object.
invoiceRequestId
String
The identifier of the outbound invoice to which this message makes reference. This field will be populated only if the message references an outbound invoice (that is, if message type is “FACTURA TRIMISA”).
inboundInvoiceRequestId
String
The identifier of the inbound invoice to which this message makes reference. This field will be populated only if the message references an inbound invoice (that is, if message type is “FACTURA PRIMITA”).
details
String
Any other information which may be applicable to the message.
type
String
The message type, as populated by ANAF.
File type
Attribute
Type
Description
id
ID
The ID of the file in the File Management Service.
downloadUrl(expiresIn)
Uri
The file’s download URL. The download URL is available for the number of seconds supplied to the expiresIn input argument.
name
String
The attachment file name.
contentType
String
The MIME type of the attachment file.
contentLength
String
The size of the attachment file, in bytes.
Party type
Attribute
Type
Description
partyName
String
The name of the of the supplier or customer that appears on the invoice.
Provides further details about the supplier or customer that appears on the invoice.
PartyTaxScheme type
Attribute
Type
Description
companyID
String
The party’s identification code for tax purposes. This is typically the Romanian CIF (Cod de identificare fiscală) prefixed by the country’s two letter code (BT-31). This may also be the fiscal identifier of a company that is not registered as a VAT payer (BT-32).
PartyLegalEntity type
Attribute
Type
Description
registrationName
String
The party’s legal name.
companyID
String
The party’s identification code for tax purposes. This is typically the Romanian CIF (Cod de identificare fiscală) prefixed by the country’s two letter code (BT-31). This may also be the fiscal identifier of a company that is not registered as a VAT payer (BT-32).
The total amount of the invoice with VAT deducted for the prepaid amount. The amount is zero in case of a fully paid invoice. The amount may be negative, in which case the seller owes that amount to the buyer.
BT-115
CurrencyAmount type
Attribute
Type
Description
Code
currency
String
The currency code. Valid values are according to ISO 4217 (for example, RON for Romanian Lei).
amount
Float
The amount, rounded to two decimals.
invoiceByRequestId
Retrieves an invoice by its requestId attribute. An invoice gets a request ID upon upload to ANAF; therefore, running this query is meaningful only for uploaded invoices (regardless of the upload outcome).
Argument
Type
Description
organizationId
ID!
Mandatory. The organization for which the invoice retrieval is requested.
Retrieves a list of created and submitted invoices, filtered by the organization ID and status.
Arguments
Argument
Type
Description
organizationId
ID!
Mandatory. Specifies the organization ID for which invoices are to be retrieved.
filter
InvoicesFilter!
Mandatory. Specifies the filtering options, as an InvoicesFilter input.
nextToken
String
Optional argument used to fetch the next set of query results. This value can be obtained from the nextToken attribute of the InvoicesResult type.
InvoicesFilter input
Attribute
Type
Description
status
InvoiceStatus
Optional. Provides the ability to filter by the invoice status. Valid values: CREATED - the invoice has been created but not uploaded yet, UPLOADED - the invoice has been uploaded and is pending resolution with ANAF, SIGNED - the invoice has been signed and accepted by ANAF, REJECTED - the invoice has been rejected by ANAF.
Optional. Lets you filter invoices uploaded within a specific date interval. The invoice upload date is provided by ANAF; therefore, use the Romanian time zone when applying this filter.
Optional. Lets you filter inbound invoices issued within a specific date interval. Use the GMT time zone when applying this filter.
invoiceTypeCode
String
Optional. Lets you filter invoices by type. Valid values: 380 - Invoice, 389 - Self-invoice, 384 - Corrected invoice, 381 - Credit note, 751 - Invoice information for accounting purposes.
supplierTin
Int
Optional. Lets you filter invoices by the supplier’s tax identification number.
customerTin
Int
Optional. Lets you filter invoices by the customer’s tax identification number.
invoiceNumberLike
String
Optional. Lets you filter invoices by the full or partial number of the invoice.
supplierNameLike
String
Optional. Lets you filter invoices by the full or partial supplier company name. Filtering by this criterion is case-insensitive (for example, “son” will match both “Sonar” and “Thomson”).
customerNameLike
String
Optional. Lets you filter invoices by the full or partial customer company name. Filtering by this criterion is case-insensitive.
Result
InvoicesResult type
Attribute
Type
Description
items
[Invoice]
The list of Invoice objects matching the filtering criteria.
nextToken
String
If null, then the query has reached the end of the list of invoices that match the query criteria. If not null, then use this value in the nextToken input argument to obtain the next page.
messages
Lists up-to-date messages as provided by ANAF in real time. A message indicates that some event was registered by ANAF, for example:
an invoice has been uploaded to ANAF or received from ANAF
an invoice has been rejected by ANAF due to errors
a notification concerning some invoice was sent or received
The type field of each Message indicates the actual kind of event that took place.
Note the following:
the messages query retrieves messages only for the past 60 days. To retrieve older messages, run the storedMessages query.
the messages query retrieves a global list of messages for all invoices. To retrieve messages for specific invoices only, run the invoice or invoices query. Any messages pertaining to the invoice are listed in the messages field of the response Invoice object.
Arguments
Argument
Type
Description
organizationId
ID!
Mandatory. Specifies the organization ID for which messages are to be retrieved.
filter
MessagesFilter!
Mandatory. Specifies the filtering options, as an MessagesFilter input.
nextToken
String
Optional argument used to fetch the next set of query results. This value can be obtained from the nextToken attribute of the MessagesResult type.
MessagesFilter input
Attribute
Type
Description
days
Float!
Mandatory. Specifies the number of days for which messages are to be retrieved.
typeCode
MessageTypeCode
Optional. Lets you filter messages by their type as assigned by ANAF. Valid values: E - ERORI FACTURA, P - FACTURA PRIMITA, T - FACTURA TRIMISA, R - MESAJ CUMPARATOR PRIMIT or MESAJ CUMPARATOR TRANSMIS
Result
MessagesResult type
Attribute
Type
Description
items
[Message]
The list of Message objects matching the filtering criteria.
nextToken
String
If null, then the query has reached the end of the list of messages that match the query criteria. If not null, then use this value in the nextToken input argument to obtain the next page.
Mandatory. Specifies the organization ID for which the notification is to be retrieved.
messageId
MessageId!
Mandatory. Specifies the ID of the ANAF message that concerns this notification. This must be an ANAF message of type “MESAJ CUMPARATOR TRANSMIS” or “MESAJ CUMPARATOR PRIMIT”.
Returns a list of active organizations defined in the Organizations Service. This is a convenience query used to obtain the list of organizations in e-Factura without having to query the Organizations Service separately.
Result
The result is an array of Organization. Note this is a simplified type compared to the Organization type from the Organizations Service, and contains only the fields relevant for e-Factura.
Organization type
Attribute
Type
Description
id
ID!
Specifies the organization’s unique identifier.
name
String
Specifies the organization’s name.
tin
String
Specifies the organization’s tax identification number (TIN) (in Romanian, CIF - cod de identificare fiscală) issued by ANAF (in Romanian, ANAF - Agenția Națională de Administrare Fiscală).
regNo
String
Specifies the organization’s registration number issued by the National Trade Registration Office (in Romanian, ONRC - Oficiul National al Registrului Comerțului).
country
CountryCode
Enum value that identifies the ISO 3166-2 two-letter country code.
createdAt
DateTime
The date and time when the organization record was created in SBS.
previewInvoice
Generates an XML invoice string according to the input, without storing any objects. If the input is not valid, then the response contains all the validation errors as returned by ANAF. This query is intended only for development purpose, for example, when you need to create an invoice just for testing, without actually storing it. It works in the same way as the createInvoice mutation, the only difference being that, in case of previewInvoice, the resulting XML invoice is not stored anywhere.
The generated XML invoice string follows the UBL (Universal Business Language) syntax.
Arguments
Argument
Type
Description
input
CreateInvoiceInput!
The input data, as a CreateInvoiceInput object, from which the XML invoice is to be created.
CreateInvoiceInput input
Attribute
Type
Description
Code
invoiceNumber
String!
Mandatory. The internal reference which uniquely identifies the invoice in the seller’s invoicing system.
BT-1
issueDate
Date!
Mandatory. The invoice issue date, in YYYY-MM-DD format.
BT-2
dueDate
Date
Optional. The invoice due date, in YYYY-MM-DD format.
BT-9
invoiceTypeCode
String!
Mandatory. The type of the invoice. Valid values: 380 - Invoice, 389 - Self-invoice, 384 - Corrected invoice, 381 - Credit note, 751 - Invoice information for accounting purposes.
BT-3
notes
[String]
Optional. Stores free text pertaining to the invoice. You can supply multiple note strings as input. If any given note string exceeds 300 characters in length, it will be split into multiple <cbc:Note> elements in the resulting XML, so that the length of each <cbc:Note> obeys ANAF’s validation rules.
BT-22
profileId
String
Optional. Identifies the business process context in which the transaction appears, to enable the Buyer to process the Invoice in an appropriate way.
BT-23
taxPointDate
Date
Optional. The date when the VAT becomes due for an invoice. This field is mutually exclusive with Invoice Period (BT-8).
BT-7
documentCurrencyCode
String!
Mandatory. The currency in which amounts stated on the invoice are expressed. Valid values are according to ISO 4217.
BT-5
taxCurrencyCode
String
Optional. The currency in which VAT is expressed. Valid values are according to ISO 4217.
Optional. Provides information about the VAT effective date. See invoicePeriodInput.
buyerReference
String
Optional. An identifier of the buyer on the invoice, as assigned by the buyer for their own internal purposes.
BT-10
orderReference
OrderReferenceInput
Optional. An identifier specified by the buyer on the invoice, which provides the link between the invoice and the purchase order. See OrderReferenceInput.
billingReference
[BillingReferenceInput]
Optional. Provides billing information about one or more previous invoices, specified by the seller, as a list of BillingReferenceInput objects.
BG-3
despatchDocumentReference
SimpleReferenceInput
Optional. Provides information about the document or identifier that confirms the dispatch or transportation of the goods from the seller to the buyer, as a SimpleReferenceInput object.
BT-16
contractDocumentReference
SimpleReferenceInput
Optional. References the contract document or identifier associated with the transaction between the buyer and the seller, as a SimpleReferenceInput object.
BT-12
projectReference
ProjectReferenceInput
Optional. References a project-related identifier or reference number associated with the goods or services provided, as a ProjectReferenceInput object.
Optional. Provides reference to a previous invoice.
BG-3
InvoiceDocumentReferenceInput input
Attribute
Type
Description
Code
id
String!
The identifier of the referenced document.
BT-25
issueDate
Date
The issue date of the referenced document.
BT-26
SimpleReferenceInput input
Attribute
Type
Description
Code
id
String!
The identifier of the referenced document.
AdditionalDocumentReferenceInput input
An additional document reference may be:
a reference to a previous invoice. In this case, populate id with the ID of referenced invoice and documentTypeCode with 130.
a reference to a URI. In this case, populate id, documentDescription (optionally), and attachment/externalReference.
an attachment. In this case, populate id, documentDescription (optionally), and attachment/embeddedDocumentBinaryObject.
Attribute
Type
Description
Code
id
String!
Mandatory. The identifier of the referenced document.
BT-122 or BT-18a
documentTypeCode
String
Conditional. If the document referenced by id is an invoice, use code 130. NOTE: If you populate this field, do not populate documentDescription and attachment, and vice versa.
BT-18b
documentDescription
String
Conditional. A text description of the referenced document. NOTE: if you populate this field, do not populate documentTypeCode, and vice versa.
Conditional. The actual attachment data, as an AttachmentInput object. The attached data can be either a URI reference or the ID of a file created through the File Management Service. NOTE: if you populate this field, do not populate documentTypeCode, and vice versa.
ReceiptDocumentReferenceInput input
Attribute
Type
Description
Code
id
String!
Mandatory. The identifier of the referenced receipt.
BT-15
AttachmentInput input
Attribute
Type
Description
Code
externalReference
ExternalReferenceInput
Conditional. The URI reference, as an object of type ExternalReferenceInput. This field is mutually exclusive with embeddedDocumentBinaryObject.
BT-124
embeddedDocumentBinaryObject
EmbeddedDocumentBinaryObjectInput
Conditional. The embedded binary object, as an object of type EmbeddedDocumentBinaryObjectInput. This field is mutually exclusive with externalReference.
Mandatory. Provides information about the party taking part in the transaction (customer or supplier), as a PartyInput object.
AccountingCustomerPartyInput input
Attribute
Type
Description
party
PartyInput!
Mandatory. Provides information about the party taking part in the transaction (customer or supplier), as a PartyInput object.
PartyInput input
Attribute
Type
Description
Code
endpointID
String
Currently not in use.
partyIdentification
String
Optional. The identifier of the party, according to the identification scheme provided by schemeID (see below).
BT-29 (for suppliers), BT-46 (for customers)
schemeID
String
Optional. The scheme that identifies the party provided in partyIdentification. Valid values are in the ISO 6523 ICD list. For example, 0088 indicates that the party is identified by an EAN Location Code. If you don’t populate this field, the schemeID attribute in the XML invoice will be 0088.
BT-29 (for suppliers), BT-46 (for customers)
partyName
String
Optional. The trade name of the party, other than the formal name reported in BT-27 (for suppliers) or BT-44 (for customers).
BT-28 (for suppliers), BT-45 (for customers)
postalAddress
AddressInput
Optional. The address of the party, as an AddressInput object.
Conditional. The party’s identification code for tax purposes. This is typically the Romanian CIF (Cod de identificare fiscală) prefixed by the country’s two letter code.
BT-31 (for suppliers), BT-48 (for customers)
taxScheme
TaxSchemeInput
Conditional. Identifies the tax scheme, see TaxSchemeInput.
TaxSchemeInput input
Attribute
Type
Description
id
String
Conditional. Identifies the tax scheme. Valid values are according to UNTDID 5153. Set this value to “VAT” if BT-31 is a Romanian CIF (Cod de identificare fiscală).
PartyLegalEntityInput input
Attribute
Type
Description
Code
registrationName
String
Optional. The party’s formal name by which it is entered in the national register.
BT-27 (for suppliers), BT-44 (for customers)
companyID
String
Optional. The officially issued identifier of the party.
BT-30 (for suppliers), BT-47 (for customers)
companyLegalForm
String
Optional. Captures additional legal information about the party (for example, the so-called company’s “memorandum of association”).
BT-33 (for suppliers)
ContactInput input
Attribute
Type
Description
Code
name
String
Optional. The contact name.
BT-41 (for suppliers), BT-56 (for customers)
telephone
String
Optional. The contact’s phone number.
BT-42 (for suppliers), BT-57 (for customers)
email
EmailAddress
Optional. The contact’s email address
BT-43 (for suppliers), BT-58 (for customers)
DeliveryInput input
Attribute
Type
Description
Code
actualDeliveryDate
Date
Optional. The date of completion of delivery of goods or services.
BT-72
deliveryLocation
DeliveryLocationInput
Optional. The place where the goods or services are being delivered to, as a DeliveryLocationInput object.
deliveryParty
PartyInput
Optional. The name of the party to whom goods and services are supplied. Used if delivery is to a customer other than the buyer. See PartyInput.
BT-70
DeliveryLocationInput input
Attribute
Type
Description
Code
id
String
Optional. Provides an identifier of the delivery location. The scheme of the identifier may be indicated in the schemeID field below; otherwise, the scheme is assumed to be 0088 by default.
BT-71
address
AddressInput
Optional. Provides information about the address at which the invoiced goods or services are being delivered to. See AddressInput.
BG-15
schemeID
String
Optional. Identifies the scheme used to identify the delivery location. Valid values are according to the ISO 6523 code list.
BT-71
PaymentMeansInput input
Attribute
Type
Description
Code
name
String
Optional. Describes the payments means as text.
BT-82
code
String!
Mandatory. Identifies the way in which payment is expected, or has been made. Valid values are according to UNTDID 4461 [6] code list.
BT-81
paymentId
String
Optional. Allocation information which establishes a link between the payment and the invoice issued by the seller (usually, the number of the invoice being paid).
BT-83
cardAccount
CardAccountInput
Optional. Provides information about the card used to pay, as CardAccountInput. Used only if the buyer has paid with a card.
Optional. Provides information about a direct debit mandate, as PaymentMandateInput. Applicable if the payment has been or is to be made through direct debit means.
BG-19
CardAccountInput input
Attribute
Type
Description
Code
primaryAccountNumberId
String
Optional. The primary account number of the card used for payment. According to the latest PCI Data Security Standards, this value must not be included in full. Only the first six and the last four digits are to be displayed.
BT-87
networkId
String
Optional. The identifier of the payment network that facilitates the transaction.
holderName
String
Optional. The name of the payer.
BT-88
FinancialAccountInput input
Attribute
Type
Description
Code
id
String
Optional. The identifier of the account to which payment is to be executed. This can be the IBAN in case of SEPA payments.
BT-84
name
String
Optional. The name of the account to which payment is to be executed.
BT-85
financialInstitutionBranchId
String
Optional. The identifier of the payment service provider, for example, BIC (Bank Interchange Code).
BT-86
PaymentMandateInput input
Attribute
Type
Description
Code
id
String
Optional. The unique identifier assigned by the payee in reference to the direct debit authorization.
BT-89
payerFinancialAccount
FinancialAccountInput
Optional. The bank account which is charged by direct debit, as FinancialAccountInput.
BT-91
PaymentTermsInput input
Attribute
Type
Description
Code
note
String
The textual description of payment terms applicable to the amount due.
BT-20
TaxTotalInput input
Attribute
Type
Description
Code
taxAmount
CurrencyAmountInput
The VAT amount applicable to the invoice.
BT-110, BT-111
taxSubtotals
[TaxSubtotalInput]
A list of TaxSubtotalInput objects that provide information about the distribution of VAT by different categories, rates, and reasons for VAT exemption.
BG-23
CurrencyAmountInput input
Attribute
Type
Description
Code
currency
String
Mandatory. The currency code. Valid values are according to ISO 4217 (for example, RON for Romanian Lei).
amount
Float
Mandatory. The amount, rounded to two decimals.
TaxSubtotalInput input
Attribute
Type
Description
Code
taxableAmount
CurrencyAmountInput
The amount on which VAT is applied.
BT-116
taxAmount
CurrencyAmountInput
The VAT amount applicable to this subtotal.
BT-117
taxCategory
TaxCategoryInput
The VAT details (including VAT category code and rate), expressed as a TaxCategoryInput object, applicable to this subtotal.
TaxCategoryInput input
Attribute
Type
Description
Code
id
String
Mandatory. The VAT category code. Valid values are according to UNTDID 5305[6]
BT-118, BT-151
percent
Float
Mandatory. The VAT rate, expressed as a percentage.
BT-119, BT-152
taxExemptionReason
String
Optional. A textual statement of the reason why the amount is exempt from VAT.
BT-120
taxExemptionReasonCode
String
Optional. A code expressing the reason why the amount is exempt from VAT. Valid values are according to CEF (Connecting Europe Facility) VATEX code list.
BT-121
taxScheme
TaxSchemeInput
Mandatory. Identifies the tax scheme used, see TaxSchemeInput.
LegalMonetaryTotalInput input
Attribute
Type
Description
Code
lineExtensionAmount
CurrencyAmountInput
The total of all net amounts of all items on the invoice.
BT-106
taxExclusiveAmount
CurrencyAmountInput
The total amount of the invoice, excluding VAT.
BT-109
taxInclusiveAmount
CurrencyAmountInput
The total amount of the invoice, including VAT.
BT-112
allowanceTotalAmount
CurrencyAmountInput
The total of all document-level discounts on the invoice.
BT-107
chargeTotalAmount
CurrencyAmountInput
The total of all document-level charges on the invoice.
BT-108
prepaidAmount
CurrencyAmountInput
The total of prepaid amounts on the invoice. This amount is deducted from the total VAT for the calculation of the payment due amount.
BT-113
payableRoundingAmount
CurrencyAmountInput
The amount which must be added to the total in order to round off the payment amount.
BT-114
payableAmount
CurrencyAmountInput
The total amount of the invoice with VAT deducted for the prepaid amount. The amount is zero in case of a fully paid invoice. The amount may be negative, in which case the seller owes that amount to the buyer.
BT-115
InvoiceLineInput input
Attribute
Type
Description
Code
id
String!
Mandatory. The identifier of the invoiced item.
BT-126
notes
[String]
Optional. The text note relevant to the invoiced item. Note that a single item having maximum 300 characters in length is accepted in the input array, to meet ANAF’s validation rules.
Optional. Provides withholding tax information about the invoiced items, as a list of TaxTotalInput objects.
item
ItemInput!
Mandatory. Provides information about the invoiced good or service, as an ItemInput object.
BG-31
price
PriceInput
Optional. The item’s price details, as a PriceInput object.
BG-29
QuantityInput input
Attribute
Type
Description
Code
unitCode
String!
Mandatory. The unit of measure applicable to the invoiced quantity. Valid values are according to the UN/ECE Recommendation 20 [7] and UN/ECE Recommendation 21 [19].
BT-130
quantity
Float!
Mandatory. The quantity of invoiced goods or services.
BT-129
OrderLineReferenceInput input
Attribute
Type
Description
Code
id
String
Mandatory. The identifier of the purchase order issued by the buyer.
BT-132
LineAllowanceChargeInput input
Attribute
Type
Description
Code
chargeIndicator
Boolean
Optional. Determines whether a charge or discount applies to this line item. Valid values: false - discount, true - charge.
allowanceChargeReasonCode
String
Optional. If chargeIndicator = false, this is the discount reason, expressed as a code. Valid values are according to UNTDID 5189 [6] code list. If chargeIndicator = true, this is the charge reason, expressed as a code. Valid values are according to UNTDID 7161 [6] code list.
BT-140 if chargeIndicator = false, BT-145 if chargeIndicator = true
allowanceChargeReason
String
Optional. If chargeIndicator = false, this is the discount reason, expressed as text. If chargeIndicator = true, this is the charge reason, expressed as text.
BT-139 if chargeIndicator = false, BT-144 if chargeIndicator = true
multiplierFactorNumeric
Float
Optional. If chargeIndicator = false, this is the percentage that, together with the base amount of the invoice item, can be used to calculate the discount amount for the invoice item. If chargeIndicator = true, this is the percentage that, together with the base amount of the invoice item, can be used to calculate the charge for the invoice item.
BT-138 if chargeIndicator = false, BT-143 if chargeIndicator = true
Optional. If chargeIndicator = false, this is the basic amount that, together with the discount percentage of the invoice item, can be used to calculate the discount amount of the invoice item. If chargeIndicator = true, this is the basic amount that, together with the charge percentage of the invoice item, can be used to calculate the charge of the invoice item.
BT-137 if chargeIndicator = false, BT-142 if chargeIndicator = true
ItemInput input
Attribute
Type
Description
Code
description
String
Optional. The description of the invoiced item.
BT-154
name
String
Optional. The name of the invoiced item.
BT-153
buyersItemIdentifications
ItemIdentificationInput
Optional. The identifier assigned to the item by the buyer, as an ItemIdentificationInput object.
BT-156
sellersItemIdentification
ItemIdentificationInput
Optional. The identifier assigned to the item by the seller, as an ItemIdentificationInput object.
Optional. This field provides additional item properties (name-value pairs), as a list of AdditionalItemPropertyInput objects.
BG-32
ItemIdentificationInput input
Attribute
Type
Description
Code
id
String
The actual identifier value assigned to the item.
StandardItemIdentificationInput input
Attribute
Type
Description
Code
id
String
Optional. The identifier value assigned to the item, for example, an EAN (European Article Number) code.
schemeID
String
Optional. The identifier of the scheme that describes the identifier value above. Valid values are according to ISO/IEC 6523. If you don’t supply this value, the scheme identifier is assumed to be 0160 (this code denotes a Global Trade Item Number, according to ISO/IEC 6523).
Mandatory. The identification scheme used for classification. Valid values are according to UNTDID 7143 [6].
BT-158
listVersionID
String
Optional. The version of the identification scheme.
BT-158
AdditionalItemPropertyInput input
Attribute
Type
Description
Code
name
String
The name of the additional property. For example, “color”.
BT-160
value
String
The value of the additional property. For example, “red”.
BT-161
PriceInput input
Attribute
Type
Description
Code
priceAmount
CurrencyAmountInput
The item’s price without VAT after deduction of the discount price. The net price of the item must be equal to the gross price of the item, reduced by the value of the discount of the item.
BT-146
baseQuantity
QuantityInput
The number of item units to which the price refers, as a QuantityInput object.
BT-149
allowanceCharge
AllowanceChargeInput
Provides information about (i) the discounts or (ii) the charges and taxes other than the VAT, applicable at line level, as an AllowanceChargeInput object.
AllowanceChargeInput input
Attribute
Type
Description
Code
chargeIndicator
Boolean
Specifies whether a charge or a discount is involved. Valid values: true - tax or charge, false - discount.
amount
CurrencyAmountInput
For discounts, it specifies the amount of discount, without VAT. For charges, it specifies the amount charged, without VAT.
BT-147
baseAmount
CurrencyAmountInput
For discounts, it specifies the basic amount that, together with the discount percentage of the invoice item, can be used to calculate the discount amount of the invoice item. For charges, it specifies the basic amount that, together with the charge percentage of an invoice item, can be used to calculate the charge of the invoice item.
BT-148
Result
The generated XML invoice, as a String type.
storedMessages
Retrieves messages received from ANAF and subsequently stored in SBS. Unlike the messages query, the storedMessages query enables listing of messages older than 60 days.
Arguments
Argument
Type
Description
organizationId
ID!
Mandatory. Specifies the organization ID for which messages are to be retrieved.
Optional argument used to fetch the next set of query results. This value can be obtained from the nextToken attribute of the StoredMessagesResult type.
StoredMessagesFilter input
Attribute
Type
Description
createdAt
DateFilter
Mandatory. Specifies the date range for which messages are to be retrieved, as a DateFilter input.
Result
StoredMessagesResult type
Attribute
Type
Description
items
[StoredMessage]
The list of StoredMessage objects matching the filtering criteria.
nextToken
String
If null, then the query has reached the end of the list of messages that match the query criteria. If not null, then use this value in the nextToken input argument to obtain the next page.
StoredMessage type
Attribute
Type
Description
id
String
The unique identifier of the message.
creationDate
String
The date when the message was created by ANAF.
tin
String
The tax identification number (TIN) of the organization to which this message applies.
requestId
String
The identifier of the ANAF request. This field is provided by ANAF; it identifies either an invoice or an invoice notification submitted to ANAF. If message type is “FACTURA TRIMISA” or “FACTURA PRIMITA”, the requestId correlates with the requestId of the Invoice object.
invoiceRequestId
String
The identifier of the outbound invoice to which this message makes reference. This field will be populated only if the message references an outbound invoice (that is, if message type is “FACTURA TRIMISA”).
inboundInvoiceRequestId
String
The identifier of the inbound invoice to which this message makes reference. This field will be populated only if the message references an inbound invoice (that is, if message type is “FACTURA PRIMITA”).
details
String
Any other information which may be applicable to the message.
type
String
The message type, as populated by ANAF.
createdAt
DateTime
The date and time when the message was stored in SBS.
verifyXml
Returns the result of validating an XML invoice against the ANAF validation API. This method is a wrapper around the ANAF e-Factura validation API, therefore, it returns the same errors and validation outcome as returned by ANAF.
Arguments
Argument
Type
Description
xml
String!
Mandatory. The XML invoice to be validated, as a string type.
Result
VerifyXmlResult type
Attribute
Type
Description
status
VerifyXmlStatus
An enumeration with the following valid values: ok - validation successful, error - validation failed with errors.
errors
[String]
If validation fails, this field is populated with the actual validation errors encountered.
version
Returns the API version.
Mutations
createInvoice
Creates an invoice without actually uploading it to ANAF. This call does not require authorization to ANAF.
Arguments
Attribute
Type
Description
organizationId
ID!
Mandatory. The ID of the organization issuing the invoice. You can create organizations through the Organizations Service.
input
CreateInvoiceInput!
Mandatory. The input data for creating the invoice, as a CreateInvoiceInput object.
Creates an invoice from XML input, and also uploads it to ANAF, in one operation. Running this mutation is equivalent to running createInvoiceFromXml and uploadInvoice.
Arguments
Attribute
Type
Description
organizationId
ID!
Mandatory. The ID of the organization issuing the invoice. You can create organizations through the Organizations Service.
xml
String!
Mandatory. A string that provides the invoice data in XML format, using the UBL 2.1 syntax.
Uploads an invoice to ANAF. Before using this call, the invoice must first be created either through the createInvoice or createInvoiceFromXml mutation.
This call requires authorization to ANAF, which you can obtain through the RO ANAF OAuth Service.
Arguments
Attribute
Type
Description
organizationId
ID!
Mandatory. The ID of the organization uploading the invoice.