Storing invoices
Learn the process for storing invoices using the Standard Business Document (SBD) format, including mandatory nodes and archiving recommendations.
The following diagram gives a detailed overview of the process for storing invoices based on the Archiving business process:
Step 1: Supplier Creates the Standard Business Document
An invoice in the SCI format should not be archived as the main document, as it's not a legally valid document. Instead, Sovos recommends archiving it as an attachment to the legal invoice.
| Node | Required | Attributes | Value |
|---|---|---|---|
| StandardBusinessDocumentHeader.Sender.Identifier | Yes | Authority=Supplier's ISO 3166-1 alpha-2 country code, which should reflect the country of the applicable law for the invoice. | Supplier's tax ID |
| StandardBusinessDocumentHeader.Sender.ContactInformation.Contact | Yes | Supplier's company ID registered during the configuration. If the invoice will not be stored for the supplier, set it to the supplier's name. | |
| StandardBusinessDocumentHeader.Receiver.Identifier | Yes | Authority=Buyer's ISO 3166-1 alpha-2 country code, which should reflect the country of the applicable law for the invoice. | Buyer's tax ID |
| StandardBusinessDocumentHeader.Receiver.ContactInformation.Contact | Yes | Buyer's company ID registered during the configuration. If the invoice will not be stored for the buyer, set it to the buyer's name. | |
| StandardBusinessDocumentHeader.DocumentIdentification.Standard | Yes | urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2 | |
| StandardBusinessDocumentHeader.DocumentIdentification.TypeVersion | Yes | 2.1 | |
| StandardBusinessDocumentHeader.DocumentIdentification.Type | Yes | Attachment | |
| StandardBusinessDocumentHeader.DocumentIdentification.InstanceIdentifier | Yes | The legal invoice number | |
| StandardBusinessDocumentHeader.DocumentIdentification.CreationDateAndTime | Yes | The invoice date | |
| StandardBusinessDocumentHeader.Manifest.NumberOfItems | Yes if there are attachments that must be stored along with the invoice | The number of attachments that must be stored along with the invoice, ranging from 1 to 7. | |
| StandardBusinessDocumentHeader.Manifest.ManifestItem (with child nodes) | Yes for every attachment that must be stored along with the invoice (up to 7) | Child node Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes (in most cases) | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes for additional features | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes for additional features | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes for additional features | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes for additional features | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes for additional features | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes for additional features | Child node Child node | |
| StandardBusinessDocumentHeader.BusinessScope.Scope (with child nodes) | Yes for additional features | Child node Child node |
It's important to include all the mandatory nodes as specified in the SBDH schema. If information cannot be provided and the respective mandatory node hasn't been mentioned on the current page, for example the receiver.identifier, the node can be left empty but must still be included in the SBDH.
<sbd:StandardBusinessDocumentHeader>
<sbd:HeaderVersion>1.0</sbd:HeaderVersion>
<sbd:Sender>
<sbd:Identifier Authority="IN">123456789</sbd:Identifier>
<sbd:ContactInformation>
<sbd:Contact>CompanyXYZ</sbd:Contact>
<sbd:EmailAddress/>
<sbd:FaxNumber/>
<sbd:TelephoneNumber/>
<sbd:ContactTypeIdentifier/>
</sbd:ContactInformation>
</sbd:Sender>
<sbd:Receiver>
<sbd:Identifier Authority="IN">987654321</sbd:Identifier>
<sbd:ContactInformation>
<sbd:Contact>CompanyABC</sbd:Contact>
<sbd:EmailAddress/>
<sbd:FaxNumber/>
<sbd:TelephoneNumber/>
<sbd:ContactTypeIdentifier/>
</sbd:ContactInformation>
</sbd:Receiver>
<sbd:DocumentIdentification>
<sbd:Standard>urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2</sbd:Standard>
<sbd:TypeVersion>2.1</sbd:TypeVersion>
<sbd:InstanceIdentifier>12345X</sbd:InstanceIdentifier>
<sbd:Type>Attachment</sbd:Type>
<sbd:MultipleType>false</sbd:MultipleType>
<sbd:CreationDateAndTime>2020-06-12T12:00:00Z</sbd:CreationDateAndTime>
</sbd:DocumentIdentification>
<sbd:Manifest>
<sbd:NumberOfItems>2</sbd:NumberOfItems>
<sbd:ManifestItem>
<sbd:MimeTypeQualifierCode>application/pdf</sbd:MimeTypeQualifierCode>
<sbd:UniformResourceIdentifier>#Attachment1</sbd:UniformResourceIdentifier>
<sbd:Description>Attachment</sbd:Description>
</sbd:ManifestItem>
<sbd:ManifestItem>
<sbd:MimeTypeQualifierCode>application/xml</sbd:MimeTypeQualifierCode>
<sbd:UniformResourceIdentifier>#Attachment2</sbd:UniformResourceIdentifier>
<sbd:Description>Attachment</sbd:Description>
</sbd:ManifestItem>
</sbd:Manifest>
<sbd:BusinessScope>
<sbd:Scope>
<sbd:Type>SenderDocumentId</sbd:Type>
<sbd:InstanceIdentifier/>
<sbd:Identifier>123456789</sbd:Identifier>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>BusinessProcess</sbd:Type>
<sbd:InstanceIdentifier/>
<sbd:BusinessService>
<sbd:BusinessServiceName>Archiving</sbd:BusinessServiceName>
</sbd:BusinessService>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>Archiving.DocumentFormat</sbd:Type>
<sbd:InstanceIdentifier/>
<sbd:Identifier>PDF</sbd:Identifier>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>Archiving.SignatureType</sbd:Type>
<sbd:InstanceIdentifier/>
<sbd:Identifier>Implicit</sbd:Identifier>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>Archiving.SignatureFormat</sbd:Type>
<sbd:InstanceIdentifier/>
<sbd:Identifier>PDF</sbd:Identifier>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>Archiving.AuditCategory</sbd:Type>
<sbd:InstanceIdentifier/>
<sbd:Identifier>PADESEPES</sbd:Identifier>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>Archiving.StoreFor</sbd:Type>
<sbd:InstanceIdentifier/>
<sbd:Identifier>Supplier</sbd:Identifier>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>Archiving.CustomProperty</sbd:Type>
<sbd:InstanceIdentifier>TestCategory</sbd:InstanceIdentifier>
<sbd:Identifier>Test23</sbd:Identifier>
</sbd:Scope>
<sbd:Scope>
<sbd:Type>Archiving.CustomNumericProperty</sbd:Type>
<sbd:InstanceIdentifier>CategoryX</sbd:InstanceIdentifier>
<sbd:Identifier>1234</sbd:Identifier>
</sbd:Scope>
</sbd:BusinessScope>
</sbd:StandardBusinessDocumentHeader>| Node | Required | Attributes | Value |
|---|---|---|---|
| SovosDocument.SovosLegalDocument.Base64Document.EmbeddedDocument (with child nodes) | Yes |
| The string of the Base64-encoded invoice. |
| SovosDocument.SovosLegalDocument.Attachment (with child nodes) | Yes for each attachment (up to 7) | Required attributes for EmbeddedDocumentBinaryObject:
| Child node Child node |
<svs:SovosDocument>
<svs:SovosLegalDocument>
<enc:Base64Document>
<enc:EmbeddedDocument id="1" filename="invoice.pdf" mimeCode="application/pdf">JVB...0YK</enc:EmbeddedDocument>
</enc:Base64Document>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject filename="attachment1.pdf" mimeCode="application/pdf">JVB...PRg==</cbc:EmbeddedDocumentBinaryObject>
<cac:ExternalReference>
<cbc:Description>Attachment1</cbc:Description>
</cac:ExternalReference>
</cac:Attachment>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject filename="attachment2.xml" mimeCode="application/xml">PHN...BlPg==</cbc:EmbeddedDocumentBinaryObject>
<cac:ExternalReference>
<cbc:Description>Attachment2</cbc:Description>
</cac:ExternalReference>
</cac:Attachment>
</svs:SovosLegalDocument>
</svs:SovosDocument>- Attachments
- As explained before, an invoice is stored via the Base64Document node. In addition, it's possible to store attachments related to the invoice. Attachments are documents associated with the invoice and can be, for example, purchase orders, delivery notes, agreements, invoice hash value, and tax authority response. As explained before, to store attachments, one should include the
Manifestnode as part of the SBDH and theAttachmentnode as part of theSovos Documentcontainer. Up to 7 attachments can be stored with the invoice. - Custom Storage Period End Date
- By default, Sovos applies a storage period to every invoice which is compliant with the applicable law. If you prefer to apply a customized storage end date for a particular invoice, a custom end date can be set via the
Archiving.StoragePeriodOverridescope information. The earliest date that can be set is 3 days in the future.Note:Using this element overrides the default storage period and is an explicit request for Sovos eArchive to delete the invoice on that specific date. Hence, setting an incorrect date may cause the document to be deleted before its legally regulated lifetime, so this feature should be used carefully.
Step 2: Supplier Sends the SBD to Sovos
The supplier sends a POST request to the /archived-documents endpoint.
| Name | Type | Required | Description |
|---|---|---|---|
| data | string | Yes | Set it to the SBD encoded in Base64, as created in step 1. |
| dataEncoding | string | Yes | Always set it to "base64". |
See API Specifications for more information about the request. In addition, there's a full sample request and response on the Postman Samples page.
curl --location --request POST 'https://api-test-tls.sovos.com/v1/archived-documents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--header 'x-correlationId: SET-TO-UNIQUE-VALUE' \
--data-raw '{
"data": "PD9...dD4=",
"dataEncoding": "base64"
}'{
"success": true,
"status": 200,
"message": "Document Stored",
"timestamp": 1648827072703,
"data": {
"supplierReference": "dfcafdc20a27427ca88675426cc7c6a4"
"depositInfo": {
"documentHash":"sKkPmBdneBmYi7F53YkoFg6TrOp9uDuYn8kqSo8=",
"documentHashAlgorithm": "Sha256",
"documentDate": "2022-04-01T15:31:12:557104Z"
}
}
}Step 3: Sovos Stores the Invoice
Sovos stores the invoice along with the metadata and any attachments in the specified company.
Step 4: Sovos Returns the Invoice Reference
As part of the response, the client application will receive an invoice reference related to the specific file that has been stored. If the operation is performed for both parties, i.e., Archiving.StoreFor has been set for both the supplier and the buyer, two invoice references (one for the supplier and one for the buyer) will be returned within the same response. Finally, if Archiving.AdditionalOutput was specified, the response will also contain those details. See also step 2 for a sample response.
Error Handling
Adhere to the error handling principles outlined on the responses page.
In general, all error codes in the 400 range are client errors, so analyze them individually. After fixing the error, it's possible to resend the request. Error codes 408 and 429 are exceptions: in these cases, you should wait at least 60 seconds before retrying. The error codes in the 500 range are server errors. In that case, you need to resend the request, according to the instructions given on the responses page, which also includes a full list of error codes the COAPI can return.
