Retrieve documents
TrustWeaver provides several operations for retrieving stored invoices and documents from the storage service.
After invoices are stored in the TrustWeaver storage service, you can retrieve them individually by reference, search for invoices using metadata criteria, or download all documents in a section at once.
Available retrieval operations
The following operations are available for retrieving and managing stored documents:
- GetInvoice
- Retrieves a store invoice by reference, including the document, signature, metadata, and all attachments.
- SearchInvoices
- Searches for invoices in a storage area using metadata criteria and only returns references and metadata. To retrieve the full invoice or attachment data, use GetInvoice.
- ListInvoiceReferences
- Returns all references for invoices stored in a named section and supports pagination.
- ListExpiringInvoiceReferences
- Returns references for invoices whose storage period is approaching expiration.
- UpdateInvoice
- Updates the metadata or document data of a stored invoice.
- CreateToken
- Creates a single-use access token for downloading a specific document without client certificate authentication.
- OffloadSection
-
Bulk downloads all section documents, as long as the section is in the
LockedForArchivingstate. Intended for offboarding or bulk retrieval.
References
Each stored invoice is identified by a unique reference string. The reference is returned when you store the invoice, and you need it to retrieve the invoice later. An invoice stored for both the supplier and the buyer results in two stored invoices, each with a separate reference: One where the supplier is the principal party and one where the buyer is the principal party.
Section states and retrieval
You can retrieve documents from sections in the Enabled or Locked state. Retrieval is not available for sections in the Closed state.
ListInvoiceReferences. Locking prevents race conditions that could occur if documents are stored while the listing is in progress, which could cause recently stored documents not to be included.
Retrieve an invoice through the API
You must have the reference string for the stored invoice. The reference is returned in the StoreInvoice response or from a SearchInvoices call.
The GetInvoice operation returns the full invoice document, including the electronic signature and all attachments. It also returns metadata such as invoice number, date, supplier and buyer information, custom properties, storage time, and the storage period end date.
To share a document with a recipient who doesn't have a client certificate, generate a single-use download token. See Create a download token through the API.
A successful call returns the invoice document, signature data, and all associated metadata. Either SupplierInfo or BuyerInfo have StoreFor set to true, identifying the party that owns the stored invoice. For error codes returned by this operation, see Storage service error codes.
Search criteria reference
Criteria and combination logic
A criterion is a condition on a single invoice metadata property. A criterion is fulfilled when the property value matches the condition. By default, all criteria in a request are combined with AND logic. An invoice is returned only when every criterion is fulfilled.
To apply OR logic across a criteria group, assign them to the same disjunction group. A disjunction group is fulfilled when at least one of its criteria is fulfilled. Disjunction groups are combined with each other and with any ungrouped criteria using AND logic.
For a request with criteria A, B, C, D, and E, where A and B belong to group 1, C and D belong to group 2, and E is ungrouped, the combined condition is:
(A OR B) AND (C OR D) AND E
The name given to a disjunction group has no meaning beyond grouping. Any criteria that share the same group name are treated as belonging to the same disjunction group. Group names are case-sensitive.
DisjunctionGroup element
The DisjunctionGroup element is a child of the base Criterion type. It is available on every criterion element in the request, including StringCriterion, TimeRangeCriterion, and BooleanCriterion.
| Element | Type | Cardinality | Description |
|---|---|---|---|
| DisjunctionGroup | xs:string | 0..1 | The case-sensitive name of the disjunction group this criterion belongs to. When present, the criterion is combined with other criteria in the same group using OR logic. When absent, the criterion is combined with all others using AND logic. Because the maximum length is not specified in the source; any non-empty string is valid. |
Here is an example that returns invoices where the invoice number starts with "INV-" OR the original invoice number starts with "INV-":
<InvoiceInfo>
<InvoiceNo>
<DisjunctionGroup>invoiceNumberGroup</DisjunctionGroup>
<MatchType>StartsWith</MatchType>
<CriterionValues>
<CriterionValue>INV-</CriterionValue>
</CriterionValues>
</InvoiceNo>
<OriginalInvoiceNo>
<DisjunctionGroup>invoiceNumberGroup</DisjunctionGroup>
<MatchType>StartsWith</MatchType>
<CriterionValues>
<CriterionValue>INV-</CriterionValue>
</CriterionValues>
</OriginalInvoiceNo>
</InvoiceInfo>
Match types
String criteria and numeric criteria use different match type enumerations.
- String match types (StringMatchType)
-
Value Description Exact The entire property value must match the criterion value. Case sensitivity depends on the property. StartsWith The property value must begin with the criterion value. Case sensitivity depends on the property. A
StringCriterioncan include up to 20 criterion values. The criterion is fulfilled if the property matches any one of the values. - Numeric match types (NumericMatchType)
-
Value Description LessThan The property value must be strictly less than the criterion value. LessThanOrEqualTo The property value must be less than or equal to the criterion value. EqualTo The property value must equal the criterion value. GreaterThan The property value must be strictly greater than the criterion value. GreaterThanOrEqualTo The property value must be greater than or equal to the criterion value. NotEqualTo The property value must not be equal to the searched value. - Time range criteria (TimeRangeCriterion)
-
Time range criteria don't use a
MatchTypeelement. Instead, provide theStartTimeorEndTimeasxs:dateTimevalues. Both bounds are inclusive. Either bound can be omitted to leave it open.Element Type Cardinality Description StartTime xs:dateTime 0..1 The beginning of the time range (inclusive). Omit for no lower bound. If you don't specifiy a time zone, it uses UTC. EndTime xs:dateTime 0..1 The end of the time range (inclusive). Omit for no upper bound. If you don't specify a time zone, it uses UTC. Note: ForInvoiceDate, only the date part of the value is used for matching. Time and time zone information inInvoiceDatecriteria are ignored.
Search invoices through the API
The SearchInvoices operation returns invoice metadata and references for all invoices matching your criteria. Document and attachment data are not included in the results. Use the returned references with GetInvoice to retrieve full document data.
The response returns invoice metadata and unique references for all invoices that match the criteria, up to the MaxHits limit. For error codes returned by this operation, see Storage service error codes.
Invoice reference operations
ListInvoiceReferences operation
Returns the references of all invoices stored in a named section. Supports pagination using MaxHits and Offset. The result list is stable: New invoices stored during a paginated sequence always appear at the end of the list and don't affect the order of existing results.
- Request elements
-
Request type
tas:ListInvoiceReferencesRequestextendstac:TrustArchiveRequestElement Type Cardinality Description Section xs:string 1 The section name. Maximum 80 characters. MaxHits xs:int 1 The maximum number of references to return, capped at the server-configured limit. Must be non-negative. Offset xs:int 0..1 The number of results to skip from the start of the list. Set to the total number of references already retrieved to fetch the next page. Must be non-negative if specified. - Request example
-
CODE
<ListInvoiceReferences xmlns="http://www.trustweaver.com/trustarchive/storage/v1"> <Request xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <TransactionId xmlns="http://www.trustweaver.com/trustarchive/common/v1" >d651...</TransactionId> <Section>section1</Section> <MaxHits>5</MaxHits> <Offset>3</Offset> </Request> </ListInvoiceReferences> - Response elements
-
Result type:
tas:ListInvoiceReferencesResultElement Cardinality Description Hits 1 A collection of 32-digit hexadecimal Referencevalues ordered by stored time (ascending). This order is stable across paginated calls.MaxHitsExceeded 1 Returns truewhen more invoices exist beyond the returned page. IncrementOffsetbyMaxHitsand repeat to retrieve the next page.CODE<ListInvoiceReferencesResponse xmlns="http://www.trustweaver.com/trustarchive/storage/v1"> <Result xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Hits xmlns:a="http://www.trustweaver.com/trustarchive/common/v1"> <a:Reference>ABCD1234</a:Reference> <a:Reference>ABCD1234</a:Reference> <a:Reference>ABCD1234</a:Reference> </Hits> <MaxHitsExceeded>true</MaxHitsExceeded> </Result> </ListInvoiceReferencesResponse> - Error codes
- For error codes returned by this operation, see Storage service error codes.
ListExpiringInvoiceReferences operation
Returns section invoices whose storage period ends within a specified date range. Use this operation to identify invoices approaching expiration beforeoffboarding or updating your UI. Supports pagination using MaxHits and Offset.
- Request elements
-
Request type
tas:ListExpiringInvoiceReferencesRequestextendstac:TrustArchiveRequestElement Type Cardinality Description Section xs:string 1 The section name with up to 80 characters. ExpiryStartDate tac:OmittableDateTime 1 The earliest expiry date to include. Must be before the ExpiryEndDate. For the structure of omittable types, see Omittable types.ExpiryEndDate tac:OmittableDateTime 1 The latest expiry date to include. Must be after ExpiryStartDate.IncludeInvoicesWithExplicitExpiryDate xs:boolean 0..1 When true, invoices that have an explicitStoragePeriodEndDateset are included in results. Whenfalseor omitted, they are excluded.MaxHits xs:int 1 The maximum number of results to return capped by the server-configured limit. Must be non-negative. Offset xs:int 0..1 The number of results to skip. Set to the total number of results already retrieved to fetch the next page. If specified, it must be non-negative. - Request example
-
CODE
<ListExpiringInvoiceReferences xmlns="http://www.trustweaver.com/trustarchive/storage/v1"> <Request xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <TransactionId xmlns="http://www.trustweaver.com/trustarchive/common/v1" >d651...</TransactionId> <Section>section1</Section> <ExpiryStartDate> <i:Value>2020-04-30T11:18:02.3576459Z</i:Value> </ExpiryStartDate> <ExpiryEndDate> <i:Value>2020-05-30T11:18:02.3576459Z</i:Value> </ExpiryEndDate> <IncludeInvoicesWithExplicitExpiryDate>true</IncludeInvoicesWithExplicitExpiryDate> <MaxHits>100</MaxHits> <Offset>0</Offset> </Request> </ListExpiringInvoiceReferences> - Response elements
-
Result type:
tas:ListExpiringInvoiceReferencesResultElement Cardinality Description Hits 1 A collection of ExpiredInvoiceentries. See theExpiredInvoiceelements entry.MaxHitsExceeded 1 Returns truewhen more invoices exist beyond the returned page. Increase theOffsetand repeat. - ExpiredInvoice elements
-
Element Cardinality Description Reference 1 The 32-digit hexadecimal reference to the stored invoice. InvoiceDate 1 The invoice date specified when the invoice is stored. ExpiryDate 1 The date when the invoice storage period ends. HasExplicitExpiryDate 1 Returns truewhen the invoice has an explicitStoragePeriodEndDateset.CODE<ListExpiringInvoiceReferencesResponse xmlns="http://www.trustweaver.com/trustarchive/storage/v1"> <Result xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Hits> <ExpiredInvoice> <Reference>ABCD1234</Reference> <InvoiceDate>2019-08-10T00:00:00+02:00</InvoiceDate> <ExpiryDate>2024-08-10T00:00:00+02:00</ExpiryDate> <HasExplicitExpiryDate>false</HasExplicitExpiryDate> </ExpiredInvoice> <ExpiredInvoice> <Reference>ABCD1234</Reference> <InvoiceDate>2019-07-26T00:00:00+02:00</InvoiceDate> <ExpiryDate>2021-07-26T00:00:00+02:00</ExpiryDate> <HasExplicitExpiryDate>true</HasExplicitExpiryDate> </ExpiredInvoice> </Hits> <MaxHitsExceeded>true</MaxHitsExceeded> </Result> </ListExpiringInvoiceReferencesResponse> - Error codes
- For error codes returned by this operation, see Storage service error codes.
Update and inspect stored invoices
UpdateInvoice operation
This operation adds attachments, custom properties, or custom numeric properties to a stored invoice, or updates its storage period end date. At least one of these updates must be included. A request with no updates is rejected.
StoragePeriodEndDate might cause the document to be deleted before its legally required retention period ends. The date must be at least three days in the future.
- Request elements
-
Request type
tas:UpdateInvoiceRequestextendstac:TrustArchiveRequestElement Type Cardinality Description Reference xs:string 1 The 32-digit hexadecimal reference to the stored invoice. AddAttachments tas:Attachments 0..1 Attachments to add to the stored invoice. You can add up to seven attachments per invoice. The limit applies to the invoice as a whole, not only to what is added in this request. AddCustomProperties tas:CustomProperties 0..1 Custom string properties to add. You can add up to seven custom properties per invoice. AddCustomNumericProperties tas:CustomNumericProperties 0..1 Custom numeric properties to add. You can add up to seven custom numeric properties per invoice. StoragePeriodEndDate tac:OmittableDateTime 0..1 The new storage period end date. Must be at least three days in the future (UTC). For the structure of omittable types, see Omittable types. - Request example
-
CODE
<UpdateInvoice xmlns="http://www.trustweaver.com/trustarchive/storage/v1" xmlns:tac="http://www.trustweaver.com/trustarchive/common/v1"> <Request> <tac:TransactionId>3580f...</tac:TransactionId> <Reference>ABCD1234</Reference> <AddAttachments> <Attachment> <Filename>Attachment1.xml</Filename> <MimeType>text/xml</MimeType> <Description>Attachment</Description> <Data>ABCD1234</Data> </Attachment> </AddAttachments> <AddCustomProperties> <Property> <Name>Property1</Name> <Value>Value1</Value> </Property> </AddCustomProperties> <StoragePeriodEndDate> <tac:Value>2030-01-01T00:00:00</tac:Value> </StoragePeriodEndDate> </Request> </UpdateInvoice> - Response
-
A successful response contains no sub-elements:
CODE<UpdateInvoiceResponse xmlns="http://www.trustweaver.com/trustarchive/storage/v1"/> - Error codes
- For error codes returned by this operation, see Storage service error codes.
GetDocumentMetadata operation
Retrieves metadata for a stored invoice or custom document. Only metadata fields are returned. Use GetInvoice to retrieve the full document content.
- Request elements
-
Request type
tas:GetDocumentMetadataRequestextendstac:TrustArchiveRequestElement Type Cardinality Description Reference xs:string 1 The 32-digit hexadecimal reference to the stored invoice. - Request example
-
CODE
<GetDocumentMetadata xmlns="http://www.trustweaver.com/trustarchive/storage/v1" xmlns:tac="http://www.trustweaver.com/trustarchive/common/v1"> <Request> <tac:TransactionId>3580f...</tac:TransactionId> <Reference>ABCD1234</Reference> </Request> </GetDocumentMetadata> - Response elements
-
Request type:
tas:GetDocumentMetadataResultElement Cardinality Description Document 1 Document format and signature metadata. Document content data is not included. DocumentPartyInfo 1 Information about the document owner: section name and country code. Attachments 0..1 Metadata for all attached documents. Attachment content data is not included. CustomProperties 0..1 Custom string properties associated with the document. CustomNumericProperties 0..1 Custom numeric properties associated with the document. StoredTime 1 The UTC date and time when the document is stored. StoragePeriodEndDate 0..1 The date when the storage period ends. This is a calculated value and may change if configuration changes. ClosureEvidences 0..1 Metadata for all closure evidence documents associated with the document. Closure evidence content data is not included. Omitted if there are no closure evidences. CODE<GetDocumentMetadataResponse xmlns="http://www.trustweaver.com/trustarchive/storage/v1"> <Result> <Document> <DocumentFormat>PDF</DocumentFormat> <ImplicitSignatureInfo> <SignatureFormat>PDF</SignatureFormat> <AuditCategory>CADESA</AuditCategory> </ImplicitSignatureInfo> </Document> </DocumentPartyInfo> <Attachments> <Attachment> <Filename>attached.xml</Filename> <MimeType>text/xml</MimeType> <Description>Some XML attachment</Description> </Attachment> </Attachments> <CustomProperties> <Property> <Name>MyProperty</Name> <Value>some value</Value> </Property> </CustomProperties> <CustomNumericProperties> <Property> <Name>MyNumericProperty</Name> <Value>1234</Value> </Property> </CustomNumericProperties> <StoredTime>2010-09-07T13:15:44Z</StoredTime> <StoragePeriodEndDate>2020-09-06T00:00:00</StoragePeriodEndDate> </Result> </GetDocumentMetadataResponse> - Error codes
- For error codes returned by this operation, see Storage service error codes.
Create a download token through the API
- Your application must be authenticated with a valid X.509v3 client certificate.
- You must have the 32-digit hexadecimal reference of the stored invoice or document.
- The invoice must not be expired.
The CreateToken operation generates an access token that allows a single download of a specific invoice or document without requiring client certificate authentication. The token is valid for one download only and expires 30 days after creation.
You can now share the generated token with the recipient. They can use it to download the specified document once, without authentication.
For error codes returned by this operation, see Storage service error codes.
Download all section documents
The section must be in the LockedForArchiving status before you can start a bulk download. Call LockSection to lock the section. Locking prevents issues between storing new documents and listing the documents of a section.
A bulk download is typically used during offboarding, the process of permanently removing documents from the TrustWeaver storage service. TrustWeaver provides two options:
-
An automatic download using the OffloadSection endpoint.
-
A self-service approach using standard API operations.
- To download all documents in a section (automatic download):
- If you prefer to implement the download yourself (self-service download), follow these steps:
- Call
GetSectionInfoand confirm the section is in theLockedForArchivingstate. - Call
ListInvoiceReferencesto get a list of references for the section's documents. SetMaxHitsto the number of references to retrieve per call. SetOffsetto the total number of references already retrieved (use0for the first call). - Call
GetInvoicefor each reference returned. - If
MaxHitsExceededin theListInvoiceReferencesresponse istrue, repeat from second step with the updatedOffset.
- Call
After downloading all documents, call CloseSection to put the section in the ClosedForArchiving state. This hides all documents in the section and starts a grace period before permanent deletion. You must close the section before youpermanently delete the documents.
The final step in authorizing permanent deletion of the section's documents (offboarding) is an out-of-band process. Contact Sovos Support to complete this irreversible step.
For the full request and response reference for ListInvoiceReferences and ListExpiringInvoiceReferences, see Invoice reference operations.
